AbstractAction.py :  » Language-Interface » JPype » JPype-0.5.4.1 » src » python » jpypex » swing » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Language Interface » JPype 
JPype » JPype 0.5.4.1 » src » python » jpypex » swing » AbstractAction.py
from jpype import *;

class AbstractAction(object) :
    ACCELERATOR_KEY    = javax.swing.Action.ACCELERATOR_KEY
    ACTION_COMMAND_KEY = javax.swing.Action.ACTION_COMMAND_KEY
    DEFAULT            = javax.swing.Action.DEFAULT
    LONG_DESCRIPTION   = javax.swing.Action.LONG_DESCRIPTION
    MNEMONIC_KEY       = javax.swing.Action.MNEMONIC_KEY
    NAME               = javax.swing.Action.NAME
    SHORT_DESCRIPTION  = javax.swing.Action.SHORT_DESCRIPTION
    SMALL_ICON         = javax.swing.Action.SMALL_ICON
    
    def __init__(self, cb, name=None, icon=None) :
        object.__init__(self)
        
        self.__proxy = JProxy(javax.swing.Action, inst=self)
        self.__values = {}
        self.__cb = cb
        self.__listeners = []
        self.__enabled = True
        
        if name is not None :
            self.putValue(AbstractAction.NAME, name)
            
        if icon is not None :
            self.putValue(AbstractAction.SMALL_ICON, icon)
    
    proxy = property(lambda self : self.__proxy) 
    
    def addPropertyChangeListener(self, listener) :
        self.__listeners.append(listener)
        
    def getValue(self, key) :
        return self.__values.get(key, None)
          
    def isEnabled(self) :
        if self.__enabled :
            return True
        return False
          
    def putValue(self, key, value) :
        oldVal = self.__values.get(key, None)
        if oldVal != value :
            self.__values[key] = value
            self.__notify(key, oldVal, value)
          
    def removePropertyChangeListener(self,listener) :
        self.__listeners.remove(listener)
          
    def setEnabled(self,b) : 
        if (b and not self.__enabled) or ( not b and self.__enabled) :
            self.__enabled = b
            self.__notify("enabled", java.lang.Boolean(not b), java.lang.Boolean(b))  

    def actionPerformed(self, ev) :
        self.__cb(ev) 

    def __notify(self, k, oldVal, newVal) :
        ev = java.beans.PropertyChangeEvent(self.__proxy, k, oldVal, newVal)
        for i in self.__listeners :
            i.propertyChange(ev) 
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.