[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue common/src/GObjects.py common/src/GRootObj...
From: |
Jason Cater |
Subject: |
gnue common/src/GObjects.py common/src/GRootObj... |
Date: |
Fri, 29 Nov 2002 02:07:02 -0500 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Jason Cater <address@hidden> 02/11/29 02:07:00
Modified files:
common/src : GObjects.py GRootObj.py
designer/src : EventEditor.py Instance.py TemplateBase.py
TriggerEditor.py
designer/src/forms: Incubator.py Instance.py
forms/src : GFForm.py GFParser.py
Log message:
* Improved trigger selector support
* Improved code editor interaction with rest of system
* Fixed outstanding bugs related to wizards/templates and object
creation
* Many bug fixes
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GObjects.py.diff?tr1=1.46&tr2=1.47&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/common/src/GRootObj.py.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/EventEditor.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/Instance.py.diff?tr1=1.71&tr2=1.72&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/TemplateBase.py.diff?tr1=1.18&tr2=1.19&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/TriggerEditor.py.diff?tr1=1.24&tr2=1.25&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/forms/Incubator.py.diff?tr1=1.4&tr2=1.5&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/forms/Instance.py.diff?tr1=1.20&tr2=1.21&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFForm.py.diff?tr1=1.213&tr2=1.214&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFParser.py.diff?tr1=1.99&tr2=1.100&r1=text&r2=text
Patches:
Index: gnue/common/src/GObjects.py
diff -c gnue/common/src/GObjects.py:1.46 gnue/common/src/GObjects.py:1.47
*** gnue/common/src/GObjects.py:1.46 Wed Nov 27 19:11:31 2002
--- gnue/common/src/GObjects.py Fri Nov 29 02:06:59 2002
***************
*** 190,201 ****
ns = "out%s" % i
xmlnamespaces[self._xmlnamespace] = ns
xmlnsdef = ' xmlns:%s="%s"' % (ns, self._xmlchildnamespace)
- elif self._xmlchildnamespaces:
- pass
-
except AttributeError:
pass
xmlEntity = self.getXmlTag()
xmlString = "%s<%s%s%s" % (gap[:-2],xmlns, xmlEntity, xmlnsdef)
--- 190,206 ----
ns = "out%s" % i
xmlnamespaces[self._xmlnamespace] = ns
xmlnsdef = ' xmlns:%s="%s"' % (ns, self._xmlchildnamespace)
except AttributeError:
pass
+
+ try:
+ if self._xmlchildnamespaces:
+ for abbrev in self._xmlchildnamespaces:
+ xmlnsdef += ' xmlns:%s="%s"' %
(abbrev,self._xmlchildnamespaces[abbrev])
+ except AttributeError:
+ pass
+
xmlEntity = self.getXmlTag()
xmlString = "%s<%s%s%s" % (gap[:-2],xmlns, xmlEntity, xmlnsdef)
***************
*** 234,239 ****
--- 239,253 ----
(attribute, string.join(val,','))
else:
addl = ' %s="%s"' % (attribute, saxutils.escape('%s' % val))
+ if len(addl) + pos > 78:
+ xmlString += "\n" + " " * indent + addl
+ pos = indent
+ else:
+ xmlString += addl
+ pos += len(addl)
+ if attribute.find('__') > 0 and attribute.split('__')[0] in
xmlnamespaces.keys():
+ if val != None:
+ addl = ' %s="%s"' % (attribute.replace('__',':'),
saxutils.escape('%s' % val))
if len(addl) + pos > 78:
xmlString += "\n" + " " * indent + addl
pos = indent
Index: gnue/common/src/GRootObj.py
diff -c gnue/common/src/GRootObj.py:1.7 gnue/common/src/GRootObj.py:1.8
*** gnue/common/src/GRootObj.py:1.7 Tue Nov 26 18:45:20 2002
--- gnue/common/src/GRootObj.py Fri Nov 29 02:06:59 2002
***************
*** 43,48 ****
--- 43,49 ----
self.__xmlElementCallback = xmlElementCallback
self._xmlParser = xmlParser
self._xmlnamespaces = {}
+ self._standardnamespaces = {}
# This will store any "global myVar" that the triggers execute.
self._globalRuntimeNamespace = {}
***************
*** 52,61 ****
def dumpXML(self, treeDump=1, gap=" "):
return GObj.dumpXML(self, self.__xmlElementCallback(),
! treeDump, gap, xmlnamespaces=self._xmlnamespaces)
!
!
!
--- 53,59 ----
def dumpXML(self, treeDump=1, gap=" "):
return GObj.dumpXML(self, self.__xmlElementCallback(),
! treeDump, gap, xmlnamespaces=self._standardnamespaces)
Index: gnue/designer/src/EventEditor.py
diff -c gnue/designer/src/EventEditor.py:1.3
gnue/designer/src/EventEditor.py:1.4
*** gnue/designer/src/EventEditor.py:1.3 Mon Nov 25 23:23:33 2002
--- gnue/designer/src/EventEditor.py Fri Nov 29 02:06:59 2002
***************
*** 30,37 ****
import sys, os, string
from wxPython.wx import *
from wxPython.grid import *
! from gnue.common import GDebug, GTypecast, GTrigger
from ToolPanel import *
class EventEditor (ToolPanel):
--- 30,40 ----
import sys, os, string
from wxPython.wx import *
from wxPython.grid import *
! from gnue.common import GDebug, GTypecast
! from gnue.common.GTrigger import GTrigger
! from gnue.common.GParserHelpers import GContent
from ToolPanel import *
+ from PropertyEditor import CharCellEditor
class EventEditor (ToolPanel):
***************
*** 90,96 ****
# Speed up the process by not refreshing the grid yet
self.grid.BeginBatch()
-
# Delete any old rows from a previous object
nr = self.grid.GetNumberRows()
if nr:
--- 93,98 ----
***************
*** 105,121 ****
self.triggerTypes = {'':'(None)',
'(Custom Trigger)':'(Custom Trigger)'}
for name in self.namedMap.keys():
self.triggerTypes[name] = name + ' (named)'
mappedTriggers = {}
for child in object._children:
! if isinstance(child, GTrigger.GTrigger):
if hasattr(child,'src') and child.src:
mappedTriggers[child.type.upper()] = child.src
else:
mappedTriggers[child.type.upper()] = '(Custom Trigger)'
i = 0
for key in self.rowList:
--- 107,127 ----
self.triggerTypes = {'':'(None)',
'(Custom Trigger)':'(Custom Trigger)'}
+ self.triggerMap = {}
for name in self.namedMap.keys():
self.triggerTypes[name] = name + ' (named)'
mappedTriggers = {}
for child in object._children:
! if isinstance(child, GTrigger):
if hasattr(child,'src') and child.src:
mappedTriggers[child.type.upper()] = child.src
else:
mappedTriggers[child.type.upper()] = '(Custom Trigger)'
+ self.triggerMap[child.type.upper()] = child
+
+ self.mappedTriggers = mappedTriggers
i = 0
for key in self.rowList:
***************
*** 125,135 ****
self.grid.SetCellValue(i,0, "%s" % mappedTriggers[key])
except KeyError:
self.grid.SetCellValue(i,0, "%s" % '')
! i = i + 1
# Redraw the grid
- ## self.grid.AutoSize()
self.grid.EndBatch()
try:
self.grid.ForceRefresh() # Added in 2.3.1
--- 131,140 ----
self.grid.SetCellValue(i,0, "%s" % mappedTriggers[key])
except KeyError:
self.grid.SetCellValue(i,0, "%s" % '')
! i += 1
# Redraw the grid
self.grid.EndBatch()
try:
self.grid.ForceRefresh() # Added in 2.3.1
***************
*** 146,152 ****
handler = event.originator
if object == None:
return
! if isinstance(object,GTrigger.GTrigger) and \
object.type.upper() == 'NAMED' and \
event.new.has_key('name'):
try:
--- 151,157 ----
handler = event.originator
if object == None:
return
! if isinstance(object,GTrigger) and \
object.type.upper() == 'NAMED' and \
event.new.has_key('name'):
try:
***************
*** 170,176 ****
def inventoryObject(self, object):
! if isinstance(object,GTrigger.GTrigger) and object.type.upper() ==
'NAMED':
self.namedMap[object.name] = object
--- 175,181 ----
def inventoryObject(self, object):
! if isinstance(object,GTrigger) and object.type.upper() == 'NAMED':
self.namedMap[object.name] = object
***************
*** 192,349 ****
if self.grid.CanEnableCellControl():
self.grid.EnableCellEditControl()
def OnCellChange(self, evt):
attr = self.rowList[evt.GetRow()]
value = self.grid.GetCellValue(evt.GetRow(), evt.GetCol())
- return
-
try:
! try:
! oldVal = {attr: self.object.__dict__[attr]}
! except KeyError:
! oldVal = {attr: None}
! self.object.__dict__[attr] = self.attributes[attr]['Typecast'](value)
! newVal = {attr: self.object.__dict__[attr]}
! self.dispatchEvent('ObjectModified',
! object=self.object,
! originator=self,
! old=oldVal,
! new=newVal)
! evt.Skip()
! except ValueError:
! wxBell()
!
! #
! #
! #
! class CharCellEditor (wxPyGridCellEditor):
! def __init__(self, grid, attributes):
! wxPyGridCellEditor.__init__(self)
! self.grid = grid
! self.attributes = attributes
! self.__created = 0
!
!
! def Create(self, parent, id, evtHandler):
! self.__created = 1
! GDebug.printMesg(10,'Creating CharCellEditor')
! self._tc = wxTextCtrl(parent, id, "")
! self._tc.SetInsertionPoint(0)
! self.SetControl(self._tc)
! if evtHandler:
! self._tc.PushEventHandler(evtHandler)
!
! def SetSize(self, rect):
! self._tc.SetDimensions(rect.x, rect.y, rect.width+2, rect.height+2)
!
! def Show(self, show, attr):
! self.base_Show(show, attr)
!
! def PaintBackground(self, rect, attr):
! pass
!
! def BeginEdit(self, row, col, grid):
! self.startValue = grid.GetTable().GetValue(row, col)
! self._tc.SetValue(self.startValue)
! self._tc.SetInsertionPointEnd()
! self._tc.SetFocus()
!
! # For this example, select the text
! self._tc.SetSelection(0, self._tc.GetLastPosition())
!
!
! def EndEdit(self, row, col, grid):
! changed = false
!
! val = self._tc.GetValue()
! if val != self.startValue:
! changed = true
! grid.GetTable().SetValue(row, col, val) # update the table
!
! self.startValue = ''
! self._tc.SetValue('')
! return changed
!
!
! def Reset(self):
! self._tc.SetValue(self.startValue)
! self._tc.SetInsertionPointEnd()
!
!
! def IsAcceptedKey(self, evt):
! return (not (evt.ControlDown() or evt.AltDown()) and
! evt.GetKeyCode() != WXK_SHIFT)
!
!
! def StartingKey(self, evt):
! GDebug.printMesg(10, "Starting Key; created=%s" % self.__created)
! key = evt.GetKeyCode()
! ch = None
! if key in [WXK_NUMPAD0, WXK_NUMPAD1, WXK_NUMPAD2, WXK_NUMPAD3,
WXK_NUMPAD4,
! WXK_NUMPAD5, WXK_NUMPAD6, WXK_NUMPAD7, WXK_NUMPAD8,
WXK_NUMPAD9]:
! ch = ch = chr(ord('0') + key - WXK_NUMPAD0)
!
! elif key < 256 and key >= 0 and chr(key):
! ch = chr(key)
! if not evt.ShiftDown():
! ch = string.lower(ch)
!
! if ch is not None:
! # For this example, replace the text. Normally we would append it.
! #self._tc.AppendText(ch)
! # self._tc.SetValue(ch)
! # self._tc.SetInsertionPointEnd()
! pass
! else:
! evt.Skip()
!
! def StartingClick(self):
! pass
! def Destroy(self):
! self.base_Destroy()
! def Clone(self):
! return CharCellEditor(self.attributes)
! class IntCellEditor (CharCellEditor):
! def __init__(self, grid, attributes):
! CharCellEditor.__init__(self, grid, attributes)
! def Create(self, parent, id, evtHandler):
! CharCellEditor.Create(self, parent, id, evtHandler)
! EVT_CHAR(self._tc, self.OnKeyPressed)
! def OnKeyPressed(self, evt):
! if (ord('0') <= evt.KeyCode() <= ord('9') or \
! evt.KeyCode() in (ord('-'), ord('+')) or \
! evt.KeyCode() < 32 or evt.KeyCode() > 126):
! evt.Skip()
!
! def StartingKey(self, evt):
! key = evt.GetKeyCode()
! ch = None
! if key in [WXK_NUMPAD0, WXK_NUMPAD1, WXK_NUMPAD2, WXK_NUMPAD3,
WXK_NUMPAD4,
! WXK_NUMPAD5, WXK_NUMPAD6, WXK_NUMPAD7, WXK_NUMPAD8,
WXK_NUMPAD9]:
! ch = ch = chr(ord('0') + key - WXK_NUMPAD0)
!
! elif key < 256 and key >= 0 and chr(key):
! ch = chr(key)
! if not evt.ShiftDown():
! ch = string.lower(ch)
!
! if '0' <= ch <= '9':
! # For this example, replace the text. Normally we would append it.
! #self._tc.AppendText(ch)
! pass
! # self._tc.SetValue(ch)
! # self._tc.SetInsertionPointEnd()
else:
! evt.Skip()
class RestrictedCellEditor (CharCellEditor):
def __init__(self, grid, attributes):
CharCellEditor.__init__(self, grid, attributes)
--- 197,283 ----
if self.grid.CanEnableCellControl():
self.grid.EnableCellEditControl()
+
+ def _generateName(self, object):
+ parent = object._parent
+ name = '%s.%s (%s-Level Trigger)' % (parent.name,
parent._validTriggers[object.type.upper()], parent._type[2:].capitalize())
+ return name
+
+
def OnCellChange(self, evt):
attr = self.rowList[evt.GetRow()]
value = self.grid.GetCellValue(evt.GetRow(), evt.GetCol())
try:
! oldvalue = self.mappedTriggers[attr]
! except:
! oldvalue = ""
! if oldvalue == value:
! return
! trigType = self.object._validTriggers[attr]
! try:
! trigger = self.triggerMap[attr]
! new = 0
! except KeyError:
! trigger = GTrigger(self.object, trigType)
! new = 1
+ oldStuff = {}
+ newStuff = {}
! # If custom trigger, save the text in case the user changes his mind
! if oldvalue == '(Custom Trigger)':
! try:
! self.object.__triggerHistory
! except:
! self.object.__triggerHistory = {}
! self.object.__triggerHistory[attr] = trigger.getChildrenAsContent()
! elif oldvalue:
! oldStuff[src] = oldvalue
! newStuff[src] = ""
! # Clear any old content
! trigger._children = []
! if value:
! if value == '(Custom Trigger)':
! try:
! # Restore a previous life's custom trigger text...
! text = self.object.__triggerHistory[attr]
! except:
! # ... or not, and create a new blank trigger
! text = "##\n## %s\n##\n\nreturn\n\n" % (self._generateName(trigger))
! trigger.src = None
! GContent(trigger,text)
! elif value:
! # named trigger
! trigger.src = value
! if not oldStuff.has_key('src'):
! oldStuff['src'] = ''
! newStuff['src'] = value
!
! if new:
! self.dispatchEvent('ObjectCreated',object=trigger,
originator=__name__)
! else:
! self.dispatchEvent('ObjectModified',object=trigger,
originator=__name__,
! old=oldStuff, new=newStuff)
!
! if trigger.src:
!
self.dispatchEvent('TriggerSelected',object=self.namedMap[trigger.src],
originator=__name__)
! else:
! self.dispatchEvent('TriggerSelected',object=trigger,
originator=__name__)
else:
! # No trigger
! self.object._children.pop(self.object._children.index(trigger))
! self.dispatchEvent('ObjectDeleted',object=trigger, originator=__name__)
! self.dispatchEvent('TriggerSelected',object=None, originator=__name__)
+ ##
+ ##
+ ##
class RestrictedCellEditor (CharCellEditor):
def __init__(self, grid, attributes):
CharCellEditor.__init__(self, grid, attributes)
***************
*** 363,369 ****
def Create(self, parent, id, evtHandler):
GDebug.printMesg(10,'Creating CharCellEditor')
! self._tc = wxComboBox(parent, id, "", style=wxCB_READONLY,
choices=self.selectionList)
self.SetControl(self._tc)
if evtHandler:
--- 297,303 ----
def Create(self, parent, id, evtHandler):
GDebug.printMesg(10,'Creating CharCellEditor')
! self._tc = wxComboBox(parent, id, "", style=wxCB_READONLY,
choices=self.selectionList)
self.SetControl(self._tc)
if evtHandler:
***************
*** 389,456 ****
def Reset(self):
self._tc.SetSelection(self.valueMap[self.startValue])
- #self._tc.SetInsertionPointEnd()
-
-
- def StartingKey(self, evt):
- key = evt.GetKeyCode()
- ch = None
- if key in [WXK_NUMPAD0, WXK_NUMPAD1, WXK_NUMPAD2, WXK_NUMPAD3,
WXK_NUMPAD4,
- WXK_NUMPAD5, WXK_NUMPAD6, WXK_NUMPAD7, WXK_NUMPAD8,
WXK_NUMPAD9]:
- ch = ch = chr(ord('0') + key - WXK_NUMPAD0)
-
- elif key < 256 and key >= 0 and chr(key):
- ch = chr(key)
- if not evt.ShiftDown():
- ch = string.lower(ch)
-
- if ch is not None:
- # For this example, replace the text. Normally we would append it.
- #self._tc.AppendText(ch)
- pass
- # self._tc.SetValue(ch)
- # self._tc.SetInsertionPointEnd()
- else:
- evt.Skip()
-
-
- class BoolCellEditor (CharCellEditor):
- def __init__(self, grid, attributes):
- CharCellEditor.__init__(self, grid, attributes)
-
- self.selectionList = ['FALSE','TRUE']
-
- def Create(self, parent, id, evtHandler):
- self._tc = wxComboBox(parent, id, "", style=wxCB_READONLY,
- choices=self.selectionList)
- self.SetControl(self._tc)
- if evtHandler:
- self._tc.PushEventHandler(evtHandler)
-
- def BeginEdit(self, row, col, grid):
- self.startValue = grid.GetTable().GetValue(row, col)
-
- self._tc.SetValue(self.startValue)
- self._tc.SetFocus()
-
- def EndEdit(self, row, col, grid):
- changed = false
-
- if self._tc.GetSelection():
- val = 'TRUE'
- else:
- val = 'FALSE'
- if val != self.startValue:
- changed = true
- grid.GetTable().SetValue(row, col, "%s" % val) # update the table
-
- self.startValue = ''
- self._tc.SetSelection(0)
- return changed
-
-
- def Reset(self):
- self._tc.SetValue(self.startValue)
#self._tc.SetInsertionPointEnd()
--- 323,328 ----
Index: gnue/designer/src/Instance.py
diff -c gnue/designer/src/Instance.py:1.71 gnue/designer/src/Instance.py:1.72
*** gnue/designer/src/Instance.py:1.71 Wed Nov 27 19:11:31 2002
--- gnue/designer/src/Instance.py Fri Nov 29 02:06:59 2002
***************
*** 438,445 ****
handler = event.originator
self._currentObject = object
! def __onCreateObject (self, object, handler):
! self.__inventory(object)
self.makeDirty()
def __onModifyObject (self, event):
--- 438,445 ----
handler = event.originator
self._currentObject = object
! def __onCreateObject (self, event):
! self.__inventory(event.object)
self.makeDirty()
def __onModifyObject (self, event):
Index: gnue/designer/src/TemplateBase.py
diff -c gnue/designer/src/TemplateBase.py:1.18
gnue/designer/src/TemplateBase.py:1.19
*** gnue/designer/src/TemplateBase.py:1.18 Wed Nov 27 19:11:31 2002
--- gnue/designer/src/TemplateBase.py Fri Nov 29 02:06:59 2002
***************
*** 114,126 ****
# methods.
def AddElement(self, tag, parent, attributes={}, content=""):
! o = self.parser.elements[tag]['BaseClass'](parent)
! o.__dict__.update(attributes)
if content:
! self.SetContent(o, content)
! o._buildObject()
! self.parser.instance.onCreateObject(o, __name__)
! return o
def SetContent(self, element, content):
--- 114,127 ----
# methods.
def AddElement(self, tag, parent, attributes={}, content=""):
! instance = self.parser.instance
if content:
! attr = {'_content_': content}
! else:
! attr = {}
! attr.update(attributes)
! return instance.incubator.createObject(instance, instance.rootObject,
! tag, parent=parent, attributes=attr, select=0)
def SetContent(self, element, content):
***************
*** 134,144 ****
def ModifyElement(self, element, **modifications):
! element.__dict__.update(modifications)
! mods = []
for attr in modifications.keys():
! mods.append((attr, modifications[attr]))
! self.parser.instance.onModifyObject(element, __name__, mods)
def GetAvailableConnections(self):
--- 135,152 ----
def ModifyElement(self, element, **modifications):
! oldMods = {}
for attr in modifications.keys():
! try:
! oldMods[attr] = element.__dict__[attr]
! except KeyError:
! oldMods[attr] = None
!
! element.__dict__.update(modifications)
!
! self.parser.instance.dispatchEvent('ObjectModified',
! object=element, originator=__name__,
! new=modifications, old=oldMods)
def GetAvailableConnections(self):
***************
*** 268,271 ****
# is provided or if the root object is not in a
# sufficient state.
class InsufficientInformation(StandardError):
! pass
\ No newline at end of file
--- 276,279 ----
# is provided or if the root object is not in a
# sufficient state.
class InsufficientInformation(StandardError):
! pass
Index: gnue/designer/src/TriggerEditor.py
diff -c gnue/designer/src/TriggerEditor.py:1.24
gnue/designer/src/TriggerEditor.py:1.25
*** gnue/designer/src/TriggerEditor.py:1.24 Wed Nov 27 19:11:31 2002
--- gnue/designer/src/TriggerEditor.py Fri Nov 29 02:06:59 2002
***************
*** 61,67 ****
# self.editor.SetSize(self.GetClientSize())
self.object = None
! self.namedTriggerList = []
# TODO: Historical stuff (pre-ToolPanel)
--- 61,68 ----
# self.editor.SetSize(self.GetClientSize())
self.object = None
! self.triggerList = []
! self.triggerMap = {}
# TODO: Historical stuff (pre-ToolPanel)
***************
*** 70,76 ****
self.editor.SetReadOnly(1)
- self.triggerList = []
EVT_SIZE(self, self._onSize)
EVT_KILL_FOCUS(self.editor, self.OnKillFocus)
self.__ignoreevent = 0
--- 71,76 ----
***************
*** 80,111 ****
self.toolpanel = wxPanel(self, -1, pos=wxPoint(0,0), size=wxSize(32,32),
style=wxRAISED_BORDER|wxCLIP_CHILDREN)
self.namedNameLabel = wxStaticText(self.toolpanel, -1, _("Trigger: "),
pos=wxPoint(4,6))
! self.namedTriggerCombo = wxComboBox(self.toolpanel, -1,
choices=[''],pos=wxPoint(self.namedNameLabel.GetSize().width + 10,4),
style=wxCB_READONLY)
! self.toolh = max(self.namedNameLabel.GetSizeTuple()[1],
self.namedTriggerCombo.GetSizeTuple()[1]) + 12
self.editor.SetPosition((0, self.toolh))
! EVT_COMBOBOX(self, self.namedTriggerCombo.GetId(),
self.OnNamedTriggerSelected)
# EventAware provided by ToolPanel
self.registerEventListeners({
'ObjectSelected' : self.onSetCurrentObject,
'ObjectCreated' : self.onCreateObject,
'ObjectModified' : self.onModifyObject,
'ObjectDeleted' : self.onDeleteObject,
})
self.rootObject.walk(self.inventoryObject)
! if self.object:
! self._setObject(object)
! def OnNamedTriggerSelected(self, event):
s= event.GetSelection()
if s:
! self.dispatchEvent('ObjectSelected',
! object = self.namedTriggerList[s-1],
originator = None)
self.editor.SetReadOnly(0)
else:
self.editor.InEditMode = 0
--- 80,118 ----
self.toolpanel = wxPanel(self, -1, pos=wxPoint(0,0), size=wxSize(32,32),
style=wxRAISED_BORDER|wxCLIP_CHILDREN)
self.namedNameLabel = wxStaticText(self.toolpanel, -1, _("Trigger: "),
pos=wxPoint(4,6))
! self.triggerCombo = wxComboBox(self.toolpanel, -1, choices=['This is to
make the combo box big enough'],pos=wxPoint(self.namedNameLabel.GetSize().width
+ 10,4), style=wxCB_READONLY)
! self.toolh = max(self.namedNameLabel.GetSizeTuple()[1],
self.triggerCombo.GetSizeTuple()[1]) + 12
self.editor.SetPosition((0, self.toolh))
! EVT_COMBOBOX(self, self.triggerCombo.GetId(), self.OnTriggerSelected)
# EventAware provided by ToolPanel
self.registerEventListeners({
'ObjectSelected' : self.onSetCurrentObject,
+ 'TriggerSelected' : self.onSetCurrentObject,
'ObjectCreated' : self.onCreateObject,
'ObjectModified' : self.onModifyObject,
'ObjectDeleted' : self.onDeleteObject,
})
self.rootObject.walk(self.inventoryObject)
! # if self.object:
! # self._setObject(object)
! def OnTriggerSelected(self, event):
s= event.GetSelection()
if s:
! trigger = self.triggerMap[self.triggerList[s-1]]
! self.dispatchEvent('TriggerSelected',
! object = trigger,
originator = None)
+ if trigger.type.upper() != 'NAMED':
+ self.dispatchEvent('ObjectSelected',
+ object = trigger._parent,
+ originator = None)
+
self.editor.SetReadOnly(0)
else:
self.editor.InEditMode = 0
***************
*** 116,122 ****
self.object = None
-
def _onSize(self, event):
w,h = self.GetClientSizeTuple()
self.toolpanel.SetSize(wxSize(w,self.toolh))
--- 123,128 ----
***************
*** 129,151 ****
if object == None:
return
! if isinstance(object, GTrigger.GTrigger):
self._setObject(object)
def _setObject(self, object):
- ## self.__ignoreevent = 1
self.__ignoreevent = 0
self.object = object
self.editor.SetReadOnly(0)
! if not len(self.object._children):
GParserHelpers.GContent(object, "")
! elif len(self.object._children) > 1:
! content = self.object.getChildrenAsContent()
! self.object._children = []
! GParserHelpers.GContent(self.object, content)
self.editor.InEditMode = 0
self.editor.SetText(object.getChildrenAsContent())
--- 135,156 ----
if object == None:
return
! if isinstance(object, GTrigger.GTrigger) and not object.src:
self._setObject(object)
def _setObject(self, object):
self.__ignoreevent = 0
self.object = object
self.editor.SetReadOnly(0)
! if not len(object._children):
GParserHelpers.GContent(object, "")
! elif len(object._children) > 1:
! content = object.getChildrenAsContent()
! object._children = []
! GParserHelpers.GContent(object, content)
self.editor.InEditMode = 0
self.editor.SetText(object.getChildrenAsContent())
***************
*** 153,187 ****
self.editor.Colourise(0, -1)
self.editor.InEditMode = 1
! if object.type == 'NAMED':
! self.mode = NAMED_TRIGGER
! i = 0
! while self.namedTriggerList[i] != object:
! i = i + 1
! self.namedTriggerCombo.SetSelection(i+1)
else:
! self.mode = EVENT_TRIGGER
! def refillNamedTriggerCombo(self):
! cur = self.namedTriggerCombo.GetSelection()
! self.namedTriggerCombo.Clear()
! for i in range(0, len(self.namedTriggerList)):
! self.namedTriggerCombo.Append(self.namedTriggerList[i].name)
! if cur > len(self.namedTriggerList):
! cur = 0
- self.namedTriggerCombo.SetSelection(cur)
try:
! self._setObject(self._namedTriggerList[cur])
except:
pass
def inventoryObject(self, object):
if isinstance(object, GTrigger.GTrigger):
! if object.type == 'NAMED':
! self.namedTriggerList.append(object)
! self.namedTriggerCombo.Append(object.name)
def OnKillFocus(self, event):
if self.object != None and not self.__ignoreevent:
--- 158,224 ----
self.editor.Colourise(0, -1)
self.editor.InEditMode = 1
! i = self.triggerList.index(self._generateName(object)) + 1
! self.triggerCombo.SetSelection(i)
!
! def refillTriggerCombo(self):
! i = self.triggerCombo.GetSelection()
! if i:
! cur = self.triggerList[i-1]
! else:
! cur = None
! nt = []
! ct = []
!
! for key, trigger in self.triggerMap.items():
! if trigger.type.upper() == 'NAMED':
! nt.append(key)
else:
! ct.append(key)
!
! nt.sort()
! ct.sort()
!
! self.triggerList = nt + ct
! self.triggerCombo.Clear()
! self.triggerCombo.Append('')
! for i in range(0, len(self.triggerList)):
! self.triggerCombo.Append(self.triggerList[i])
try:
! i = self.triggerList.index(cur) + 1
except:
+ i = 0
+
+
+ self.triggerCombo.SetSelection(i)
+ try:
+ self._setObject(self.triggerMap[self.triggerList[i - 1]])
+ except KeyError:
pass
+ self.Refresh()
+
+ def _generateName(self, trigger):
+ if trigger.type.upper() == 'NAMED':
+ return trigger.name
+ else:
+ parent = trigger._parent
+ name = '%s.%s' % (parent.name,
parent._validTriggers[trigger.type.upper()])
+ try:
+ name = parent._parent.name + '.' + name
+ except:
+ pass
+ return '('+name+')'
+
+
def inventoryObject(self, object):
if isinstance(object, GTrigger.GTrigger):
! if not object.src:
! self.triggerMap[self._generateName(object)] = object
! self.refillTriggerCombo()
def OnKillFocus(self, event):
if self.object != None and not self.__ignoreevent:
***************
*** 205,211 ****
if isinstance(object, GTrigger.GTrigger):
if object.type == 'NAMED':
! self.refillNamedTriggerCombo()
def onDeleteObject (self, event):
--- 242,248 ----
if isinstance(object, GTrigger.GTrigger):
if object.type == 'NAMED':
! self.refillTriggerCombo()
def onDeleteObject (self, event):
***************
*** 214,228 ****
if object == None:
return
! if isinstance(object, GTrigger.GTrigger):
! if object.type == 'NAMED':
!
! i = 0
! while self.namedTriggerList[i] != object:
! i = i + 1
!
! self.namedTriggerList.pop(i)
! self.namedComboBox.Delete(i)
try:
--- 251,259 ----
if object == None:
return
! if isinstance(object, GTrigger.GTrigger) and not object.src:
! del self.triggerMap[self._generateName(object)]
! self.refilTriggerCombo()
try:
Index: gnue/designer/src/forms/Incubator.py
diff -c gnue/designer/src/forms/Incubator.py:1.4
gnue/designer/src/forms/Incubator.py:1.5
*** gnue/designer/src/forms/Incubator.py:1.4 Wed Nov 27 19:11:31 2002
--- gnue/designer/src/forms/Incubator.py Fri Nov 29 02:07:00 2002
***************
*** 32,38 ****
from gnue.designer.Incubator import *
def createObject(instance, form, tag, type=None, parent=None,
! parentHint=None, attributes={}):
GDebug.printMesg(3,'Creating a "%s" object' % tag)
--- 32,38 ----
from gnue.designer.Incubator import *
def createObject(instance, form, tag, type=None, parent=None,
! parentHint=None, attributes={}, select=1):
GDebug.printMesg(3,'Creating a "%s" object' % tag)
***************
*** 62,69 ****
parent = form
else:
parent = parent or parentHint
! elif tag in ('page','datasource','import'):
parent = form
o = objclass(parent or parentHint)
--- 62,71 ----
parent = form
else:
parent = parent or parentHint
! elif tag in ('datasource','import'):
parent = form
+ elif tag in ('page',):
+ parent = form._layout
o = objclass(parent or parentHint)
***************
*** 96,111 ****
for attr in attributes.keys():
if attrs.has_key(attr):
o.__dict__[attr] = attributes[attr]
! elif attr.index(':')+1:
# Hackery for forms namespace support
! o.__dict__[attr.replace(':','__')]
!
o.name = name
instance.nameMappings[o.name] = o
o._buildObject()
instance.dispatchEvent('ObjectCreated',object=o, originator=__name__)
! instance.dispatchEvent('ObjectSelected',object=object, originator=__name__)
return o
--- 98,114 ----
for attr in attributes.keys():
if attrs.has_key(attr):
o.__dict__[attr] = attributes[attr]
! elif attr.find(':')+1:
# Hackery for forms namespace support
! o.__dict__[attr.replace(':','__')] = attributes[attr]
!
o.name = name
instance.nameMappings[o.name] = o
o._buildObject()
instance.dispatchEvent('ObjectCreated',object=o, originator=__name__)
! if select:
! instance.dispatchEvent('ObjectSelected',object=object,
originator=__name__)
return o
***************
*** 123,129 ****
newCurrentObject = parent = object._parent
for child in object._children:
! child.deleteObject(instance, form, child, firstRun=0)
instance.dispatchEvent('ObjectDeleted',object=object, originator=__name__)
--- 126,133 ----
newCurrentObject = parent = object._parent
for child in object._children:
! if not child._type == '_content_':
! child.deleteObject(instance, form, child, firstRun=0)
instance.dispatchEvent('ObjectDeleted',object=object, originator=__name__)
Index: gnue/designer/src/forms/Instance.py
diff -c gnue/designer/src/forms/Instance.py:1.20
gnue/designer/src/forms/Instance.py:1.21
*** gnue/designer/src/forms/Instance.py:1.20 Wed Nov 27 19:11:31 2002
--- gnue/designer/src/forms/Instance.py Fri Nov 29 02:07:00 2002
***************
*** 63,80 ****
# TODO: part of the main Instance class, but an
# TODO: attribute such as Instance.formInstance?
! GFInstance.GFInstance.__init__(self, app, -1,
app.connections,
None, disableSplash=1)
# For GFInstance support, iirc
self._pages = []
BaseInstance.__init__(self, app, *args, **params)
! self.registerEventListeners({
! 'ObjectModified' : self.onModifyObject,
! })
def loadBuffer(self, buffer):
form = GFParser.loadFile (buffer, self, initialize=0)
--- 63,91 ----
# TODO: part of the main Instance class, but an
# TODO: attribute such as Instance.formInstance?
! GFInstance.GFInstance.__init__(self, app,
app.connections,
None, disableSplash=1)
# For GFInstance support, iirc
self._pages = []
+ # Build a list of positionable widgets
+ self._positionableList = []
+ elements = Incubator.elements
+ for tag in elements.keys():
+ try:
+ if elements['Positionable']:
+ self._positionableList.append(tag)
+ except KeyError:
+ pass
+
+
BaseInstance.__init__(self, app, *args, **params)
! ## self.registerEventListeners({
! ## 'ObjectModified' : self.onModifyObject,
! ## })
def loadBuffer(self, buffer):
form = GFParser.loadFile (buffer, self, initialize=0)
***************
*** 91,97 ****
form.width = 40
GFObjects.GFLogic(form)
layout = GFObjects.GFLayout(form)
- layout._xmlchildnamespaces = {'Char':'GNUe:Layout:Char'}
layout.Char__width = 40
layout.Char__height = 12
GFObjects.GFPage(layout)
--- 102,107 ----
***************
*** 105,110 ****
--- 115,122 ----
object._parent._logic = object
elif object._type == 'GFLayout':
object._parent._layout = object
+ # Yes, you guessed it! More layout mgmt hackery...
+ object._xmlchildnamespaces = {'Char':'GNUe:Layout:Char'}
elif object._type == 'GFBlock':
if self.rootObject._blockMap.has_key(object.name):
raise "Warning: Multiple blocks with name %s" % object.name
***************
*** 117,124 ****
object._popupMenu = ObjectMenu(self, object)
! def onModifyObject(self, event):
! object = event.object
def createTools(self):
self.addTool('visualEditor', _('Layout Editor'), LayoutEditor, 'F11')
--- 129,136 ----
object._popupMenu = ObjectMenu(self, object)
! ## def onModifyObject(self, event):
! ## object = event.object
def createTools(self):
self.addTool('visualEditor', _('Layout Editor'), LayoutEditor, 'F11')
***************
*** 213,224 ****
# Used by TemplateParser to build a wizard.current dict
def buildWizardCurrentDict(self):
! return {}
# Hack having to do with UIwxpython import
def uiEventTrap(self, event):
pass
-
-
--- 225,239 ----
# Used by TemplateParser to build a wizard.current dict
def buildWizardCurrentDict(self):
! return {'form': self.rootObject,
! 'logic': self.rootObject._logic,
! 'layout': self.rootObject._layout,
! 'page': self.visualEditor.page,
! 'block': self.visualEditor.block,
! 'object': self._currentObject}
# Hack having to do with UIwxpython import
def uiEventTrap(self, event):
pass
Index: gnue/forms/src/GFForm.py
diff -c gnue/forms/src/GFForm.py:1.213 gnue/forms/src/GFForm.py:1.214
*** gnue/forms/src/GFForm.py:1.213 Thu Nov 28 01:07:59 2002
--- gnue/forms/src/GFForm.py Fri Nov 29 02:07:00 2002
***************
*** 83,89 ****
self._dialogDictionary={}
# Hackery until proper layout support is added
! self._xmlnamespaces = {'c': 'GNUe:Forms:Character'}
# The "None" init gives datasources time to setup master/detail
--- 83,89 ----
self._dialogDictionary={}
# Hackery until proper layout support is added
! self._standardnamespaces = {'Char': 'GNUe:Forms:Char'}
# The "None" init gives datasources time to setup master/detail
Index: gnue/forms/src/GFParser.py
diff -c gnue/forms/src/GFParser.py:1.99 gnue/forms/src/GFParser.py:1.100
*** gnue/forms/src/GFParser.py:1.99 Wed Nov 27 21:24:39 2002
--- gnue/forms/src/GFParser.py Fri Nov 29 02:07:00 2002
***************
*** 25,30 ****
--- 25,33 ----
# Class that contains a sax based xml processor for GNUe forms
#
# NOTES:
+ # 1. Designer uses the 'Positionable' attribute. It is specific to
+ # forms+designer and is not part of the GParser spec. If set to
+ # true, then this object is a visible, movable, sizable attribute.
#
from gnue.common import GDataSource, GParser, GMenu
***************
*** 253,258 ****
--- 256,262 ----
## 'Required': 1,
## 'Typecast': GTypecast.whole,
## 'Description': 'The text row starting position of the
widget. Based upon the top row of the screen being 0.' } },
+ 'Positionable': 1,
'ParentTags': ('page',),
'Description': 'TODO' },
***************
*** 464,469 ****
--- 468,474 ----
## 'Typecast': GTypecast.whole,
## 'Description': 'The text row starting position of the
widget. '
## 'Based upon the top row of the screen being
0.' } },
+ 'Positionable': 1,
'ParentTags': ('page',),
'Description': 'An {entry} is the visual counterpart to a {field}.'
},
***************
*** 490,495 ****
--- 495,501 ----
## 'Required': 1,
## 'Typecast': GTypecast.whole,
## 'Description': 'The text row starting position of the
widget. Based upon the top row of the screen being 0.' } },
+ 'Positionable': 1,
'ParentTags': ('page',),
'Description': 'TODO' },
***************
*** 522,527 ****
--- 528,534 ----
## 'Required': 1,
## 'Typecast': GTypecast.whole,
## 'Description': 'The text row starting position of the
widget. Based upon the top row of the screen being 0.' } },
+ 'Positionable': 1,
'ParentTags': ('page',),
'Description': 'TODO' },
***************
*** 555,560 ****
--- 562,568 ----
## 'Required': 1,
## 'Typecast': GTypecast.whole,
## 'Description': 'The text row starting position of the
widget. Based upon the top row of the screen being 0.' } },
+ 'Positionable': 1,
'ParentTags': ('page',),
'Description': 'TODO' },
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue common/src/GObjects.py common/src/GRootObj...,
Jason Cater <=