-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestactions.py
41 lines (34 loc) · 1.31 KB
/
testactions.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# encoding: utf-8
import gvsig
from org.gvsig.tools import ToolsLocator
from org.gvsig.app.project.documents.view.toc import TocItemLeaf
from java.awt.event import ActionListener
from javax.swing import JMenuItem
from org.gvsig.app.project.documents.view import IContextMenuActionWithIcon
from javax.swing import JPopupMenu
class MenuItem(JMenuItem, ActionListener):
def __init__(self, action, layer, tocItem):
self.action = action
self.layer = layer
self.tocItem = tocItem
self.addActionListener(self)
self.setText(self.action.getText())
if isinstance(self.action, IContextMenuActionWithIcon):
self.setIcon(self.action.getIcon())
def actionPerformed(self, event):
self.action.execute(self.tocItem,(self.layer,))
def main(*args):
menu = JPopupMenu()
ep = ToolsLocator.getExtensionPointManager().get("View_TocActions")
layer = gvsig.currentLayer()
tocItem = TocItemLeaf(None, layer.getName(),layer.getShapeType())
for x in ep.iterator():
action = x.create()
print "action", action
continue
if action.isVisible(tocItem, (layer,)):
print action
menu.add(MenuItem(action, layer,tocItem))
else:
print "*** else:", action
#menu.show(None,100,100)