[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/designer/src base/Instance.py base/tools/P...
From: |
Jason Cater |
Subject: |
gnue/designer/src base/Instance.py base/tools/P... |
Date: |
Fri, 06 Jun 2003 22:18:24 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Branch:
Changes by: Jason Cater <address@hidden> 03/06/06 22:18:24
Modified files:
designer/src/base: Instance.py
designer/src/base/tools: PropertyEditor.py
designer/src/forms: Instance.py
Log message:
add support to Property Editor for 'linked attributes' (i.e.,
block.datasource will show a combobox with all datasources)
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/base/Instance.py.diff?tr1=1.102&tr2=1.103&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/base/tools/PropertyEditor.py.diff?tr1=1.44&tr2=1.45&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/forms/Instance.py.diff?tr1=1.43&tr2=1.44&r1=text&r2=text
Patches:
Index: gnue/designer/src/base/Instance.py
diff -c gnue/designer/src/base/Instance.py:1.102
gnue/designer/src/base/Instance.py:1.103
*** gnue/designer/src/base/Instance.py:1.102 Fri Jun 6 21:24:57 2003
--- gnue/designer/src/base/Instance.py Fri Jun 6 22:18:24 2003
***************
*** 43,48 ****
--- 43,49 ----
from gnue.designer.base.ToolDock import ToolDock
from gnue.designer.base.ToolPanel import *
from gnue.designer.base.Debugger import DebugSession
+ from gnue.designer.base.ObjectList import ObjectList
from gnue.designer.base import TemplateBase
from gnue.designer.base.TemplateParser import WizardRunner
from PrimaryToolBar import PrimaryToolBar
***************
*** 133,138 ****
--- 134,141 ----
self._pages = []
+ self.objectLists = {}
+
self._path = ""
self.globalAccelerators = []
***************
*** 312,317 ****
--- 315,348 ----
def addToolCreate(self, title, method):
self._menubar.addToolCreate(title, method)
+ # Return, or create, an ObjectList based on the xml tag
+ def getObjectList(self, tag):
+ try:
+ return self.objectLists[tag]
+ except KeyError:
+ defin = self.incubator.elements[tag]
+ baseClass = defin['BaseClass']
+
+ # Determine the "name" attribute"
+ nameAttr = None
+ try:
+ if defin['Attributes'].has_key('name'):
+ nameAttr = 'name'
+ else:
+ for attribute, props in defin['Attributes'].items():
+ try:
+ if props['Unique']:
+ nameAttr = attribute
+ break
+ except KeyError:
+ pass
+ except KeyError:
+ pass
+
+ list = ObjectList(self, baseClass, nameAttr)
+ self.objectLists[tag] = list
+ return list
+
def __loadFromFile(self, location):
try:
self._path = location
***************
*** 702,716 ****
def __init__(self, instance, object):
self.instance = instance
self.object = object
- object._getItemHook = self._getItemHook
object._setItemHook = self._setItemHook
# Replace the getitem hooks from GObject
# This is for the wizards, so they can do
# entry['Char:x']-type calls and get back
# what they expected.
- def _getItemHook(self, key):
- return self.object.__dict__[key.replace(':','__')]
def _setItemHook(self, key, value):
ek = key.replace(':','__')
--- 733,744 ----
Index: gnue/designer/src/base/tools/PropertyEditor.py
diff -c gnue/designer/src/base/tools/PropertyEditor.py:1.44
gnue/designer/src/base/tools/PropertyEditor.py:1.45
*** gnue/designer/src/base/tools/PropertyEditor.py:1.44 Fri Jun 6 21:24:57 2003
--- gnue/designer/src/base/tools/PropertyEditor.py Fri Jun 6 22:18:24 2003
***************
*** 211,216 ****
--- 211,220 ----
# (Integer, Boolean, Dropdown, Char)
if self.attributes[key].has_key('ValueSet'):
field = LimitedSetEditor(self.fieldPanel,self.attributes[key])
+ elif self.attributes[key].has_key('References'):
+ tag, attr = self.attributes[key]['References'].split('.')
+ objectList = self.editor.instance.getObjectList(tag)
+ field = LinkedTextEditor(self.fieldPanel, self.attributes[key],
objectList, attr)
elif self.attributes[key]['Typecast'] == GTypecast.boolean:
field = BoolEditor(self.fieldPanel,self.attributes[key])
elif self.attributes[key]['Typecast'] in (GTypecast.integer,
***************
*** 283,289 ****
oldVal = {attr: ov}
# We only care if user actually changed the current value...
! if ov != value:
# If value is None, then user basically selected "No value"
if value != None:
# Typecast the value, then store in the object's dictionary
--- 287,293 ----
oldVal = {attr: ov}
# We only care if user actually changed the current value...
! if ov != value and not (ov == None and value in (0,'')):
# If value is None, then user basically selected "No value"
if value != None:
# Typecast the value, then store in the object's dictionary
***************
*** 360,391 ****
# Property Editor whose selections are linked to lists of other objects
#
class LinkedTextEditor(wxComboBox):
! def __init__(self, parent, attributes, objectList, forceToList=1):
wxComboBox.__init__(self, parent, -1,
! style=wxTE_PROCESS_ENTER|wxCB_DROPDOWN|(forceToList and
wxCB_READONLY)|wxCB_SORT)
self.attributes = attributes
self.updateList()
! try:
! objectList.addListener(self.updateList)
! except AttributeError:
! pass
def Destroy(self):
! try:
! objectList.removeListener(self.updateList)
! except:
! pass
wxComboBox.Destroy(self)
def GetValue(self):
return wxComboBox.GetValue(self) or None
def updateList(self):
self.Clear()
if not (self.attributes.has_key('Required') and
self.attributes['Required'] ):
self.Append('')
! for v in objectList:
! self.Append("%s" % (self.attributes['ValueSet'][v] or v))
#
# Property editor for boolean types
--- 364,400 ----
# Property Editor whose selections are linked to lists of other objects
#
class LinkedTextEditor(wxComboBox):
! def __init__(self, parent, attributes, objectList, attr):
wxComboBox.__init__(self, parent, -1,
! style=wxTE_PROCESS_ENTER|wxCB_DROPDOWN|wxCB_SORT)
self.attributes = attributes
+ self.objectList = objectList
+ self.attr = attr
self.updateList()
! objectList.addListener(self.updateList)
def Destroy(self):
! self.objectList.removeListener(self.updateList)
wxComboBox.Destroy(self)
def GetValue(self):
return wxComboBox.GetValue(self) or None
+ def SetValue(self, value):
+ if value in self.list:
+ self.SetSelection(self.list.index(value))
+ else:
+ wxComboBox.SetValue(self, value)
+
def updateList(self):
self.Clear()
+ self.list = []
if not (self.attributes.has_key('Required') and
self.attributes['Required'] ):
+ self.list.append(None)
self.Append('')
! for v in self.objectList:
! self.list.append(v[self.attr])
! self.Append("%s" % v[self.attr])
#
# Property editor for boolean types
Index: gnue/designer/src/forms/Instance.py
diff -c gnue/designer/src/forms/Instance.py:1.43
gnue/designer/src/forms/Instance.py:1.44
*** gnue/designer/src/forms/Instance.py:1.43 Fri Jun 6 21:11:01 2003
--- gnue/designer/src/forms/Instance.py Fri Jun 6 22:18:24 2003
***************
*** 96,103 ****
})
# Convenience list to keep track of datasources and blocks
! self.datasources = ObjectList(self, GDataSource.GDataSource, 'name')
! self.blocks = ObjectList(self, GFBlock, 'name')
def loadBuffer(self, buffer):
--- 96,106 ----
})
# Convenience list to keep track of datasources and blocks
! # TODO: Anything that needs either of these two
! # TODO: should call getObjectList directly.
! # TODO: Left for historical reasons.
! self.datasources = self.getObjectList('datasource')
! self.blocks = self.getObjectList('block')
def loadBuffer(self, buffer):
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/designer/src base/Instance.py base/tools/P...,
Jason Cater <=