root / branches / v2_0_0_prep / frameworks / _fwAndami / src / org / gvsig / andami / actioninfo / ActionInfo.java @ 38621
History | View | Annotate | Download (8.06 KB)
1 | 38621 | nbrodin | package org.gvsig.andami.actioninfo; |
---|---|---|---|
2 | |||
3 | import java.awt.event.ActionListener; |
||
4 | import java.util.Collection; |
||
5 | |||
6 | import javax.swing.Action; |
||
7 | import javax.swing.ImageIcon; |
||
8 | import javax.swing.KeyStroke; |
||
9 | |||
10 | import org.gvsig.andami.PluginServices; |
||
11 | import org.gvsig.andami.plugins.IExtension; |
||
12 | |||
13 | /**
|
||
14 | * Esta entidad representa a una accion dentro de gvSIG, que podra ser usada
|
||
15 | * por menus, botones de la toolbar, menus contextuales, o desde cualquier
|
||
16 | * otro elemento de gvSIG que precise invocar a una accion.
|
||
17 | *
|
||
18 | * La accion esta compuesta por una definicion de cual es su etiqueta, su
|
||
19 | * icono, teclas aceleradoras, su tip, o su posicion respecto a otras acciones,
|
||
20 | * junto con una extension (IExtension) que aporta el codigo de la accion.
|
||
21 | *
|
||
22 | * Una accion responde principalmente a cuatro operaciones:
|
||
23 | *
|
||
24 | * - isActive, que nos indica si la accion esta activa, es decir, si
|
||
25 | * debera presentarse al usuario o no. Si una extension no esta activa,
|
||
26 | * los metodos isVisible y isEnabled retornaran siempre false, sin invocar
|
||
27 | * al codigo de la extension asociada a la accion.
|
||
28 | *
|
||
29 | * - isVisible, que nos indica si la accion debera presentarse o no en el
|
||
30 | * interface de usuario. De forma general podemos asumir que cuando se
|
||
31 | * invoque a este metodo se delegara en el metodo isVisible de la extension
|
||
32 | * asociada a la accion.
|
||
33 | *
|
||
34 | * - isEnabled, que nos indica si la accion debera estar habilitada o no en
|
||
35 | * el interface de usuario. De forma general podemos asumir que cuando se
|
||
36 | * invoque a este metodo se delegara en el metodo isEnabled de la extension
|
||
37 | * asociada a la accion.
|
||
38 | *
|
||
39 | * - execute, que provocara que se ejecute el codigo asociado a la accion.
|
||
40 | * De forma general podemos asumir que cuando se invoque a estos metodo se
|
||
41 | * delegara en el metodo execute de la extension asociada a esta accion, pasandole
|
||
42 | * el "command" de la accion como parametro.
|
||
43 | *
|
||
44 | * Ademas de la definicion de la accion, esta tambien puede disponer de una coleccion
|
||
45 | * de acciones hacia las que puede ser redirigida. Esto es, en un momento dado
|
||
46 | * nos puede interesar que cuando sea invocada la accion "A", en lugar de ejecutarse
|
||
47 | * las operaciones de esta, se ejecuten las operaciones de otra accion "B". Esto nos
|
||
48 | * permite atrapar la ejecucion de una accion independientemente de desde donde se este
|
||
49 | * invocando. Cuando una accion tenga asignadas otras acciones a las que redirigir
|
||
50 | * su ejecucion, solo se redigira a una de ellas, la primera en la coleccion de acciones a
|
||
51 | * redirigir que responda "true" a su metodo isEnabled, y en caso de que no responda true
|
||
52 | * ninguna se ejecutara el codigo de la accion original. El orden de la coleccion de
|
||
53 | * acciones a las que redirigir de una accion sera el orden inverso en el que se han
|
||
54 | * ido registrandose las redirecciones. Asi primero se intentara con la ultima redireccion
|
||
55 | * asignada, luego con la anterior, y asi sucesivamente se recorreran todas las redireccion
|
||
56 | * hasta que una responda "true" a su isEnabled, ejecutandose entonces el codigo de esta.
|
||
57 | *
|
||
58 | *
|
||
59 | * @author jjdelcerro
|
||
60 | *
|
||
61 | */
|
||
62 | public interface ActionInfo extends Action, ActionListener{ |
||
63 | |||
64 | /**
|
||
65 | * returns the plugin of the extension asociated to the action.
|
||
66 | *
|
||
67 | * @return pluginServices asiciated to the action.
|
||
68 | */
|
||
69 | public PluginServices getPlugin();
|
||
70 | |||
71 | /**
|
||
72 | * returns the extension asociated to the action. The action
|
||
73 | * delegates the methods isEnabled, isVisible and execute in this
|
||
74 | * extension when these are invoked.
|
||
75 | *
|
||
76 | * @return IExtension asociated to the action
|
||
77 | */
|
||
78 | public IExtension getExtension();
|
||
79 | |||
80 | /**
|
||
81 | * Return the plugin name of the plugin asociated to the action.
|
||
82 | * This is a utility method checkins null values. is equivalent to:
|
||
83 | *
|
||
84 | * action.getPlugin().getPluginName()
|
||
85 | *
|
||
86 | *
|
||
87 | * @return plugin name
|
||
88 | * @see #getPlugin()
|
||
89 | */
|
||
90 | public String getPluginName(); |
||
91 | |||
92 | /**
|
||
93 | * Returns the extension name of the extension asociated to this action.
|
||
94 | * This a utility method that check null values. Is equivalent to:
|
||
95 | *
|
||
96 | * action.getExtension().getClass().getName()
|
||
97 | *
|
||
98 | * @return extension name.
|
||
99 | * @see #getExtension()
|
||
100 | */
|
||
101 | public String getExtensionName(); |
||
102 | |||
103 | /**
|
||
104 | * Returns the name of the action. This name is usaed to retrieve the
|
||
105 | * action thwros the manager.
|
||
106 | *
|
||
107 | * @return action name
|
||
108 | */
|
||
109 | public String getName(); |
||
110 | |||
111 | /**
|
||
112 | * Return a label asociated to the action. This label can be used
|
||
113 | * in buttons, o menus.
|
||
114 | *
|
||
115 | * @return label of action
|
||
116 | */
|
||
117 | public String getLabel(); |
||
118 | |||
119 | /**
|
||
120 | * Returns the command used for invoking the execute method of
|
||
121 | * the extension asociated to this action.
|
||
122 | *
|
||
123 | * @return command of action
|
||
124 | */
|
||
125 | public String getCommand(); |
||
126 | |||
127 | /**
|
||
128 | * Return an icon asociated to the action. This icon can be used
|
||
129 | * in buttons, o menus.
|
||
130 | *
|
||
131 | * @return ImageIcon asociated tho the action
|
||
132 | */
|
||
133 | public ImageIcon getIcon(); |
||
134 | |||
135 | /**
|
||
136 | * Returns the name of icon asociated to the action. This name is
|
||
137 | * used to retrive the icon from the current icon theme of the application.
|
||
138 | *
|
||
139 | * @return icon name.
|
||
140 | */
|
||
141 | public String getIconName(); |
||
142 | |||
143 | /**
|
||
144 | * returns a representation human readable of the accelerator to be used
|
||
145 | * associated to the action.
|
||
146 | *
|
||
147 | * @return String representing the accelerator
|
||
148 | */
|
||
149 | public String getAccelerator(); |
||
150 | |||
151 | /**
|
||
152 | * returns the KeyStroke which represents the accelerator of this
|
||
153 | * action.
|
||
154 | *
|
||
155 | * @return keystroke asociated to this action
|
||
156 | * @see #getAccelerator()
|
||
157 | */
|
||
158 | public KeyStroke getKeyStroke(); |
||
159 | |||
160 | /**
|
||
161 | * Return a string that represents a tip asociated whit the action,
|
||
162 | * usually used as tooltip in buttons or menus.
|
||
163 | *
|
||
164 | * @return the tip of the action
|
||
165 | */
|
||
166 | public String getTooltip(); |
||
167 | |||
168 | /**
|
||
169 | * Return the position absolute of the action referred to all actions.
|
||
170 | *
|
||
171 | * @return the position of the action
|
||
172 | */
|
||
173 | public long getPosition(); |
||
174 | |||
175 | /**
|
||
176 | * retrurn if the action can be visible in the user interface or not.
|
||
177 | * This method call the isVisible of the extension asociated to the action,
|
||
178 | * unless the action is inactive.
|
||
179 | * If has a ExclusiveUIExtension set, then this is invoqued instead of the
|
||
180 | * the isVisible of the extension.
|
||
181 | *
|
||
182 | * @return if the action if visible for the user.
|
||
183 | */
|
||
184 | public boolean isVisible(); |
||
185 | |||
186 | /**
|
||
187 | * retrurn if the action is enables.
|
||
188 | * This method call the isEnabled of the extension asociated to the action,
|
||
189 | * unless the action is inactive.
|
||
190 | * This method is used to determine whether it is possible to redirect
|
||
191 | * to this action or not.
|
||
192 | * If has a ExclusiveUIExtension set, then this is invoqued instead of the
|
||
193 | * the isEnabled of the extension.
|
||
194 | *
|
||
195 | * @return if the action if visible for the user.
|
||
196 | */
|
||
197 | public boolean isEnabled(); |
||
198 | |||
199 | /**
|
||
200 | * Execute the code asociated to the action.
|
||
201 | * This method call the execute method of the asociated exetnsion using the
|
||
202 | * command of action as argument.
|
||
203 | * If the action is redirected try to call to the redirected actions.
|
||
204 | *
|
||
205 | */
|
||
206 | public void execute(); |
||
207 | |||
208 | /**
|
||
209 | * Execute the code asociated to the action.
|
||
210 | * Pass the args to the execute of the asociated extension.
|
||
211 | *
|
||
212 | * @see #execute()
|
||
213 | */
|
||
214 | public void execute(Object[] args); |
||
215 | |||
216 | /**
|
||
217 | * Execute the code asociated to the action.
|
||
218 | * Pass the args to the execute of the asociated extension.
|
||
219 | *
|
||
220 | * @see #execute()
|
||
221 | */
|
||
222 | public void execute(Object arg); |
||
223 | |||
224 | /**
|
||
225 | * Return true is the action is active. When an action is active the methods
|
||
226 | * isEnable and isVisible call the methods of the extension asociated to this.
|
||
227 | * When is inactive always return false.
|
||
228 | *
|
||
229 | * @return if the action is active
|
||
230 | */
|
||
231 | public boolean isActive(); |
||
232 | /**
|
||
233 | * Set the active state of an ActionInfo.
|
||
234 | * When the active state is set to false, isEnabled, and isVisible
|
||
235 | * returns false.
|
||
236 | *
|
||
237 | * @param active
|
||
238 | */
|
||
239 | public void setActive(boolean active); |
||
240 | |||
241 | /**
|
||
242 | *
|
||
243 | * An action can redirect the execution of the execute, isVisible and isEnabled methods
|
||
244 | * to other action. Using this method is can be query and set this redirections.
|
||
245 | * The redirect will be established only if the method isEnabled of target action
|
||
246 | * returns true. Otherwise execute methods of initial action.
|
||
247 | *
|
||
248 | * @return the redirections established for this action
|
||
249 | */
|
||
250 | public Collection<ActionInfo> getRedirections(); |
||
251 | |||
252 | } |