3 |
3 |
*
|
4 |
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
5 |
*
|
6 |
|
* This program is free software; you can redistribute it and/or
|
7 |
|
* modify it under the terms of the GNU General Public License
|
8 |
|
* as published by the Free Software Foundation; either version 3
|
9 |
|
* of the License, or (at your option) any later version.
|
|
6 |
* This program is free software; you can redistribute it and/or modify it under
|
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
|
8 |
* Foundation; either version 3 of the License, or (at your option) any later
|
|
9 |
* version.
|
10 |
10 |
*
|
11 |
|
* This program is distributed in the hope that it will be useful,
|
12 |
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 |
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14 |
|
* GNU General Public License for more details.
|
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
|
14 |
* details.
|
15 |
15 |
*
|
16 |
|
* You should have received a copy of the GNU General Public License
|
17 |
|
* along with this program; if not, write to the Free Software
|
18 |
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
|
19 |
|
* MA 02110-1301, USA.
|
|
16 |
* You should have received a copy of the GNU General Public License along with
|
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51
|
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
20 |
19 |
*
|
21 |
|
* For any additional information, do not hesitate to contact us
|
22 |
|
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
|
21 |
* gvsig.com, or visit our website www.gvsig.com.
|
23 |
22 |
*/
|
24 |
23 |
package org.gvsig.andami.actioninfo.impl;
|
25 |
24 |
|
... | ... | |
49 |
48 |
import org.slf4j.LoggerFactory;
|
50 |
49 |
|
51 |
50 |
public class DefaultActionInfo extends AbstractAction implements ActionInfo {
|
52 |
|
/**
|
53 |
|
*
|
54 |
|
*/
|
55 |
|
private static final long serialVersionUID = 1620939552263334110L;
|
56 |
51 |
|
57 |
|
private static Logger logger = LoggerFactory
|
58 |
|
.getLogger(DefaultActionInfo.class);
|
|
52 |
/**
|
|
53 |
*
|
|
54 |
*/
|
|
55 |
private static final long serialVersionUID = 1620939552263334110L;
|
59 |
56 |
|
60 |
|
private Class<? extends IExtension> extensionClass;
|
61 |
|
private IExtension extension;
|
62 |
|
private String name;
|
63 |
|
private String text;
|
64 |
|
private String command;
|
65 |
|
private String iconName;
|
66 |
|
private String accelerator;
|
67 |
|
private long position;
|
68 |
|
private String tip;
|
69 |
|
private List<ActionInfo> redirections;
|
70 |
|
private boolean active;
|
|
57 |
private static Logger logger = LoggerFactory
|
|
58 |
.getLogger(DefaultActionInfo.class);
|
71 |
59 |
|
72 |
|
private Boolean previousEnabled = null;
|
|
60 |
private Class<? extends IExtension> extensionClass;
|
|
61 |
private IExtension extension;
|
|
62 |
private String name;
|
|
63 |
private String text;
|
|
64 |
private String command;
|
|
65 |
private String iconName;
|
|
66 |
private String accelerator;
|
|
67 |
private long position;
|
|
68 |
private String tip;
|
|
69 |
private List<ActionInfo> redirections;
|
|
70 |
private boolean active;
|
73 |
71 |
|
74 |
|
DefaultActionInfo(Class<? extends IExtension> extension, String name,
|
75 |
|
String text, String command, String icon, String accelerator,
|
76 |
|
long position, String tip) {
|
77 |
|
this.extensionClass = extension;
|
78 |
|
this.name = name;
|
79 |
|
this.text = emptyToNull(text);
|
80 |
|
this.command = emptyToNull(command);
|
81 |
|
this.iconName = emptyToNull(icon);
|
82 |
|
this.accelerator = emptyToNull(accelerator);
|
83 |
|
this.position = position;
|
84 |
|
this.tip = emptyToNull(tip);
|
85 |
|
this.redirections = null;
|
86 |
|
this.active = true;
|
87 |
|
|
88 |
|
fixIcon();
|
89 |
|
}
|
90 |
|
|
91 |
|
private void fixIcon() {
|
92 |
|
if (iconName != null && (iconName.contains("/") || iconName.contains("."))) {
|
93 |
|
// it's a file path
|
94 |
|
String name = FilenameUtils.getBaseName(iconName);
|
95 |
|
IconTheme iconTheme = ToolsSwingLocator.getIconThemeManager().getDefault();
|
96 |
|
URL resource = null;
|
97 |
|
try {
|
98 |
|
resource = this.extensionClass.getClassLoader().getResource(iconName);
|
|
72 |
private Boolean previousEnabled = null;
|
|
73 |
|
|
74 |
DefaultActionInfo(Class<? extends IExtension> extension, String name,
|
|
75 |
String text, String command, String icon, String accelerator,
|
|
76 |
long position, String tip) {
|
|
77 |
this.extensionClass = extension;
|
|
78 |
this.name = name;
|
|
79 |
this.text = emptyToNull(text);
|
|
80 |
this.command = emptyToNull(command);
|
|
81 |
this.iconName = emptyToNull(icon);
|
|
82 |
this.accelerator = emptyToNull(accelerator);
|
|
83 |
this.position = position;
|
|
84 |
this.tip = emptyToNull(tip);
|
|
85 |
this.redirections = null;
|
|
86 |
this.active = true;
|
|
87 |
|
|
88 |
fixIcon();
|
|
89 |
}
|
|
90 |
|
|
91 |
public Object clone() throws CloneNotSupportedException {
|
|
92 |
DefaultActionInfo other = (DefaultActionInfo) super.clone();
|
|
93 |
if (other.redirections != null) {
|
|
94 |
other.redirections = new ArrayList<ActionInfo>();
|
|
95 |
other.redirections.addAll(this.redirections);
|
|
96 |
}
|
|
97 |
return other;
|
|
98 |
}
|
|
99 |
|
|
100 |
private void fixIcon() {
|
|
101 |
if (iconName != null && (iconName.contains("/") || iconName.contains("."))) {
|
|
102 |
// it's a file path
|
|
103 |
String name = FilenameUtils.getBaseName(iconName);
|
|
104 |
IconTheme iconTheme = ToolsSwingLocator.getIconThemeManager().getDefault();
|
|
105 |
URL resource = null;
|
|
106 |
try {
|
|
107 |
resource = this.extensionClass.getClassLoader().getResource(iconName);
|
99 |
108 |
} catch (Exception e) {
|
100 |
109 |
return;
|
101 |
110 |
}
|
102 |
|
if (resource == null) {
|
103 |
|
return;
|
104 |
|
}
|
105 |
|
iconTheme.registerDefault(this.getPluginName(), "broken", name, null, resource);
|
|
111 |
if (resource == null) {
|
|
112 |
return;
|
|
113 |
}
|
|
114 |
iconTheme.registerDefault(this.getPluginName(), "broken", name, null, resource);
|
106 |
115 |
logger.info("Plugin " + this.getPluginName() + " contains icons out of icon theme (" + iconName + ")");
|
107 |
|
iconName = name;
|
108 |
|
}
|
109 |
|
}
|
110 |
|
|
111 |
|
|
|
116 |
iconName = name;
|
|
117 |
}
|
|
118 |
}
|
112 |
119 |
|
113 |
|
private String emptyToNull(String s) {
|
114 |
|
if (s == null) {
|
115 |
|
return null;
|
116 |
|
}
|
117 |
|
return s.trim().length() < 0 ? null : s;
|
118 |
|
}
|
|
120 |
private String emptyToNull(String s) {
|
|
121 |
if (s == null) {
|
|
122 |
return null;
|
|
123 |
}
|
|
124 |
return s.trim().length() < 0 ? null : s;
|
|
125 |
}
|
119 |
126 |
|
120 |
|
public Collection<ActionInfo> getRedirections() {
|
121 |
|
if (this.redirections == null) {
|
122 |
|
this.redirections = new ArrayList<ActionInfo>();
|
123 |
|
}
|
124 |
|
return this.redirections;
|
125 |
|
}
|
|
127 |
public Collection<ActionInfo> getRedirections() {
|
|
128 |
if (this.redirections == null) {
|
|
129 |
this.redirections = new ArrayList<ActionInfo>();
|
|
130 |
}
|
|
131 |
return this.redirections;
|
|
132 |
}
|
126 |
133 |
|
127 |
|
public void merge(ActionInfo other) {
|
128 |
|
if (this.extensionClass == null) {
|
129 |
|
this.extensionClass = other.getExtension().getClass();
|
130 |
|
this.extension = other.getExtension();
|
131 |
|
}
|
132 |
|
if (this.text == null) {
|
133 |
|
this.text = other.getLabel();
|
134 |
|
}
|
135 |
|
if (this.command == null) {
|
136 |
|
this.command = other.getCommand();
|
137 |
|
}
|
138 |
|
if (this.iconName == null) {
|
139 |
|
this.iconName = other.getIconName();
|
140 |
|
}
|
141 |
|
if (this.accelerator == null) {
|
142 |
|
this.accelerator = other.getAccelerator();
|
143 |
|
}
|
144 |
|
if (this.position < 1) {
|
145 |
|
this.position = other.getPosition();
|
146 |
|
}
|
147 |
|
if (this.tip == null) {
|
148 |
|
this.tip = other.getTooltip();
|
149 |
|
}
|
|
134 |
public void merge(ActionInfo other) {
|
|
135 |
if (this.extensionClass == null) {
|
|
136 |
this.extensionClass = other.getExtension().getClass();
|
|
137 |
this.extension = other.getExtension();
|
|
138 |
}
|
|
139 |
if (this.text == null) {
|
|
140 |
this.text = other.getLabel();
|
|
141 |
}
|
|
142 |
if (this.command == null) {
|
|
143 |
this.command = other.getCommand();
|
|
144 |
}
|
|
145 |
if (this.iconName == null) {
|
|
146 |
this.iconName = other.getIconName();
|
|
147 |
}
|
|
148 |
if (this.accelerator == null) {
|
|
149 |
this.accelerator = other.getAccelerator();
|
|
150 |
}
|
|
151 |
if (this.position < 1) {
|
|
152 |
this.position = other.getPosition();
|
|
153 |
}
|
|
154 |
if (this.tip == null) {
|
|
155 |
this.tip = other.getTooltip();
|
|
156 |
}
|
150 |
157 |
|
151 |
|
}
|
|
158 |
}
|
152 |
159 |
|
153 |
|
public PluginServices getPlugin() {
|
154 |
|
PluginServices plugin = PluginsLocator.getManager().getPlugin(
|
155 |
|
this.extensionClass);
|
156 |
|
return plugin;
|
157 |
|
}
|
|
160 |
public PluginServices getPlugin() {
|
|
161 |
PluginServices plugin = PluginsLocator.getManager().getPlugin(
|
|
162 |
this.extensionClass);
|
|
163 |
return plugin;
|
|
164 |
}
|
158 |
165 |
|
159 |
|
public String getPluginName() {
|
160 |
|
if( this.getPlugin()==null ) {
|
161 |
|
return null;
|
162 |
|
}
|
163 |
|
return this.getPlugin().getPluginName();
|
164 |
|
}
|
|
166 |
public String getPluginName() {
|
|
167 |
if (this.getPlugin() == null) {
|
|
168 |
return null;
|
|
169 |
}
|
|
170 |
return this.getPlugin().getPluginName();
|
|
171 |
}
|
165 |
172 |
|
166 |
|
public IExtension getExtension() {
|
167 |
|
if (this.extension == null) {
|
168 |
|
this.extension = PluginsLocator.getManager().getExtension(
|
169 |
|
this.extensionClass);
|
170 |
|
}
|
171 |
|
return this.extension;
|
172 |
|
}
|
|
173 |
public IExtension getExtension() {
|
|
174 |
if (this.extension == null) {
|
|
175 |
this.extension = PluginsLocator.getManager().getExtension(
|
|
176 |
this.extensionClass);
|
|
177 |
}
|
|
178 |
return this.extension;
|
|
179 |
}
|
173 |
180 |
|
174 |
|
public String getExtensionName() {
|
175 |
|
if( this.extensionClass==null ) {
|
176 |
|
return null;
|
177 |
|
}
|
178 |
|
return this.extensionClass.getName();
|
179 |
|
}
|
|
181 |
public String getExtensionName() {
|
|
182 |
if (this.extensionClass == null) {
|
|
183 |
return null;
|
|
184 |
}
|
|
185 |
return this.extensionClass.getName();
|
|
186 |
}
|
180 |
187 |
|
181 |
|
public boolean isVisible() {
|
182 |
|
if (!this.isActive()) {
|
183 |
|
logger.info("isVisible(), action {} not active", this.getName());
|
184 |
|
return false;
|
185 |
|
}
|
186 |
|
ActionInfo redirection = this.getRedirection();
|
187 |
|
if (redirection!=null) {
|
188 |
|
return redirection.isVisible();
|
189 |
|
}
|
|
188 |
public boolean isVisible() {
|
|
189 |
if (!this.isActive()) {
|
|
190 |
logger.info("isVisible(), action {} not active", this.getName());
|
|
191 |
return false;
|
|
192 |
}
|
|
193 |
ActionInfo redirection = this.getRedirection();
|
|
194 |
if (redirection != null) {
|
|
195 |
return redirection.isVisible();
|
|
196 |
}
|
190 |
197 |
|
191 |
|
ExclusiveUIExtension eui = PluginsLocator.getManager()
|
192 |
|
.getExclusiveUIExtension();
|
193 |
|
if (eui == null) {
|
194 |
|
return ExtensionHelper.isVisible(this.getExtension(), this.command);
|
195 |
|
}
|
196 |
|
return eui.isVisible(this.getExtension());
|
197 |
|
}
|
|
198 |
ExclusiveUIExtension eui = PluginsLocator.getManager()
|
|
199 |
.getExclusiveUIExtension();
|
|
200 |
if (eui == null) {
|
|
201 |
return ExtensionHelper.isVisible(this.getExtension(), this.command);
|
|
202 |
}
|
|
203 |
return eui.isVisible(this.getExtension());
|
|
204 |
}
|
198 |
205 |
|
199 |
|
public boolean isEnabled() {
|
200 |
|
boolean value;
|
201 |
|
if (!this.isActive()) {
|
202 |
|
logger.info("isEnabled(), action {} not active", this.getName());
|
203 |
|
value = false;
|
204 |
|
} else {
|
205 |
|
ActionInfo redirection = this.getRedirection();
|
206 |
|
if (redirection!=null) {
|
207 |
|
value = true;
|
208 |
|
} else {
|
209 |
|
ExclusiveUIExtension eui = PluginsLocator.getManager()
|
210 |
|
.getExclusiveUIExtension();
|
211 |
|
if (eui == null) {
|
212 |
|
value = ExtensionHelper.isEnabled(this.getExtension(), this.command);
|
213 |
|
} else {
|
214 |
|
value = eui.isEnabled(this.getExtension());
|
215 |
|
}
|
216 |
|
}
|
217 |
|
}
|
218 |
|
if( this.previousEnabled == null || this.previousEnabled.booleanValue() != value ) {
|
219 |
|
this.setEnabled(value); // force call listeners
|
220 |
|
}
|
221 |
|
return value;
|
222 |
|
}
|
223 |
|
|
224 |
|
private ActionInfo getRedirection() {
|
225 |
|
if( this.redirections == null ) {
|
226 |
|
return null;
|
227 |
|
}
|
228 |
|
for( int n=this.redirections.size()-1; n>=0 ; n-- ) {
|
229 |
|
ActionInfo redirection = this.redirections.get(n);
|
230 |
|
if (redirection.isEnabled()) {
|
231 |
|
return redirection;
|
232 |
|
}
|
233 |
|
}
|
234 |
|
return null;
|
235 |
|
}
|
|
206 |
public boolean isEnabled() {
|
|
207 |
boolean value;
|
|
208 |
if (!this.isActive()) {
|
|
209 |
logger.info("isEnabled(), action {} not active", this.getName());
|
|
210 |
value = false;
|
|
211 |
} else {
|
|
212 |
ActionInfo redirection = this.getRedirection();
|
|
213 |
if (redirection != null) {
|
|
214 |
value = true;
|
|
215 |
} else {
|
|
216 |
ExclusiveUIExtension eui = PluginsLocator.getManager()
|
|
217 |
.getExclusiveUIExtension();
|
|
218 |
if (eui == null) {
|
|
219 |
value = ExtensionHelper.isEnabled(this.getExtension(), this.command);
|
|
220 |
} else {
|
|
221 |
value = eui.isEnabled(this.getExtension());
|
|
222 |
}
|
|
223 |
}
|
|
224 |
}
|
|
225 |
if (this.previousEnabled == null || this.previousEnabled.booleanValue() != value) {
|
|
226 |
this.setEnabled(value); // force call listeners
|
|
227 |
}
|
|
228 |
return value;
|
|
229 |
}
|
236 |
230 |
|
237 |
|
public void execute() {
|
|
231 |
private ActionInfo getRedirection() {
|
|
232 |
if (this.redirections == null) {
|
|
233 |
return null;
|
|
234 |
}
|
|
235 |
for (int n = this.redirections.size() - 1; n >= 0; n--) {
|
|
236 |
ActionInfo redirection = this.redirections.get(n);
|
|
237 |
if (redirection.isEnabled()) {
|
|
238 |
return redirection;
|
|
239 |
}
|
|
240 |
}
|
|
241 |
return null;
|
|
242 |
}
|
|
243 |
|
|
244 |
public void execute() {
|
238 |
245 |
// if (!this.isActive()) {
|
239 |
246 |
// logger.info("execute(), action {} not active", this.getName());
|
240 |
247 |
// return;
|
241 |
248 |
// }
|
242 |
|
ActionInfo redirection = this.getRedirection();
|
243 |
|
if (redirection!=null) {
|
244 |
|
logger.info("{}.execute('{}') redirected", this.getPluginName()
|
245 |
|
+ ":" + this.getExtensionName(), this.getCommand());
|
246 |
|
redirection.execute();
|
247 |
|
return;
|
248 |
|
}
|
249 |
|
logger.info("{}.execute('{}')",
|
250 |
|
this.getPluginName() + ":" + this.getExtensionName(),
|
251 |
|
this.getCommand());
|
252 |
|
this.getExtension().execute(this.command);
|
253 |
|
}
|
|
249 |
ActionInfo redirection = this.getRedirection();
|
|
250 |
if (redirection != null) {
|
|
251 |
logger.info("{}.execute('{}') redirected", this.getPluginName()
|
|
252 |
+ ":" + this.getExtensionName(), this.getCommand());
|
|
253 |
redirection.execute();
|
|
254 |
return;
|
|
255 |
}
|
|
256 |
logger.info("{}.execute('{}')",
|
|
257 |
this.getPluginName() + ":" + this.getExtensionName(),
|
|
258 |
this.getCommand());
|
|
259 |
this.getExtension().execute(this.command);
|
|
260 |
}
|
254 |
261 |
|
255 |
|
public void execute(Object[] args) {
|
|
262 |
public void execute(Object[] args) {
|
256 |
263 |
// if (!this.isActive()) {
|
257 |
264 |
// logger.info("execute(args), action {} not active", this.getName());
|
258 |
265 |
// return;
|
259 |
266 |
// }
|
260 |
|
ActionInfo redirection = this.getRedirection();
|
261 |
|
if (redirection!=null) {
|
262 |
|
logger.info("{}.execute('{}', args) redirected", this.getPluginName()
|
263 |
|
+ ":" + this.getExtensionName(), this.getCommand());
|
264 |
|
redirection.execute(args);
|
265 |
|
return;
|
266 |
|
}
|
267 |
|
logger.info("{}.execute('{}', Object[] args)",
|
268 |
|
this.getPluginName() + ":" + this.getExtensionName(),
|
269 |
|
this.getCommand());
|
270 |
|
ExtensionHelper.execute(this.getExtension(), this.command, args);
|
271 |
|
}
|
|
267 |
ActionInfo redirection = this.getRedirection();
|
|
268 |
if (redirection != null) {
|
|
269 |
logger.info("{}.execute('{}', args) redirected", this.getPluginName()
|
|
270 |
+ ":" + this.getExtensionName(), this.getCommand());
|
|
271 |
redirection.execute(args);
|
|
272 |
return;
|
|
273 |
}
|
|
274 |
logger.info("{}.execute('{}', Object[] args)",
|
|
275 |
this.getPluginName() + ":" + this.getExtensionName(),
|
|
276 |
this.getCommand());
|
|
277 |
ExtensionHelper.execute(this.getExtension(), this.command, args);
|
|
278 |
}
|
272 |
279 |
|
273 |
|
public void execute(Object arg) {
|
274 |
|
if (arg instanceof Object[]) {
|
275 |
|
execute((Object[]) arg);
|
276 |
|
return;
|
277 |
|
}
|
278 |
|
execute(new Object[] { arg });
|
279 |
|
}
|
|
280 |
public void execute(Object arg) {
|
|
281 |
if (arg instanceof Object[]) {
|
|
282 |
execute((Object[]) arg);
|
|
283 |
return;
|
|
284 |
}
|
|
285 |
execute(new Object[]{arg});
|
|
286 |
}
|
280 |
287 |
|
281 |
|
public void execute(Map args) {
|
282 |
|
logger.info("{}.execute('{}', Map args)",
|
283 |
|
this.getPluginName() + ":" + this.getExtensionName(),
|
284 |
|
this.getCommand());
|
285 |
|
ExtensionHelper.execute(this.getExtension(), this.command, new Object[] { args });
|
286 |
|
}
|
|
288 |
public void execute(Map args) {
|
|
289 |
logger.info("{}.execute('{}', Map args)",
|
|
290 |
this.getPluginName() + ":" + this.getExtensionName(),
|
|
291 |
this.getCommand());
|
|
292 |
ExtensionHelper.execute(this.getExtension(), this.command, new Object[]{args});
|
|
293 |
}
|
287 |
294 |
|
288 |
|
public void actionPerformed(ActionEvent arg0) {
|
289 |
|
this.execute();
|
290 |
|
}
|
|
295 |
public void actionPerformed(ActionEvent arg0) {
|
|
296 |
this.execute();
|
|
297 |
}
|
291 |
298 |
|
292 |
|
public String getName() {
|
293 |
|
return this.name;
|
294 |
|
}
|
|
299 |
public String getName() {
|
|
300 |
return this.name;
|
|
301 |
}
|
295 |
302 |
|
296 |
|
public String getLabel() {
|
297 |
|
return this.text;
|
298 |
|
}
|
|
303 |
public String getLabel() {
|
|
304 |
return this.text;
|
|
305 |
}
|
299 |
306 |
|
300 |
|
public String getCommand() {
|
301 |
|
return this.command;
|
302 |
|
}
|
|
307 |
public String getCommand() {
|
|
308 |
return this.command;
|
|
309 |
}
|
303 |
310 |
|
304 |
|
public String getIconName() {
|
305 |
|
return this.iconName;
|
306 |
|
}
|
|
311 |
public String getIconName() {
|
|
312 |
return this.iconName;
|
|
313 |
}
|
307 |
314 |
|
308 |
|
public ImageIcon getIcon() {
|
309 |
|
IconTheme iconTheme = PluginServices.getIconTheme();
|
310 |
|
return iconTheme.get(this.iconName);
|
311 |
|
}
|
|
315 |
public ImageIcon getIcon() {
|
|
316 |
IconTheme iconTheme = PluginServices.getIconTheme();
|
|
317 |
return iconTheme.get(this.iconName);
|
|
318 |
}
|
312 |
319 |
|
313 |
|
public String getAccelerator() {
|
314 |
|
return this.accelerator;
|
315 |
|
}
|
|
320 |
public String getAccelerator() {
|
|
321 |
return this.accelerator;
|
|
322 |
}
|
316 |
323 |
|
317 |
|
public KeyStroke getKeyStroke() {
|
318 |
|
if (emptyToNull(this.accelerator) == null) {
|
319 |
|
return null;
|
320 |
|
}
|
321 |
|
return KeyMapping.getKeyStroke(this.accelerator);
|
322 |
|
}
|
|
324 |
public KeyStroke getKeyStroke() {
|
|
325 |
if (emptyToNull(this.accelerator) == null) {
|
|
326 |
return null;
|
|
327 |
}
|
|
328 |
return KeyMapping.getKeyStroke(this.accelerator);
|
|
329 |
}
|
323 |
330 |
|
324 |
|
public long getPosition() {
|
325 |
|
return this.position;
|
326 |
|
}
|
|
331 |
public long getPosition() {
|
|
332 |
return this.position;
|
|
333 |
}
|
327 |
334 |
|
328 |
|
public String getTooltip() {
|
329 |
|
return this.tip;
|
330 |
|
}
|
|
335 |
public String getTooltip() {
|
|
336 |
return this.tip;
|
|
337 |
}
|
331 |
338 |
|
332 |
|
public Object getValue(String key) {
|
333 |
|
if (Action.ACTION_COMMAND_KEY.equalsIgnoreCase(key)) {
|
334 |
|
return this.command;
|
335 |
|
}
|
336 |
|
if (Action.LONG_DESCRIPTION.equalsIgnoreCase(key)) {
|
337 |
|
return this.tip;
|
338 |
|
}
|
339 |
|
if (Action.NAME.equalsIgnoreCase(key)) {
|
340 |
|
return this.name;
|
341 |
|
}
|
342 |
|
if (Action.SMALL_ICON.equalsIgnoreCase(key)) {
|
343 |
|
return this.getIcon();
|
344 |
|
}
|
345 |
|
if (Action.ACTION_COMMAND_KEY.equalsIgnoreCase(key)) {
|
346 |
|
return this.command;
|
347 |
|
}
|
348 |
|
if (Action.ACCELERATOR_KEY.equalsIgnoreCase(key)) {
|
349 |
|
return this.getKeyStroke();
|
350 |
|
}
|
351 |
|
if (Action.LARGE_ICON_KEY.equalsIgnoreCase(key)) {
|
352 |
|
return this.getIcon();
|
353 |
|
}
|
354 |
|
if (ActionInfo.ICON_NAME.equalsIgnoreCase(key)) {
|
355 |
|
return this.iconName;
|
356 |
|
}
|
357 |
|
if (Action.SHORT_DESCRIPTION.equalsIgnoreCase(key)) {
|
358 |
|
return this.text;
|
359 |
|
}
|
360 |
|
if (ActionInfo.TOOLTIP.equalsIgnoreCase(key)) {
|
361 |
|
return this.text;
|
362 |
|
}
|
363 |
|
if (ActionInfo.POSITION.equalsIgnoreCase(key)) {
|
364 |
|
return this.position;
|
365 |
|
}
|
366 |
|
if (ActionInfo.REDIRECTIONS.equalsIgnoreCase(key)) {
|
367 |
|
return this.redirections;
|
368 |
|
}
|
369 |
|
if (ActionInfo.REDIRECTION.equalsIgnoreCase(key)) {
|
370 |
|
return this.getRedirection();
|
371 |
|
}
|
372 |
|
if (ActionInfo.EXTENSION.equalsIgnoreCase(key)) {
|
373 |
|
return this.getExtension();
|
374 |
|
}
|
375 |
|
if (ActionInfo.EXTENSION_NAME.equalsIgnoreCase(key)) {
|
376 |
|
return this.getExtensionName();
|
377 |
|
}
|
378 |
|
if (ActionInfo.PLUGIN.equalsIgnoreCase(key)) {
|
379 |
|
return this.getPlugin();
|
380 |
|
}
|
381 |
|
if (ActionInfo.PLUGIN_NAME.equalsIgnoreCase(key)) {
|
382 |
|
return this.getPluginName();
|
383 |
|
}
|
384 |
|
if (ActionInfo.VISIBLE.equalsIgnoreCase(key)) {
|
385 |
|
return this.isVisible();
|
386 |
|
}
|
387 |
|
if (ActionInfo.ACTIVE.equalsIgnoreCase(key)) {
|
388 |
|
return this.active;
|
389 |
|
}
|
390 |
|
if (ActionInfo.ACCELERATOR.equalsIgnoreCase(key)) {
|
391 |
|
return this.accelerator;
|
392 |
|
}
|
393 |
|
return super.getValue(key);
|
394 |
|
}
|
|
339 |
public Object getValue(String key) {
|
|
340 |
if (Action.ACTION_COMMAND_KEY.equalsIgnoreCase(key)) {
|
|
341 |
return this.command;
|
|
342 |
}
|
|
343 |
if (Action.LONG_DESCRIPTION.equalsIgnoreCase(key)) {
|
|
344 |
return this.tip;
|
|
345 |
}
|
|
346 |
if (Action.NAME.equalsIgnoreCase(key)) {
|
|
347 |
return this.name;
|
|
348 |
}
|
|
349 |
if (Action.SMALL_ICON.equalsIgnoreCase(key)) {
|
|
350 |
return this.getIcon();
|
|
351 |
}
|
|
352 |
if (Action.ACTION_COMMAND_KEY.equalsIgnoreCase(key)) {
|
|
353 |
return this.command;
|
|
354 |
}
|
|
355 |
if (Action.ACCELERATOR_KEY.equalsIgnoreCase(key)) {
|
|
356 |
return this.getKeyStroke();
|
|
357 |
}
|
|
358 |
if (Action.LARGE_ICON_KEY.equalsIgnoreCase(key)) {
|
|
359 |
return this.getIcon();
|
|
360 |
}
|
|
361 |
if (ActionInfo.ICON_NAME.equalsIgnoreCase(key)) {
|
|
362 |
return this.iconName;
|
|
363 |
}
|
|
364 |
if (Action.SHORT_DESCRIPTION.equalsIgnoreCase(key)) {
|
|
365 |
return this.text;
|
|
366 |
}
|
|
367 |
if (ActionInfo.TOOLTIP.equalsIgnoreCase(key)) {
|
|
368 |
return this.text;
|
|
369 |
}
|
|
370 |
if (ActionInfo.POSITION.equalsIgnoreCase(key)) {
|
|
371 |
return this.position;
|
|
372 |
}
|
|
373 |
if (ActionInfo.REDIRECTIONS.equalsIgnoreCase(key)) {
|
|
374 |
return this.redirections;
|
|
375 |
}
|
|
376 |
if (ActionInfo.REDIRECTION.equalsIgnoreCase(key)) {
|
|
377 |
return this.getRedirection();
|
|
378 |
}
|
|
379 |
if (ActionInfo.EXTENSION.equalsIgnoreCase(key)) {
|
|
380 |
return this.getExtension();
|
|
381 |
}
|
|
382 |
if (ActionInfo.EXTENSION_NAME.equalsIgnoreCase(key)) {
|
|
383 |
return this.getExtensionName();
|
|
384 |
}
|
|
385 |
if (ActionInfo.PLUGIN.equalsIgnoreCase(key)) {
|
|
386 |
return this.getPlugin();
|
|
387 |
}
|
|
388 |
if (ActionInfo.PLUGIN_NAME.equalsIgnoreCase(key)) {
|
|
389 |
return this.getPluginName();
|
|
390 |
}
|
|
391 |
if (ActionInfo.VISIBLE.equalsIgnoreCase(key)) {
|
|
392 |
return this.isVisible();
|
|
393 |
}
|
|
394 |
if (ActionInfo.ACTIVE.equalsIgnoreCase(key)) {
|
|
395 |
return this.active;
|
|
396 |
}
|
|
397 |
if (ActionInfo.ACCELERATOR.equalsIgnoreCase(key)) {
|
|
398 |
return this.accelerator;
|
|
399 |
}
|
|
400 |
return super.getValue(key);
|
|
401 |
}
|
395 |
402 |
|
396 |
|
public void putValue(String key, Object newValue) {
|
397 |
|
super.putValue(key, newValue);
|
398 |
|
// This class is immutable, only "active" can be changed
|
399 |
|
if (ActionInfo.ACTIVE.equalsIgnoreCase(key)) {
|
400 |
|
this.setActive(this.active);
|
401 |
|
}
|
402 |
|
}
|
|
403 |
public void putValue(String key, Object newValue) {
|
|
404 |
super.putValue(key, newValue);
|
|
405 |
// This class is immutable, only "active" can be changed
|
|
406 |
if (ActionInfo.ACTIVE.equalsIgnoreCase(key)) {
|
|
407 |
this.setActive(this.active);
|
|
408 |
}
|
|
409 |
}
|
403 |
410 |
|
404 |
|
public String toString() {
|
405 |
|
StringBuffer buffer = new StringBuffer();
|
406 |
|
buffer.append("ActionInfo {");
|
407 |
|
buffer.append("name='").append(this.name).append("', ");
|
408 |
|
buffer.append("active='").append(this.active).append("', ");
|
409 |
|
buffer.append("label='").append(this.text).append("', ");
|
410 |
|
buffer.append("tooltip='").append(this.tip).append("', ");
|
411 |
|
buffer.append("actionCommand='").append(this.command).append("', ");
|
412 |
|
buffer.append("position='").append(this.position).append("', ");
|
413 |
|
buffer.append("icon='").append(this.iconName).append("', ");
|
414 |
|
buffer.append("extension='").append(this.getExtensionName())
|
415 |
|
.append("', ");
|
416 |
|
if (this.redirections != null) {
|
417 |
|
buffer.append("redirection=(");
|
418 |
|
for (ActionInfo redirection : this.redirections) {
|
419 |
|
buffer.append(redirection.getName());
|
420 |
|
buffer.append(" ");
|
421 |
|
}
|
422 |
|
buffer.append("), ");
|
423 |
|
} else {
|
424 |
|
buffer.append("redirections=( ), ");
|
425 |
|
}
|
426 |
|
buffer.append("accelerator='").append(this.accelerator);
|
427 |
|
buffer.append("' }");
|
428 |
|
return buffer.toString();
|
429 |
|
}
|
|
411 |
public String toString() {
|
|
412 |
StringBuffer buffer = new StringBuffer();
|
|
413 |
buffer.append("ActionInfo {");
|
|
414 |
buffer.append("name='").append(this.name).append("', ");
|
|
415 |
buffer.append("active='").append(this.active).append("', ");
|
|
416 |
buffer.append("label='").append(this.text).append("', ");
|
|
417 |
buffer.append("tooltip='").append(this.tip).append("', ");
|
|
418 |
buffer.append("actionCommand='").append(this.command).append("', ");
|
|
419 |
buffer.append("position='").append(this.position).append("', ");
|
|
420 |
buffer.append("icon='").append(this.iconName).append("', ");
|
|
421 |
buffer.append("extension='").append(this.getExtensionName())
|
|
422 |
.append("', ");
|
|
423 |
if (this.redirections != null) {
|
|
424 |
buffer.append("redirection=(");
|
|
425 |
for (ActionInfo redirection : this.redirections) {
|
|
426 |
buffer.append(redirection.getName());
|
|
427 |
buffer.append(" ");
|
|
428 |
}
|
|
429 |
buffer.append("), ");
|
|
430 |
} else {
|
|
431 |
buffer.append("redirections=( ), ");
|
|
432 |
}
|
|
433 |
buffer.append("accelerator='").append(this.accelerator);
|
|
434 |
buffer.append("' }");
|
|
435 |
return buffer.toString();
|
|
436 |
}
|
430 |
437 |
|
431 |
|
public boolean isActive() {
|
432 |
|
return this.active;
|
433 |
|
}
|
|
438 |
public boolean isActive() {
|
|
439 |
return this.active;
|
|
440 |
}
|
434 |
441 |
|
435 |
|
public void setActive(boolean active) {
|
436 |
|
logger.info("setActive({})", active);
|
437 |
|
this.active = active;
|
438 |
|
}
|
|
442 |
public void setActive(boolean active) {
|
|
443 |
logger.info("setActive({})", active);
|
|
444 |
this.active = active;
|
|
445 |
}
|
439 |
446 |
|
440 |
447 |
}
|