Revision 42161
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/ui/mdiFrame/MDIFrame.java | ||
---|---|---|
205 | 205 |
private static final String noIcon = "no-icon"; |
206 | 206 |
|
207 | 207 |
private Map<JComponent,IExtension> control2extensions = new HashMap<JComponent, IExtension>(); |
208 |
|
|
208 |
|
|
209 | 209 |
private MDIFrame() { |
210 | 210 |
|
211 | 211 |
} |
... | ... | |
213 | 213 |
public static boolean isInitialized() { |
214 | 214 |
return instance!=null ; |
215 | 215 |
} |
216 |
|
|
216 |
|
|
217 | 217 |
public static MDIFrame getInstance() { |
218 | 218 |
if ( instance == null ) { |
219 | 219 |
instance = new MDIFrame(); |
... | ... | |
328 | 328 |
jtb.add(dropDownButton); |
329 | 329 |
addControl(dropDownButton); |
330 | 330 |
} |
331 |
dropDownButton.add(action); |
|
331 |
dropDownButton.add(actionManager.getTranslated(action));
|
|
332 | 332 |
} |
333 | 333 |
return; |
334 | 334 |
} |
335 |
|
|
335 |
|
|
336 | 336 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
337 | 337 |
|
338 | 338 |
JToolBarToggleButton btn; |
... | ... | |
444 | 444 |
jtb.add(dropDownButton); |
445 | 445 |
addControl(dropDownButton); |
446 | 446 |
} |
447 |
dropDownButton.add(action); |
|
447 |
dropDownButton.add(actionManager.getTranslated(action));
|
|
448 | 448 |
} |
449 | 449 |
return; |
450 | 450 |
} |
451 |
|
|
451 |
|
|
452 | 452 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
453 | 453 |
|
454 | 454 |
JToolBarButton btn; |
... | ... | |
493 | 493 |
jtb.addSeparator(); |
494 | 494 |
} |
495 | 495 |
} |
496 |
|
|
496 |
|
|
497 | 497 |
private SelectableToolBar getToolBar(final String toolBarName) { |
498 | 498 |
SelectableToolBar jtb = (SelectableToolBar) toolBarMap.get(toolBarName); |
499 | 499 |
if ( jtb == null ) { |
... | ... | |
505 | 505 |
} |
506 | 506 |
return jtb; |
507 | 507 |
} |
508 |
|
|
508 |
|
|
509 | 509 |
public void addTool(final ActionInfo action, final String toolBarName, final String dropDownName) { |
510 | 510 |
if ( !SwingUtilities.isEventDispatchThread() ) { |
511 | 511 |
SwingUtilities.invokeLater(new Runnable() { |
... | ... | |
521 | 521 |
dropDownButton = new DropDownButton(); |
522 | 522 |
jtb.add(dropDownButton); |
523 | 523 |
} |
524 |
dropDownButton.add(action); |
|
524 |
ActionInfoManager actionManager = PluginsLocator.getActionInfoManager(); |
|
525 |
dropDownButton.add(actionManager.getTranslated(action)); |
|
525 | 526 |
} |
526 |
|
|
527 |
|
|
527 | 528 |
public void addTool(final ActionInfo action, final String toolBarName) { |
528 | 529 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
529 | 530 |
|
... | ... | |
1649 | 1650 |
public void addToolBarControl(Class<?> extensionClass, JToolBar control, String name) { |
1650 | 1651 |
toolBars.add(control); |
1651 | 1652 |
addControl(control); |
1652 |
|
|
1653 |
|
|
1653 | 1654 |
PluginsManager pluginsManager = PluginsLocator.getManager(); |
1654 | 1655 |
IExtension extension = pluginsManager.getExtension((Class<? extends IExtension>) extensionClass); |
1655 | 1656 |
this.control2extensions.put(control, extension); |
... | ... | |
1691 | 1692 |
/* |
1692 | 1693 |
* We also add action listener for menu with |
1693 | 1694 |
* no name but with text: |
1694 |
*
|
|
1695 |
* |
|
1695 | 1696 |
* Window/Project manager |
1696 | 1697 |
* Window/View - 1 |
1697 | 1698 |
* Window/View - 2 |
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/actioninfo/impl/TranslatedActionInfo.java | ||
---|---|---|
1 |
package org.gvsig.andami.actioninfo.impl; |
|
2 |
|
|
3 |
import java.awt.event.ActionEvent; |
|
4 |
import java.beans.PropertyChangeListener; |
|
5 |
import java.util.Collection; |
|
6 |
import java.util.Map; |
|
7 |
|
|
8 |
import javax.swing.Action; |
|
9 |
import javax.swing.ImageIcon; |
|
10 |
import javax.swing.KeyStroke; |
|
11 |
|
|
12 |
import org.gvsig.andami.PluginServices; |
|
13 |
import org.gvsig.andami.actioninfo.ActionInfo; |
|
14 |
import org.gvsig.andami.plugins.IExtension; |
|
15 |
import org.gvsig.tools.ToolsLocator; |
|
16 |
|
|
17 |
|
|
18 |
public class TranslatedActionInfo implements ActionInfo { |
|
19 |
|
|
20 |
private ActionInfo actionInfo; |
|
21 |
|
|
22 |
TranslatedActionInfo(ActionInfo actionInfo) { |
|
23 |
this.actionInfo = actionInfo; |
|
24 |
} |
|
25 |
|
|
26 |
public Object getValue(String key) { |
|
27 |
if (Action.SHORT_DESCRIPTION.equalsIgnoreCase(key)) { |
|
28 |
return this.getLabel(); |
|
29 |
} |
|
30 |
if (ActionInfo.TOOLTIP.equalsIgnoreCase(key)) { |
|
31 |
return this.getTooltip(); |
|
32 |
} |
|
33 |
|
|
34 |
return this.actionInfo.getValue(key); |
|
35 |
} |
|
36 |
|
|
37 |
public void putValue(String key, Object value) { |
|
38 |
this.actionInfo.putValue(key, value); |
|
39 |
|
|
40 |
} |
|
41 |
|
|
42 |
public void setEnabled(boolean b) { |
|
43 |
this.actionInfo.setEnabled(b); |
|
44 |
|
|
45 |
} |
|
46 |
|
|
47 |
public void addPropertyChangeListener(PropertyChangeListener listener) { |
|
48 |
this.actionInfo.addPropertyChangeListener(listener); |
|
49 |
} |
|
50 |
|
|
51 |
public void removePropertyChangeListener(PropertyChangeListener listener) { |
|
52 |
this.actionInfo.removePropertyChangeListener(listener); |
|
53 |
} |
|
54 |
|
|
55 |
public void actionPerformed(ActionEvent e) { |
|
56 |
this.actionInfo.actionPerformed(e); |
|
57 |
} |
|
58 |
|
|
59 |
public PluginServices getPlugin() { |
|
60 |
return this.actionInfo.getPlugin(); |
|
61 |
} |
|
62 |
|
|
63 |
public IExtension getExtension() { |
|
64 |
return this.actionInfo.getExtension(); |
|
65 |
} |
|
66 |
|
|
67 |
public String getPluginName() { |
|
68 |
return this.actionInfo.getPluginName(); |
|
69 |
} |
|
70 |
|
|
71 |
public String getExtensionName() { |
|
72 |
return this.actionInfo.getExtensionName(); |
|
73 |
} |
|
74 |
|
|
75 |
public String getName() { |
|
76 |
return this.actionInfo.getName(); |
|
77 |
} |
|
78 |
|
|
79 |
public String getLabel() { |
|
80 |
return ToolsLocator.getI18nManager().getTranslation(this.actionInfo.getLabel()); |
|
81 |
} |
|
82 |
|
|
83 |
public String getCommand() { |
|
84 |
return this.actionInfo.getCommand(); |
|
85 |
} |
|
86 |
|
|
87 |
public ImageIcon getIcon() { |
|
88 |
return this.actionInfo.getIcon(); |
|
89 |
} |
|
90 |
|
|
91 |
public String getIconName() { |
|
92 |
return this.actionInfo.getIconName(); |
|
93 |
} |
|
94 |
|
|
95 |
public String getAccelerator() { |
|
96 |
return this.actionInfo.getAccelerator(); |
|
97 |
} |
|
98 |
|
|
99 |
public KeyStroke getKeyStroke() { |
|
100 |
return this.actionInfo.getKeyStroke(); |
|
101 |
} |
|
102 |
|
|
103 |
public String getTooltip() { |
|
104 |
return ToolsLocator.getI18nManager().getTranslation(this.actionInfo.getTooltip()); |
|
105 |
} |
|
106 |
|
|
107 |
public long getPosition() { |
|
108 |
return this.actionInfo.getPosition(); |
|
109 |
} |
|
110 |
|
|
111 |
public boolean isVisible() { |
|
112 |
return this.actionInfo.isVisible(); |
|
113 |
} |
|
114 |
|
|
115 |
public boolean isEnabled() { |
|
116 |
return this.actionInfo.isEnabled(); |
|
117 |
} |
|
118 |
|
|
119 |
public void execute() { |
|
120 |
this.actionInfo.execute(); |
|
121 |
|
|
122 |
} |
|
123 |
|
|
124 |
public void execute(Object[] args) { |
|
125 |
this.actionInfo.execute(args); |
|
126 |
|
|
127 |
} |
|
128 |
|
|
129 |
public void execute(Map args) { |
|
130 |
this.actionInfo.execute(args); |
|
131 |
} |
|
132 |
|
|
133 |
public void execute(Object arg) { |
|
134 |
this.actionInfo.execute(arg); |
|
135 |
|
|
136 |
} |
|
137 |
|
|
138 |
public boolean isActive() { |
|
139 |
return this.actionInfo.isActive(); |
|
140 |
} |
|
141 |
|
|
142 |
public void setActive(boolean active) { |
|
143 |
this.actionInfo.setActive(active); |
|
144 |
|
|
145 |
} |
|
146 |
|
|
147 |
public Collection<ActionInfo> getRedirections() { |
|
148 |
return this.actionInfo.getRedirections(); |
|
149 |
} |
|
150 |
|
|
151 |
public Object clone() throws CloneNotSupportedException { |
|
152 |
TranslatedActionInfo other = (TranslatedActionInfo) super.clone(); |
|
153 |
other.actionInfo = (ActionInfo) this.actionInfo.clone(); |
|
154 |
return other; |
|
155 |
} |
|
156 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/actioninfo/impl/DefaultActionInfo.java | ||
---|---|---|
195 | 195 |
} |
196 | 196 |
return this.identityManager; |
197 | 197 |
} |
198 |
|
|
198 |
|
|
199 | 199 |
private SimpleIdentity getCurrentUser() { |
200 | 200 |
return this.getIdentityManager().getCurrentIdentity(); |
201 | 201 |
} |
202 |
|
|
202 |
|
|
203 | 203 |
public boolean isVisible() { |
204 | 204 |
if( !this.getCurrentUser().isAuthorized(this.getName()) ) { |
205 | 205 |
return false; |
... | ... | |
395 | 395 |
return this.iconName; |
396 | 396 |
} |
397 | 397 |
if (Action.SHORT_DESCRIPTION.equalsIgnoreCase(key)) { |
398 |
return this.text;
|
|
398 |
return this.getLabel();
|
|
399 | 399 |
} |
400 | 400 |
if (ActionInfo.TOOLTIP.equalsIgnoreCase(key)) { |
401 |
return this.text;
|
|
401 |
return this.getTooltip();
|
|
402 | 402 |
} |
403 | 403 |
if (ActionInfo.POSITION.equalsIgnoreCase(key)) { |
404 | 404 |
return this.position; |
... | ... | |
435 | 435 |
|
436 | 436 |
public void putValue(String key, Object newValue) { |
437 | 437 |
super.putValue(key, newValue); |
438 |
// This class is immutable, only "active" can be changed
|
|
438 |
// This class is immutable, only "active" can be changed |
|
439 | 439 |
if (ActionInfo.ACTIVE.equalsIgnoreCase(key)) { |
440 | 440 |
this.setActive(this.active); |
441 | 441 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/actioninfo/impl/DefaultActionInfoManager.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
public class DefaultActionInfoManager implements ActionInfoManager { |
44 | 44 |
private static Logger logger = LoggerFactory.getLogger(DefaultActionInfoManager.class); |
45 |
|
|
45 |
|
|
46 | 46 |
private Map<String, ActionInfo>actions = new HashMap<String, ActionInfo>(); |
47 | 47 |
private int anonymousCounter = 1; |
48 |
|
|
48 |
|
|
49 | 49 |
public ActionInfo createAction(Class<? extends IExtension> extension, String name, String text, String command, String icon, String accelerator, long position, String tip) { |
50 | 50 |
name = emptyToNull(name); |
51 | 51 |
String actionName = name; |
... | ... | |
65 | 65 |
} |
66 | 66 |
return action; |
67 | 67 |
} |
68 |
|
|
68 |
|
|
69 | 69 |
private String emptyToNull(String s) { |
70 | 70 |
if( s==null ) { |
71 | 71 |
return null; |
72 | 72 |
} |
73 | 73 |
return "".equals(s.trim())? null:s; |
74 | 74 |
} |
75 |
|
|
75 |
|
|
76 | 76 |
public ActionInfo registerAction(ActionInfo action) { |
77 | 77 |
if( action == null ) { |
78 | 78 |
// Avisamos en el log de que se intenta registrar una accion null, intentado |
... | ... | |
96 | 96 |
return action; |
97 | 97 |
} |
98 | 98 |
} |
99 |
|
|
99 |
|
|
100 | 100 |
public ActionInfo getAction(String name) { |
101 | 101 |
if( name == null || "".equals(name) ) { |
102 | 102 |
try { |
... | ... | |
108 | 108 |
} |
109 | 109 |
return this.actions.get(name); |
110 | 110 |
} |
111 |
|
|
111 |
|
|
112 | 112 |
public Iterator<ActionInfo> getActions() { |
113 | 113 |
List<ActionInfo> actions = new ArrayList<ActionInfo>(); |
114 | 114 |
actions.addAll(this.actions.values()); |
... | ... | |
121 | 121 |
}); |
122 | 122 |
return actions.iterator(); |
123 | 123 |
} |
124 |
|
|
124 |
|
|
125 | 125 |
public ActionInfoStatusCache createActionStatusCache() { |
126 | 126 |
return new DefaultActionInfoStatusCache(); |
127 | 127 |
} |
... | ... | |
146 | 146 |
action.execute(parameters); |
147 | 147 |
} |
148 | 148 |
|
149 |
|
|
149 |
public ActionInfo getTranslated(ActionInfo actionInfo) { |
|
150 |
return new TranslatedActionInfo(actionInfo); |
|
151 |
} |
|
152 |
|
|
153 |
|
|
150 | 154 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.framework/org.gvsig.andami/src/main/java/org/gvsig/andami/actioninfo/ActionInfoManager.java | ||
---|---|---|
31 | 31 |
|
32 | 32 |
/** |
33 | 33 |
* Create a new action and return. |
34 |
*
|
|
34 |
* |
|
35 | 35 |
* @param extension, class that execute the action, extends IExtension |
36 | 36 |
* @param name, name of the action |
37 | 37 |
* @param text, text to use to represent the action. |
... | ... | |
43 | 43 |
* @return |
44 | 44 |
*/ |
45 | 45 |
public ActionInfo createAction(Class<? extends IExtension> extension, String name, String text, String command, String icon, String accelerator, long position, String tip); |
46 |
|
|
46 |
|
|
47 | 47 |
/** |
48 | 48 |
* Register the action in the actions of the system, and return the action |
49 | 49 |
* that is registered. |
50 |
*
|
|
50 |
* |
|
51 | 51 |
* If an action with the same name is in the system then actions are merged |
52 | 52 |
* and the merged action is returned and remain in the system. |
53 |
*
|
|
53 |
* |
|
54 | 54 |
* @param action |
55 | 55 |
*/ |
56 | 56 |
public ActionInfo registerAction(ActionInfo action); |
57 |
|
|
57 |
|
|
58 | 58 |
/** |
59 | 59 |
* Retrieve an action by name |
60 |
*
|
|
60 |
* |
|
61 | 61 |
* @param name |
62 | 62 |
* @return the action associated to this name |
63 | 63 |
*/ |
64 | 64 |
public ActionInfo getAction(String name); |
65 |
|
|
65 |
|
|
66 | 66 |
/** |
67 | 67 |
* Return an iterator over all registered actions. |
68 |
*
|
|
68 |
* |
|
69 | 69 |
* @return iterator over al acctions |
70 | 70 |
*/ |
71 | 71 |
public Iterator<ActionInfo> getActions(); |
72 |
|
|
72 |
|
|
73 | 73 |
public ActionInfoStatusCache createActionStatusCache(); |
74 |
|
|
74 |
|
|
75 | 75 |
/** |
76 | 76 |
* Redirect the action source to the target. |
77 |
*
|
|
77 |
* |
|
78 | 78 |
* @param sourceName of action |
79 | 79 |
* @param targetName of action |
80 | 80 |
*/ |
81 | 81 |
public void redirect(String sourceName, String targetName); |
82 |
|
|
82 |
|
|
83 | 83 |
public void execute(String actionName, Object[] parameters); |
84 |
|
|
85 |
public ActionInfo getTranslated(ActionInfo actionInfo); |
|
84 | 86 |
} |
Also available in: Unified diff