View Javadoc

1   package com.explosion.expf;
2   
3   /*
4    * =============================================================================
5    * 
6    * Copyright 2004 Stephen Cowx
7    * 
8    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
9    * use this file except in compliance with the License. You may obtain a copy of
10   * the License at
11   * 
12   * http://www.apache.org/licenses/LICENSE-2.0
13   * 
14   * Unless required by applicable law or agreed to in writing, software
15   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
16   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
17   * License for the specific language governing permissions and limitations under
18   * the License.
19   * 
20   * =============================================================================
21   */
22  
23  import java.awt.event.ActionEvent;
24  import java.awt.event.ActionListener;
25  import java.awt.event.KeyEvent;
26  import java.awt.event.KeyListener;
27  
28  /***
29   * @author Stephen Cowx Date created:@07-Feb-2003
30   * 
31   * <p>
32   * Listeners in expf applications work as follows.
33   * 
34   * <p>
35   * There is this listener, there are listeners that listen to global events,
36   * listeners that listen to local events and listeners that listen to component
37   * events. All events that are managed by the ApplicationFramework will come
38   * through this listener. Here they will either be responded to or propagated
39   * 
40   * <p>
41   * The difference between local and global events is that local events are
42   * events that must be applied to the currently active window and global events
43   * are events that apply to all windows whether they are active or not.
44   * 
45   * <p>
46   * e.g. "File >> Open" and "File >> Close all" are global events whereas "File
47   * >>" Save is a local event.
48   * 
49   * <p>
50   * Listeners need to be registered as either local or global listeners. They
51   * also need to be able to provide a list of events that they listen for i.e
52   * they should implement the ExpListener interface.
53   * 
54   * <P>
55   * For every event that occurs, the following logic is followed
56   * 
57   * 1) If events of this type are handled by this listener then it is handled
58   * here and not passed on. <br>
59   * 2) If it isn't handled by this listener then: <br>
60   * 3) A local listener is sought for the currently active window (by object
61   * reference) <br>
62   * 4) If there is one and it listens for events of this type, then the event is
63   * sent to this listener and not passed any furthur <br>
64   * 5) If there isn't one (or there is and it doesn't listen for event of this
65   * type) then the event is sent to each global listener that listenes for events
66   * of this type <br>
67   */
68  
69  public abstract class ExpListener implements ActionListener, KeyListener
70  {
71     /***
72       * Action performed
73       * 
74       * @param e
75       */
76      public abstract void actionPerformed(ActionEvent e);
77      
78      /***
79       * This method adds a global ExpAction Listener to the compound listener An
80       * application can have more than one listener per reference. When events
81       * are handled, the CompundListener will iterate through all of the
82       * listeners for that reference in the order in which they were added.
83       * 
84       * @param listener
85       */
86      public abstract void addGlobalActionListener(ExpActionListener listener, Object reference);
87  
88      /***
89       * This method removes all of the global action listener from the compound
90       * listener for the given reference
91       * 
92       * @param listener
93       */
94      public abstract void removeGlobalActionListenersForReference(Object reference);
95      /***
96       * This method adds a local ExpAction Listener to the compound listener
97       * 
98       * @param listener
99       */
100     public abstract void addLocalActionListener(ExpActionListener listener, Object reference);
101 
102     /***
103      * This method removes the specified local action listener from the compound
104      * listener
105      * 
106      * @param listener
107      */
108     public abstract void removeLocalActionListenerForReference(ExpActionListener listener, Object reference);
109 
110     /***
111      * This method adds a component ExpAction Listener to the compound listener
112      * 
113      * @param listener
114      */
115     public abstract void addComponentActionListener(ExpActionListener listener, Object localReference, Object componentReference);
116 
117     /***
118      * This method removes the specified component action listener from the
119      * compound listener
120      * 
121      * @param listener
122      */
123     public abstract void removeComponentActionListenerForReference(ExpActionListener listener, Object localReference);
124 
125     /***
126      * Clean sup all references to any objects registered with this reference
127      */
128     public abstract void cleanUpForReference(Object reference);
129     
130     /***
131      * This method sets the look and feel of the help frame and it's children
132      * This is done because it doesn't happen automatically
133      */
134     protected abstract void updateLookAndFeelOfHelp() throws Exception;
135 
136     /***
137      * Responds to for F1 key code currently. It pops up a help window assuming
138      * it recieves the event.
139      */
140     public abstract void keyPressed(KeyEvent e);
141     /***
142      * Does nothing currently
143      */
144     public abstract void keyReleased(KeyEvent e);
145     /***
146      * Does nothing currently
147      */
148     public abstract void keyTyped(KeyEvent e);
149 
150 }