Revision 743

View differences:

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
28 28

  
29 29
import inspect
30 30

  
31
from gvsig import getResource
32

  
31 33
from org.gvsig.tools.swing.api import ToolsSwingLocator
32 34
from org.gvsig.tools.task import TaskStatus
33 35
from org.gvsig.tools.observer import Observer
34 36
from org.gvsig.tools import ToolsLocator
35 37
import org.gvsig.tools.swing.api.Component
36 38

  
37
def getResource(*args):
38
  base = args[0]
39
  if os.path.isfile(base):
40
    base = os.path.dirname(base)
41
  x = [ base,]
42
  x.extend(args[1:])
43
  return os.path.join(*x)
44 39

  
45 40
class ListenerAdapter(object):
46 41
  def __init__(self,function,componentName=None):
......
145 140
      pass
146 141
  def keyReleased(self,*args):
147 142
    pass
148
    
143

  
149 144
class FunctionRunnable(java.lang.Runnable):
150 145
  def __init__(self,fn, *args):
151 146
    self.__fn = fn
......
245 240
          component.addActionListener(ActionListenerAdapter(method,methodName))
246 241
        elif isinstance(component, javax.swing.AbstractButton):
247 242
          component.addActionListener(ActionListenerAdapter(method,methodName))
248
  
243

  
249 244
      elif methodName.endswith("_change"):
250 245
        name = methodName[0:-len("_change")]
251 246
        component = getattr(self,name, None)
......
261 256
          component.getDocument().addDocumentListener(DocumentListenerAdapter(method,methodName))
262 257
        elif isinstance(component, javax.swing.AbstractButton):
263 258
          component.addActionListener(ActionListenerAdapter(method,methodName))
264
  
259

  
265 260
      elif methodName.endswith("_perform"):
266 261
        name = methodName[0:-len("_perform")]
267 262
        component = getattr(self,name, None)
268 263
        if isinstance(component, javax.swing.Timer):
269
          component.addActionListener(ActionListenerAdapter(method,methodName)) 
264
          component.addActionListener(ActionListenerAdapter(method,methodName))
270 265

  
271 266
      elif methodName.endswith("_focusGained"):
272 267
        name = methodName[0:-len("_focusGained")]
......
274 269
        if component!=None:
275 270
          addFocusListener = getattr(component,"addFocusListener",None)
276 271
          if addFocusListener !=None:
277
            addFocusListener(FocusGainedListenerAdapter(method,methodName)) 
278
          
272
            addFocusListener(FocusGainedListenerAdapter(method,methodName))
273

  
279 274
      elif methodName.endswith("_focusLost"):
280 275
        name = methodName[0:-len("_focusLost")]
281 276
        component = getattr(self,name, None)
282 277
        if component!=None:
283 278
          addFocusListener = getattr(component,"addFocusListener",None)
284 279
          if addFocusListener !=None:
285
            addFocusListener(FocusLostListenerAdapter(method,methodName)) 
280
            addFocusListener(FocusLostListenerAdapter(method,methodName))
286 281

  
287 282
      elif methodName.endswith("_mouseClick"):
288 283
        name = methodName[0:-len("_mouseClick")]
......
290 285
        if component!=None:
291 286
          addMouseListener = getattr(component,"addMouseListener",None)
292 287
          if addMouseListener !=None:
293
            addMouseListener(MouseListenerAdapter(method,methodName)) 
288
            addMouseListener(MouseListenerAdapter(method,methodName))
294 289

  
295 290
      elif methodName.endswith("_keyPressed"):
296 291
        name = methodName[0:-len("_keyPressed")]
......
310 305

  
311 306
  def getRootPane(self):
312 307
    return self.asJComponent().getParent().getParent()
313
    
308

  
314 309
  def getPreferredSize(self):
315 310
    return self.asJComponent().getPreferredSize()
316
    
311

  
317 312
  def setPreferredSize(self, withOrDimension, height=None):
318 313
    if height == None:
319 314
      self.asJComponent().setPreferredSize(withOrDimension)
320 315
    else:
321 316
      self.asJComponent().setPreferredSize(java.awt.Dimension(withOrDimension,height))
322
      
317

  
323 318
  def getPanel(self):
324 319
    return self.asJComponent()
325 320

  
326 321
  def asJComponent(self):
327 322
    return self._panel
328
  
323

  
329 324
  def hide(self):
330 325
    self._panel.setVisible(False)
331 326

  

Also available in: Unified diff