svn-gvsig-desktop / branches / v2_0_0_prep / frameworks / _fwAndami / src / org / gvsig / andami / plugins / ExtensionHelper.java @ 38564
History | View | Annotate | Download (1.28 KB)
1 |
package org.gvsig.andami.plugins; |
---|---|
2 |
|
3 |
import org.slf4j.Logger; |
4 |
import org.slf4j.LoggerFactory; |
5 |
|
6 |
public class ExtensionHelper { |
7 |
|
8 |
private static Logger logger = LoggerFactory.getLogger(ExtensionHelper.class); |
9 |
|
10 |
public static boolean canQueryByAction(IExtension extension) { |
11 |
if( extension instanceof IExtensionQueryByAction ) { |
12 |
return ((IExtensionQueryByAction)extension).canQueryByAction();
|
13 |
} |
14 |
return false; |
15 |
} |
16 |
|
17 |
public static boolean isVisible(IExtension extension, String action) { |
18 |
if( extension instanceof IExtensionQueryByAction ) { |
19 |
return ((IExtensionQueryByAction) extension).isVisible(action);
|
20 |
} |
21 |
return extension.isVisible();
|
22 |
} |
23 |
|
24 |
public static boolean isEnabled(IExtension extension, String action) { |
25 |
if( extension instanceof IExtensionQueryByAction ) { |
26 |
return ((IExtensionQueryByAction) extension).isEnabled(action);
|
27 |
} |
28 |
return extension.isEnabled();
|
29 |
} |
30 |
|
31 |
public static void execute(IExtension extension, String command, Object[] args) { |
32 |
if( extension instanceof IExtensionExecuteWithArgs ) { |
33 |
((IExtensionExecuteWithArgs) extension).execute(command, args); |
34 |
return;
|
35 |
} |
36 |
if( args!= null && args.length>0 ) { |
37 |
logger.info("callong execute with args in a extension that not support ("+extension.getClass().getSimpleName()+")."); |
38 |
} |
39 |
extension.execute(command); |
40 |
} |
41 |
} |