Revision 724 org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/resources-plugin/scripting/lib/gvsig/libs/formpanel.py
formpanel.py | ||
---|---|---|
11 | 11 |
import javax.swing.AbstractButton |
12 | 12 |
import javax.swing.JButton |
13 | 13 |
import javax.swing.JComboBox |
14 |
import javax.swing.JList |
|
14 | 15 |
import javax.swing.JRadioButton |
15 | 16 |
import javax.swing.JSpinner |
16 |
import javax.swing.event.ChangeListener |
|
17 |
import javax.swing.event.DocumentListener |
|
18 | 17 |
import javax.swing.SwingUtilities |
19 | 18 |
import javax.swing.ImageIcon |
20 | 19 |
import javax.swing.text.JTextComponent |
21 | 20 |
import javax.swing.Timer |
21 |
import javax.swing.event.ChangeListener |
|
22 |
import javax.swing.event.DocumentListener |
|
23 |
import javax.swing.event.ListSelectionListener |
|
22 | 24 |
|
23 | 25 |
import os |
24 | 26 |
import os.path |
... | ... | |
92 | 94 |
#print "ItemListenerAdapter %s %s" % (self.componentName, args[0]) |
93 | 95 |
self(*args) |
94 | 96 |
|
97 |
class ListSelectionListenerAdapter(ListenerAdapter, javax.swing.event.ListSelectionListener): |
|
98 |
def __init__(self,function, componentName=None): |
|
99 |
ListenerAdapter.__init__(self,function,componentName) |
|
100 |
def valueChanged(self,*args): |
|
101 |
#print "ListSelectionListenerAdapter %s %s" % (self.componentName, args[0]) |
|
102 |
self(*args) |
|
103 |
|
|
95 | 104 |
class FocusGainedListenerAdapter(ListenerAdapter, java.awt.event.FocusListener): |
96 | 105 |
def __init__(self,function, componentName=None): |
97 | 106 |
ListenerAdapter.__init__(self,function,componentName) |
... | ... | |
124 | 133 |
def mouseReleased(self,*args): |
125 | 134 |
self(*args) |
126 | 135 |
|
127 |
|
|
136 |
class KeyPressedListenerAdapter(ListenerAdapter, java.awt.event.KeyListener): |
|
137 |
def __init__(self,function, componentName=None): |
|
138 |
ListenerAdapter.__init__(self,function,componentName) |
|
139 |
def keyTyped(self,*args): |
|
140 |
pass |
|
141 |
def keyPressed(self,*args): |
|
142 |
try: |
|
143 |
self(*args) |
|
144 |
except java.lang.Throwable, t: |
|
145 |
pass |
|
146 |
def keyReleased(self,*args): |
|
147 |
pass |
|
148 |
|
|
128 | 149 |
class FunctionRunnable(java.lang.Runnable): |
129 | 150 |
def __init__(self,fn, *args): |
130 | 151 |
self.__fn = fn |
... | ... | |
230 | 251 |
component = getattr(self,name, None) |
231 | 252 |
if isinstance(component, javax.swing.JComboBox): |
232 | 253 |
component.addItemListener(ItemListenerAdapter(method,methodName)) |
233 |
if isinstance(component, javax.swing.JRadioButton): |
|
254 |
elif isinstance(component, javax.swing.JList): |
|
255 |
component.addListSelectionListener(ListSelectionListenerAdapter(method,methodName)) |
|
256 |
elif isinstance(component, javax.swing.JRadioButton): |
|
234 | 257 |
component.addItemListener(ItemListenerAdapter(method,methodName)) |
235 | 258 |
elif isinstance(component, javax.swing.JSpinner): |
236 | 259 |
component.addChangeListener(ChangeListenerAdapter(method,methodName)) |
... | ... | |
268 | 291 |
addMouseListener = getattr(component,"addMouseListener",None) |
269 | 292 |
if addMouseListener !=None: |
270 | 293 |
addMouseListener(MouseListenerAdapter(method,methodName)) |
271 |
|
|
294 |
|
|
295 |
elif methodName.endswith("_keyPressed"): |
|
296 |
name = methodName[0:-len("_keyPressed")] |
|
297 |
component = getattr(self,name, None) |
|
298 |
if component!=None: |
|
299 |
addKeyListener = getattr(component,"addKeyListener",None) |
|
300 |
if addKeyListener != None: |
|
301 |
addKeyListener(KeyPressedListenerAdapter(method,methodName)) |
|
302 |
|
|
272 | 303 |
class FormPanel(FormComponent): |
273 | 304 |
|
274 | 305 |
def __init__(self,formfile=None): |
Also available in: Unified diff