svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / resources-plugin / scripting / scripts / validatelayer / autorun.py @ 47568
History | View | Annotate | Download (1.84 KB)
1 |
# encoding: utf-8
|
---|---|
2 |
|
3 |
import gvsig |
4 |
import validate_layer |
5 |
|
6 |
from gvsig import getResource, currentLayer |
7 |
|
8 |
from java.io import File |
9 |
from org.gvsig.andami import PluginsLocator |
10 |
from org.gvsig.app import ApplicationLocator |
11 |
from org.gvsig.scripting.app.extension import ScriptingExtension |
12 |
from org.gvsig.tools import ToolsLocator |
13 |
from org.gvsig.tools.swing.api import ToolsSwingLocator |
14 |
|
15 |
class ValidateLayerExtension(ScriptingExtension): |
16 |
def __init__(self): |
17 |
pass
|
18 |
|
19 |
def canQueryByAction(self): |
20 |
return True |
21 |
|
22 |
def isEnabled(self,action): |
23 |
return True |
24 |
|
25 |
def isVisible(self,action): |
26 |
layer = currentLayer() |
27 |
return layer != None |
28 |
|
29 |
def execute(self,actionCommand, *args): |
30 |
actionCommand = actionCommand.lower() |
31 |
if actionCommand == "layer-validate": |
32 |
validate_layer.main() |
33 |
|
34 |
def selfRegister(): |
35 |
application = ApplicationLocator.getManager() |
36 |
|
37 |
#
|
38 |
# Registramos las traducciones
|
39 |
i18n = ToolsLocator.getI18nManager() |
40 |
i18n.addResourceFamily("text",File(getResource(__file__,"i18n"))) |
41 |
|
42 |
#
|
43 |
# Registramos los iconos en el tema de iconos
|
44 |
icon = File(getResource(__file__,"images","layer-validate.png")).toURI().toURL() |
45 |
iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent() |
46 |
#iconTheme.registerDefault("scripting.ValidateLayerExtension", "action", "layer-validate", None, icon)
|
47 |
|
48 |
#
|
49 |
# Creamos la accion
|
50 |
extension = ValidateLayerExtension() |
51 |
actionManager = PluginsLocator.getActionInfoManager() |
52 |
action = actionManager.createAction( |
53 |
extension, |
54 |
"layer-validate", # Action name |
55 |
u"_Validate_geometries", # Text |
56 |
"layer-validate", # Action command |
57 |
"layer-validate", # Icon name |
58 |
None, # Accelerator |
59 |
650700601, # Position |
60 |
u"_Validate_geometries" # Tooltip |
61 |
) |
62 |
action = actionManager.registerAction(action) |
63 |
#application.addMenu(action, u"Layer/_Validate_geometries")
|
64 |
|
65 |
def main(*args): |
66 |
selfRegister() |