[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnue] r8210 - in trunk/gnue-designer: images src src/base src/base/tool
From: |
jcater |
Subject: |
[gnue] r8210 - in trunk/gnue-designer: images src src/base src/base/tools src/forms src/forms/LayoutEditor src/forms/LayoutEditor/renderers/Base src/forms/events src/navigator src/reports src/reports/Char src/reports/Standard src/schema src/schema/DiaEditor src/templates/forms src/templates/reports src/templates/schema src/uidrivers/wx src/uidrivers/wx/uihelpers |
Date: |
Mon, 6 Mar 2006 18:04:36 -0600 (CST) |
Author: jcater
Date: 2006-03-06 18:04:31 -0600 (Mon, 06 Mar 2006)
New Revision: 8210
Added:
trunk/gnue-designer/src/base/Document.py
trunk/gnue-designer/src/base/EditorBase.py
trunk/gnue-designer/src/forms/Document.py
trunk/gnue-designer/src/navigator/Document.py
trunk/gnue-designer/src/reports/Document.py
trunk/gnue-designer/src/schema/Document.py
Removed:
trunk/gnue-designer/src/base/Instance.py
trunk/gnue-designer/src/forms/Instance.py
trunk/gnue-designer/src/navigator/Instance.py
trunk/gnue-designer/src/reports/Instance.py
trunk/gnue-designer/src/schema/Instance.py
trunk/gnue-designer/src/uidrivers/wx/docks/
Modified:
trunk/gnue-designer/images/editor_painter-16x16.png
trunk/gnue-designer/src/Designer.py
trunk/gnue-designer/src/base/Incubator.py
trunk/gnue-designer/src/base/MRUManager.py
trunk/gnue-designer/src/base/MenuBar.py
trunk/gnue-designer/src/base/MultiObjectGridEditor.py
trunk/gnue-designer/src/base/PopupMenu.py
trunk/gnue-designer/src/base/PrimaryToolBar.py
trunk/gnue-designer/src/base/TemplateBase.py
trunk/gnue-designer/src/base/TemplateParser.py
trunk/gnue-designer/src/base/ToolBar.py
trunk/gnue-designer/src/base/ToolBase.py
trunk/gnue-designer/src/base/UndoManager.py
trunk/gnue-designer/src/base/tools/DataSourceEditor.py
trunk/gnue-designer/src/base/tools/EventEditor.py
trunk/gnue-designer/src/base/tools/PropertyEditor.py
trunk/gnue-designer/src/base/tools/SchemaNavigator.py
trunk/gnue-designer/src/base/tools/SchemaViewer.py
trunk/gnue-designer/src/base/tools/TreeView.py
trunk/gnue-designer/src/base/tools/TriggerEditor.py
trunk/gnue-designer/src/forms/BlockEditor.py
trunk/gnue-designer/src/forms/Debugger.py
trunk/gnue-designer/src/forms/LayoutEditor/DisplayDropTarget.py
trunk/gnue-designer/src/forms/LayoutEditor/LayoutEditor.py
trunk/gnue-designer/src/forms/LayoutEditor/PopupEditor.py
trunk/gnue-designer/src/forms/LayoutEditor/ReorderFocus.py
trunk/gnue-designer/src/forms/LayoutEditor/WidgetFocusTab.py
trunk/gnue-designer/src/forms/LayoutEditor/Workspace.py
trunk/gnue-designer/src/forms/LayoutEditor/renderers/Base/Driver.py
trunk/gnue-designer/src/forms/LayoutEditor/renderers/Base/GridPane.py
trunk/gnue-designer/src/forms/PropertyEditor.py
trunk/gnue-designer/src/forms/TreeView.py
trunk/gnue-designer/src/forms/WizardRunner.py
trunk/gnue-designer/src/forms/events/Arrange.py
trunk/gnue-designer/src/forms/events/Resize.py
trunk/gnue-designer/src/reports/Char/FilterSupport.py
trunk/gnue-designer/src/reports/Char/LayoutEditor.py
trunk/gnue-designer/src/reports/FilterSupport.py
trunk/gnue-designer/src/reports/Incubator.py
trunk/gnue-designer/src/reports/Standard/FilterSupport.py
trunk/gnue-designer/src/reports/Standard/LayoutEditor.py
trunk/gnue-designer/src/schema/DiaEditor/VisualEditor.py
trunk/gnue-designer/src/schema/DiaEditor/VisualTable.py
trunk/gnue-designer/src/schema/LayoutEditor.py
trunk/gnue-designer/src/templates/forms/FormBuilder.py
trunk/gnue-designer/src/templates/forms/Simple.py
trunk/gnue-designer/src/templates/reports/CharReport.py
trunk/gnue-designer/src/templates/reports/Labels.py
trunk/gnue-designer/src/templates/reports/MailMerge.py
trunk/gnue-designer/src/templates/reports/SimpleReport.py
trunk/gnue-designer/src/templates/schema/Introspection.py
trunk/gnue-designer/src/uidrivers/wx/Base.py
trunk/gnue-designer/src/uidrivers/wx/Instance.py
trunk/gnue-designer/src/uidrivers/wx/MenuBar.py
trunk/gnue-designer/src/uidrivers/wx/uihelpers/GridCellEditors.py
trunk/gnue-designer/src/uidrivers/wx/uihelpers/NotebookCtrl.py
trunk/gnue-designer/src/uidrivers/wx/uihelpers/PyAUI.py
trunk/gnue-designer/src/uidrivers/wx/uihelpers/PythonEditor.py
Log:
more work on wx2.6-ifying designer
Modified: trunk/gnue-designer/images/editor_painter-16x16.png
===================================================================
(Binary files differ)
Modified: trunk/gnue-designer/src/Designer.py
===================================================================
--- trunk/gnue-designer/src/Designer.py 2006-03-06 20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/Designer.py 2006-03-07 00:04:31 UTC (rev 8210)
@@ -125,8 +125,8 @@
elif self.OPTIONS['new']:
try:
- #self.SetTopWindow(self.newInstance(self.OPTIONS['new']))
- self.newInstance(self.OPTIONS['new'])
+ #self.SetTopWindow(self.newDocument(self.OPTIONS['new']))
+ self.newDocument(self.OPTIONS['new'])
except ImportError:
raise
self.handleStartupError('"%s" is not a valid option for --new' % (
@@ -137,8 +137,8 @@
# TODO: jcater thinks of some task selector like kword uses,
# TODO: or, restore the session to the way it was (same files, etc)
- #self.SetTopWindow(self.newInstance('forms'))
- self.newInstance('forms')
+ #self.SetTopWindow(self.newDocument('forms'))
+ self.newDocument('forms')
# Close startup screen
# self.ui.closeStartupSplash()
@@ -201,7 +201,7 @@
# ==========================================================================
- # Instance functions
+ # Document functions
# ==========================================================================
def load(self, file):
"""
@@ -229,17 +229,17 @@
print "I do not know what to do with a .%s file!" % extension
return None
- return self.newInstance(self.moduleExtensionMapping[extension], file)
+ return self.newDocument(self.moduleExtensionMapping[extension], file)
- def newInstance(self, module, *args, **parms):
+ def newDocument(self, module, *args, **parms):
"""
Creates an instance of the appropriate designer editor module
"""
- c = dyn_import("gnue.designer.%s.Instance" % module).Instance(self, *args,
**parms)
+ c = dyn_import("gnue.designer.%s.Document" % module).Document(self, *args,
**parms)
return c
- def addInstance(self, instance):
+ def addDocument(self, instance):
"""
Adds a newly created instance to the list of open instances
Sets several event handlers in the instance to point back to
@@ -260,7 +260,7 @@
'RequestExit' : self.OnExit
})
- def removeInstance(self, instance):
+ def removeDocument(self, instance):
"""
Removes an instance from the list of open instances
@@ -322,7 +322,8 @@
param event: The event request
"""
for instance in self._instances[:]:
- instance.OnClose(event)
+ # TODO: this should be an event
+ instance._OnClose(event)
#
# If this Close() causes issues you can replace
# with the following.
@@ -379,7 +380,7 @@
type event: GNUe Event
param event: The event request
"""
- self.newInstance(event.type)
+ self.newDocument(event.type)
# ==========================================================================
@@ -427,11 +428,11 @@
except:
style = None
- instance = self.newInstance(product, style=style)
+ instance = self.newDocument(product, style=style)
if not TemplateParser.TemplateParser(instance, instance.rootObject,
- instance.uiinstance, templateInformation).run():
- instance.uiinstance.close()
+ instance.ui, templateInformation).run():
+ instance.ui.close()
if __name__ == '__main__':
Copied: trunk/gnue-designer/src/base/Document.py (from rev 8208,
trunk/gnue-designer/src/base/Instance.py)
===================================================================
--- trunk/gnue-designer/src/base/Instance.py 2006-03-06 14:54:02 UTC (rev
8208)
+++ trunk/gnue-designer/src/base/Document.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -0,0 +1,834 @@
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Copyright 2001-2006 Free Software Foundation
+#
+# FILE:
+# Document.py
+#
+# DESCRIPTION:
+# This is the base instance class for a designer session. Every
+# open file will be associated with its own Instance.
+#
+# NOTES:
+#
+
+__all__ = ['BaseInstance']
+
+#----------------------------------------------------------------------------
+# System imports
+#----------------------------------------------------------------------------
+import sys
+import os
+import time
+import dircache
+
+#----------------------------------------------------------------------------
+# GNUe Imports
+#----------------------------------------------------------------------------
+from gnue.common.apps import GDebug
+from gnue.common.apps import RuntimeSettings
+from gnue.common.utils.FileUtils import dyn_import
+from gnue.common.events import EventController, Event
+
+from gnue.designer.base.MenuBar import MenuBar
+from gnue.designer.base.UndoManager import UndoManager
+from gnue.designer.base.tools import TriggerEditor
+from gnue.designer.base.ToolBase import ToolBase
+from gnue.designer.base.ObjectList import ObjectList
+from gnue.designer.base import TemplateBase
+from gnue.designer.base.TemplateParser import WizardRunner
+from gnue.designer import VERSION, PACKAGE as TITLE
+
+from ModuleSupport import SupportedModules
+
+
+#============================================================================
+# Base document class
+#============================================================================
+class BaseDocument(EventController):
+
+
+ #==========================================================================
+ # Virtual functions (Override these functions in your Instance)
+ #==========================================================================
+ wizardRunner = WizardRunner
+
+ def init(self):
+ """
+ initialize the instance (called at the
+ beginning of the __init__ process)
+ """
+
+ def init(self):
+ """
+ Finalize the instance (called at the
+ end of the __init__ process)
+ """
+
+ def loadFile(self, buffer):
+ """
+ Called to load the object from a file buffer/handle
+ """
+ return None
+
+ def loadEmpty(self, style=None):
+ """
+ Called to load an "empty" (new) object. Create the root object
+ and any initial child objects (if appropriate)
+ """
+ return None
+
+ def inventoryObject(self, object):
+ """
+ Called in a tree-like fashion for every object
+ whether loaded in the beginning or later added.
+ """
+ pass
+
+ def preSave(self):
+ """
+ Called just before saving the file using GObject's dumpTree
+ You might do some sanity checks, etc.
+ """
+ return
+
+ def createTools(self):
+ """
+ Add any ToolBase instances
+ """
+ pass
+
+ def createEditors(self):
+ """
+ Add any EditorComponent instances
+ """
+ pass
+
+ def createWizards(self):
+ """
+ Add any runtime-loadable wizards/tools
+ """
+ pass
+
+ def initMenu(self):
+ """
+ Add any tool-specific functions to the menu bar
+ """
+ pass
+
+ def initToolBar(self):
+ """
+ Add any tool-specific functions to the tool bar
+ """
+ pass
+
+
+ def buildWizardCurrentDict(self):
+ """
+ Used by TemplateParser to build a wizard.current dict
+ """
+ return {'object': self._currentObject}
+
+
+ #==========================================================================
+ # Public Functions
+ #==========================================================================
+
+
+ #--------------------------------------------------------------------------
+ # Register interface elements
+ #--------------------------------------------------------------------------
+ def addTool(self, id, title, baseclass, hotkey=None, menuGroup=499):
+ """
+ Add a ToolBase instance
+ """
+ self._toolCache.append( (id, title, baseclass, hotkey, menuGroup) )
+
+
+ def registerEditor(self, baseclass, gtype, filter=None):
+ """
+ Register an editor class
+
+ Parameters:
+
+ baseclass: An EditorComponent class
+
+ gtype: A string indicating a GObject._type identifier,
+ or a list of such strings.
+
+ filter: A function that is passed a GObject and should
+ return True/False indicating if an editor instance
+ should be created.
+
+ """
+ if isinstance(gtype,basestring):
+ gtype = [gtype]
+ for gtype1 in gtype:
+ self._editorMapping[gtype1] = (filter, baseclass)
+
+
+ #--------------------------------------------------------------------------
+ # Set the saved/unsaved status
+ #--------------------------------------------------------------------------
+
+ def save(self):
+
+ if self.preSave():
+ print "Not saving definition"
+ return
+
+ location = self._path
+ fileHandle = None
+ fileHandle2 = None
+ if self._makeBackup:
+ try:
+ fileHandle = open(location,'r')
+ fileHandle2 = open(location + "~",'w')
+ fileHandle2.writelines(fileHandle.readlines())
+ except:
+ pass
+ else:
+ if fileHandle != None:
+ fileHandle.close()
+ if fileHandle2 != None:
+ fileHandle2.close()
+
+ self._makeBackup = 0
+
+ fileHandle = open(location,'w')
+
+ fileHandle.write('<?xml version="1.0" encoding="%s"?>\n\n' % \
+ gConfig('textEncoding'))
+
+ for comment in self.rootObject._rootComments:
+ if comment.find(TITLE) > 0:
+ self.rootObject._rootComments.remove(comment)
+
+ # Place a timestamp in the XML as a comment
+ # TODO: Replace with Dublin Core?
+ fileHandle.write('<!-- %s (%s)\n%s Saved on: %s -->\n\n' \
+ % (TITLE, VERSION, (len(self.wizardName) and (" Created by " +
self.wizardName + "\n") or ""),\
+ time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))))
+
+ fileHandle.write(''.join(["<!--%s-->\n\n" %
comment.encode(gConfig('textEncoding')) \
+ for comment in self.rootObject._rootComments]))
+
+
fileHandle.write(self.rootObject.dumpXML(treeDump=True).encode(gConfig('textEncoding')))
+ fileHandle.close()
+
+ self.app.mru.addLocation(location)
+ self.makeClean()
+
+
+ # Mark our form as "dirty" (unsaved changes)
+ def makeDirty(self):
+ if not self._isdirty:
+ self._isdirty = True
+ if self._path == "":
+ self.ui.setTitle( _("Untitled %s*") % self.properties.nickname)
+ else:
+ self.ui.setTitle(self._path + "*")
+ self.dispatchEvent('MakeDirty')
+
+
+ # Mark our form as "clean" (no unsaved changes)
+ def makeClean(self):
+ self._isdirty = 0
+ self._isnew = 0
+ if self._path == "":
+ self.ui.setTitle( _("Untitled %s") % self.properties.nickname)
+ else:
+ self.ui.setTitle( self._path)
+ self.dispatchEvent('MakeClean')
+
+
+ #--------------------------------------------------------------------------
+ # GObject convenience methods
+ #--------------------------------------------------------------------------
+ def getNextGenericName (self, type):
+ return self.getUniqueName(type.capitalize() + '1')
+
+
+ def getUniqueName(self, name, limitingObject=None):
+
+ try:
+ usedNames = limitingObject.usedNames
+ except:
+ usedNames = self.usedNames
+
+ if name.lower() not in usedNames:
+ usedNames.append(name.lower())
+ return name
+
+ index = len(name) - 1
+
+ while index > 0 and '0' <= name[index] <= '9':
+ index -= 1
+
+ index += 1
+ if index >= len(name):
+ start = 1
+ base = name
+ else:
+ start = int(name[index:])
+ base = name[:index]
+
+ while ("%s%s" % (base, start)).lower() in usedNames:
+ start += 1
+
+ rv = "%s%s" % (base, start)
+ usedNames.append(rv.lower())
+ if rv.lower() not in self.usedNames:
+ self.usedNames.append(rv.lower())
+ return rv
+
+
+ #--------------------------------------------------------------------------
+ # 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
+
+
+ #==========================================================================
+ # Private functions
+ #==========================================================================
+
+ def __init__(self, app, location=None, buffer=None, style=None):
+ EventController.__init__(self)
+
+ self.app = app
+ self.ui = app.ui.createInstance(self)
+
+ # During startup, we will cache all events
+ # so we can execute them when everything has
+ # been initialized.
+ self.startCachingEvents()
+
+ # Local variables
+ self.wizardName = ""
+ self._isdirty = False
+ self._makeBackup = True
+ self._isNew = True
+ self.connections = app.connections
+ self.nameMappings = {}
+ self.usedNames = []
+
+ # Create the supplemental tools
+ self._toolCache = []
+ self._editorMapping = {}
+ self._pages = []
+ self.objectLists = {}
+ self._path = ""
+
+ self.globalAccelerators = []
+ self.globalAcceleratorListeners = []
+
+ self._nameMappers = {} # {GDataSource: {'name': [(GFBlock,'name')]}}
+
+
+ self.registerEventListeners({
+ # Menu/Toolbar stuff
+ 'RequestSave' : self._OnSave,
+ 'RequestSaveAs' : self._OnSaveAs,
+ 'RequestClose' : self._OnClose,
+
+ # Object stuff
+ 'ObjectSelected' : self.__onSetCurrentObject,
+ 'ObjectCreated' : self.__onCreateObject,
+ 'ObjectModified' : self.__onModifyObject,
+ 'ObjectDeleted' : self.__onDeleteObject,
+ })
+
+
+ # Call the document-specific init method
+ self.init()
+
+ # Register ourself with RuntimeSettings
+ RuntimeSettings.init(configFilename="gnue-des.ini", homeConfigDir=".gnue")
+ RuntimeSettings.registerInstance(self)
+
+ # Tell RuntimeSettings that we have information to save
+ self.runtime_section = self.properties.nickname + 'Layout'
+ RuntimeSettings.registerRuntimeSettingHandler(self, self)
+
+ # And the "Most Recenty Used" manager
+ RuntimeSettings.registerRuntimeSettingHandler(self, app.mru)
+
+ # Set up the Undo/Redo Manager
+ UndoManager(self)
+
+ # Load any files specified on the command line, or create a new document
+ if location == None:
+
+ if buffer != None:
+ self.__loadFromBuffer(buffer)
+ self.makeDirty()
+ else:
+ self.__createEmptyInstance(style)
+
+ else:
+ if not os.access (location, os.R_OK):
+ self.show()
+ if not self.ui.dialogYesNo(
+ _('The requested file does not exist.\n') +
+ _('Do you want to create this file?') +
+ _('\n\nFile: %s') \
+ % location, _("File Not Found"), self.ui):
+ # TODO: Is this right?
+ sys.exit()
+ self.hide()
+ self.__createEmptyInstance(style)
+ self._path = location
+ self.makeDirty()
+
+ elif not os.access (location, os.W_OK):
+ self.show()
+ if not self.ui.dialogCancel(
+ _('The requested file is Read Only.\n') +
+ _('To save any changes, you will \n') +
+ _('be required to do a "Save As..."\n\nFile: %s') \
+ % location, _("Read Only Warning"), self.ui) :
+ # TODO: Is this right?
+ sys.exit()
+ self.hide()
+ self.__loadFromFile(location)
+ else:
+ self.__loadFromFile(location)
+
+ self.menubar = MenuBar(self)
+
+
+ gStartupStatus(_('Creating User Interface'))
+
+ # Set up the menu system
+ # ... our common menu
+ self._initMenu()
+ # ... and the document-centric menu
+ self.initMenu()
+
+ self.createWizards()
+
+ # Set up the editor components...
+ # ... common
+ self.registerEditor(TriggerEditor.TriggerEditor, 'GCTrigger',
+ TriggerEditor.EditorFilter)
+ # ... and document-centric
+ self.createEditors()
+
+ # Create the document-centric tools
+ self.createTools()
+
+ # And tell the UI driver to create the UI portions
+ self.ui.initTools()
+
+ # Finalize menu bar
+ self.menubar.finalize()
+ self.app.mru.addMenu(self.menubar.getMenu('File|Open Recent|'), self)
+
+ self.toolbar = self.ui.toolbar
+ self.initToolBar()
+
+ # TODO: This is a hack to disable any menu items
+ # TODO: for actions we've yet to implement
+ for action in ('RequestRevert','RequestRedo','RequestCopy',
+ 'RequestPaste','RequestPasteSpecial','RequestCut'):
+ self.dispatchEvent('Disable:%s' % action)
+
+
+ # Add ourselve to the main app's instance list
+ self.app.addDocument(self)
+
+
+ self.dispatchEvent('ObjectSelected', originator=self,
+ object=self.rootObject)
+
+ # Inventory the objects
+ gStartupStatus(_('Inventorying Document Objects'))
+ self.rootObject.walk(self.__inventory)
+
+ self.finalize()
+ self.ui.finalize()
+
+ self.stopCachingEvents()
+
+
+ def _initMenu(self):
+ # Add the [sub]menus
+ for location, text, grouping in (
+ ('File', _('&File'), 100),
+ ('File|New', _('&New'), 100),
+ ('File|Open Recent', _('&Open Recent'), 200.1),
+ ('File|Connect To', _('&Connect To'), 400),
+ ('Edit', _('&Edit'), 200),
+ ('Insert',_('&Insert'), 300),
+ ('Modify',_('&Modify'), 400),
+ ('Tools',_('&Tools'), 500),
+ ('View',_('&View'), 800),
+ ('Help',_('&Help'), 999)):
+
+ self.menubar.addMenu(location, text, grouping)
+
+ for location, event, text, hotkey, help, grouping in (
+ ('File', 'RequestOpen', _('&Open'), 'Ctrl+O', _("Open an existing
document"), 200.1),
+ ('File|Open Recent', 'XXXX', _('&Foo'), None, _("This is a placeholder
for the Open Recent menu"), 200.1),
+ ('File|New', 'RequestNewWizard', _('From &Wizard...'), None, _("Create
a new document using a wizard"), 900.1),
+ ('File', 'RequestSave', _("&Save"), 'Ctrl+S', _("Save the current
document"),300.1),
+ ('File', 'RequestSaveAs', _("Save &As..."),None, _("Save the current
document under a new name"), 300.2),
+ ('File', 'RequestSaveAll', _("Save A&ll"),None,_("Save all open
document"),300.3),
+ ('File', 'RequestRevert', _("Reload"), None, _("Reload the current
document as of its last save (abandoning any changes)"), 500),
+ ('File', 'RequestClose', _("&Close"), 'Ctrl+W', _("Close the current
document"), 990),
+ ('File', 'RequestExit', _("E&xit"), None, _("Exit GNUe Designer"), 995),
+ ('Edit', 'RequestUndo', _("&Undo"), 'Ctrl+Z', _("Undo the last
action"), 100.1),
+ ('Edit', 'RequestRedo', _("&Redo"), 'Ctrl+Y', _("Redo the last undo
action"), 100.2),
+ ('Edit', 'RequestCut', _("Cu&t"), 'Ctrl+X', _("Cut the current object
and move to the clipboard"), 200.1),
+ ('Edit', 'RequestCopy', _("&Copy"), 'Ctrl+C', _("Copy the current
object to the clipboard"), 200.2),
+ ('Edit', 'RequestPaste', _("&Paste"), 'Ctrl+V', _("Paste the current
object on the clipboard"), 200.3),
+ ('Edit', 'RequestPasteSpecial', _("Paste &Special..."), None, _("Paste
the current object on the clipboard with special attributes"), 200.4),
+ ('Modify','RequestDelete', _("&Delete Item"), 'Delete', _("Delete the
current object"),100),
+ ('Help', 'RequestAbout', _("&About GNUe Designer"), None, _("More
information about GNUe Designer"), 900),
+ ):
+ self.menubar.addAction(location, text, event,
+ grouping, canDisable=True,
+ icon=None, hotkey=hotkey, help=help)
+
+ # Add supported tools to File|New
+ for tool in SupportedModules:
+ self.menubar.addAction('File|New', '&%s' % tool.properties.nickname,
+ 'RequestNew', 100,
+ help=_('Create a new %s') % tool.properties.nickname.lower(),
eventdata={'type': tool.properties.module })
+
+ # Add connections
+ for conn in self.connections.getAllConnectionParameters().keys():
+ self.menubar.addAction('File|Connect To', conn, 'Connect:%s' % conn,
+ help=_("Login to %s connection") % conn,
+ eventdata={'connection': conn})
+ self.registerEventListeners({'Connect:%s' % conn:self.__OnConnectTo})
+
+
+ def __loadFromFile(self, location):
+ try:
+ self._path = location
+ fileHandle = open(location,'r')
+ self.__loadFromBuffer(fileHandle)
+ fileHandle.close()
+ self.makeClean()
+ self._isNew = 0
+ except IOError, msg:
+ print "\n%s %s\n\nUnable to open file '%s'. \nUnexpected read error:\n
%s.\n" % (TITLE, VERSION, location, msg)
+ sys.exit()
+ self.app.mru.addLocation(location)
+
+
+ def addNameMapper(self, instance, attribute, childinst, childattr):
+ try:
+ instm = self._nameMappers[instance]
+ except KeyError:
+ instm = {}
+ self._nameMappers[instance] = instm
+ try:
+ attrm = instm[attribute]
+ except KeyError:
+ attrm = []
+ instm[attribute] = attrm
+ attrm.append ( (childinst, childattr) )
+
+
+ def __loadFromBuffer(self, fileHandle):
+ self.rootObject = self.loadBuffer(fileHandle)
+
+
+ def __createEmptyInstance(self, style):
+ self.rootObject = self.loadEmpty(style)
+ self.makeClean()
+ self._isNew = True
+
+
+ #--------------------------------------------------------------------------
+ #
+ #--------------------------------------------------------------------------
+ #
+ # Used by RuntimeSettings
+ #
+ def saveRuntimeSettings(self):
+ return ( self.runtime_section, self.ui.getRuntimeSettings() )
+
+
+ #--------------------------------------------------------------------------
+ #
+ #--------------------------------------------------------------------------
+ # Do we need to be saved?
+ def isDirty(self):
+ return self._isdirty
+
+
+ #--------------------------------------------------------------------------
+ #
+ #--------------------------------------------------------------------------
+ # Take an object and mangle it all up
+ # until it is useful to us
+ def __inventory (self, object):
+
+ # Add a GObjectHelper to intercept __getitem__ calls on GObject
+ GObjectHelper(self, object)
+
+ if object != self.rootObject:
+
+ # Assign an ID if none exists
+ # TODO: in the future, I want to change these to id=".." instead of
name=".."
+ if hasattr(object, 'name'):
+ if object.name == None or object.name[:3] == "__G":
+ object.name = self.getNextGenericName(object._type[2:])
+ self.nameMappings[object.name.lower()] = object
+ self.usedNames.append(object.name.lower())
+
+ # Do we create an EditorComponent instance?
+ if object._type in self._editorMapping.keys():
+ filter = self._editorMapping[object._type][0]
+ if filter is None or filter(object):
+ self.ui.createEditor(object, *self._editorMapping[object._type][1:])
+
+ # Now, give the tool-specific instances a chance
+ self.inventoryObject(object)
+
+
+ def __onSetCurrentObject (self, event):
+ object = event.object
+ handler = event.originator
+ self._currentObject = object
+
+ def __onCreateObject (self, event):
+ self.__inventory(event.object)
+ self.makeDirty()
+
+ def __onModifyObject (self, event):
+ object = event.object
+ # Check for any name dependencies
+ # (i.e., GFEntry is dependent on GFBlock.name and GFField.name)
+ # Automatically create any change events for the child objects
+ if hasattr(object, '_nameDependencies'):
+ for key in object._nameDependencies.keys():
+ masterattr, slaveattr = object._nameDependencies[key]
+ if masterattr in event.new.keys():
+ oa = {slaveattr: key[slaveattr]}
+ na = {slaveattr: object[masterattr]}
+ key.__dict__.update(na)
+ self.dispatchEvent( 'ObjectModified',
+ object=key,
+ originator=self,
+ old=oa, new=na )
+ self.makeDirty()
+
+
+ def __onDeleteObject (self, event):
+ object = event.object
+
+ # Delete the actual object from its parent
+ object.getParent ()._children.remove(object)
+ ##object.getParent ()._children.pop(object.getParent
()._children.index(object))
+
+ self.makeDirty()
+
+
+
+ def __OnConnectTo(self, event):
+ conn = event.connection
+ try:
+ tempDO = self.connections.getConnection(conn, 'object')
+ self.dispatchEvent('ConnectionEstablished',connection=conn)
+ self.dispatchEvent('Disable:Connect:%s' % conn)
+ except:
+ print _("Unable to connect to %s") % conn
+
+
+ #--------------------------------------------------------------------------
+ #
+ #--------------------------------------------------------------------------
+ def _OnSave(self, event):
+ if not len(self._path):
+ self.OnSaveAs(event)
+ else:
+ self.save()
+
+
+ def _OnSaveAs(self, event):
+ wildcards = []
+ # Make the "default" file extension for a tool
+ # appear before the other extensions.
+ filterIndex = [self.properties.defaultFileExtension]
+ wildcards += [
+ ( self.properties.defaultFileExtension,
+ self.properties.fileExtensions[self.properties.defaultFileExtension]) ]
+
+ for type in self.properties.fileExtensions.keys():
+ if type != self.properties.defaultFileExtension:
+ wildcards += [
+ ( type, self.properties.fileExtensions[type]) ]
+ filterIndex.append(type)
+
+ path = self.ui.dialogSaveFile(_("Save %s As...") %
self.properties.description,
+ wildcards = wildcards,
+ parentWindow=self.ui)
+
+ if path:
+# if len(path) < 4 or not (path[-4] == '.' and path[-3:].lower() in
self.properties.fileExtensions.keys()):
+# path += "." + filterIndex[dlg.GetFilterIndex()]
+
+ if os.path.isfile(path):
+ overwrite = self.ui.dialogYesNo(
+ _('The file "%s".\n' % path) +
+ _("exists. Overwrite?"),
+ _("Unsaved Changes"), icon="warn", parentWindow=self.ui)
+ if not overwrite:
+ self.OnSaveAs(event)
+ return
+
+ self._path = path
+ self.ui.setTitle (self._path)
+ self.save()
+
+
+
+ def _OnClose(self, event):
+ if self.isDirty():
+ save = self.ui.dialogYesNoCancel(
+ _("This document has unsaved changes.\n") +
+ _("Save changes before closing?"),
+ _("Unsaved Changes"), icon="warn", parentWindow=self.ui)
+ if save == True:
+ self.OnSave(event)
+ elif save == -1:
+ event.Veto()
+ return
+
+ RuntimeSettings.saveRuntimeSettings(self)
+ self.app.mru.removeMenu(self.menubar.getMenu('File|Open Recent|'), self)
+ self.app.removeDocument(self)
+ self.ui.close()
+
+
+ #--------------------------------------------------------------------------
+ #
+ #--------------------------------------------------------------------------
+ def loadWizards(self, package):
+ templates = []
+
+ basedir = os.path.dirname(package.__file__)
+ processed = [] # Base file names processed (e.g., base of Simple.py*
+ # is Simple) This will keep us from importing Simple
+ # three times if Simple.py, Simple.pyc, and Simple.lib
+ # all exist.
+
+ for dir in dircache.listdir(basedir):
+ base = dir.split('.')[0]
+ if not dir[0] in ('.','_') and not base in processed:
+ processed.append(base)
+ try:
+ templates.append(dyn_import(
+ '%s.%s' % (package.__name__,base)).TemplateInformation)
+ except ImportError, mesg:
+ assert gDebug(2,"%s.%s doesn't appear to be a valid wizard" %
(package.__name__, base))
+ assert gDebug(5,' --> %s' % (mesg))
+ except AttributeError:
+ assert gDebug(2,'Wizard %s for package %s is missing'
+ ' an \'TemplateInformation\' attribute.' %
+ (base,package.__name__))
+
+ for template in templates:
+ try:
+ location = template['MenuLocation']
+ try:
+ location, translation, grouping = location
+ grouping = float(grouping)
+ except:
+ location, translation = location
+ grouping = 499.0
+
+ if location:
+ self.wizardRunner(template, self)
+ self.menubar.addAction(location=location, text=translation,
+ event='Wizard:%s' % template['BaseID'],
+ grouping=grouping, canDisable=True,
+ eventdata={'template':template},
help=template['Description'])
+ except ValueError:
+ continue
+
+# ===========================================================================
+# Wrapper Class
+# ===========================================================================
+class GObjectHelper:
+ def __init__(self, instance, object):
+ self.document = instance
+ self.object = object
+ 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 _setItemHook(self, key, value):
+ ek = key.replace(':','__')
+ object = self.object
+ try:
+ ov = {key: object.__dict__[ek]}
+ except KeyError:
+ ov = {}
+ object.__dict__[key.replace(':','__')] = value
+ self.document.dispatchEvent('ObjectModified',
+ object = object, new={key:value}, old=ov, originator = '__inline__')
+
+ def setStatus(self, text):
+ self.ui.setStatus(text)
+
+# ===========================================================================
+# Helper class used by the tool-specific packages
+# ===========================================================================
+class ModuleProperties:
+ xmlOpeningTag = 'undefined'
+ short = 'undefined'
+ application = 'GNUe Tool'
+ description = 'undefined'
+ fileExtensions = {}
+ defaultFileExtension = 'undefined'
+
Added: trunk/gnue-designer/src/base/EditorBase.py
===================================================================
--- trunk/gnue-designer/src/base/EditorBase.py 2006-03-06 20:23:30 UTC (rev
8209)
+++ trunk/gnue-designer/src/base/EditorBase.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -0,0 +1,76 @@
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Copyright 2001-2006 Free Software Foundation
+#
+# FILE:
+# Tools.py
+#
+# DESCRIPTION:
+# Base class for all Tool panels
+#
+# NOTES:
+#
+
+__all__ = ['EditorBase']
+
+import wx
+from gnue.common.apps import RuntimeSettings
+from gnue.common import events
+
+# ===========================================================================
+#
+# ===========================================================================
+class EditorBase(wx.Panel, events.EventAware):
+ """
+ An "Editor Component" is presented usually as an editor to the user
+ and is considered a "primary window".
+ """
+ default_dock = 'primary'
+ icon = 'painter'
+
+ def __init__(self, object, document, parentWindow):
+ wx.Panel.__init__(self, parentWindow, -1)
+ events.EventAware.__init__(self, document)
+
+ self.document = document
+
+ # TODO: Phase out this
+ self.rootObject = document.rootObject
+
+ self.document.globalAcceleratorListeners.append(self)
+
+ self.init(object)
+
+ RuntimeSettings.registerRuntimeSettingHandler(self.document, self)
+
+ def saveRuntimeSettings(self):
+ return (self.runtime_section, {})
+
+ def setFeedback(self, text):
+ print "TODO: setFeedback"
+
+ def setCaption(self, caption):
+ self._caption = caption
+ # TODO: tell the ui instance to update, if necessary
+
+ def destroy(self):
+ self.Destroy()
+
+ def setFeedback(self, text):
+ print "TODO: setFeedback"
Modified: trunk/gnue-designer/src/base/Incubator.py
===================================================================
--- trunk/gnue-designer/src/base/Incubator.py 2006-03-06 20:23:30 UTC (rev
8209)
+++ trunk/gnue-designer/src/base/Incubator.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -56,7 +56,7 @@
try:
name = attributes['name']
except KeyError:
- name = self.instance.getNextGenericName(tag)
+ name = self.document.getNextGenericName(tag)
try:
objclass = self.elements[tag]['BaseClass']
@@ -92,11 +92,11 @@
self._handleUnknownAttribute(tag, o, attr, attributes[attr])
o.name = name
- self.instance.nameMappings[o.name] = o
+ self.document.nameMappings[o.name] = o
o._buildObject()
- self.instance.dispatchEvent('ObjectCreated',object=o, originator=__name__)
+ self.document.dispatchEvent('ObjectCreated',object=o, originator=__name__)
if select:
- self.instance.dispatchEvent('ObjectSelected',object=o,
originator=__name__)
+ self.document.dispatchEvent('ObjectSelected',object=o,
originator=__name__)
return o
##
@@ -111,7 +111,7 @@
if not child._type == '_content_':
self.deleteObject(rootObject, child, firstRun=0)
- self.instance.dispatchEvent('ObjectDeleted',object=object,
originator=__name__)
+ self.document.dispatchEvent('ObjectDeleted',object=object,
originator=__name__)
if firstRun:
o = parent
@@ -120,7 +120,7 @@
o = o.getParent ()
if newCurrentObject:
- self.instance.dispatchEvent('ObjectSelected',object=object,
originator=__name__)
+ self.document.dispatchEvent('ObjectSelected',object=object,
originator=__name__)
##
@@ -128,7 +128,7 @@
##
def __init__(self, instance):
- self.instance = instance
+ self.document = instance
# Figure out tag dependencies
self._calcDependencies()
Deleted: trunk/gnue-designer/src/base/Instance.py
===================================================================
--- trunk/gnue-designer/src/base/Instance.py 2006-03-06 20:23:30 UTC (rev
8209)
+++ trunk/gnue-designer/src/base/Instance.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -1,747 +0,0 @@
-#
-# This file is part of GNU Enterprise.
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# Copyright 2001-2006 Free Software Foundation
-#
-# FILE:
-# Instance.py
-#
-# DESCRIPTION:
-# This is the base instance class for a designer session. Every
-# open file will be associated with its own Instance.
-#
-# NOTES:
-#
-
-__all__ = ['BaseInstance']
-
-import sys, os, time, dircache, string
-from gnue.common.apps import GDebug
-from gnue.common.apps import RuntimeSettings
-from gnue.common.utils.FileUtils import dyn_import
-from gnue.common.events import EventController, Event
-from gnue.designer.base.MenuBar import MenuBar
-from gnue.designer.base.UndoManager import UndoManager
-from gnue.designer.base.tools.TriggerEditor import TriggerEditor
-from gnue.designer.base.ToolBase import ToolBase
-from gnue.designer.base.ObjectList import ObjectList
-from gnue.designer.base import TemplateBase
-from gnue.designer.base.TemplateParser import WizardRunner
-from gnue.designer import VERSION, PACKAGE as TITLE
-from ModuleSupport import SupportedModules
-
-
-class BaseInstance(EventController):
-
- # ------------------------------------------------------------
- #
- # Virtual functions...
- #
- # Override these functions in your Instance
- #
-
- wizardRunner = WizardRunner
-
- # Called to load the object from a file buffer/handle
- def loadFile(self, buffer):
- return None
-
- # Called to load an "empty" object. Create the root object
- # and any initial child objects (if appropriate)
- def loadEmpty(self, style=None):
- return None
-
- # Called in a tree-like fashion for every object
- # whether loaded in the beginning or later added.
- def inventoryObject(self, object):
- pass
-
- # Called just before saving the file using GObject's dumpTree
- # You might do some sanity checks, etc.
- def preSave(self):
- return
-
- #
- def createTools(self):
- pass
-
- #
- def createEditors(self):
- pass
-
- #
- def createWizards(self):
- pass
-
- #
- def initMenu(self):
- pass
-
- # Instances can add to the primary toolbar
- def initToolBar(self):
- pass
-
-
- # Used by TemplateParser to build a wizard.current dict
- def buildWizardCurrentDict(self):
- return {'object': self._currentObject}
-
- ########################################################################
- #
- # BaseInstance-specific stuff
- # If you need to overwrite something here,
- # then odds are we really need to provide
- # a hook of some sorts.
- #
- def __init__(self, app, location=None, buffer=None, style=None):
- EventController.__init__(self)
-
- self.uiinstance = app.ui.createInstance(self)
-
- # During startup, we will cache all events
- # so we can execute them when everything has
- # been initialized.
- self.startCachingEvents()
-
- # Register ourself with RuntimeSettings
- RuntimeSettings.init(configFilename="gnue-des.ini", homeConfigDir=".gnue")
- RuntimeSettings.registerInstance(self)
-
- # Tell RuntimeSettings that we have information to save
- self.runtime_section = self.properties.nickname + 'Layout'
- RuntimeSettings.registerRuntimeSettingHandler(self, self)
-
- # And the MRU
- RuntimeSettings.registerRuntimeSettingHandler(self, app.mru)
-
- # Set up the Undo/Redo Manager
- UndoManager(self)
-
- self.wizardName = ""
- self._isdirty = False
- self._makeBackup = True
- self._isNew = True
-
- # Create the supplemental tools
- self._toolCache = []
- self._editorMapping = {}
-
- self._app = self.base = app
- self.connections = app.connections
- self.nameMappings = {}
- self.usedNames = []
-
- self._pages = []
-
- self.objectLists = {}
-
- self._path = ""
-
- self.globalAccelerators = []
- self.globalAcceleratorListeners = []
-
- self._nameMappers = {} # {GDataSource: {'name': [(GFBlock,'name')]}}
-
-
- self.registerEventListeners({
- # Menu/Toolbar stuff
- 'RequestSave' : self.OnSave,
- 'RequestSaveAs' : self.OnSaveAs,
- 'RequestClose' : self.OnClose,
-
- # Object stuff
- 'ObjectSelected' : self.__onSetCurrentObject,
- 'ObjectCreated' : self.__onCreateObject,
- 'ObjectModified' : self.__onModifyObject,
- 'ObjectDeleted' : self.__onDeleteObject,
- })
-
- if location == None:
-
- if buffer != None:
- self.__loadFromBuffer(buffer)
- self.makeDirty()
- else:
- self.__createEmptyInstance(style)
-
- else:
-
- if not os.access (location, os.R_OK):
- self.show()
- if not self.base.ui.dialogYesNo(
- _('The requested file does not exist.\n') +
- _('Do you want to create this file?') +
- _('\n\nFile: %s') \
- % location, _("File Not Found"), self.uiinstance):
- # TODO: Is this right?
- sys.exit()
- self.hide()
- self.__createEmptyInstance(style)
- self._path = location
- self.makeDirty()
-
- elif not os.access (location, os.W_OK):
- self.show()
- if not self.base.ui.dialogCancel(
- _('The requested file is Read Only.\n') +
- _('To save any changes, you will \n') +
- _('be required to do a "Save As..."\n\nFile: %s') \
- % location, _("Read Only Warning"), self.uiinstance) :
- # TODO: Is this right?
- sys.exit()
- self.hide()
- self.__loadFromFile(location)
- else:
- self.__loadFromFile(location)
-
- self.menubar = MenuBar(self)
-
-
- gStartupStatus(_('Creating User Interface'))
-
-
- # Set up the menu system
- self._initMenu()
- self.initMenu()
-
- self.createWizards()
-
- # All tools could support triggers
- self.registerEditor('triggerEditor', _('Trigger Editor'), TriggerEditor,
- 'GCTrigger')
- # Let the instances register their own editors
- self.createEditors()
-
- self.createTools()
- self.uiinstance.initTools()
-
- # Finalize menu bar
- self.menubar.finalize()
- self._app.mru.addMenu(self.menubar.getMenu('File|Open Recent|'), self)
-
- self.toolbar = self.uiinstance.toolbar
- self.initToolBar()
-
- # TODO: This is a hack to disable any menu items
- # TODO: for actions we've yet to implement
- for action in ('RequestRevert','RequestRedo','RequestCopy',
- 'RequestPaste','RequestPasteSpecial','RequestCut'):
- self.dispatchEvent('Disable:%s' % action)
-
-
- # Add ourselve to the main app's instance list
- self._app.addInstance(self)
-
-
- self.dispatchEvent('ObjectSelected', originator=self,
- object=self.rootObject)
-
- # Inventory the objects
- gStartupStatus(_('Inventorying Document Objects'))
- self.rootObject.walk(self.__inventory)
-
-
- self.uiinstance.finalize()
-
- self.stopCachingEvents()
-
- def _initMenu(self):
- # Add the [sub]menus
- for location, text, grouping in (
- ('File', _('&File'), 100),
- ('File|New', _('&New'), 100),
- ('File|Open Recent', _('&Open Recent'), 200.1),
- ('File|Connect To', _('&Connect To'), 400),
- ('Edit', _('&Edit'), 200),
- ('Insert',_('&Insert'), 300),
- ('Modify',_('&Modify'), 400),
- ('Tools',_('&Tools'), 500),
- ('View',_('&View'), 800),
- ('Help',_('&Help'), 999)):
-
- self.menubar.addMenu(location, text, grouping)
-
- for location, event, text, hotkey, help, grouping in (
- ('File', 'RequestOpen', _('&Open'), 'Ctrl+O', _("Open an existing
document"), 200.1),
- ('File|Open Recent', 'XXXX', _('&Foo'), None, _("This is a placeholder
for the Open Recent menu"), 200.1),
- ('File|New', 'RequestNewWizard', _('From &Wizard...'), None, _("Create
a new document using a wizard"), 900.1),
- ('File', 'RequestSave', _("&Save"), 'Ctrl+S', _("Save the current
document"),300.1),
- ('File', 'RequestSaveAs', _("Save &As..."),None, _("Save the current
document under a new name"), 300.2),
- ('File', 'RequestSaveAll', _("Save A&ll"),None,_("Save all open
document"),300.3),
- ('File', 'RequestRevert', _("Reload"), None, _("Reload the current
document as of its last save (abandoning any changes)"), 500),
- ('File', 'RequestClose', _("&Close"), 'Ctrl+W', _("Close the current
document"), 990),
- ('File', 'RequestExit', _("E&xit"), None, _("Exit GNUe Designer"), 995),
- ('Edit', 'RequestUndo', _("&Undo"), 'Ctrl+Z', _("Undo the last
action"), 100.1),
- ('Edit', 'RequestRedo', _("&Redo"), 'Ctrl+Y', _("Redo the last undo
action"), 100.2),
- ('Edit', 'RequestCut', _("Cu&t"), 'Ctrl+X', _("Cut the current object
and move to the clipboard"), 200.1),
- ('Edit', 'RequestCopy', _("&Copy"), 'Ctrl+C', _("Copy the current
object to the clipboard"), 200.2),
- ('Edit', 'RequestPaste', _("&Paste"), 'Ctrl+V', _("Paste the current
object on the clipboard"), 200.3),
- ('Edit', 'RequestPasteSpecial', _("Paste &Special..."), None, _("Paste
the current object on the clipboard with special attributes"), 200.4),
- ('Modify','RequestDelete', _("&Delete Item"), 'Delete', _("Delete the
current object"),100),
- ('Help', 'RequestAbout', _("&About GNUe Designer"), None, _("More
information about GNUe Designer"), 900),
- ):
- self.menubar.addAction(location, text, event,
- grouping, canDisable=True,
- icon=None, hotkey=hotkey, help=help)
-
- # Add supported tools to File|New
- for tool in SupportedModules:
- self.menubar.addAction('File|New', '&%s' % tool.properties.nickname,
- 'RequestNew', 100,
- help=_('Create a new %s') % string.lower(tool.properties.nickname),
eventdata={'type': tool.properties.module })
-
- # Add connections
- for conn in self.connections.getAllConnectionParameters().keys():
- self.menubar.addAction('File|Connect To', conn, 'Connect:%s' % conn,
- help=_("Login to %s connection") % conn,
- eventdata={'connection': conn})
- self.registerEventListeners({'Connect:%s' % conn:self.__OnConnectTo})
-
-
- def addTool(self, id, title, baseclass, hotkey=None, menuGroup=499):
- self._toolCache.append( (id, title, baseclass, hotkey, menuGroup) )
-
-
- def registerEditor(self, id, title, baseclass, gtype):
- self._editorMapping[gtype] = (id, title, baseclass)
-
-
-
- # 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
- fileHandle = open(location,'r')
- self.__loadFromBuffer(fileHandle)
- fileHandle.close()
- self.makeClean()
- self._isNew = 0
- except IOError, msg:
- print "\n%s %s\n\nUnable to open file '%s'. \nUnexpected read error:\n
%s.\n" % (TITLE, VERSION, location, msg)
- sys.exit()
- self._app.mru.addLocation(location)
-
-
- def addNameMapper(self, instance, attribute, childinst, childattr):
- try:
- instm = self._nameMappers[instance]
- except KeyError:
- instm = {}
- self._nameMappers[instance] = instm
- try:
- attrm = instm[attribute]
- except KeyError:
- attrm = []
- instm[attribute] = attrm
- attrm.append ( (childinst, childattr) )
-
-
- def __loadFromBuffer(self, fileHandle):
- self.rootObject = self.loadBuffer(fileHandle)
-
-
- def __createEmptyInstance(self, style):
- self.rootObject = self.loadEmpty(style)
- self.makeClean()
- self._isNew = True
-
-
- #--------------------------------------------------------------------------
- #
- #--------------------------------------------------------------------------
- #
- # Used by RuntimeSettings
- #
- def saveRuntimeSettings(self):
- return ( self.runtime_section, self.uiinstance.getRuntimeSettings() )
-
-
- #--------------------------------------------------------------------------
- #
- #--------------------------------------------------------------------------
- # Do we need to be saved?
- def isDirty(self):
- return self._isdirty
-
- # Mark our form as "dirty" (unsaved changes)
- def makeDirty(self):
- if not self._isdirty:
- self._isdirty = True
- if self._path == "":
- self.uiinstance.setTitle( _("Untitled %s*") % self.properties.nickname)
- else:
- self.uiinstance.setTitle(self._path + "*")
- self.dispatchEvent('MakeDirty')
-
- # Mark our form as "clean" (no unsaved changes)
- def makeClean(self):
- self._isdirty = 0
- self._isnew = 0
- if self._path == "":
- self.uiinstance.setTitle( _("Untitled %s") % self.properties.nickname)
- else:
- self.uiinstance.setTitle( self._path)
- self.dispatchEvent('MakeClean')
-
-
- #--------------------------------------------------------------------------
- #
- #--------------------------------------------------------------------------
- # Take an object and mangle it all up
- # until it is useful to us
- def __inventory (self, object):
-
- # Add a GObjectHelper to intercept __getitem__ calls on GObject
- GObjectHelper(self, object)
-
- if object != self.rootObject:
-
- # Assign an ID if none exists
- # TODO: in the future, I want to change these to id=".." instead of
name=".."
- if hasattr(object, 'name'):
- if object.name == None or object.name[:3] == "__G":
- object.name = self.getNextGenericName(object._type[2:])
- self.nameMappings[string.lower(object.name)] = object
- self.usedNames.append(object.name.lower())
-
- # Do we create an EditorComponent instance?
- print ' >> ' + object._type
- if object._type in self._editorMapping.keys():
- self.uiinstance.createEditor(object, *self._editorMapping[object._type])
-
- # Now, give the tool-specific instances a chance
- self.inventoryObject(object)
-
-
- def __onSetCurrentObject (self, event):
- object = event.object
- handler = event.originator
- self._currentObject = object
-
- def __onCreateObject (self, event):
- self.__inventory(event.object)
- self.makeDirty()
-
- def __onModifyObject (self, event):
- object = event.object
- # Check for any name dependencies
- # (i.e., GFEntry is dependent on GFBlock.name and GFField.name)
- # Automatically create any change events for the child objects
- if hasattr(object, '_nameDependencies'):
- for key in object._nameDependencies.keys():
- masterattr, slaveattr = object._nameDependencies[key]
- if masterattr in event.new.keys():
- oa = {slaveattr: key[slaveattr]}
- na = {slaveattr: object[masterattr]}
- key.__dict__.update(na)
- self.dispatchEvent( 'ObjectModified',
- object=key,
- originator=self,
- old=oa, new=na )
- self.makeDirty()
-
- def __onDeleteObject (self, event):
- object = event.object
-
- # Delete the actual object from its parent
- object.getParent ()._children.remove(object)
- ##object.getParent ()._children.pop(object.getParent
()._children.index(object))
-
- self.makeDirty()
-
-
- #--------------------------------------------------------------------------
- #
- #--------------------------------------------------------------------------
- def getNextGenericName (self, type):
- return self.getUniqueName(type.capitalize() + '1')
-
-
- def getUniqueName(self, name, limitingObject=None):
-
- try:
- usedNames = limitingObject.usedNames
- except:
- usedNames = self.usedNames
-
- if name.lower() not in usedNames:
- usedNames.append(name.lower())
- return name
-
- index = len(name) - 1
-
- while index > 0 and '0' <= name[index] <= '9':
- index -= 1
-
- index += 1
- if index >= len(name):
- start = 1
- base = name
- else:
- start = int(name[index:])
- base = name[:index]
-
- while ("%s%s" % (base, start)).lower() in usedNames:
- start += 1
-
- rv = "%s%s" % (base, start)
- usedNames.append(rv.lower())
- if rv.lower() not in self.usedNames:
- self.usedNames.append(rv.lower())
- return rv
-
-
-
- def save(self):
-
- if self.preSave():
- print "Not saving definition"
- return
-
- location = self._path
- fileHandle = None
- fileHandle2 = None
- if self._makeBackup:
- try:
- fileHandle = open(location,'r')
- fileHandle2 = open(location + "~",'w')
- fileHandle2.writelines(fileHandle.readlines())
- except:
- pass
- else:
- if fileHandle != None:
- fileHandle.close()
- if fileHandle2 != None:
- fileHandle2.close()
-
- self._makeBackup = 0
-
- fileHandle = open(location,'w')
-
- fileHandle.write('<?xml version="1.0" encoding="%s"?>\n\n' % \
- gConfig('textEncoding'))
-
- for comment in self.rootObject._rootComments:
- if comment.find(TITLE) > 0:
- self.rootObject._rootComments.remove(comment)
-
- # Place a timestamp in the XML as a comment
- # TODO: Replace with Dublin Core?
- fileHandle.write('<!-- %s (%s)\n%s Saved on: %s -->\n\n' \
- % (TITLE, VERSION, (len(self.wizardName) and (" Created by " +
self.wizardName + "\n") or ""),\
- time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(time.time()))))
-
- fileHandle.write(''.join(["<!--%s-->\n\n" %
comment.encode(gConfig('textEncoding')) \
- for comment in self.rootObject._rootComments]))
-
-
fileHandle.write(self.rootObject.dumpXML(treeDump=True).encode(gConfig('textEncoding')))
- fileHandle.close()
-
- self._app.mru.addLocation(location)
- self.makeClean()
-
-
-
- def __OnConnectTo(self, event):
- conn = event.connection
- try:
- tempDO = self.connections.getConnection(conn, 'object')
- self.dispatchEvent('ConnectionEstablished',connection=conn)
- self.dispatchEvent('Disable:Connect:%s' % conn)
- except:
- print _("Unable to connect to %s") % conn
-
-
- #--------------------------------------------------------------------------
- #
- #--------------------------------------------------------------------------
- def OnSave(self, event):
- if not len(self._path):
- self.OnSaveAs(event)
- else:
- self.save()
-
-
- def OnSaveAs(self, event):
- wildcards = []
- # Make the "default" file extension for a tool
- # appear before the other extensions.
- filterIndex = [self.properties.defaultFileExtension]
- wildcards += [
- ( self.properties.defaultFileExtension,
- self.properties.fileExtensions[self.properties.defaultFileExtension]) ]
-
- for type in self.properties.fileExtensions.keys():
- if type != self.properties.defaultFileExtension:
- wildcards += [
- ( type, self.properties.fileExtensions[type]) ]
- filterIndex.append(type)
-
- path = self.base.ui.dialogSaveFile(_("Save %s As...") %
self.properties.description,
- wildcards = wildcards,
- parentWindow=self.uiinstance)
-
- if path:
-# if len(path) < 4 or not (path[-4] == '.' and string.lower(path[-3:])
in self.properties.fileExtensions.keys()):
-# path += "." + filterIndex[dlg.GetFilterIndex()]
-
- if os.path.isfile(path):
- overwrite = self.base.ui.dialogYesNo(
- _('The file "%s".\n' % path) +
- _("exists. Overwrite?"),
- _("Unsaved Changes"), icon="warn", parentWindow=self.uiinstance)
- if not overwrite:
- self.OnSaveAs(event)
- return
-
- self._path = path
- self.uiinstance.setTitle (self._path)
- self.save()
-
-
-
- def OnClose(self, event):
- if self.isDirty():
- save = self.base.ui.dialogYesNoCancel(
- _("This document has unsaved changes.\n") +
- _("Save changes before closing?"),
- _("Unsaved Changes"), icon="warn", parentWindow=self.uiinstance)
- if save == True:
- self.OnSave(event)
- elif save == -1:
- event.Veto()
- return
-
- RuntimeSettings.saveRuntimeSettings(self)
- self._app.mru.removeMenu(self.menubar.getMenu('File|Open Recent|'), self)
- self._app.removeInstance(self)
- self.uiinstance.close()
-
-
- #--------------------------------------------------------------------------
- #
- #--------------------------------------------------------------------------
- def loadWizards(self, package):
- templates = []
-
- basedir = os.path.dirname(package.__file__)
- processed = [] # Base file names processed (e.g., base of Simple.py*
- # is Simple) This will keep us from importing Simple
- # three times if Simple.py, Simple.pyc, and Simple.lib
- # all exist.
-
- for dir in dircache.listdir(basedir):
- base = string.split(dir,'.')[0]
- if not dir[0] in ('.','_') and not base in processed:
- processed.append(base)
- try:
- templates.append(dyn_import(
- '%s.%s' % (package.__name__,base)).TemplateInformation)
- except ImportError, mesg:
- assert gDebug(2,"%s.%s doesn't appear to be a valid wizard" %
(package.__name__, base))
- assert gDebug(5,' --> %s' % (mesg))
- except AttributeError:
- assert gDebug(2,'Wizard %s for package %s is missing'
- ' an \'TemplateInformation\' attribute.' %
- (base,package.__name__))
-
- for template in templates:
- try:
- location = template['MenuLocation']
- try:
- location, translation, grouping = location
- grouping = float(grouping)
- except:
- location, translation = location
- grouping = 499.0
-
- if location:
- self.wizardRunner(template, self)
- self.menubar.addAction(location=location, text=translation,
- event='Wizard:%s' % template['BaseID'],
- grouping=grouping, canDisable=True,
- eventdata={'template':template},
help=template['Description'])
- except ValueError:
- continue
-
-# ===========================================================================
-# Wrapper Class
-# ===========================================================================
-class GObjectHelper:
- def __init__(self, instance, object):
- self.instance = instance
- self.object = object
- 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 _setItemHook(self, key, value):
- ek = key.replace(':','__')
- object = self.object
- try:
- ov = {key: object.__dict__[ek]}
- except KeyError:
- ov = {}
- object.__dict__[key.replace(':','__')] = value
- self.instance.dispatchEvent('ObjectModified',
- object = object, new={key:value}, old=ov, originator = '__inline__')
-
- def setStatus(self, text):
- self.uiinstance.setStatus(text)
-
-# ===========================================================================
-# Helper class used by the tool-specific packages
-# ===========================================================================
-class ModuleProperties:
- xmlOpeningTag = 'undefined'
- short = 'undefined'
- application = 'GNUe Tool'
- description = 'undefined'
- fileExtensions = {}
- defaultFileExtension = 'undefined'
-
Modified: trunk/gnue-designer/src/base/MRUManager.py
===================================================================
--- trunk/gnue-designer/src/base/MRUManager.py 2006-03-06 20:23:30 UTC (rev
8209)
+++ trunk/gnue-designer/src/base/MRUManager.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -42,7 +42,7 @@
self._menus = []
self._locations = []
self.menulist = []
- self._app = app
+ self.app = app
self.mruMenuMap = {}
# TODO: Should this be user configurable?
@@ -155,7 +155,7 @@
menu.Append ( tid, '&%s %s' % (i+1, location),
_('Open "%s" in a new window') % self._locations[i] )
- wx.EVT_MENU(menu.__instance.uiinstance, tid, self._app.OnOpenRecent)
+ wx.EVT_MENU(menu.__instance.ui, tid, self.app.OnOpenRecent)
self.mruMenuMap[tid] = self._locations[i]
i += 1
Modified: trunk/gnue-designer/src/base/MenuBar.py
===================================================================
--- trunk/gnue-designer/src/base/MenuBar.py 2006-03-06 20:23:30 UTC (rev
8209)
+++ trunk/gnue-designer/src/base/MenuBar.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -36,13 +36,13 @@
class MenuBar:
def __init__(self, instance):
- self.instance = instance
+ self.document = instance
self._menus = {}
self._menuItems = {'':[]}
print instance
- self.uimenu = instance.uiinstance.createMenuBar()
+ self.uimenu = instance.ui.createMenuBar()
# Locations can be <loc>|<loc> where <loc> is <location>/<translation>@group
Modified: trunk/gnue-designer/src/base/MultiObjectGridEditor.py
===================================================================
--- trunk/gnue-designer/src/base/MultiObjectGridEditor.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/base/MultiObjectGridEditor.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -60,7 +60,7 @@
def __init__(self, parent, instance):
Grid.__init__(self, parent, -1)
- self.instance = instance
+ self.document = instance
self.objects = []
self.rows = []
self.current = None
@@ -328,7 +328,7 @@
except KeyError:
old = {}
- self.instance.dispatchEvent('ObjectModified',
+ self.document.dispatchEvent('ObjectModified',
object=object, originator=self,
old=old, new = {attribute: val})
@@ -340,7 +340,7 @@
# Fire an ObjectSelected event
object = self.rows[event.GetRow()]
if object != self.current:
- self.instance.dispatchEvent('ObjectSelected',
+ self.document.dispatchEvent('ObjectSelected',
object=self.rows[event.GetRow()],
originator = self)
self.current = object
Modified: trunk/gnue-designer/src/base/PopupMenu.py
===================================================================
--- trunk/gnue-designer/src/base/PopupMenu.py 2006-03-06 20:23:30 UTC (rev
8209)
+++ trunk/gnue-designer/src/base/PopupMenu.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -37,7 +37,7 @@
class ActionMenu(wx.Menu):
def __init__(self, instance, object, parent=None, text=None,
parentText=None):
wx.Menu.__init__(self, text)
- self.instance = instance
+ self.document = instance
self.__parent = parent
self._object = object
self._newMap = {}
@@ -101,20 +101,20 @@
self.AppendMenu(wx.NewId(), hasattr(child,'name') and child.name or \
string.upper(child._type[2]) + \
string.lower(child._type[3:]),
- PageMenu(self.instance, child, self.x, self.y))
+ PageMenu(self.document, child, self.x, self.y))
def addCreateTag(self, tag, text):
tid = wx.NewId()
self._newMap[tid] = tag
self.Append(tid, text)
- wx.EVT_MENU(self.instance.uiinstance, tid, self.OnCreateObject)
+ wx.EVT_MENU(self.document.ui, tid, self.OnCreateObject)
def OnEditProperties(self, event):
- self.instance.propertyEditorWindow.Show(1)
- self.instance.propertyEditorWindow.Raise()
- self.instance.propertyEditorWindow.SetFocus()
+ self.document.propertyEditorWindow.Show(1)
+ self.document.propertyEditorWindow.Raise()
+ self.document.propertyEditorWindow.SetFocus()
def OnEditEvent(self, event):
pass
@@ -126,20 +126,20 @@
if tag == 'trigger':
attributes['type']='named'
- self.instance.incubator.createObject(self.instance.rootObject, tag,
+ self.document.incubator.createObject(self.document.rootObject, tag,
self._object, attributes)
def OnCreateDataSource(self, event):
- self.instance.incubator.createObject(self.instance.rootObject,
'datasource')
+ self.document.incubator.createObject(self.document.rootObject,
'datasource')
def OnCreateNamedTrigger(self, event):
- self.instance.incubator.createObject(self.instance.rootObject, 'trigger')
+ self.document.incubator.createObject(self.document.rootObject, 'trigger')
def OnCreatePage(self, event):
- self.instance.incubator.createObject(self.instance.rootObject, 'page')
+ self.document.incubator.createObject(self.document.rootObject, 'page')
def OnDeleteObject(self, event):
- self.instance.dispatchEvent('ObjectDeleted', object=self._object,
+ self.document.dispatchEvent('ObjectDeleted', object=self._object,
originator=self)
def OnReorderLayout(self, event):
@@ -163,7 +163,7 @@
object._popupMenu.OnReorderLayout(event)
object.__savedChildren = object._children[:]
for o2 in object.__savedChildren:
- self.instance.onDeleteObject(o2, __name__)
+ self.document.onDeleteObject(o2, __name__)
oid = "%5d.%5d.%5d" % (object._upperY, object._upperX, unqId)
unqId = unqId + 1
@@ -183,34 +183,34 @@
navObjects[oid] = object
# Notify everyone that this object was deleted
- self.instance.onDeleteObject(object, __name__)
+ self.document.onDeleteObject(object, __name__)
self._object._children = []
# First, add back triggers
for object in triggerObjects:
self._object._children.append(object)
- self.instance.onCreateObject(object, __name__)
+ self.document.onCreateObject(object, __name__)
# Next, add back hidden objects
for object in hiddenObjects:
self._object._children.append(object)
- self.instance.onCreateObject(object, __name__)
+ self.document.onCreateObject(object, __name__)
# Now, add hidden objects
boxes = boxObjects.keys()
boxes.sort()
for box in boxes:
self._object._children.append(boxObjects[box])
- self.instance.onCreateObject(boxObjects[box], __name__)
+ self.document.onCreateObject(boxObjects[box], __name__)
# The rest of the objects (other than blocks) go here
nav = navObjects.keys()
nav.sort()
for n in nav:
self._object._children.append(navObjects[n])
- self.instance.onCreateObject(navObjects[n], __name__)
+ self.document.onCreateObject(navObjects[n], __name__)
# And, finally, any child blocks
blocks = blockObjects.keys()
@@ -218,10 +218,10 @@
for block in blocks:
children = blockObjects[block].__savedChildren[:]
self._object._children.append(blockObjects[block])
- self.instance.onCreateObject(blockObjects[block], __name__)
+ self.document.onCreateObject(blockObjects[block], __name__)
for child in children:
blockObjects[block]._children.append(child)
- self.instance.onCreateObject(child,__name__)
+ self.document.onCreateObject(child,__name__)
class CreateObjectMenu(ActionMenu):
@@ -232,9 +232,9 @@
self.AppendSeparator()
tag = string.lower(object._type[2:])
- if self.instance.incubator.elementMapping.has_key(tag):
- self.instance.incubator.elementMapping[tag].sort()
- for element in self.instance.incubator.elementMapping[tag]:
+ if self.document.incubator.elementMapping.has_key(tag):
+ self.document.incubator.elementMapping[tag].sort()
+ for element in self.document.incubator.elementMapping[tag]:
descr = string.upper(element[0])+string.lower(element[1:])
if descr == 'Import':
descr = 'Import Library'
Modified: trunk/gnue-designer/src/base/PrimaryToolBar.py
===================================================================
--- trunk/gnue-designer/src/base/PrimaryToolBar.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/base/PrimaryToolBar.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -26,8 +26,15 @@
# NOTES:
+#----------------------------------------------------------------------------
+# GNUe Imports
+#----------------------------------------------------------------------------
from gnue.designer.base.ToolBar import BaseToolBar
+
+#----------------------------------------------------------------------------
+# Module Globals
+#----------------------------------------------------------------------------
ToolbarMapping = 'RequestNewForm,tb_new,pulldown;' \
+ 'RequestOpen,tb_open,pulldown;' \
+ 'RequestSave,tb_save;' \
@@ -36,23 +43,40 @@
+ 'RequestExit,tb_exit;'
+#----------------------------------------------------------------------------
+# Tool Bar class
+#----------------------------------------------------------------------------
class PrimaryToolBar(BaseToolBar):
+ """
+ The primary tool bar that is common to all documents
+ (includes New, Open, Save, Exit, etc)
+ """
def init(self):
- self.registerEventListeners( {'MakeDirty' : self.onDirty,
- 'MakeClean' : self.onClean, } )
+ # Register our icons
self.addToolbarMapping(ToolbarMapping)
+
+ # Listen for document-level "saved/unsaved" events
+ # So we can enable/disable the Save icon
+ self.registerEventListeners( {'MakeDirty' : self._onDirty,
+ 'MakeClean' : self._onClean, } )
- def onDirty(self, event):
+ def _onDirty(self, event):
+ """
+ Enable the Save icon
+ """
try:
self.EnableTool(self.mapping['RequestSave'],1)
except KeyError:
pass
-
- def onClean(self, event):
+ def _onClean(self, event):
+ """
+ Disable the Save icon
+ """
try:
self.EnableTool(self.mapping['RequestSave'],0)
except KeyError:
pass
+
Modified: trunk/gnue-designer/src/base/TemplateBase.py
===================================================================
--- trunk/gnue-designer/src/base/TemplateBase.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/base/TemplateBase.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -118,7 +118,7 @@
# methods.
def AddElement(self, tag, parent, attributes={}, content=""):
- instance = self.parser.instance
+ instance = self.parser.document
if content:
attr = {'_content_': content}
else:
@@ -148,7 +148,7 @@
element.__dict__.update(modifications)
- self.parser.instance.dispatchEvent('ObjectModified',
+ self.parser.document.dispatchEvent('ObjectModified',
object=element, originator=__name__,
new=modifications, old=oldMods)
@@ -213,7 +213,7 @@
def GetUniqueName(self, name, limitingObject=None):
- return self.instance.getUniqueName(name, limitingObject)
+ return self.document.getUniqueName(name, limitingObject)
##########################################
@@ -224,8 +224,8 @@
def __init__(self, parser):
self.parser = parser
- self.instance = parser.instance
- self._connections = parser.instance._app.connections
+ self.document = parser.document
+ self._connections = parser.document.app.connections
self.__cachedConnections = {}
self.__cachedSources = {}
Modified: trunk/gnue-designer/src/base/TemplateParser.py
===================================================================
--- trunk/gnue-designer/src/base/TemplateParser.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/base/TemplateParser.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -37,7 +37,7 @@
def __init__(self, instance, rootObject, parent,
templateInformation, currentObject=None):
self.parent = parent
- self.instance = instance
+ self.document = instance
self.templateInformation = templateInformation
self.rootObject = rootObject
self.currentObject = currentObject
@@ -55,7 +55,7 @@
# Clear out any old variables
self.template.variables = {}
self.template.Start(self.rootObject,
- self.instance.buildWizardCurrentDict(),
+ self.document.buildWizardCurrentDict(),
**params)
# If this is simply a template and not a wizard,
@@ -636,19 +636,19 @@
class WizardRunner:
def __init__(self, template, instance):
self.template = template
- self.instance = instance
+ self.document = instance
instance.registerEventListeners(
{ 'Wizard:%s' % template['BaseID']: self.run,
'Cancel:Wizard:%s' % template['BaseID']: self.cancel } )
def run(self, event, *args, **parms):
- self.instance.dispatchEvent('BeginWizard', template=self.template)
- self.instance.dispatchEvent('BeginUndoGroup')
- self.parser = TemplateParser(self.instance, self.instance.rootObject,
- self.instance.uiinstance, self.template)
+ self.document.dispatchEvent('BeginWizard', template=self.template)
+ self.document.dispatchEvent('BeginUndoGroup')
+ self.parser = TemplateParser(self.document, self.document.rootObject,
+ self.document.ui, self.template)
self.parser.run(*args, **parms)
- self.instance.dispatchEvent('EndUndoGroup')
- self.instance.dispatchEvent('EndWizard', template=self.template)
+ self.document.dispatchEvent('EndUndoGroup')
+ self.document.dispatchEvent('EndWizard', template=self.template)
def cancel(self, event=None):
self.parser.cancel()
@@ -693,14 +693,14 @@
def fieldEventTrap(self, event):
keycode = event.KeyCode()
- if keycode in (WXK_RETURN, WXK_TAB):
+ if keycode in (wx.WXK_RETURN,wx.WXK_TAB):
if self.seq < len(self.app.textctrlList) - 1:
self.app.textctrlList[self.seq+1].SetFocus()
else:
- if keycode == WXK_TAB:
+ if keycode == wx.WXK_TAB:
if event.ShiftDown():
self.app.textctrlList[self.seq-1].SetFocus()
- elif keycode == WXK_ESCAPE:
+ elif keycode == wx.WXK_ESCAPE:
self.app.OnCancel(None)
else:
event.Skip()
Modified: trunk/gnue-designer/src/base/ToolBar.py
===================================================================
--- trunk/gnue-designer/src/base/ToolBar.py 2006-03-06 20:23:30 UTC (rev
8209)
+++ trunk/gnue-designer/src/base/ToolBar.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -19,27 +19,37 @@
# Copyright 2001-2006 Free Software Foundation
#
# FILE:
-# LayoutEditor.py
+# ToolBar.py
#
# DESCRIPTION:
-#
+"""
+Base "Tool Bar" instance
+"""
# NOTES:
-import os, string
+
+#----------------------------------------------------------------------------
+# System Imports
+#----------------------------------------------------------------------------
+import os
+import string
+
+#----------------------------------------------------------------------------
+# External Imports
+#----------------------------------------------------------------------------
import wx
-from gnue.common.apps import GDebug, GConfig
+#----------------------------------------------------------------------------
+# GNUe Imports
+#----------------------------------------------------------------------------
from gnue.common.events import Event, EventAware
-iconlocation =
os.path.join(GConfig.getInstalledBase('designer_images','common_images')
,'designer')
-def getIcon(name, w, h):
- path = os.path.join(iconlocation,"%s-%sx%s.png" % (name,w, h))
- if not os.path.exists(path):
- return None
- return wx.Image(path,
- wx.BITMAP_TYPE_PNG).ConvertToBitmap()
+#----------------------------------------------------------------------------
+# Tool bar base class
+#----------------------------------------------------------------------------
+# TODO: This needs to be decoupled from wx
class BaseToolBar(wx.ToolBar, EventAware):
ICON_SIZE = (24,24)
@@ -50,15 +60,16 @@
def init(self):
pass
- def __init__(self, parent, instance):
- self.instance = instance
+ def __init__(self, parent, document):
+ self.document = document
wx.ToolBar.__init__(self, parent, -1, wx.DefaultPosition, wx.DefaultSize,
wx.TB_FLAT | wx.TB_NODIVIDER)
- EventAware.__init__(self, instance)
+ EventAware.__init__(self, document)
self.mapping = {}
self.SetToolBitmapSize(wx.Size(*self.ICON_SIZE))
self.init()
self.Realize()
+
def addToolbarMapping(self, mapping):
for type in string.split(mapping,';'):
@@ -73,7 +84,7 @@
options = ()
try:
- shortHelp, longHelp = self.instance.menubar.getEventHelp(handle)
+ shortHelp, longHelp = self.document.menubar.getEventHelp(handle)
shortHelp = shortHelp.replace('&','') #Menu entries can contain
shortcut keys
longHelp = longHelp.replace('&','')
except:
@@ -89,8 +100,9 @@
if 'pulldown' in options:
print "Erm, I don't yet support pulldown toolbar buttons (%s)" %
handle
+ print self.document.__class__
self.AddTool(id,
- getIcon(image, *self.ICON_SIZE),
+ self.document.app.ui.getIcon(image, *self.ICON_SIZE),
isToggle=1,
shortHelpString=shortHelp,
longHelpString=longHelp)
@@ -98,6 +110,7 @@
self.SetToolClientData(id, handle)
wx.EVT_TOOL(self, id, self.OnButtonSelected)
+ self.Realize()
def resetTool(self, mode):
@@ -124,4 +137,4 @@
else:
evt = handle
- self.instance.dispatchEvent(evt)
+ self.document.dispatchEvent(evt)
Modified: trunk/gnue-designer/src/base/ToolBase.py
===================================================================
--- trunk/gnue-designer/src/base/ToolBase.py 2006-03-06 20:23:30 UTC (rev
8209)
+++ trunk/gnue-designer/src/base/ToolBase.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -27,40 +27,45 @@
# NOTES:
#
-__all__ = ['ToolBase', 'EditorComponent']
+__all__ = ['ToolBase']
import wx
+from gnue.designer.uidrivers.wx.uihelpers import NotebookCtrl
from gnue.common.apps import RuntimeSettings
from gnue.common import events
# ===========================================================================
-#
+# Basic Component
# ===========================================================================
class ToolBase (wx.Panel, events.EventAware):
-
+ """
+ The base of all tool interfaces
+ """
default_visible = 1
default_dock = 'frame'
runtime_section = ""
uses_feedback_bar = 0
uses_toolbar = 0
- def __init__(self, id, title, instance, rootObject, parentWindow):
+ def __init__(self, id, title, document, rootObject, parentWindow):
wx.Panel.__init__(self,parentWindow,-1)
- events.EventAware.__init__(self, instance)
+ events.EventAware.__init__(self, document)
self.id = id
self.title = title
# self.dockpane = parentWindow
- self.instance = instance
+ self.document = document
self.rootObject = rootObject
- self.instance.globalAcceleratorListeners.append(self)
+ self.document.globalAcceleratorListeners.append(self)
+ self._createOuterInterfaces()
+
self.init()
- instance.registerEventListeners({'Show:Tool:%s' % id: self.__show,
+ document.registerEventListeners({'Show:Tool:%s' % id: self.__show,
'Hide:Tool:%s' % id: self.__hide})
- RuntimeSettings.registerRuntimeSettingHandler(self.instance, self)
+ RuntimeSettings.registerRuntimeSettingHandler(document, self)
def saveRuntimeSettings(self):
return (self.runtime_section, {})
@@ -77,45 +82,37 @@
def __hide(self, event):
self._visible = False
# self.dockpane.hide()
+
+ # Used by UI-specific subclasses below
+ def _createOuterInterfaces(self):
+ pass
-
# ===========================================================================
-#
+# Notebook-based Component
# ===========================================================================
-class EditorComponent(wx.Panel, events.EventAware):
+class ToolNotebook(ToolBase):
"""
- An "Editor Component" is presented usually as an editor to the user
- and is considered a "primary window".
+ Tool interfaces with a Notebook control as their outer component
"""
- default_dock = 'primary'
- icon = 'painter'
+ def _createOuterInterfaces(self):
+ notebook = self.notebook = NotebookCtrl.NotebookCtrl(self, -1,
+ style=NotebookCtrl.NC_DEFAULT_STYLE|NotebookCtrl.NC_BOTTOM)
+ notebook.HideOnSingleTab()
+ notebook.EnableHiding()
+ notebook.SetTabHeight(10)
+ notebook.SetPadding(wx.Size(1,1))
- def __init__(self, object, id, title, instance, rootObject, parentWindow):
- wx.Panel.__init__(self, parentWindow, -1)
- events.EventAware.__init__(self, instance)
+ self.document.app.ui.autoSizer(self, notebook)
+
+ ToolBase._createOuterInterfaces(self)
- self.id = id
- self.title = title
- self.instance = instance
- self.rootObject = rootObject
- self.instance.globalAcceleratorListeners.append(self)
+ def addPage(self, page, text):
+ self.notebook.AddPage(page, text)
+ self.notebook.SetPageTextFont(self.notebook.GetPageCount()-1, wx.Font(9,
wx.DEFAULT, wx.NORMAL, wx.NORMAL, False))
+ return page
+
+ def deletePage(self, id):
+ return self.notebook.DeletePage(id)
- self.init(object)
- RuntimeSettings.registerRuntimeSettingHandler(self.instance, self)
- def saveRuntimeSettings(self):
- return (self.runtime_section, {})
-
- def setFeedback(self, text):
- print "TODO: setFeedback"
-
- def setCaption(self, caption):
- self._caption = caption
- # TODO: tell the ui instance to update, if necessary
-
- def destroy(self):
- self.Destroy()
-
- def setFeedback(self, text):
- print "TODO: setFeedback"
Modified: trunk/gnue-designer/src/base/UndoManager.py
===================================================================
--- trunk/gnue-designer/src/base/UndoManager.py 2006-03-06 20:23:30 UTC (rev
8209)
+++ trunk/gnue-designer/src/base/UndoManager.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -36,7 +36,7 @@
self.history = []
self.future = []
- self.instance = instance
+ self.document = instance
self.deleteMap = {}
@@ -101,14 +101,14 @@
def updateEvents(self):
if self.history:
- self.instance.dispatchEvent('Enable:RequestUndo')
+ self.document.dispatchEvent('Enable:RequestUndo')
else:
- self.instance.dispatchEvent('Disable:RequestUndo')
+ self.document.dispatchEvent('Disable:RequestUndo')
if 0: #TODO# self.future:
- self.instance.dispatchEvent('Enable:RequestRedo')
+ self.document.dispatchEvent('Enable:RequestRedo')
else:
- self.instance.dispatchEvent('Disable:RequestRedo')
+ self.document.dispatchEvent('Disable:RequestRedo')
# Return the current instance of this object
def getCurrObject(self, object):
@@ -134,14 +134,14 @@
object = manager.getCurrObject(orig.object)
print object
if orig.__event__ == 'ObjectCreated':
- manager.instance.dispatchEvent('ObjectDeleted',
+ manager.document.dispatchEvent('ObjectDeleted',
object=orig.object, originator=__name__)
elif orig.__event__ == 'ObjectModified':
for key in orig.new.keys():
del object.__dict__[key.replace(':','__')]
for key, value in orig.old.items():
object.__dict__[key.replace(':','__')] = value
- manager.instance.dispatchEvent('ObjectModified',
+ manager.document.dispatchEvent('ObjectModified',
object=orig.object, originator=__name__,
new=orig.old, old=orig.new)
elif orig.__event__ == 'ObjectDeleted':
@@ -161,6 +161,6 @@
obj.getParent ()._children.insert(self.parentindex, obj)
# Notify our peeps...
- manager.instance.dispatchEvent('ObjectCreated', originator=__name__,
+ manager.document.dispatchEvent('ObjectCreated', originator=__name__,
object=obj)
Modified: trunk/gnue-designer/src/base/tools/DataSourceEditor.py
===================================================================
--- trunk/gnue-designer/src/base/tools/DataSourceEditor.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/base/tools/DataSourceEditor.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -39,7 +39,7 @@
runtime_section = "DataSourceEditor"
def init(self):
- self.connections = self.instance._app.connections
+ self.connections = self.document.app.connections
self.combopanel = wx.Panel(self, -1, pos=wx.Point(0,0))
self.splitter = wx.SplitterWindow(self, -1, style=wx.SP_3D)
@@ -72,8 +72,8 @@
self.current = None
- self.instance.rootObject.walk (self.initialInventory)
- self.instance.rootObject.walk (self.inventoryObject)
+ self.document.rootObject.walk (self.initialInventory)
+ self.document.rootObject.walk (self.inventoryObject)
self.fillList()
# EventAware provided by ToolBase
@@ -332,7 +332,7 @@
# A Datasource was selected in the menu
def OnDSSelected(self, event):
self.current = self.datasourceMap[event.GetData()]
-
self.instance.dispatchEvent(events.Event('ObjectSelected',object=self.current,
originator=__name__))
+
self.document.dispatchEvent(events.Event('ObjectSelected',object=self.current,
originator=__name__))
def OnAddDSSelected(self, event):
@@ -342,7 +342,7 @@
attributes['database'] = \
hasattr(self.current,'database') and self.current.database or ''
- self.instance.incubator.createObject(self.rootObject, 'datasource',
+ self.document.incubator.createObject(self.rootObject, 'datasource',
parent=self.rootObject, attributes=attributes)
@@ -636,7 +636,7 @@
attributes = {
"datasource": self.current.name,
- "name": self.editor.instance.getUniqueName(
+ "name": self.editor.document.getUniqueName(
"fld%s" % (
string.join(string.split(string.capwords( \
string.replace(object.name,'_',' '))),''))),
Modified: trunk/gnue-designer/src/base/tools/EventEditor.py
===================================================================
--- trunk/gnue-designer/src/base/tools/EventEditor.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/base/tools/EventEditor.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -27,27 +27,26 @@
#
-import sys, os, string
+import sys
+import os
+import string
+
import wx
from wx.grid import *
from gnue.common.apps import GDebug
from gnue.common.formatting import GTypecast
from gnue.common.logic.GTrigger import GTrigger
from gnue.common.definitions.GParserHelpers import GContent
-from gnue.designer.base.ToolBase import *
+from gnue.designer.base.ToolBase import ToolNotebook
from gnue.designer.uidrivers.wx.uihelpers.GridCellEditors import CharCellEditor
-class EventEditor (ToolBase):
+class EventEditor (ToolNotebook):
runtime_section = 'EventEditor'
- uses_feedback_bar = 1
+ uses_feedback_bar = True
default_dock = 'left-2'
def init(self):
- self.panel = wx.Panel(self,-1,style=wx.SIMPLE_BORDER, pos=wx.Point(6,6))
- self.notebook = wx.Notebook(self.panel, -1, style=wx.NB_BOTTOM)
-
-
self.object = None
# EventAware provided by ToolBase
@@ -59,11 +58,10 @@
})
self.supplemental = []
- wx.EVT_SIZE(self, self.onSize)
+
self.main = self.createMainPage()
- self.notebook.AddPage(self.main,'Properties')
+ self.addInspector(self.main,'Properties')
-
def createMainPage(self):
return InspectorPanel(self, self.notebook)
@@ -86,13 +84,13 @@
self.notebook.SetPageText(i, page.getPageText())
i += 1
- def addPage(self, inspector, label):
+ def addInspector(self, inspector, label):
self.supplemental.append(inspector)
- self.notebook.AddPage(inspector, label)
+ self.addPage(inspector, label)
def reset(self):
- for i in range(len(self.supplemental)):
- self.notebook.DeletePage(1)
+ for i in range(len(self.supplemental[1:])):
+ self.deletePage(1)
self.supplemental = []
@@ -125,12 +123,7 @@
insp.onDeleteObject(event)
- def onSize(self, event):
- w,h = self.GetClientSizeTuple()
- self.panel.SetSize((w-12,h-12))
- self.notebook.SetSize(self.panel.GetClientSizeTuple())
-
#
#
#
@@ -445,9 +438,9 @@
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)
+ if key in [wx.WXK_NUMPAD0, wx.WXK_NUMPAD1, wx.WXK_NUMPAD2, wx.WXK_NUMPAD3,
wx.WXK_NUMPAD4,
+ wx.WXK_NUMPAD5, wx.WXK_NUMPAD6, wx.WXK_NUMPAD7, wx.WXK_NUMPAD8,
wx.WXK_NUMPAD9]:
+ ch = ch = chr(ord('0') + key - wx.WXK_NUMPAD0)
elif key < 256 and key >= 0 and chr(key):
ch = chr(key)
Modified: trunk/gnue-designer/src/base/tools/PropertyEditor.py
===================================================================
--- trunk/gnue-designer/src/base/tools/PropertyEditor.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/base/tools/PropertyEditor.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -33,17 +33,15 @@
from wx.grid import *
from gnue.common.apps import GDebug
from gnue.common.formatting import GTypecast
-from gnue.designer.base.ToolBase import *
+from gnue.designer.base.ToolBase import ToolNotebook
from gnue.forms.uidrivers.wx.common import wxEncode
-class PropertyEditor (ToolBase):
+class PropertyEditor (ToolNotebook):
runtime_section = 'PropertyEditor'
default_dock = 'left-1'
def init(self):
- self.panel = wx.Panel(self,-1,style=wx.SIMPLE_BORDER, pos=wx.Point(6,6))
- self.notebook = wx.Notebook(self.panel, -1, style=wx.NB_BOTTOM)
self.object = None
@@ -56,7 +54,6 @@
})
self.supplemental = []
- wx.EVT_SIZE(self, self.__onSize)
self.main = self.createMainPage()
self.notebook.AddPage(self.main,'Properties')
@@ -114,12 +111,6 @@
pass
- def __onSize(self, event):
- w,h = self.GetClientSizeTuple()
- self.panel.SetSize((w-12,h-12))
- self.notebook.SetSize(self.panel.GetClientSizeTuple())
-
-
#
#
#
@@ -147,7 +138,7 @@
def getAttributes(self, object):
- elements = self.editor.instance.incubator.elements
+ elements = self.editor.document.incubator.elements
try:
return elements[(object._type[2:]).lower()]['Attributes']
except KeyError:
@@ -222,7 +213,7 @@
wx.EVT_COMBOBOX(field, field.GetId(), self.__valueModified)
elif self.attributes[key].has_key('References'):
tag, attr = self.attributes[key]['References'].split('.')
- objectList = self.editor.instance.getObjectList(tag)
+ objectList = self.editor.document.getObjectList(tag)
field = LinkedTextEditor(self.fieldPanel, self.attributes[key],
objectList, attr)
wx.EVT_COMBOBOX(field, field.GetId(), self.__valueModified)
elif self.attributes[key]['Typecast'] == GTypecast.boolean:
@@ -303,9 +294,9 @@
self.SetVirtualSize((x, my))
if my > y:
self.SetScrollRate(0,10)
- fw = self.fieldPanel.GetSize().x - 4
- for field in self.fields:
- field.SetSize((fw, field.GetSize().y))
+ #fw = self.fieldPanel.GetSize().x - 4
+ #for field in self.fields:
+ # field.SetSize((fw, field.GetSize().y))
# Notify system that the object has been modified
def __valueModified(self, event):
Modified: trunk/gnue-designer/src/base/tools/SchemaNavigator.py
===================================================================
--- trunk/gnue-designer/src/base/tools/SchemaNavigator.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/base/tools/SchemaNavigator.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -66,7 +66,7 @@
uses_feedback_bar = 1
def init(self):
- self.connections = self.instance._app.connections
+ self.connections = self.document.app.connections
self.connectionName = None
self.connectionNames = self.connections.getConnectionNames()
@@ -104,7 +104,7 @@
self.Layout()
def createToolbar(self, parent):
- return _SchemaToolbar(parent, self.instance)
+ return _SchemaToolbar(parent, self.document)
# Since this class is the root node, we need to
# emulate part of the Node class
@@ -117,10 +117,10 @@
dropSource = wx.DropSource(self)
dropSource.SetData(do)
- self.instance.dispatchEvent('BeginUndoGroup')
+ self.document.dispatchEvent('BeginUndoGroup')
# win32 needs wx.Drag_AllowMove to really enable DnD...
result = dropSource.DoDragDrop(wx.Drag_CopyOnly | wx.Drag_AllowMove)
- self.instance.dispatchEvent('EndUndoGroup')
+ self.document.dispatchEvent('EndUndoGroup')
def OnBeginRDrag(self, event):
self.OnBeginDrag(event, right=1)
Modified: trunk/gnue-designer/src/base/tools/SchemaViewer.py
===================================================================
--- trunk/gnue-designer/src/base/tools/SchemaViewer.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/base/tools/SchemaViewer.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -40,7 +40,7 @@
runtime_section = "SchemaViewer"
def init(self):
- self.connections = self.instance._app.connections
+ self.connections = self.document.app.connections
self.connectionName = None
self.connectionNames = self.connections.getConnectionNames()
@@ -285,8 +285,8 @@
string.replace(
string.replace(object.name,'.',''),'_',' '))),'')
- dname = self.instance.getUniqueName("dts%s" % basename)
- bname = self.instance.getUniqueName("blk%s" % basename)
+ dname = self.document.getUniqueName("dts%s" % basename)
+ bname = self.document.getUniqueName("blk%s" % basename)
data = [ { "Type" : "datasource",
"Attributes": {
@@ -419,7 +419,7 @@
attributes = {
"block": data[1]['Attributes']['name'],
- "name": self.editor.instance.getUniqueName("fld%s" % (
+ "name": self.editor.document.getUniqueName("fld%s" % (
string.join(string.split(string.capwords( \
string.replace(object.name,'_',' '))),''))),
"field": object.name,
Modified: trunk/gnue-designer/src/base/tools/TreeView.py
===================================================================
--- trunk/gnue-designer/src/base/tools/TreeView.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/base/tools/TreeView.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -177,8 +177,8 @@
self.tree.EnsureVisible(id)
self.tree.SelectItem(id)
if not isinstance(object, ObjectMenu):
- self.instance.propertyEditorWindow.Show(1)
- self.instance.propertyEditorWindow.Raise()
- self.instance.propertyEditorWindow.SetFocus()
+ self.document.propertyEditorWindow.Show(1)
+ self.document.propertyEditorWindow.Raise()
+ self.document.propertyEditorWindow.SetFocus()
Modified: trunk/gnue-designer/src/base/tools/TriggerEditor.py
===================================================================
--- trunk/gnue-designer/src/base/tools/TriggerEditor.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/base/tools/TriggerEditor.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -21,10 +21,9 @@
# $Id$
-from gnue.common.apps import GDebug
from gnue.common.definitions import GParserHelpers
from gnue.common.logic import GTrigger
-from gnue.designer.base.ToolBase import *
+from gnue.designer.base.EditorBase import EditorBase
from gnue.designer.uidrivers.wx.uihelpers.PythonEditor import PythonSTC
import wx
@@ -38,25 +37,20 @@
# ===========================================================================
-#
+# The TriggerEditor class
# ===========================================================================
-class TriggerEditor (EditorComponent):
+class TriggerEditor (EditorBase):
runtime_section = "TriggerEditor"
icon = 'py'
def init(self, object):
- self.editor = PythonEditorControl(self,-1, pos=wx.Point(0,32))
- self.editor.InEditMode = True
+ editor = self.editor = PythonEditorControl(self,-1, pos=wx.Point(0,32))
+ editor.InEditMode = True
- box = wx.BoxSizer(wx.VERTICAL)
- box.Add(self.editor, 2, wx.EXPAND)
+ self.document.app.ui.autoSizer(self, editor)
- self.SetAutoLayout(True)
- self.SetSizer(box)
- self.Layout()
-
self.object = object
self.triggerList = []
@@ -108,13 +102,22 @@
# ===========================================================================
+# Filter function
+# ===========================================================================
+def EditorFilter(gctrigger):
+ assert gctrigger._type == 'GCTrigger'
+ return not gctrigger.src
+
+
+# ===========================================================================
# Scintilla control for python source code
# ===========================================================================
# TODO: Add support for our JavaScript triggers
+# TODO: Move to uidrivers/wx?
class PythonEditorControl(PythonSTC):
def __init__(self, parent, *args, **parms):
PythonSTC.__init__(self, parent, *args, **parms)
- self.__makeDirty = parent.instance.makeDirty
+ self.__makeDirty = parent.document.makeDirty
self.__parent = parent
# TODO: FInd a better way...
Modified: trunk/gnue-designer/src/forms/BlockEditor.py
===================================================================
--- trunk/gnue-designer/src/forms/BlockEditor.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/forms/BlockEditor.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -45,14 +45,14 @@
## uses_feedback_bar = 1
def init(self):
- self.grid = _BlockEditorGrid(self, self.instance)
+ self.grid = _BlockEditorGrid(self, self.document)
wx.EVT_SIZE(self, self.__OnSize)
def __OnSize(self, event):
self.grid.SetSize(self.GetClientSize())
def createToolbar(self, parent):
- return _BlockToolbar(parent, self.instance)
+ return _BlockToolbar(parent, self.document)
@@ -64,9 +64,9 @@
base_gobject = GFBlock
def init(self):
- self.datasources = ObjectList(self.instance, GDataSource,
+ self.datasources = ObjectList(self.document, GDataSource,
'name', self.__datasourcesUpdated)
- self.instance.registerEventListeners({'BlockEditor:Delete':
self.__OnDelete})
+ self.document.registerEventListeners({'BlockEditor:Delete':
self.__OnDelete})
def getColumnDefinitions(self):
@@ -131,7 +131,7 @@
#
def __OnDelete(self, event):
if self.current:
- self.instance.incubator.deleteObject(self.instance.rootObject,
+ self.document.incubator.deleteObject(self.document.rootObject,
self.current, firstRun=0)
Modified: trunk/gnue-designer/src/forms/Debugger.py
===================================================================
--- trunk/gnue-designer/src/forms/Debugger.py 2006-03-06 20:23:30 UTC (rev
8209)
+++ trunk/gnue-designer/src/forms/Debugger.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -60,8 +60,8 @@
try:
self._saveexit = sys.exit
sys.exit = self.debugClosing
- debugInstance = GFInstance.GFInstance(caller._app, \
- connections=caller._app.connections, \
+ debugInstance = GFInstance.GFInstance(caller.app, \
+ connections=caller.app.connections, \
ui=DummyInterfaceModule, disableSplash=True, \
moduleName='gnue.forms.uidrivers.wx.UIdriver')
#debugInstance.addDialogs()
Copied: trunk/gnue-designer/src/forms/Document.py (from rev 8208,
trunk/gnue-designer/src/forms/Instance.py)
===================================================================
--- trunk/gnue-designer/src/forms/Instance.py 2006-03-06 14:54:02 UTC (rev
8208)
+++ trunk/gnue-designer/src/forms/Document.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -0,0 +1,410 @@
+#
+# Copyright 2001-2006 Free Software Foundation
+#
+# This file is part of GNU Enterprise
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# $Id$
+
+__all__ = ['Document']
+
+# ---------------------------------------------------------------------------
+# System imports
+# ---------------------------------------------------------------------------
+
+# ---------------------------------------------------------------------------
+# External imports
+# ---------------------------------------------------------------------------
+import wx
+
+# ---------------------------------------------------------------------------
+# GNUe Imports
+# ---------------------------------------------------------------------------
+from gnue.designer.forms import properties as formProperties
+from gnue.designer.base.Document import BaseDocument
+from gnue.designer.base import PopupMenu
+from gnue.designer.base.ObjectList import ObjectList
+from gnue.designer.base.PopupMenu import ObjectMenu
+
+from gnue.forms import GFInstance
+from gnue.forms import GFForm, GFParser, GFObjects, GFLibrary
+from gnue.forms.GFObjects.GFBlock import GFBlock
+
+from gnue.common.logic import GTrigger
+from gnue.common.apps import GDebug
+from gnue.common.datasources import GDataSource
+
+from Debugger import DebugSession
+from Incubator import Incubator
+from events.Events import registerEvents
+import wizards
+from WizardRunner import WizardRunner
+
+# Tool support...
+from LayoutEditor import LayoutEditor
+from TreeView import TreeView
+from PropertyEditor import PropertyEditor
+from EventEditor import EventEditor
+from BlockEditor import BlockEditor
+from gnue.designer.base.tools.DataSourceEditor import DataSourceEditor
+##from gnue.designer.base.tools.SchemaViewer import SchemaViewer
+from gnue.designer.base.tools.SchemaNavigator import SchemaNavigator
+
+
+
+#============================================================================
+# Document Instance class
+#============================================================================
+class Document(BaseDocument):
+ """
+ Designer's form editor document.
+ """
+
+ # =========================================================================
+ # Public methods
+ # =========================================================================
+
+ def init(self):
+ app = self.app
+ self.incubator = Incubator(self) # Incubator
+ self.properties = formProperties # List of the modules properties
+ self.wizardRunner = WizardRunner #
+ self.debugLevel = '1' # The debug level used when running a form
+ # inside designer
+
+ # Create a GFInstance instance
+ self.gfinstance = GFInstance.GFInstance(app,
+ app.connections,
+ None, disableSplash=1)
+
+ # For GFInstance support, iirc
+ ##self._pages = []
+
+ # Build a list of positionable widgets
+ self._positionableList = []
+ elements = self.incubator.elements
+ for tag in elements.keys():
+ try:
+ if elements['Positionable']:
+ self._positionableList.append(tag)
+ except KeyError:
+ pass
+
+ self.registerEventListeners({
+ 'ObjectModified' : self.__onModifyObject,
+ 'ObjectDeleted' : self.__onDeleteObject,
+ 'Forms:RunForm': self.__onRunForm,
+ 'Forms:RequestDebugLevel': self.__onSetDebugLevel
+ })
+
+ # Add our events/* stuff
+ registerEvents(self)
+
+ def finalize(self):
+ # 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')
+
+
+
+ # -------------------------------------------------------------------------
+ # Load a form
+ # -------------------------------------------------------------------------
+ def loadBuffer(self, buffer):
+ form = GFParser.loadFile (buffer, self.gfinstance, initialize=0)
+ return form
+
+
+ def loadEmpty(self, style=None):
+ form = GFForm.GFForm()
+ options = GFObjects.GFOptions(form)
+ form.title = _("Untitled Form")
+ form.height = 12
+ GFObjects.GFLogic(form)
+ layout = GFObjects.GFLayout(form)
+ layout.Char__width = 40
+ layout.Char__height = 12
+ GFObjects.GFPage(layout)
+ return form
+
+ # -------------------------------------------------------------------------
+ # Create the document tools/editors
+ # -------------------------------------------------------------------------
+ def createEditors(self):
+ # Associate our LayoutEditor with GFPage objects
+ self.registerEditor(LayoutEditor, 'GFPage')
+
+
+ def createTools(self):
+ self.addTool('propertyEditor', _('Property Inspector'), PropertyEditor,
+ hotkey='F10', menuGroup=301)
+ self.addTool('treeEditor', _('Object Navigator'), TreeView,
+ hotkey='F8', menuGroup=311)
+
+ self.addTool('schemaNavigator',_('Schema Navigator'), SchemaNavigator,
+ menuGroup=301)
+ #self.addTool('datasourceEditor',_('Data Source Editor'), DataSourceEditor,
+ # hotkey='F9', menuGroup=311)
+ #self.addTool('blockEditor', _('Block Editor'), BlockEditor,
+ # hotkey='F5', menuGroup=311)
+ #self.addTool('fieldEditor', _('Field Editor'), FieldEditor,
+ # hotkey='F6', menuGroup=201)
+ self.addTool('eventEditor', _('Trigger Mappings'), EventEditor,
+ hotkey='F7', menuGroup=321)
+
+ def createWizards(self):
+ self.loadWizards(wizards)
+
+ # Instances can add to the primary toolbar
+ def initToolBar(self):
+ self.toolbar.addToolbarMapping(';Forms:RunForm,tb_exec;')
+
+
+ def initMenu(self):
+ # Add the [sub]menus
+ for location, text, grouping in (
+ ('Modify|Arrange Items',_('&Arrange Items'), 501),):
+
+ self.menubar.addMenu(location, text, grouping)
+
+ for location, event, text, hotkey, help, grouping, canToggle in (
+ ('View', 'LayoutEditor:ZoomIn', _("Zoom In"), None, _("Zoom in"), 11.1,
0),
+ ('View', 'LayoutEditor:ZoomOut', _("Zoom Out"), None, _("Zoom out"),
11.2, 0),
+ ('View', 'LayoutEditor:ShowFocus', _("Show Focus Order"), None, _("Show
the navigation order on the layout editor"), 21, 1),
+
+ ('Tools','Forms:RunForm', _("Run Form"), None, _("Display and run the
current form"), 101.1, 0),
+ ('Tools','Forms:RequestDebugLevel', _("Change debugging level..."),
None, _("Change the debugging output level for the Run Form option"), 101.2, 0),
+
+ ('Modify|Align Items','Forms:AlignLeft', _("&Align Left Edges"), None,
_("Horizontally align the currently selected items along their left
edges"),101.1, 0),
+ ('Modify|Align Items','Forms:AlignRight', _("&Align Right Edges"),
None, _("Horizontally align the currently selected items along their right
edges"),101.2, 0),
+ ('Modify|Align Items','Forms:AlignHCenter', _("&Align Horizontal
Center"), None, _("Horizontally align the currently selected items along their
centers"),101.2, 0),
+ ('Modify|Align Items','Forms:AlignTop', _("&Align Top Edges"), None,
_("Vertically align the currently selected items along their top edges"),111.1,
0),
+ ('Modify|Align Items','Forms:AlignBottom', _("&Align Bottom Edges"),
None, _("Vertically align the currently selected items along their bottom
edges"),111.2, 0),
+ ('Modify|Align Items','Forms:AlignVCenter', _("&Align Vertical
Center"), None, _("Vertically align the currently selected items along their
centers"),111.3, 0),
+ ('Modify|Align Items','Forms:SmartAlign', _("&Smart Align
Labels/Fields"), None, _("Align Labels and fields into a block formation, with
all fields left aligned and all labels left aligned."),121.1, 0),
+
+ ('Modify','LayoutEditor:FocusOrder', _("&Set Focus Order Manually"),
None, _("Set the focus order by hand"),201.2, 0),
+ ('Modify','LayoutEditor:AutoArrange', _("&Reset Focus Order by
Position"), None, _("Automatically set the focus order based on an items
position"),201.3, 0)):
+ self.menubar.addAction(location, text, event,
+ grouping, canDisable=1, canToggle=canToggle,
+ icon=None, hotkey=hotkey, help=help)
+
+
+ # -------------------------------------------------------------------------
+ # Called by the base instance just before a save occurs, for cleanup
+ # -------------------------------------------------------------------------
+ def preSave(self):
+
+ # Get rid of form.name = '__main__'
+ try:
+ if self.rootObject.name == '__main__':
+ del self.rootObject.name
+ except AttributeError:
+ pass
+
+ # Do a little rearranging of objects
+
+ options = []
+ imports = []
+ databases = []
+ datasources = []
+ triggers = []
+ logic = []
+ layout = []
+ other = []
+
+ for child in self.rootObject._children:
+ if isinstance(child, GFObjects.GFOptions):
+ options.append(child)
+ elif isinstance(child, GFLibrary.GFImport):
+ imports.append(child)
+ elif isinstance(child, GDataSource.GConnection):
+ databases.append(child)
+ elif isinstance(child, GFObjects.GFDataSource) or \
+ (isinstance(child, GFLibrary.GFImportItem) and
+ child._type == 'GFimport-datasource'):
+ datasources.append(child)
+ elif isinstance(child, GTrigger.GTrigger) or \
+ (isinstance(child, GFLibrary.GFImportItem) and
+ child._type == 'GFimport-trigger'):
+ triggers.append(child)
+ elif isinstance(child, GFObjects.GFLayout) or \
+ (isinstance(child, GFLibrary.GFImportItem) and
+ child._type == 'GFimport-layout'):
+ layout.append(child)
+ elif isinstance(child, GFObjects.GFLogic) or \
+ (isinstance(child, GFLibrary.GFImportItem) and
+ child._type == 'GFimport-logic'):
+ logic.append(child)
+ else:
+ other.append(child)
+
+
+ # Do a little sanity check before saving...
+ if len(logic[0]._children):
+ valid = 1
+ else:
+ valid = 0 # No blocks! :(
+
+ if not valid:
+ if wx.MessageDialog(None,
+ _('The form definition you are about to save\n' + \
+ 'does not appear to be a workable definition.' + \
+ '\n\nIf you save an incomplete definition, you\n' + \
+ 'may not be able to reopen it in Designer.\n\nSave anyway?'),
+ _("Incomplete Form Definition"), wx.YES_NO|wx.ICON_QUESTION
).ShowModal() == wx.ID_NO:
+ return 1
+
+ # Reorder the children so items of same class are grouped
+ self.rootObject._children = []
+ for child in options:
+ self.rootObject._children.append(child)
+ for child in imports:
+ self.rootObject._children.append(child)
+ for child in databases:
+ self.rootObject._children.append(child)
+ for child in datasources:
+ self.rootObject._children.append(child)
+ for child in triggers:
+ self.rootObject._children.append(child)
+ for child in logic:
+ self.rootObject._children.append(child)
+ for child in layout:
+ self.rootObject._children.append(child)
+ for child in other:
+ self.rootObject._children.append(child)
+
+ # -------------------------------------------------------------------------
+ # TemplateParser support
+ # -------------------------------------------------------------------------
+ # Used by TemplateParser to build a wizard.current dict
+ def buildWizardCurrentDict(self):
+ baseForm = self._currentObject.findParentOfType('GFForm')
+ return {'form': baseForm,
+ 'logic': baseForm._logic,
+ 'layout': baseForm._layout,
+ 'page': self.visualEditor.page,
+ 'block': self.visualEditor.block,
+ 'object': self._currentObject}
+
+
+
+ # =========================================================================
+ # Private methods
+ # =========================================================================
+
+ # -------------------------------------------------------------------------
+ # Object tracking
+ # -------------------------------------------------------------------------
+ def inventoryObject(self, object):
+ if object._type == 'GFForm':
+ object._blockMap = {}
+ elif object._type == 'GFLogic':
+ object.getParent ()._logic = object
+ elif object._type == 'GFLayout':
+ object.getParent ()._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" % str(object.name)
+ self.rootObject._blockMap[object.name] = object
+ object._fieldMap = {}
+ elif object._type == 'GFField':
+ object.findParentOfType('GFBlock')._fieldMap[object.name] = object
+ elif object._type == 'GFEntry':
+ object._block = self.rootObject._blockMap[object.block]
+ object._field = object._block._fieldMap[object.field]
+ elif isinstance(object, GFObjects.GFPage) and \
+ object.getParent () == self.rootObject:
+ self._pages.append(object)
+
+ object._popupMenu = ObjectMenu(self, object)
+
+
+ def __onModifyObject(self, event):
+
+ object = event.object
+
+ #
+ # Maintain all those fun dicts/lists created in inventoryObject()
+ #
+ old = event.old
+ if object._type == 'GFBlock':
+ try:
+ del self.rootObject._blockMap[old['name']]
+ except KeyError:
+ pass
+ self.rootObject._blockMap[object.name] = object
+
+ elif object._type == 'GFField':
+ block = object.findParentOfType('GFBlock')
+ try:
+ del block._fieldMap[old['name']]
+ except KeyError:
+ pass
+ block._fieldMap[object.name] = object
+
+
+ def __onDeleteObject(self, event):
+ object = event.object
+ if object._type == 'GFPage':
+ self._pages.remove(object)
+
+ # Maintain all those fun dicts/lists created in inventoryObject()
+ if object._type == 'GFBlock':
+ del self.rootObject._blockMap[object.name]
+ elif object._type == 'GFField':
+ del object.findParentOfType('GFBlock')._fieldMap[object.name]
+ elif isinstance(object, GFObjects.GFPage) and \
+ object.getParent () == self.rootObject:
+ del self._pages[object]
+
+ object._popupMenu = ObjectMenu(self, object)
+
+
+ # -------------------------------------------------------------------------
+ # Form Debugging support
+ # -------------------------------------------------------------------------
+ def __onSetDebugLevel(self, event):
+ """Opens a dialog to let the user set the debug level
+ before running a form inside Designer."""
+ tmpLevel = self.debugLevel
+ tmpRez = ''
+ tmpMessage = _("Please enter debugging level - integer numbers [0..n]")
+ tmpCaption = _("Choose debug level")
+ tmpRez = wx.GetTextFromUser(tmpMessage, tmpCaption, tmpLevel, None)
+ if (tmpRez != ''):
+ self.debugLevel = tmpRez
+
+
+ def __onRunForm (self, event):
+ #TODO: This does not work... But everyone tried this first...
+ #TODO: No, not just you. I mean EVERYONE!!!
+ GDebug.setDebug(str(self.debugLevel), "")
+ DebugSession(self)
+ #~ wx.MessageDialog(self,
+ #~ _('Running a form within GNUe Designer is\n' + \
+ #~ 'not implemented yet.' + \
+ #~ '\n\nPlease save the form and run it using\n' + \
+ #~ 'the GNUe Forms tool (gnue-forms).'),
+ #~ _("NOT IMPLEMENTED"), wx.OK|wx.ICON_EXCLAMATION ).ShowModal()
+
+
Deleted: trunk/gnue-designer/src/forms/Instance.py
===================================================================
--- trunk/gnue-designer/src/forms/Instance.py 2006-03-06 20:23:30 UTC (rev
8209)
+++ trunk/gnue-designer/src/forms/Instance.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -1,377 +0,0 @@
-#
-# Copyright 2001-2006 Free Software Foundation
-#
-# This file is part of GNU Enterprise
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# $Id$
-
-__all__ = ['Instance']
-
-import wx
-
-from gnue.designer.forms import properties as formProperties
-from gnue.designer.base.Instance import BaseInstance
-from gnue.designer.base import PopupMenu
-from gnue.designer.base.ObjectList import ObjectList
-from WizardRunner import WizardRunner
-from Debugger import DebugSession
-from Incubator import Incubator
-from events.Events import registerEvents
-
-# Wizards
-import wizards
-
-# Tool support...
-from LayoutEditor import LayoutEditor
-from TreeView import TreeView
-from PropertyEditor import PropertyEditor
-from EventEditor import EventEditor
-from BlockEditor import BlockEditor
-from gnue.designer.base.tools.DataSourceEditor import DataSourceEditor
-##from gnue.designer.base.tools.SchemaViewer import SchemaViewer
-from gnue.designer.base.tools.SchemaNavigator import SchemaNavigator
-
-from gnue.designer.base.PopupMenu import ObjectMenu
-
-from gnue.forms import GFInstance
-from gnue.forms import GFForm, GFParser, GFObjects, GFLibrary
-from gnue.forms.GFObjects.GFBlock import GFBlock
-from gnue.common.logic import GTrigger
-from gnue.common.apps import GDebug
-from gnue.common.datasources import GDataSource
-
-class Instance(BaseInstance, GFInstance.GFInstance):
- """
- Designer's form editor instance.
- """
- def __init__(self, app, *args, **params):
-
- self.incubator = Incubator(self) # Incubator
- self.properties = formProperties # List of the modules properties
- self.wizardRunner = WizardRunner #
- self.debugLevel = '1' # The debug level used when running a form
- # inside designer
-
- # TODO: Can we make it so the GFInstance is not
- # 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 = self.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,
- 'ObjectDeleted' : self.__onDeleteObject,
- 'Forms:RunForm': self.__onRunForm,
- 'Forms:RequestDebugLevel': self.__onSetDebugLevel
- })
-
- # Add our events/* stuff
- registerEvents(self)
-
- # 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):
- form = GFParser.loadFile (buffer, self, initialize=0)
-## if not hasattr(form,'name') or not form.name:
-## form.name = 'form'
- return form
-
-
- def loadEmpty(self, style=None):
- form = GFForm.GFForm()
- options = GFObjects.GFOptions(form)
- form.title = _("Untitled Form")
- form.height = 12
- GFObjects.GFLogic(form)
- layout = GFObjects.GFLayout(form)
- layout.Char__width = 40
- layout.Char__height = 12
- GFObjects.GFPage(layout)
- return form
-
-
- def inventoryObject(self, object):
- if object._type == 'GFForm':
- object._blockMap = {}
- elif object._type == 'GFLogic':
- object.getParent ()._logic = object
- elif object._type == 'GFLayout':
- object.getParent ()._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" % str(object.name)
- self.rootObject._blockMap[object.name] = object
- object._fieldMap = {}
- elif object._type == 'GFField':
- object.findParentOfType('GFBlock')._fieldMap[object.name] = object
- elif object._type == 'GFEntry':
- object._block = self.rootObject._blockMap[object.block]
- object._field = object._block._fieldMap[object.field]
- elif isinstance(object, GFObjects.GFPage) and \
- object.getParent () == self.rootObject:
- self._pages.append(object)
-
- object._popupMenu = ObjectMenu(self, object)
-
-
- def __onModifyObject(self, event):
-
- object = event.object
-
- #
- # Maintain all those fun dicts/lists created in inventoryObject()
- #
- old = event.old
- if object._type == 'GFBlock':
- try:
- del self.rootObject._blockMap[old['name']]
- except KeyError:
- pass
- self.rootObject._blockMap[object.name] = object
-
- elif object._type == 'GFField':
- block = object.findParentOfType('GFBlock')
- try:
- del block._fieldMap[old['name']]
- except KeyError:
- pass
- block._fieldMap[object.name] = object
-
-
- def __onDeleteObject(self, event):
- object = event.object
- if object._type == 'GFPage':
- self._pages.remove(object)
-
- # Maintain all those fun dicts/lists created in inventoryObject()
- if object._type == 'GFBlock':
- del self.rootObject._blockMap[object.name]
- elif object._type == 'GFField':
- del object.findParentOfType('GFBlock')._fieldMap[object.name]
- elif isinstance(object, GFObjects.GFPage) and \
- object.getParent () == self.rootObject:
- del self._pages[object]
-
- object._popupMenu = ObjectMenu(self, object)
-
-
- def createEditors(self):
- self.registerEditor('visualEditor', _('Layout Editor'), LayoutEditor,
- 'GFPage')
-
-
- def createTools(self):
- self.addTool('propertyEditor', _('Property Inspector'), PropertyEditor,
- hotkey='F10', menuGroup=301)
- self.addTool('treeEditor', _('Object Navigator'), TreeView,
- hotkey='F8', menuGroup=311)
-
- self.addTool('schemaNavigator',_('Schema Navigator'), SchemaNavigator,
- menuGroup=301)
- #self.addTool('datasourceEditor',_('Data Source Editor'), DataSourceEditor,
- # hotkey='F9', menuGroup=311)
- #self.addTool('blockEditor', _('Block Editor'), BlockEditor,
- # hotkey='F5', menuGroup=311)
- #self.addTool('fieldEditor', _('Field Editor'), FieldEditor,
- # hotkey='F6', menuGroup=201)
- self.addTool('eventEditor', _('Trigger Mappings'), EventEditor,
- hotkey='F7', menuGroup=321)
-
- def createWizards(self):
- self.loadWizards(wizards)
-
- # Instances can add to the primary toolbar
- def initToolBar(self):
- self.toolbar.addToolbarMapping(';Forms:RunForm,tb_exec;')
-
-
- def initMenu(self):
- # Add the [sub]menus
- for location, text, grouping in (
- ('Modify|Arrange Items',_('&Arrange Items'), 501),):
-
- self.menubar.addMenu(location, text, grouping)
-
- for location, event, text, hotkey, help, grouping, canToggle in (
- ('View', 'LayoutEditor:ZoomIn', _("Zoom In"), None, _("Zoom in"), 11.1,
0),
- ('View', 'LayoutEditor:ZoomOut', _("Zoom Out"), None, _("Zoom out"),
11.2, 0),
- ('View', 'LayoutEditor:ShowFocus', _("Show Focus Order"), None, _("Show
the navigation order on the layout editor"), 21, 1),
-
- ('Tools','Forms:RunForm', _("Run Form"), None, _("Display and run the
current form"), 101.1, 0),
- ('Tools','Forms:RequestDebugLevel', _("Change debugging level..."),
None, _("Change the debugging output level for the Run Form option"), 101.2, 0),
-
- ('Modify|Align Items','Forms:AlignLeft', _("&Align Left Edges"), None,
_("Horizontally align the currently selected items along their left
edges"),101.1, 0),
- ('Modify|Align Items','Forms:AlignRight', _("&Align Right Edges"),
None, _("Horizontally align the currently selected items along their right
edges"),101.2, 0),
- ('Modify|Align Items','Forms:AlignHCenter', _("&Align Horizontal
Center"), None, _("Horizontally align the currently selected items along their
centers"),101.2, 0),
- ('Modify|Align Items','Forms:AlignTop', _("&Align Top Edges"), None,
_("Vertically align the currently selected items along their top edges"),111.1,
0),
- ('Modify|Align Items','Forms:AlignBottom', _("&Align Bottom Edges"),
None, _("Vertically align the currently selected items along their bottom
edges"),111.2, 0),
- ('Modify|Align Items','Forms:AlignVCenter', _("&Align Vertical
Center"), None, _("Vertically align the currently selected items along their
centers"),111.3, 0),
- ('Modify|Align Items','Forms:SmartAlign', _("&Smart Align
Labels/Fields"), None, _("Align Labels and fields into a block formation, with
all fields left aligned and all labels left aligned."),121.1, 0),
-
- ('Modify','LayoutEditor:FocusOrder', _("&Set Focus Order Manually"),
None, _("Set the focus order by hand"),201.2, 0),
- ('Modify','LayoutEditor:AutoArrange', _("&Reset Focus Order by
Position"), None, _("Automatically set the focus order based on an items
position"),201.3, 0)):
- self.menubar.addAction(location, text, event,
- grouping, canDisable=1, canToggle=canToggle,
- icon=None, hotkey=hotkey, help=help)
-
-
-
- def preSave(self):
-
-
- # Get rid of form.name = '__main__'
- try:
- if self.rootObject.name == '__main__':
- del self.rootObject.name
- except AttributeError:
- pass
-
- # Do a little rearranging of objects
-
- options = []
- imports = []
- databases = []
- datasources = []
- triggers = []
- logic = []
- layout = []
- other = []
-
- for child in self.rootObject._children:
- if isinstance(child, GFObjects.GFOptions):
- options.append(child)
- elif isinstance(child, GFLibrary.GFImport):
- imports.append(child)
- elif isinstance(child, GDataSource.GConnection):
- databases.append(child)
- elif isinstance(child, GFObjects.GFDataSource) or \
- (isinstance(child, GFLibrary.GFImportItem) and
- child._type == 'GFimport-datasource'):
- datasources.append(child)
- elif isinstance(child, GTrigger.GTrigger) or \
- (isinstance(child, GFLibrary.GFImportItem) and
- child._type == 'GFimport-trigger'):
- triggers.append(child)
- elif isinstance(child, GFObjects.GFLayout) or \
- (isinstance(child, GFLibrary.GFImportItem) and
- child._type == 'GFimport-layout'):
- layout.append(child)
- elif isinstance(child, GFObjects.GFLogic) or \
- (isinstance(child, GFLibrary.GFImportItem) and
- child._type == 'GFimport-logic'):
- logic.append(child)
- else:
- other.append(child)
-
-
- # Do a little sanity check before saving...
- if len(logic[0]._children):
- valid = 1
- else:
- valid = 0 # No blocks! :(
-
- if not valid:
- if wx.MessageDialog(None,
- _('The form definition you are about to save\n' + \
- 'does not appear to be a workable definition.' + \
- '\n\nIf you save an incomplete definition, you\n' + \
- 'may not be able to reopen it in Designer.\n\nSave anyway?'),
- _("Incomplete Form Definition"), wx.YES_NO|wx.ICON_QUESTION
).ShowModal() == wx.ID_NO:
- return 1
-
- # Reorder the children so items of same class are grouped
- self.rootObject._children = []
- for child in options:
- self.rootObject._children.append(child)
- for child in imports:
- self.rootObject._children.append(child)
- for child in databases:
- self.rootObject._children.append(child)
- for child in datasources:
- self.rootObject._children.append(child)
- for child in triggers:
- self.rootObject._children.append(child)
- for child in logic:
- self.rootObject._children.append(child)
- for child in layout:
- self.rootObject._children.append(child)
- for child in other:
- self.rootObject._children.append(child)
-
- # Used by TemplateParser to build a wizard.current dict
- def buildWizardCurrentDict(self):
- baseForm = self._currentObject.findParentOfType('GFForm')
- return {'form': baseForm,
- 'logic': baseForm._logic,
- 'layout': baseForm._layout,
- 'page': self.visualEditor.page,
- 'block': self.visualEditor.block,
- 'object': self._currentObject}
-
-
- def __onSetDebugLevel(self, event):
- """Opens a dialog to let the user set the debug level
- before running a form inside Designer."""
- tmpLevel = self.debugLevel
- tmpRez = ''
- tmpMessage = _("Please enter debugging level - integer numbers [0..n]")
- tmpCaption = _("Choose debug level")
- tmpRez = wx.GetTextFromUser(tmpMessage, tmpCaption, tmpLevel, None)
- if (tmpRez != ''):
- self.debugLevel = tmpRez
-
-
- def __onRunForm (self, event):
- #TODO: This does not work... But everyone tried this first...
- #TODO: No, not just you. I mean EVERYONE!!!
- GDebug.setDebug(str(self.debugLevel), "")
- DebugSession(self)
- #~ wx.MessageDialog(self,
- #~ _('Running a form within GNUe Designer is\n' + \
- #~ 'not implemented yet.' + \
- #~ '\n\nPlease save the form and run it using\n' + \
- #~ 'the GNUe Forms tool (gnue-forms).'),
- #~ _("NOT IMPLEMENTED"), wx.OK|wx.ICON_EXCLAMATION ).ShowModal()
-
-
Modified: trunk/gnue-designer/src/forms/LayoutEditor/DisplayDropTarget.py
===================================================================
--- trunk/gnue-designer/src/forms/LayoutEditor/DisplayDropTarget.py
2006-03-06 20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/forms/LayoutEditor/DisplayDropTarget.py
2006-03-07 00:04:31 UTC (rev 8210)
@@ -64,7 +64,7 @@
# do something with it.
def OnData(self, bx, by, d):
- instance = self.editor.instance
+ instance = self.editor.document
# copy the data from the drag source to our data object
if self.GetData():
@@ -255,7 +255,7 @@
except:
return
- instance = self.editor.instance
+ instance = self.editor.document
# TODO: if params['ShowMenu'], give user options
@@ -331,7 +331,7 @@
x = int(x / self.editor.gridWidth)
maxWidth = x
page = self.editor.page
- instance = self.editor.instance
+ instance = self.editor.document
selection = []
for f in fields:
try:
@@ -473,7 +473,7 @@
# user requested we only create a new block
#
def schemaDrop_Block(self, table, fields, select=0):
- instance = self.editor.instance
+ instance = self.editor.document
datasource = self.schemaDrop_Datasource(table, fields)
o = instance.incubator.createObject(
instance.rootObject,
@@ -493,7 +493,7 @@
# User requested we only create a new datasource
#
def schemaDrop_Datasource(self, table, fields, attrs={}, select=0):
- instance = self.editor.instance
+ instance = self.editor.document
attrs.update({'name':
instance.getUniqueName('dts%s'%table['name'].capitalize()),
'connection':table['connection'],
'table': table['name']})
Modified: trunk/gnue-designer/src/forms/LayoutEditor/LayoutEditor.py
===================================================================
--- trunk/gnue-designer/src/forms/LayoutEditor/LayoutEditor.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/forms/LayoutEditor/LayoutEditor.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -42,7 +42,7 @@
from gnue.forms.uidrivers.wx.common import wxEncode
from gnue.designer.base.PopupMenu import PageMenu
from gnue.designer.base.TemplateParser import TemplateParser
-from gnue.designer.base.ToolBase import EditorComponent
+from gnue.designer.base.EditorBase import EditorBase
# My support files
from Utils import *
@@ -55,7 +55,7 @@
from renderers.Base.GridPane import GridPane
-class LayoutEditor (EditorComponent):
+class LayoutEditor (EditorBase):
runtime_section = "FormsLayoutEditor"
@@ -67,9 +67,9 @@
def init(self, object):
# TODO: blah.... historical reasons
- self._instance = self.instance
+ self._instance = self.document
- self._app = self.instance._app
+ self.app = self.document.app
self.page = object
self.block = None
@@ -88,9 +88,9 @@
# TODO: This should be moved into GFInstance...
# TODO: here for historical reasons.
try:
- self.uidriver = uidriver = self.instance.__uidriver
+ self.uidriver = uidriver = self.document.__uidriver
except AttributeError:
- self.instance.__uidriver = self.uidriver = uidriver =
UIwxpython.GFUserInterface(self.instance, 0)
+ self.document.__uidriver = self.uidriver = uidriver =
UIwxpython.GFUserInterface(self.document, 0)
# Create a list of all UI widgets
@@ -109,7 +109,7 @@
self._currentObject = None
self.mode = 'move'
- self.reorderfocus = ReorderFocus(self.instance)
+ self.reorderfocus = ReorderFocus(self.document)
# Internal mouse states... used by OnMotion, etc
self.__drawing = 0
@@ -136,7 +136,7 @@
'EndWizard': self.endWizard,
})
- self.instance.rootObject.walk (self.inventoryObject)
+ self.document.rootObject.walk (self.inventoryObject)
## Stuff needed by UIwxpython
self._pageList = [] # Needed by UIwxpython
@@ -156,7 +156,7 @@
def createToolbar(self, parent):
- self.toolbar = LayoutEditorTools(parent, self.instance)
+ self.toolbar = LayoutEditorTools(parent, self.document)
self.blockCombo = self.toolbar.blockCombo
wx.EVT_COMBOBOX(self.toolbar, self.blockCombo.GetId(),
self.OnBlockSelected)
self._rebuildBlockCombo()
@@ -629,28 +629,28 @@
block = self._currentObject._type == 'GFBlock' and self._currentObject or \
self._currentObject.findParentOfType('GFBlock')
- menu.AppendMenu(wx.NewId(), 'Form', PageMenu(self.instance, form, x, y))
+ menu.AppendMenu(wx.NewId(), 'Form', PageMenu(self.document, form, x, y))
if page:
- menu.AppendMenu(wx.NewId(), page.name, PageMenu(self.instance, page, x,
y))
+ menu.AppendMenu(wx.NewId(), page.name, PageMenu(self.document, page, x,
y))
if block:
- menu.AppendMenu(wx.NewId(), block.name, PageMenu(self.instance, block,
x, y))
+ menu.AppendMenu(wx.NewId(), block.name, PageMenu(self.document, block,
x, y))
self.panel.PopupMenu(menu, event.GetPosition())
def keyTrap(self, event):
- if event.KeyCode() in (WXK_LEFT, WXK_RIGHT, WXK_UP, WXK_DOWN) and \
+ if event.KeyCode() in (wx.WXK_LEFT,wx.WXK_RIGHT,wx.WXK_UP,wx.WXK_DOWN) and
\
len(self._currentSelection):
if event.AltDown() or event.ControlDown() or event.ShiftDown():
# caution: event.MetaDown() is always True on some architectures
resize = None
- if event.KeyCode() == WXK_LEFT:
+ if event.KeyCode() == wx.WXK_LEFT:
resize = (-1,0)
- if event.KeyCode() == WXK_RIGHT:
+ if event.KeyCode() == wx.WXK_RIGHT:
resize = (1,0)
- if event.KeyCode() == WXK_UP:
+ if event.KeyCode() == wx.WXK_UP:
resize = (0,-1)
- if event.KeyCode() == WXK_DOWN:
+ if event.KeyCode() == wx.WXK_DOWN:
resize = (0,1)
if resize:
self.dispatchEvent('BeginUndoGroup')
@@ -659,13 +659,13 @@
self.dispatchEvent('EndUndoGroup')
else:
pos = None
- if event.KeyCode() == WXK_LEFT:
+ if event.KeyCode() == wx.WXK_LEFT:
pos = (-1,0)
- if event.KeyCode() == WXK_RIGHT:
+ if event.KeyCode() == wx.WXK_RIGHT:
pos = (1,0)
- if event.KeyCode() == WXK_UP:
+ if event.KeyCode() == wx.WXK_UP:
pos = (0,-1)
- if event.KeyCode() == WXK_DOWN:
+ if event.KeyCode() == wx.WXK_DOWN:
pos = (0,1)
if pos:
@@ -675,7 +675,7 @@
widget._widgetHandler.relativeMove(*pos)
self.dispatchEvent('EndUndoGroup')
- elif event.KeyCode() == WXK_DELETE and \
+ elif event.KeyCode() == wx.WXK_DELETE and \
len(self._currentSelection):
self.dispatchEvent('BeginUndoGroup')
for object in self._currentSelection:
@@ -683,7 +683,7 @@
self.dispatchEvent('ObjectDeleted', object=object,
originator=self)
self.dispatchEvent('EndUndoGroup')
- elif event.KeyCode() == WXK_TAB:
+ elif event.KeyCode() == wx.WXK_TAB:
if event.ShiftDown():
object = self._currentObject
if hasattr(object,'_widgetHandler') and not object._type == 'GFPage':
@@ -694,7 +694,7 @@
lst.reverse()
for newobj in lst:
if hasattr(newobj,'_widgetHandler'):
- self.instance.dispatchEvent('ObjectSelected',
+ self.document.dispatchEvent('ObjectSelected',
originator=None,
object=newobj)
break
@@ -707,7 +707,7 @@
lst = self.page._children[:]
for newobj in lst:
if hasattr(newobj,'_widgetHandler'):
- self.instance.dispatchEvent('ObjectSelected',
+ self.document.dispatchEvent('ObjectSelected',
originator=None,
object=newobj)
break
Modified: trunk/gnue-designer/src/forms/LayoutEditor/PopupEditor.py
===================================================================
--- trunk/gnue-designer/src/forms/LayoutEditor/PopupEditor.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/forms/LayoutEditor/PopupEditor.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -61,10 +61,10 @@
def OnChar(self, event):
- if event.GetKeyCode() in (WXK_RETURN, WXK_TAB):
+ if event.GetKeyCode() in (wx.WXK_RETURN,wx.WXK_TAB):
self.done(1)
- elif event.GetKeyCode() == WXK_ESCAPE:
+ elif event.GetKeyCode() == wx.WXK_ESCAPE:
self.done(0)
else:
event.Skip()
Modified: trunk/gnue-designer/src/forms/LayoutEditor/ReorderFocus.py
===================================================================
--- trunk/gnue-designer/src/forms/LayoutEditor/ReorderFocus.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/forms/LayoutEditor/ReorderFocus.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -34,7 +34,7 @@
#
class ReorderFocus:
def __init__(self, instance):
- self.instance = instance
+ self.document = instance
def start(self, page):
self.click = 1
@@ -54,7 +54,7 @@
# TODO: More intelligence
# TODO: allow only cycling thru current block, selection, or page
if object._type in ('GFEntry','GFButton') and
hasattr(object,'_widgetHandler'):
- self.list.append(WidgetFocusTab(self.instance, object, self))
+ self.list.append(WidgetFocusTab(self.document, object, self))
def end(self):
while len(self.list):
Modified: trunk/gnue-designer/src/forms/LayoutEditor/WidgetFocusTab.py
===================================================================
--- trunk/gnue-designer/src/forms/LayoutEditor/WidgetFocusTab.py
2006-03-06 20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/forms/LayoutEditor/WidgetFocusTab.py
2006-03-07 00:04:31 UTC (rev 8210)
@@ -39,8 +39,8 @@
#
class WidgetFocusTab:
def __init__(self, instance, widget, container):
- self.instance = instance
- panel = self.instance.visualEditor.panel
+ self.document = instance
+ panel = self.document.visualEditor.panel
self.widget = widget
self.container = container
self.x, self.y = widget._widgetHandler.widget.GetPositionTuple()
@@ -57,7 +57,7 @@
self.widget.focusorder = position
def close(self):
- self.instance = None
+ self.document = None
self.widget = None
self.label.Destroy()
Modified: trunk/gnue-designer/src/forms/LayoutEditor/Workspace.py
===================================================================
--- trunk/gnue-designer/src/forms/LayoutEditor/Workspace.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/forms/LayoutEditor/Workspace.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -68,9 +68,9 @@
self.page = page
# TODO: blah.... historical reasons
- self._instance = self.instance = layouteditor.instance
+ self._instance = self.document = layouteditor.document
- self._app = self.instance._app
+ self.app = self.document.app
self.block = None
self.lastBlock = None
@@ -82,7 +82,7 @@
self._currentSelection = []
# Create our own WX GFUserInterface instance
- self.uidriver = uidriver = UIwxpython.GFUserInterface(self.instance, 0)
+ self.uidriver = uidriver = UIwxpython.GFUserInterface(self.document, 0)
# Create a list of all UI widgets
self.widgets = {}
@@ -99,7 +99,7 @@
self._currentObject = None
self.layouteditor.mode = 'move'
- self.reorderfocus = ReorderFocus(self.instance)
+ self.reorderfocus = ReorderFocus(self.document)
# Internal mouse states... used by OnMotion, etc
self.__drawing = 0
@@ -541,28 +541,28 @@
block = self._currentObject._type == 'GFBlock' and self._currentObject or \
self._currentObject.findParentOfType('GFBlock')
- menu.AppendMenu(wx.NewId(), 'Form', PageMenu(self.instance, form, x, y))
+ menu.AppendMenu(wx.NewId(), 'Form', PageMenu(self.document, form, x, y))
if page:
- menu.AppendMenu(wx.NewId(), page.name, PageMenu(self.instance, page, x,
y))
+ menu.AppendMenu(wx.NewId(), page.name, PageMenu(self.document, page, x,
y))
if block:
- menu.AppendMenu(wx.NewId(), block.name, PageMenu(self.instance, block,
x, y))
+ menu.AppendMenu(wx.NewId(), block.name, PageMenu(self.document, block,
x, y))
self.panel.PopupMenu(menu, event.GetPosition())
def keyTrap(self, event):
- if event.KeyCode() in (WXK_LEFT, WXK_RIGHT, WXK_UP, WXK_DOWN) and \
+ if event.KeyCode() in (wx.WXK_LEFT,wx.WXK_RIGHT,wx.WXK_UP,wx.WXK_DOWN) and
\
len(self._currentSelection):
if event.AltDown() or event.ControlDown() or event.ShiftDown():
# caution: event.MetaDown() is always True on some architectures
resize = None
- if event.KeyCode() == WXK_LEFT:
+ if event.KeyCode() == wx.WXK_LEFT:
resize = (-1,0)
- if event.KeyCode() == WXK_RIGHT:
+ if event.KeyCode() == wx.WXK_RIGHT:
resize = (1,0)
- if event.KeyCode() == WXK_UP:
+ if event.KeyCode() == wx.WXK_UP:
resize = (0,-1)
- if event.KeyCode() == WXK_DOWN:
+ if event.KeyCode() == wx.WXK_DOWN:
resize = (0,1)
if resize:
self.layouteditor.dispatchEvent('BeginUndoGroup')
@@ -571,13 +571,13 @@
self.layouteditor.dispatchEvent('EndUndoGroup')
else:
pos = None
- if event.KeyCode() == WXK_LEFT:
+ if event.KeyCode() == wx.WXK_LEFT:
pos = (-1,0)
- if event.KeyCode() == WXK_RIGHT:
+ if event.KeyCode() == wx.WXK_RIGHT:
pos = (1,0)
- if event.KeyCode() == WXK_UP:
+ if event.KeyCode() == wx.WXK_UP:
pos = (0,-1)
- if event.KeyCode() == WXK_DOWN:
+ if event.KeyCode() == wx.WXK_DOWN:
pos = (0,1)
if pos:
@@ -587,7 +587,7 @@
widget._widgetHandler.relativeMove(*pos)
self.layouteditor.dispatchEvent('EndUndoGroup')
- elif event.KeyCode() == WXK_DELETE and \
+ elif event.KeyCode() == wx.WXK_DELETE and \
len(self._currentSelection):
self.layouteditor.dispatchEvent('BeginUndoGroup')
for object in self._currentSelection:
@@ -595,7 +595,7 @@
self.layouteditor.dispatchEvent('ObjectDeleted', object=object,
originator=self)
self.layouteditor.dispatchEvent('EndUndoGroup')
- elif event.KeyCode() == WXK_TAB:
+ elif event.KeyCode() == wx.WXK_TAB:
if event.ShiftDown():
object = self._currentObject
if hasattr(object,'_widgetHandler') and not object._type == 'GFPage':
@@ -606,7 +606,7 @@
lst.reverse()
for newobj in lst:
if hasattr(newobj,'_widgetHandler'):
- self.instance.dispatchEvent('ObjectSelected',
+ self.document.dispatchEvent('ObjectSelected',
originator=None,
object=newobj)
break
@@ -619,7 +619,7 @@
lst = self.page._children[:]
for newobj in lst:
if hasattr(newobj,'_widgetHandler'):
- self.instance.dispatchEvent('ObjectSelected',
+ self.document.dispatchEvent('ObjectSelected',
originator=None,
object=newobj)
break
Modified: trunk/gnue-designer/src/forms/LayoutEditor/renderers/Base/Driver.py
===================================================================
--- trunk/gnue-designer/src/forms/LayoutEditor/renderers/Base/Driver.py
2006-03-06 20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/forms/LayoutEditor/renderers/Base/Driver.py
2006-03-07 00:04:31 UTC (rev 8210)
@@ -30,7 +30,7 @@
class BaseRenderer:
def __init__(self, instance, workspace):
- self.instance = instance
+ self.document = instance
self.workspace = workspace
Modified: trunk/gnue-designer/src/forms/LayoutEditor/renderers/Base/GridPane.py
===================================================================
--- trunk/gnue-designer/src/forms/LayoutEditor/renderers/Base/GridPane.py
2006-03-06 20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/forms/LayoutEditor/renderers/Base/GridPane.py
2006-03-07 00:04:31 UTC (rev 8210)
@@ -68,7 +68,7 @@
neww = int(w/float(self.__instance.widgetWidth)+.5)
newh = int(h/float(self.__instance.widgetHeight)+.5)
- layout = self.__instance.instance.rootObject._layout
+ layout = self.__instance.document.rootObject._layout
oldvars = {}
newvars = {}
@@ -83,7 +83,7 @@
layout.Char__height = newh
if oldvars:
- self.__instance.instance.dispatchEvent('ObjectModified', object=layout,
+ self.__instance.document.dispatchEvent('ObjectModified', object=layout,
originator="Forms::GridPane",
old=oldvars,
new=newvars)
Modified: trunk/gnue-designer/src/forms/PropertyEditor.py
===================================================================
--- trunk/gnue-designer/src/forms/PropertyEditor.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/forms/PropertyEditor.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -44,7 +44,7 @@
# Is this a Positionable widget? If so, show x,y,w,h editor
#
try:
- layout = self.instance.incubator.elements[
+ layout = self.document.incubator.elements[
(self.object._type[2:]).lower()]['Positionable']
except KeyError:
if self.object._type == 'GFLabel':
@@ -66,7 +66,7 @@
# Block?
if self.object._type == 'GFBlock' and hasattr(self.object,'datasource') \
- and self.object.datasource and hasattr(self.instance,'datasources'):
+ and self.object.datasource and hasattr(self.document,'datasources'):
self.addPage(DatasourceInspectorPanel(self, self.notebook), "Data
Source")
# Add layout
@@ -107,7 +107,7 @@
def setCurrent(self, object):
try:
if hasattr(object,'datasource') and object.datasource:
- self._setCurrent(self.editor.instance.datasources[object.datasource])
+ self._setCurrent(self.editor.document.datasources[object.datasource])
except AttributeError:
pass # Happens on startup
Modified: trunk/gnue-designer/src/forms/TreeView.py
===================================================================
--- trunk/gnue-designer/src/forms/TreeView.py 2006-03-06 20:23:30 UTC (rev
8209)
+++ trunk/gnue-designer/src/forms/TreeView.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -73,9 +73,9 @@
self.AppendItem(self.rootObject._treeItem, _("Page Layout"))
self.tree.SetItemImage(self.rootObject._treeItemPageLayout,
treeIconMap['page'])
- self.tree.SetPyData(self.rootObject._treeItemFormProperties,
ObjectMenu(self.instance,None))
- self.tree.SetPyData(self.rootObject._treeItemDataSources,
ObjectMenu(self.instance,None))
- self.tree.SetPyData(self.rootObject._treeItemNamedTriggers,
ObjectMenu(self.instance,None))
+ self.tree.SetPyData(self.rootObject._treeItemFormProperties,
ObjectMenu(self.document,None))
+ self.tree.SetPyData(self.rootObject._treeItemDataSources,
ObjectMenu(self.document,None))
+ self.tree.SetPyData(self.rootObject._treeItemNamedTriggers,
ObjectMenu(self.document,None))
self.tree.SetPyData(self.rootObject._treeItemLogic, logic)
self.tree.SetPyData(self.rootObject._treeItemPageLayout, layout)
Modified: trunk/gnue-designer/src/forms/WizardRunner.py
===================================================================
--- trunk/gnue-designer/src/forms/WizardRunner.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/forms/WizardRunner.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -42,7 +42,7 @@
# i.e., intercept the run method.
if issubclass( self.template['BaseClass'],
TemplateSupport.FormPrePositioningTemplate ):
- self.instance.dispatchEvent('BeginWizard',
+ self.document.dispatchEvent('BeginWizard',
template=self.template)
self.prepositioning = 1
event.dispatchAfter('LayoutEditor:Prepositioning', wizardrunner=self)
@@ -56,7 +56,7 @@
def cancel(self, event=None):
if hasattr(self,'prepositioning') and self.prepositioning:
- self.instance.dispatchEvent('Cancel:LayoutEditor:Prepositioning')
- self.instance.dispatchEvent('EndWizard', template=self.template)
+ self.document.dispatchEvent('Cancel:LayoutEditor:Prepositioning')
+ self.document.dispatchEvent('EndWizard', template=self.template)
else:
BaseWizardRunner.cancel(self)
Modified: trunk/gnue-designer/src/forms/events/Arrange.py
===================================================================
--- trunk/gnue-designer/src/forms/events/Arrange.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/forms/events/Arrange.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -29,7 +29,7 @@
class Arrange:
def __init__(self, instance):
- self.instance = instance
+ self.document = instance
self.enabled = 1
instance.registerEventListeners( {
'Forms:AlignLeft': self.leftEdge,
@@ -208,7 +208,7 @@
'FormsAlignBottom',
'FormsAlignVCenter',
'FormsSmartAlign'):
- self.instance.dispatchEvent('%s:%s' % (evt, task))
+ self.document.dispatchEvent('%s:%s' % (evt, task))
Modified: trunk/gnue-designer/src/forms/events/Resize.py
===================================================================
--- trunk/gnue-designer/src/forms/events/Resize.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/forms/events/Resize.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -29,7 +29,7 @@
class Resize:
def __init__(self, instance):
- self.instance = instance
+ self.document = instance
self.enabled = 1
instance.registerEventListeners( {
'Forms:AutoResizePage': self.resizeGrid } )
@@ -38,11 +38,11 @@
return hasattr(page, 'style') and page.style in ('popup',)
def resizeGrid(self, event):
- if self._isStandalonePage(self.instance.visualEditor.page):
- target = self.instance.layoutEditor.page
+ if self._isStandalonePage(self.document.visualEditor.page):
+ target = self.document.layoutEditor.page
stack = [target]
else:
- target = self.instance.rootObject._layout
+ target = self.document.rootObject._layout
stack = []
for object in target._children:
if not self._isStandalonePage(object):
@@ -97,5 +97,5 @@
old['Char:height'] = target.Char__height
new['Char:height'] = target.Char__height = my
- self.instance.dispatchEvent('ObjectModified', originator=self,
+ self.document.dispatchEvent('ObjectModified', originator=self,
old=old, new=new, object=target)
Copied: trunk/gnue-designer/src/navigator/Document.py (from rev 8208,
trunk/gnue-designer/src/navigator/Instance.py)
===================================================================
--- trunk/gnue-designer/src/navigator/Instance.py 2006-03-06 14:54:02 UTC
(rev 8208)
+++ trunk/gnue-designer/src/navigator/Document.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -0,0 +1,88 @@
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Copyright 2001-2006 Free Software Foundation
+#
+# FILE:
+# navigator/Instance.py
+#
+# DESCRIPTION:
+# Creates a "Navigator" instance
+#
+# NOTES:
+#
+
+from gnue.designer.navigator import properties as navProperties
+from gnue.designer.base.Document import BaseDocument
+from Incubator import Incubator
+
+# Tool support...
+from LayoutEditor import LayoutEditor
+##from gnue.designer.TreeView import TreeView
+##from gnue.designer.PropertyEditor import PropertyToolFrame
+##from gnue.designer.TriggerEditor import TriggerEditor
+##from gnue.designer.DataSourceEditor import DataSourceEditor
+##from gnue.designer.SchemaViewer import SchemaViewer
+
+##from PopupMenu import ObjectMenu
+
+from gnue.navigator import GNParser, GNObjects
+
+
+class Document(BaseDocument):
+
+ def init(self):
+ self.incubator = Incubator(self)
+ self.properties = navProperties
+
+ def loadBuffer(self, buffer):
+ object = GNParser.loadProcesses (buffer, initialize=0)
+## object.name = 'processes'
+ return object
+
+
+ def loadEmpty(self, style=None):
+ object = GNObjects.GNProcesses()
+ object.title = "Untitled Process"
+ return object
+
+
+ def inventoryObject(self, object):
+ pass
+
+
+ def createVisualEditor(self):
+ return LayoutEditor(self, self.rootObject, self)
+
+
+ def createTools(self):
+ pass
+## self.addTool('propertyEditor','Property Inspector', PropertyEditor)
+## self.addToolol('treeEditor','Object Navigator', TreeView)
+## self.addTool('triggerEditor','Event Editor', TriggerEditor)
+## self.addTool('datasourceEditor','Data Source Editor', DataSourceEditor)
+## self.addTool('schemaViewer','Schema Navigator', SchemaViewer)
+
+ def createWizards(self):
+ self.loadWizards(wizards)
+
+ def preSave(self):
+ pass
+
+
+
Deleted: trunk/gnue-designer/src/navigator/Instance.py
===================================================================
--- trunk/gnue-designer/src/navigator/Instance.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/navigator/Instance.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -1,91 +0,0 @@
-#
-# This file is part of GNU Enterprise.
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# Copyright 2001-2006 Free Software Foundation
-#
-# FILE:
-# navigator/Instance.py
-#
-# DESCRIPTION:
-# Creates a "Navigator" instance
-#
-# NOTES:
-#
-
-from gnue.designer.navigator import properties as navProperties
-from gnue.designer.base.Instance import BaseInstance
-from Incubator import Incubator
-
-# Tool support...
-from LayoutEditor import LayoutEditor
-##from gnue.designer.TreeView import TreeView
-##from gnue.designer.PropertyEditor import PropertyToolFrame
-##from gnue.designer.TriggerEditor import TriggerEditor
-##from gnue.designer.DataSourceEditor import DataSourceEditor
-##from gnue.designer.SchemaViewer import SchemaViewer
-
-##from PopupMenu import ObjectMenu
-
-from gnue.navigator import GNParser, GNObjects
-
-
-class Instance(BaseInstance):
-
- def __init__(self, app, *args, **params):
- self.incubator = Incubator(self)
- self.properties = navProperties
-
- BaseInstance.__init__(self, app, *args, **params)
-
-
- def loadBuffer(self, buffer):
- object = GNParser.loadProcesses (buffer, initialize=0)
-## object.name = 'processes'
- return object
-
-
- def loadEmpty(self, style=None):
- object = GNObjects.GNProcesses()
- object.title = "Untitled Process"
- return object
-
-
- def inventoryObject(self, object):
- pass
-
-
- def createVisualEditor(self):
- return LayoutEditor(self, self.rootObject, self)
-
-
- def createTools(self):
- pass
-## self.addTool('propertyEditor','Property Inspector', PropertyEditor)
-## self.addToolol('treeEditor','Object Navigator', TreeView)
-## self.addTool('triggerEditor','Event Editor', TriggerEditor)
-## self.addTool('datasourceEditor','Data Source Editor', DataSourceEditor)
-## self.addTool('schemaViewer','Schema Navigator', SchemaViewer)
-
- def createWizards(self):
- self.loadWizards(wizards)
-
- def preSave(self):
- pass
-
-
-
Modified: trunk/gnue-designer/src/reports/Char/FilterSupport.py
===================================================================
--- trunk/gnue-designer/src/reports/Char/FilterSupport.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/reports/Char/FilterSupport.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -37,7 +37,7 @@
def init(self):
# EventAware provided by ToolBase
- self.instance.registerEventListeners({
+ self.document.registerEventListeners({
'ObjectCreated' : self.onCreateObject,
'ObjectModified' : self.onModifyObject,
'ObjectDeleted' : self.onDeleteObject,
@@ -45,7 +45,7 @@
def addTools(self):
- self.instance.addTool('visualEditor', _('Layout Editor'), LayoutEditor,
+ self.document.addTool('visualEditor', _('Layout Editor'), LayoutEditor,
hotkey='F11', menuGroup=301)
Modified: trunk/gnue-designer/src/reports/Char/LayoutEditor.py
===================================================================
--- trunk/gnue-designer/src/reports/Char/LayoutEditor.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/reports/Char/LayoutEditor.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -43,9 +43,9 @@
self.backcolor = wx.WHITE
self.panel = wx.Panel(self,-1,style=wx.SIMPLE_BORDER, pos=wx.Point(6,6))
self.panelColor = self.GetBackgroundColour()
- self._instance = self.instance
- self.rootObject = self.instance.rootObject
- self._app = self.instance._app
+ self._instance = self.document
+ self.rootObject = self.document.rootObject
+ self.app = self.document.app
self.rootObject.walk(self.inventoryObject)
# EventAware provided by ToolBase
Copied: trunk/gnue-designer/src/reports/Document.py (from rev 8208,
trunk/gnue-designer/src/reports/Instance.py)
===================================================================
--- trunk/gnue-designer/src/reports/Instance.py 2006-03-06 14:54:02 UTC (rev
8208)
+++ trunk/gnue-designer/src/reports/Document.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -0,0 +1,175 @@
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Copyright 2001-2006 Free Software Foundation
+#
+# FILE:
+# reports/Instance.py
+#
+# DESCRIPTION:
+# Creates a "report" instance
+#
+# NOTES:
+#
+
+from gnue.designer.reports import properties as reportsProperties
+from gnue.designer.base.Document import BaseDocument
+from gnue.common.utils.FileUtils import dyn_import
+from gnue.common.apps import GDebug
+import wizards
+
+# Tool support...
+from TreeView import TreeView
+from gnue.designer.base.tools.PropertyEditor import PropertyEditor
+from gnue.designer.base.tools.DataSourceEditor import DataSourceEditor
+from gnue.designer.base.tools.SchemaViewer import SchemaViewer
+from gnue.designer.base.tools.TriggerEditor import TriggerEditor
+from gnue.designer.base.tools.EventEditor import EventEditor
+
+from gnue.reports.base import GRReport, GRParser, GRSources, GRParameters,
GRSortOptions
+from gnue.reports.base import layout as GRLayout
+
+
+class Document(BaseDocument):
+
+ def init(self):
+ self.properties = reportsProperties
+
+ report = self.rootObject
+ report._parameters = report.findChildOfType('GRParameters') or \
+ self.incubator.createObject(report, 'parameters', report, select=0)
+ report._sortoptions = report.findChildOfType('GRSortOptions') or \
+ self.incubator.createObject(report, 'sortoptions', report, select=0)
+ report._sources = report.findChildOfType('GRSources') or \
+ self.incubator.createObject(report, 'sources', report, select=0)
+ report._layout = report.findChildOfType('GRLayout') or \
+ self.incubator.createObject(report, 'layout', report, select=0)
+
+
+ def loadBuffer(self, buffer):
+ report = GRParser.loadFile (buffer, self, initialize=0)
+ report.name = 'report'
+
+ # Find which filter is in use... yes, this is ugly
+ namespace = report.findChildOfType('GRLayout')._findNamespace()
+ filter = namespace.split(':')[-1]
+
+ try:
+ filtersupport = dyn_import('gnue.designer.reports.%s.FilterSupport' %
filter)
+ usingDefault = 0
+ except ImportError:
+ assert gDebug(2,'No filter support for %s; using default')
+ filtersupport = dyn_import('gnue.designer.reports.Default.FilterSupport')
+ usingDefault = 1
+
+ self.filter = filtersupport.FilterSupport(self, report)
+
+ if usingDefault:
+ self.filter.setNamespace(namespace)
+
+ self.incubator = self.filter.INCUBATORCLASS(self)
+
+ return report
+
+
+ def loadEmpty(self, style=None):
+ report = GRReport.GRReport()
+ report.title = "Untitled report"
+ report.name = 'report'
+ GRParameters.GRParameters(report)._buildObject()
+ GRSortOptions.GRSortOptions(report)._buildObject()
+ GRSources.GRSources(report)._buildObject()
+ GRLayout.GRLayout(report)._buildObject()
+
+ # Find which filter is in use... yes, this is ugly
+ namespace = style or "GNUe:Reports:Standard"
+ filter = (namespace).split(':')[-1]
+
+ try:
+ filtersupport = dyn_import('gnue.designer.reports.%s.FilterSupport' %
filter)
+ usingDefault = 0
+ except ImportError:
+ assert gDebug(2,'No filter support for %s; using default')
+ filtersupport = dyn_import('gnue.designer.reports.Default.FilterSupport')
+ usingDefault = 1
+
+ self.filter = filtersupport.FilterSupport(self, report)
+
+ if usingDefault:
+ self.filter.setNamespace(namespace)
+
+ self.incubator = self.filter.INCUBATORCLASS(self)
+
+ self.filter.initAsNew()
+
+ report._buildObject()
+ return report
+
+
+ def inventoryObject(self, object):
+ pass
+
+
+ def createTools(self):
+ self.addTool('propertyEditor', _('Property Inspector'), PropertyEditor,
+ hotkey='F10', menuGroup=301)
+ self.addTool('treeEditor', _('Object Navigator'), TreeView,
+ hotkey='F8', menuGroup=301)
+ self.addTool('schemaViewer', _('Schema Navigator'), SchemaViewer,
+ menuGroup=301)
+
+ self.addTool('datasourceEditor',_('Data Source Editor'), DataSourceEditor,
+ hotkey='F9', menuGroup=311)
+ #self.addTool('groupEditor', _('Group Editor'), GroupEditor,
+ # hotkey='F5', menuGroup=311)
+ #self.addTool('fieldEditor', _('Field Editor'), FieldEditor,
+ # hotkey='F6', menuGroup=311)
+
+ self.addTool('eventEditor', _('Trigger Inspector'), EventEditor,
+ hotkey='F7', menuGroup=321)
+ self.addTool('triggerEditor', _('Code Editor'), TriggerEditor,
+ hotkey='F12', menuGroup=321)
+
+ # Add filter-specific tools
+ self.filter.addTools()
+
+
+ def createWizards(self):
+ self.loadWizards(wizards)
+
+ # Used by TemplateParser to build a wizard.current dict
+ def buildWizardCurrentDict(self):
+ report = self.rootObject
+ return { 'report': report,
+ 'sources': report._sources,
+ 'parameters': report._parameters,
+ 'layout': report._layout,
+ 'sortoptions': report._sortoptions,
+ 'object': self._currentObject }
+
+ def preSave(self):
+
+ # Resort the main sections to a logical order
+ report = self.rootObject
+ for o in [report._parameters, report._sortoptions,
+ report._sources, report._layout]:
+ report._children.pop(report._children.index(o))
+ if len(o._children):
+ report._children.append(o)
+
+
Modified: trunk/gnue-designer/src/reports/FilterSupport.py
===================================================================
--- trunk/gnue-designer/src/reports/FilterSupport.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/reports/FilterSupport.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -33,7 +33,7 @@
INCUBATORCLASS = _Incubator
def __init__(self, instance, report):
- self.instance = instance
+ self.document = instance
self.report = report
self.init()
Modified: trunk/gnue-designer/src/reports/Incubator.py
===================================================================
--- trunk/gnue-designer/src/reports/Incubator.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/reports/Incubator.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -42,9 +42,9 @@
if tag.find(':')+1:
o = self._handlePassThru(rootObject, tag, parent, attributes, select)
if o:
- self.instance.dispatchEvent('ObjectCreated',object=o,
originator=__name__)
+ self.document.dispatchEvent('ObjectCreated',object=o,
originator=__name__)
if select:
- self.instance.dispatchEvent('ObjectSelected',object=object,
originator=__name__)
+ self.document.dispatchEvent('ObjectSelected',object=object,
originator=__name__)
return o
else:
return BaseIncubator.createObject(self, rootObject, tag, parent,
attributes, select)
@@ -83,6 +83,6 @@
o._xmlnamespace = rootObject.findChildOfType('GRLayout')._xmlchildnamespace
o.name = name
- self.instance.nameMappings[o.name] = o
+ self.document.nameMappings[o.name] = o
o._buildObject()
return o
Deleted: trunk/gnue-designer/src/reports/Instance.py
===================================================================
--- trunk/gnue-designer/src/reports/Instance.py 2006-03-06 20:23:30 UTC (rev
8209)
+++ trunk/gnue-designer/src/reports/Instance.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -1,179 +0,0 @@
-#
-# This file is part of GNU Enterprise.
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# Copyright 2001-2006 Free Software Foundation
-#
-# FILE:
-# reports/Instance.py
-#
-# DESCRIPTION:
-# Creates a "report" instance
-#
-# NOTES:
-#
-
-from gnue.designer.reports import properties as reportsProperties
-from gnue.designer.base.Instance import BaseInstance
-from gnue.common.utils.FileUtils import dyn_import
-from gnue.common.apps import GDebug
-import wizards
-
-# Tool support...
-from TreeView import TreeView
-from gnue.designer.base.tools.PropertyEditor import PropertyEditor
-from gnue.designer.base.tools.DataSourceEditor import DataSourceEditor
-from gnue.designer.base.tools.SchemaViewer import SchemaViewer
-from gnue.designer.base.tools.TriggerEditor import TriggerEditor
-from gnue.designer.base.tools.EventEditor import EventEditor
-
-from gnue.reports.base import GRReport, GRParser, GRSources, GRParameters,
GRSortOptions
-from gnue.reports.base import layout as GRLayout
-
-
-class Instance(BaseInstance):
-
- def __init__(self, app, *args, **params):
- self.properties = reportsProperties
-
- #self._tableMappings = {}
- BaseInstance.__init__(self, app, *args, **params)
-
- report = self.rootObject
- report._parameters = report.findChildOfType('GRParameters') or \
- self.incubator.createObject(report, 'parameters', report, select=0)
- report._sortoptions = report.findChildOfType('GRSortOptions') or \
- self.incubator.createObject(report, 'sortoptions', report, select=0)
- report._sources = report.findChildOfType('GRSources') or \
- self.incubator.createObject(report, 'sources', report, select=0)
- report._layout = report.findChildOfType('GRLayout') or \
- self.incubator.createObject(report, 'layout', report, select=0)
-
-
-
- def loadBuffer(self, buffer):
- report = GRParser.loadFile (buffer, self, initialize=0)
- report.name = 'report'
-
- # Find which filter is in use... yes, this is ugly
- namespace = report.findChildOfType('GRLayout')._findNamespace()
- filter = namespace.split(':')[-1]
-
- try:
- filtersupport = dyn_import('gnue.designer.reports.%s.FilterSupport' %
filter)
- usingDefault = 0
- except ImportError:
- assert gDebug(2,'No filter support for %s; using default')
- filtersupport = dyn_import('gnue.designer.reports.Default.FilterSupport')
- usingDefault = 1
-
- self.filter = filtersupport.FilterSupport(self, report)
-
- if usingDefault:
- self.filter.setNamespace(namespace)
-
- self.incubator = self.filter.INCUBATORCLASS(self)
-
- return report
-
-
- def loadEmpty(self, style=None):
- report = GRReport.GRReport()
- report.title = "Untitled report"
- report.name = 'report'
- GRParameters.GRParameters(report)._buildObject()
- GRSortOptions.GRSortOptions(report)._buildObject()
- GRSources.GRSources(report)._buildObject()
- GRLayout.GRLayout(report)._buildObject()
-
- # Find which filter is in use... yes, this is ugly
- namespace = style or "GNUe:Reports:Standard"
- filter = (namespace).split(':')[-1]
-
- try:
- filtersupport = dyn_import('gnue.designer.reports.%s.FilterSupport' %
filter)
- usingDefault = 0
- except ImportError:
- assert gDebug(2,'No filter support for %s; using default')
- filtersupport = dyn_import('gnue.designer.reports.Default.FilterSupport')
- usingDefault = 1
-
- self.filter = filtersupport.FilterSupport(self, report)
-
- if usingDefault:
- self.filter.setNamespace(namespace)
-
- self.incubator = self.filter.INCUBATORCLASS(self)
-
- self.filter.initAsNew()
-
- report._buildObject()
- return report
-
-
- def inventoryObject(self, object):
- pass
-
-
- def createTools(self):
- self.addTool('propertyEditor', _('Property Inspector'), PropertyEditor,
- hotkey='F10', menuGroup=301)
- self.addTool('treeEditor', _('Object Navigator'), TreeView,
- hotkey='F8', menuGroup=301)
- self.addTool('schemaViewer', _('Schema Navigator'), SchemaViewer,
- menuGroup=301)
-
- self.addTool('datasourceEditor',_('Data Source Editor'), DataSourceEditor,
- hotkey='F9', menuGroup=311)
- #self.addTool('groupEditor', _('Group Editor'), GroupEditor,
- # hotkey='F5', menuGroup=311)
- #self.addTool('fieldEditor', _('Field Editor'), FieldEditor,
- # hotkey='F6', menuGroup=311)
-
- self.addTool('eventEditor', _('Trigger Inspector'), EventEditor,
- hotkey='F7', menuGroup=321)
- self.addTool('triggerEditor', _('Code Editor'), TriggerEditor,
- hotkey='F12', menuGroup=321)
-
- # Add filter-specific tools
- self.filter.addTools()
-
-
- def createWizards(self):
- self.loadWizards(wizards)
-
- # Used by TemplateParser to build a wizard.current dict
- def buildWizardCurrentDict(self):
- report = self.rootObject
- return { 'report': report,
- 'sources': report._sources,
- 'parameters': report._parameters,
- 'layout': report._layout,
- 'sortoptions': report._sortoptions,
- 'object': self._currentObject }
-
- def preSave(self):
-
- # Resort the main sections to a logical order
- report = self.rootObject
- for o in [report._parameters, report._sortoptions,
- report._sources, report._layout]:
- report._children.pop(report._children.index(o))
- if len(o._children):
- report._children.append(o)
-
-
Modified: trunk/gnue-designer/src/reports/Standard/FilterSupport.py
===================================================================
--- trunk/gnue-designer/src/reports/Standard/FilterSupport.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/reports/Standard/FilterSupport.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -38,7 +38,7 @@
def init(self):
# EventAware provided by ToolBase
- self.instance.registerEventListeners({
+ self.document.registerEventListeners({
'ObjectCreated' : self.onCreateObject,
'ObjectModified' : self.onModifyObject,
'ObjectDeleted' : self.onDeleteObject,
@@ -50,9 +50,9 @@
def addTools(self):
- self.instance.addToolSeparator()
- self.instance.addTool('groupEditor', _('Group Editor'), GroupEditor,
'F5')
- self.instance.addTool('visualEditor', _('Layout Editor'), LayoutEditor,
+ self.document.addToolSeparator()
+ self.document.addTool('groupEditor', _('Group Editor'), GroupEditor,
'F5')
+ self.document.addTool('visualEditor', _('Layout Editor'), LayoutEditor,
hotkey='F11', menuGroup=301)
Modified: trunk/gnue-designer/src/reports/Standard/LayoutEditor.py
===================================================================
--- trunk/gnue-designer/src/reports/Standard/LayoutEditor.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/reports/Standard/LayoutEditor.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -43,9 +43,9 @@
self.backcolor = wx.WHITE
self.panel = wx.Panel(self,-1,style=wx.SIMPLE_BORDER, pos=wx.Point(6,6))
self.panelColor = self.GetBackgroundColour()
- self._instance = self.instance
- self.rootObject = self.instance.rootObject
- self._app = self.instance._app
+ self._instance = self.document
+ self.rootObject = self.document.rootObject
+ self.app = self.document.app
self.rootObject.walk(self.inventoryObject)
# EventAware provided by ToolBase
Modified: trunk/gnue-designer/src/schema/DiaEditor/VisualEditor.py
===================================================================
--- trunk/gnue-designer/src/schema/DiaEditor/VisualEditor.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/schema/DiaEditor/VisualEditor.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -38,7 +38,7 @@
def init(self):
# basic initialisation
self.object = None
- self._app = self.instance._app
+ self.app = self.document.app
self.dragmode = False
self.tables=[]
@@ -195,7 +195,7 @@
tbl=object.findParentOfType('GSTable')
if tbl!=None:
for i in self.tables:
- if i.instance==tbl:
+ if i.document==tbl:
dc = wx.ClientDC(self.diagram)
self.diagram.PrepareDC(dc)
(w,h)=i.calculateDimensions(dc)
@@ -214,7 +214,7 @@
if object._type=="GSTable":
# search for GSTable and remove the VisualTable assigned to it
for vTbl in self.tables:
- if vTbl.instance==object:
+ if vTbl.document==object:
self.tables.remove(vTbl)
self.refresh()
@@ -222,7 +222,7 @@
# search for GSTable and update corresponding vtable
tbl=object.findParentOfType("GSTable")
for vTbl in self.tables:
- if vTbl.instance==tbl:
+ if vTbl.document==tbl:
dc = wx.MemoryDC()
vTbl.calculateDimensions(dc)
self.refresh()
@@ -341,7 +341,7 @@
# the visual editor should look the same
if object._type=='VisualTable':
- object=object.instance
+ object=object.document
self.dispatchEvent('ObjectSelected', object=object, originator=__name__)
@@ -389,9 +389,9 @@
if dialog.ShowModal() == wx.ID_OK:
tables=self.rootObject.findChildOfType("GSTables")
if tables==None:
- tables = self.instance.incubator.createObject(
+ tables = self.document.incubator.createObject(
self.rootObject, 'tables', self.rootObject)
- self.instance.incubator.createObject(self.rootObject, 'table',
+ self.document.incubator.createObject(self.rootObject, 'table',
tables, {"name":dialog.GetValue()})
dialog.Destroy()
@@ -409,7 +409,7 @@
fields=self.object.findChildOfType("GSFields")
if fields==None:
tbl=self.object.findChildOfType("GSTable")
- fields=self.instance.incubator.createObject(
+ fields=self.document.incubator.createObject(
self.rootObject,'fields', tbl)
params = {"name":dialog.GetValue()}
@@ -418,7 +418,7 @@
else:
params.update({"type":type,"size":4})
- self.instance.incubator.createObject(self.rootObject, 'field',
+ self.document.incubator.createObject(self.rootObject, 'field',
fields,params)
dialog.Destroy()
@@ -427,12 +427,12 @@
tbl=self.object.findParentOfType("GSTable")
indexes=tbl.findChildOfType("GSIndexes")
if indexes==None:
- indexes = self.instance.incubator.createObject(
+ indexes = self.document.incubator.createObject(
self.rootObject, 'indexes', tbl)
- idx=self.instance.incubator.createObject(
+ idx=self.document.incubator.createObject(
self.rootObject, 'index', indexes,
{"name":"%s_%s" % (tbl.name,self.object.name)})
- self.instance.incubator.createObject(self.rootObject, 'index', idx,
+ self.document.incubator.createObject(self.rootObject, 'index', idx,
{"name":self.object.name})
self.refresh()
@@ -440,13 +440,13 @@
tbl=self.object.findParentOfType("GSTable")
indexes=tbl.findChildOfType("GSIndexes")
if indexes==None:
- indexes = self.instance.incubator.createObject(
+ indexes = self.document.incubator.createObject(
self.rootObject, 'indexes',tbl)
- idx=self.instance.incubator.createObject(
+ idx=self.document.incubator.createObject(
self.rootObject, 'index', indexes,
{"name":"%s_%s" % (tbl.name,self.object.name),
"unique":"Y"})
- self.instance.incubator.createObject(self.rootObject, 'index', idx,
+ self.document.incubator.createObject(self.rootObject, 'index', idx,
{"name":self.object.name})
self.refresh()
@@ -461,7 +461,7 @@
if dialog.ShowModal() == wx.ID_OK:
self.object.name=dialog.GetValue()
- self.instance.onModifyObject(self.object,"schema",
+ self.document.onModifyObject(self.object,"schema",
[('name',self.object.name)])
self.refresh()
@@ -475,7 +475,7 @@
pass
def onDelete(self,event):
- self.instance.incubator.deleteObject(self.rootObject, self.object,
firstRun=1)
+ self.document.incubator.deleteObject(self.rootObject, self.object,
firstRun=1)
def onLeftClickEvent(self,event):
Modified: trunk/gnue-designer/src/schema/DiaEditor/VisualTable.py
===================================================================
--- trunk/gnue-designer/src/schema/DiaEditor/VisualTable.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/schema/DiaEditor/VisualTable.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -31,7 +31,7 @@
class VisualTable:
def __init__(self, tableinstance):
- self.instance=tableinstance
+ self.document=tableinstance
self._type='VisualTable'
#self.font = wx.Font(self.textSize, wx.DEFAULT,
wx.NORMAL,wx.NORMAL,0,fontname )
self.pen = wx.BLACK_PEN # wx.Pen(...)
@@ -47,11 +47,11 @@
def calculateDimensions(self,dc):
- (w,h)=dc.GetTextExtent(self.instance.name)
+ (w,h)=dc.GetTextExtent(self.document.name)
self.width=w
self.height=h
self.textheight=h
- fields=self.instance.findChildOfType('GSFields')
+ fields=self.document.findChildOfType('GSFields')
if fields!=None:
for c in fields._children:
(w,h)=dc.GetTextExtent(c.name)
@@ -66,11 +66,11 @@
return (self.width,self.height)
def recalculateDimensions(self,dc):
- (w,h)=dc.GetTextExtent(self.instance.name)
+ (w,h)=dc.GetTextExtent(self.document.name)
self.width=w
self.height=h
self.textheight=h
- fields=self.instance.findChildOfType('GSFields')
+ fields=self.document.findChildOfType('GSFields')
if fields!=None:
for c in fields._children:
(w,h)=dc.GetTextExtent(c.name)
@@ -103,9 +103,9 @@
self.xpos+self.width,self.ypos+self.textheight+24)
# dc.SetFont(self.font)
- dc.DrawText(self.instance.name,self.xpos+10,self.ypos+10)
+ dc.DrawText(self.document.name,self.xpos+10,self.ypos+10)
y=self.ypos+34
- fields=self.instance.findChildOfType('GSFields')
+ fields=self.document.findChildOfType('GSFields')
if fields!=None:
for c in fields._children:
@@ -119,7 +119,7 @@
y=y+self.textheight+5
# check if the table is selected
- if self.instance==current:
+ if self.document==current:
dc.SetPen(self.pen_highlighted)
dc.SetBrush(wx.TRANSPARENT_BRUSH)
dc.DrawRectangle(self.xpos+3,self.ypos+8,
@@ -134,10 +134,10 @@
# cursor in upper part -> return table
hy=self.ypos+34
if y<hy:
- return self.instance
+ return self.document
# cursor in the middle -> return fields
- fields=self.instance.findChildOfType('GSFields')
+ fields=self.document.findChildOfType('GSFields')
if fields!=None:
for c in fields._children:
hy=hy+self.textheight+5
@@ -146,7 +146,7 @@
# cursor at the bottom part -> return table
return self
- return self.instance
+ return self.document
else:
return None
Copied: trunk/gnue-designer/src/schema/Document.py (from rev 8208,
trunk/gnue-designer/src/schema/Instance.py)
===================================================================
--- trunk/gnue-designer/src/schema/Instance.py 2006-03-06 14:54:02 UTC (rev
8208)
+++ trunk/gnue-designer/src/schema/Document.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -0,0 +1,115 @@
+#
+# This file is part of GNU Enterprise.
+#
+# GNU Enterprise is free software; you can redistribute it
+# and/or modify it under the terms of the GNU General Public
+# License as published by the Free Software Foundation; either
+# version 2, or (at your option) any later version.
+#
+# GNU Enterprise is distributed in the hope that it will be
+# useful, but WITHOUT ANY WARRANTY; without even the implied
+# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
+# PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public
+# License along with program; see the file COPYING. If not,
+# write to the Free Software Foundation, Inc., 59 Temple Place
+# - Suite 330, Boston, MA 02111-1307, USA.
+#
+# Copyright 2001-2006 Free Software Foundation
+#
+# FILE:
+# schema/Instance.py
+#
+# DESCRIPTION:
+# Creates a "schema" instance
+#
+# NOTES:
+#
+
+from gnue.designer.schema import properties as schemaProperties
+from gnue.designer.base.Document import BaseDocument
+from gnue.common.datasources import GSchema
+from Incubator import Incubator
+import wizards
+
+# Tool support...
+from LayoutEditor import LayoutEditor
+from TreeView import TreeView
+from TableEditor import TableEditor
+from gnue.designer.base.tools.PropertyEditor import PropertyEditor
+from gnue.designer.base.tools.DataSourceEditor import DataSourceEditor
+##from gnue.designer.base.tools.SchemaViewer import SchemaViewer
+from gnue.designer.base.tools.SchemaNavigator import SchemaNavigator
+from gnue.designer.schema.DiaEditor.VisualEditor import VisualEditor
+
+
+
+class Document(BaseInstance):
+
+ def init(self):
+ self.incubator = Incubator(self)
+ self.properties = schemaPropertiess
+ self._tableMappings = {}
+
+ def loadBuffer(self, buffer):
+ schema = GSchema.loadFile (buffer, self, initialize=0)
+ schema.name = 'schema'
+ return schema
+
+
+ def loadEmpty(self, style=None):
+ schema = GSchema.GSSchema()
+ schema.title = "Untitled schema"
+ schema.name = 'schema'
+ GSchema.GSTables(schema)
+ return schema
+
+
+ def inventoryObject(self, object):
+ if isinstance(object, GSchema.GSTables):
+ self.tables = object
+ elif object._type == 'GSTable':
+ self._tableMappings[object.name] = object
+ object._fieldList = []
+ object._fieldMap = {}
+ elif object._type == 'GSField':
+ table = object.findParentOfType('GSTable')
+ table._fieldList.append(object)
+ table._fieldMap[object.name.lower()] = object
+
+ def createTools(self):
+ self.addTool('tableEditor', _('Table/Field Editor'), TableEditor,
+ hotkey='F11', menuGroup=301)
+ self.addTool('propertyEditor', _('Property Inspector'), PropertyEditor,
+ hotkey='F10', menuGroup=301)
+ self.addTool('treeEditor', _('Object Navigator'), TreeView,
+ hotkey='F8', menuGroup=311)
+
+ self.addTool('schemaNavigator',_('Schema Navigator'), SchemaNavigator,
+ menuGroup=301)
+ self.addTool('visualEditor',_('Visual Editor'), VisualEditor,
+ hotkey='F9', menuGroup=311)
+
+ def createWizards(self):
+ self.loadWizards(wizards)
+
+ def preSave(self):
+ pass
+
+ # Used by TemplateParser to build a wizard.current dict
+ def buildWizardCurrentDict(self):
+ return {'schema': self.rootObject,
+ 'tables': self.tables,
+ 'table': self.tableEditor.table,
+## 'field': self.visualEditor.page,
+ 'object': self._currentObject}
+
+
+## # Hack having to do with UIwxpython import
+## def uiEventTrap(self, event):
+## pass
+
+
+
+
Deleted: trunk/gnue-designer/src/schema/Instance.py
===================================================================
--- trunk/gnue-designer/src/schema/Instance.py 2006-03-06 20:23:30 UTC (rev
8209)
+++ trunk/gnue-designer/src/schema/Instance.py 2006-03-07 00:04:31 UTC (rev
8210)
@@ -1,118 +0,0 @@
-#
-# This file is part of GNU Enterprise.
-#
-# GNU Enterprise is free software; you can redistribute it
-# and/or modify it under the terms of the GNU General Public
-# License as published by the Free Software Foundation; either
-# version 2, or (at your option) any later version.
-#
-# GNU Enterprise is distributed in the hope that it will be
-# useful, but WITHOUT ANY WARRANTY; without even the implied
-# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-# PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public
-# License along with program; see the file COPYING. If not,
-# write to the Free Software Foundation, Inc., 59 Temple Place
-# - Suite 330, Boston, MA 02111-1307, USA.
-#
-# Copyright 2001-2006 Free Software Foundation
-#
-# FILE:
-# schema/Instance.py
-#
-# DESCRIPTION:
-# Creates a "schema" instance
-#
-# NOTES:
-#
-
-from gnue.designer.schema import properties as schemaProperties
-from gnue.designer.base.Instance import BaseInstance
-from gnue.common.datasources import GSchema
-from Incubator import Incubator
-import wizards
-
-# Tool support...
-from LayoutEditor import LayoutEditor
-from TreeView import TreeView
-from TableEditor import TableEditor
-from gnue.designer.base.tools.PropertyEditor import PropertyEditor
-from gnue.designer.base.tools.DataSourceEditor import DataSourceEditor
-##from gnue.designer.base.tools.SchemaViewer import SchemaViewer
-from gnue.designer.base.tools.SchemaNavigator import SchemaNavigator
-from gnue.designer.schema.DiaEditor.VisualEditor import VisualEditor
-
-
-
-class Instance(BaseInstance):
-
- def __init__(self, app, *args, **params):
- self.incubator = Incubator(self)
- self.properties = schemaProperties
-
- self._tableMappings = {}
- BaseInstance.__init__(self, app, *args, **params)
-
-
- def loadBuffer(self, buffer):
- schema = GSchema.loadFile (buffer, self, initialize=0)
- schema.name = 'schema'
- return schema
-
-
- def loadEmpty(self, style=None):
- schema = GSchema.GSSchema()
- schema.title = "Untitled schema"
- schema.name = 'schema'
- GSchema.GSTables(schema)
- return schema
-
-
- def inventoryObject(self, object):
- if isinstance(object, GSchema.GSTables):
- self.tables = object
- elif object._type == 'GSTable':
- self._tableMappings[object.name] = object
- object._fieldList = []
- object._fieldMap = {}
- elif object._type == 'GSField':
- table = object.findParentOfType('GSTable')
- table._fieldList.append(object)
- table._fieldMap[object.name.lower()] = object
-
- def createTools(self):
- self.addTool('tableEditor', _('Table/Field Editor'), TableEditor,
- hotkey='F11', menuGroup=301)
- self.addTool('propertyEditor', _('Property Inspector'), PropertyEditor,
- hotkey='F10', menuGroup=301)
- self.addTool('treeEditor', _('Object Navigator'), TreeView,
- hotkey='F8', menuGroup=311)
-
- self.addTool('schemaNavigator',_('Schema Navigator'), SchemaNavigator,
- menuGroup=301)
- self.addTool('visualEditor',_('Visual Editor'), VisualEditor,
- hotkey='F9', menuGroup=311)
-
- def createWizards(self):
- self.loadWizards(wizards)
-
- def preSave(self):
- pass
-
- # Used by TemplateParser to build a wizard.current dict
- def buildWizardCurrentDict(self):
- return {'schema': self.rootObject,
- 'tables': self.tables,
- 'table': self.tableEditor.table,
-## 'field': self.visualEditor.page,
- 'object': self._currentObject}
-
-
-## # Hack having to do with UIwxpython import
-## def uiEventTrap(self, event):
-## pass
-
-
-
-
Modified: trunk/gnue-designer/src/schema/LayoutEditor.py
===================================================================
--- trunk/gnue-designer/src/schema/LayoutEditor.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/schema/LayoutEditor.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -36,7 +36,7 @@
def init(self):
self.panelColor = self.GetBackgroundColour()
- self._app = instance._app
+ self.app = instance.app
self.rootObject.walk(self.inventoryObject)
# EventAware provided by ToolBase
Modified: trunk/gnue-designer/src/templates/forms/FormBuilder.py
===================================================================
--- trunk/gnue-designer/src/templates/forms/FormBuilder.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/templates/forms/FormBuilder.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -359,7 +359,7 @@
# No more user input is allowed at this point.
#
def Finalize(self):
- self.instance.wizardName = TemplateInformation['Name']
+ self.document.wizardName = TemplateInformation['Name']
logic = self.current['logic']
layout = self.current['layout']
Modified: trunk/gnue-designer/src/templates/forms/Simple.py
===================================================================
--- trunk/gnue-designer/src/templates/forms/Simple.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/templates/forms/Simple.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -158,7 +158,7 @@
# No more user input is allowed at this point.
#
def Finalize(self):
- self.instance.wizardName = TemplateInformation['Name']
+ self.document.wizardName = TemplateInformation['Name']
# We will use the table name as the basis for all our
# object names. We will add a prefix based on the object
Modified: trunk/gnue-designer/src/templates/reports/CharReport.py
===================================================================
--- trunk/gnue-designer/src/templates/reports/CharReport.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/templates/reports/CharReport.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -141,7 +141,7 @@
# No more user input is allowed at this point.
#
def Finalize(self):
- self.instance.wizardName = TemplateInformation['Name']
+ self.document.wizardName = TemplateInformation['Name']
# We will use the table name as the basis for all our
# object names. We will add a prefix based on the object
Modified: trunk/gnue-designer/src/templates/reports/Labels.py
===================================================================
--- trunk/gnue-designer/src/templates/reports/Labels.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/templates/reports/Labels.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -137,7 +137,7 @@
# No more user input is allowed at this point.
#
def Finalize(self):
- self.instance.wizardName = TemplateInformation['Name']
+ self.document.wizardName = TemplateInformation['Name']
# We will use the table name as the basis for all our
# object names. We will add a prefix based on the object
Modified: trunk/gnue-designer/src/templates/reports/MailMerge.py
===================================================================
--- trunk/gnue-designer/src/templates/reports/MailMerge.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/templates/reports/MailMerge.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -137,7 +137,7 @@
# No more user input is allowed at this point.
#
def Finalize(self):
- self.instance.wizardName = TemplateInformation['Name']
+ self.document.wizardName = TemplateInformation['Name']
# We will use the table name as the basis for all our
# object names. We will add a prefix based on the object
Modified: trunk/gnue-designer/src/templates/reports/SimpleReport.py
===================================================================
--- trunk/gnue-designer/src/templates/reports/SimpleReport.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/templates/reports/SimpleReport.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -141,7 +141,7 @@
# No more user input is allowed at this point.
#
def Finalize(self):
- self.instance.wizardName = TemplateInformation['Name']
+ self.document.wizardName = TemplateInformation['Name']
# We will use the table name as the basis for all our
# object names. We will add a prefix based on the object
Modified: trunk/gnue-designer/src/templates/schema/Introspection.py
===================================================================
--- trunk/gnue-designer/src/templates/schema/Introspection.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/templates/schema/Introspection.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -120,7 +120,7 @@
# No more user input is allowed at this point.
#
def Finalize(self):
- self.instance.wizardName = TemplateInformation['Name']
+ self.document.wizardName = TemplateInformation['Name']
# Set the basic attributes of the schema
self.ModifyElement(self.root, title=self.variables['title'])
Modified: trunk/gnue-designer/src/uidrivers/wx/Base.py
===================================================================
--- trunk/gnue-designer/src/uidrivers/wx/Base.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/uidrivers/wx/Base.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -31,25 +31,33 @@
# ---------------------------------------------------------------------------
# Python Imports
# ---------------------------------------------------------------------------
-import sys, os, string
+import sys
+import os
+import string
+# ---------------------------------------------------------------------------
+# GNUe Imports
+# ---------------------------------------------------------------------------
+from gnue.forms.uidrivers.wx.GFwxApp import setWxApp
+from gnue.common.apps import GConfig
# ---------------------------------------------------------------------------
# wx Imports
# ---------------------------------------------------------------------------
-try:
+try: # Force wx2.6 to load
import wxselect
wxselect.wx.VersionFinder.setpath(version="2.6")
except ImportError:
pass
-try:
+try: # Make sure 2.6 did in fact load
import wx
if wx.__version__ < '2.6.1':
raise ImportError
except ImportError:
raise "GNUe Designer requires wxPython 2.6.1 or greater."
+# Issue stability warning for old wx versions
if wx.__version__ < '2.6.2.1':
print
print "*" * 70
@@ -59,12 +67,17 @@
print
-# ---------------------------------------------------------------------------
-# GNUe Imports
-# ---------------------------------------------------------------------------
-from gnue.forms.uidrivers.wx.GFwxApp import setWxApp
+#----------------------------------------------------------------------------
+# Module globals
+#----------------------------------------------------------------------------
+iconlocation = os.path.join(GConfig.getInstalledBase(
+ 'designer_images','common_images') ,'designer')
+
+# ======================================================================
+# UI base class
+# ======================================================================
class UIBase(wx.App):
@@ -82,7 +95,7 @@
# This has to happen after setWxApp, otherwise bad things happen
from gnue.forms.uidrivers.wx import UILoginHandler
self.app.getConnectionManager().setLoginHandler(UILoginHandler())
-
+
# Call wx's MainLoop
self.app.init()
@@ -96,6 +109,24 @@
from Instance import Instance
return Instance(instance)
+
+ def getIcon(self, name, w, h):
+ path = os.path.join(iconlocation,"%s-%sx%s.png" % (name,w, h))
+ if not os.path.exists(path):
+ return None
+ return wx.Image(path,
+ wx.BITMAP_TYPE_PNG).ConvertToBitmap()
+
+ def autoSizer(self, parent, child, direction=wx.VERTICAL):
+ box = wx.BoxSizer(wx.VERTICAL)
+ box.Add(child, 2, wx.EXPAND)
+
+ parent.SetAutoLayout(True)
+ parent.SetSizer(box)
+ parent.Layout()
+
+
+
#---------------------------------------------------------------------
# Startup Splash Screen
#---------------------------------------------------------------------
Modified: trunk/gnue-designer/src/uidrivers/wx/Instance.py
===================================================================
--- trunk/gnue-designer/src/uidrivers/wx/Instance.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/uidrivers/wx/Instance.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -28,67 +28,70 @@
# NOTES:
#
+#----------------------------------------------------------------------------
+# System imports
+#----------------------------------------------------------------------------
+import os
+
+#----------------------------------------------------------------------------
+# External Imports
+#----------------------------------------------------------------------------
import wx
+
+#----------------------------------------------------------------------------
+# GNUe Imports
+#----------------------------------------------------------------------------
+from gnue.common.apps import RuntimeSettings
from gnue.designer.base import Goat
-from gnue.common.apps import RuntimeSettings
-
-
from gnue.designer import PACKAGE as TITLE
-
from gnue.designer.base.PrimaryToolBar import PrimaryToolBar
from uihelpers import PyAUI
from uihelpers import NotebookCtrl
-
from MenuBar import MenuBar
-class Instance(wx.Frame):
- def __init__(self, instance):
- wx.Frame.__init__(self, None, -1, "", style=wx.DEFAULT_FRAME_STYLE |
- wx.SUNKEN_BORDER |
- wx.CLIP_CHILDREN)
- # Setup PyAUI
- self._mgr = PyAUI.FrameManager(self)
- self._mgr.SetFrame(self)
+#----------------------------------------------------------------------------
+# Module globals
+#----------------------------------------------------------------------------
- self.instance = instance
+# Determine the format for the application window's title
+# (%s will be replaced with the document name)
+if wx.Platform == "__WXMAC__":
+ title_saved_format = '%s'
+ title_unsaved_format = '%s (*)'
+elif wx.Platform == "__WXMSW__":
+ title_saved_format = '%s - GNUe Designer'
+ title_unsaved_format = '%s* - GNUe Designer'
+else:
+ title_saved_format = '%s - GNUe Designer'
+ title_unsaved_format = '%s - GNUe Designer [modified]'
- # Set our icon
- icon = Goat.getGoatIcon()
- self.SetIcon(icon)
+#============================================================================
+# UI Instance class
+#============================================================================
+class Instance(wx.Frame):
- # Just a sane default...
- self.SetMinSize(wx.Size(400, 300))
- self.toolbar = PrimaryToolBar(self, self.instance)
- self.SetToolBar(self.toolbar)
-
- self.statusbar = self.CreateStatusBar()
- self.SetStatusText(_('Welcome to GNUe Designer.'))
-
- self._mgr.AddPane(self.toolbar, PyAUI.PaneInfo().
- Name("PrimaryToolBar").Caption("GNUe Designer").
- ToolbarPane().Top())
-
-
- wx.EVT_CLOSE(self, self.instance.OnClose)
-
- # I think PyAUI requires this...
- #self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
-
- self.currentPrimaryEditor = None
-
-
- def OnEraseBackground(self, event):
- event.Skip()
-
+ #==========================================================================
+ # Public Methods
+ #==========================================================================
+
def createMenuBar(self):
- menuBar = MenuBar(self.instance)
+ """
+ Called by base.Instance to create a menu bar
+ """
+ menuBar = MenuBar(self.document)
self.SetMenuBar(menuBar)
return menuBar
- def setTitle(self, title):
- self.SetTitle(TITLE + " - " + title)
+ def setTitle(self, title, unsaved=False):
+ """
+ Set the application's title
+ """
+ if unsaved:
+ self.SetTitle(title_unsaved_format % title)
+ else:
+ self.SetTitle(title_saved_format % title)
def show(self):
self.Show(True)
@@ -97,35 +100,83 @@
self.Show(False)
def finalize(self):
+ """
+ Called by the base instance
+ when all tools/etc have been initialized.
+ We can assume the UI is ready for display at this point
+ """
+
# Build accelerator list
- accel = wx.AcceleratorTable(self.instance.globalAccelerators)
- for child in [self] + self.instance.globalAcceleratorListeners:
+ accel = wx.AcceleratorTable(self.document.globalAccelerators)
+ for child in [self] + self.document.globalAcceleratorListeners:
child.SetAcceleratorTable(accel)
+ # TODO: debugging PyAUI... these may not be needed
# # Fit the widgets to the screen
# self.Fit()
# self.SetSize((
-# RuntimeSettings.getint(self.instance.runtime_section, 'width', 550),
-# RuntimeSettings.getint(self.instance.runtime_section, 'height', 400)))
+# RuntimeSettings.getint(self.document.runtime_section, 'width', 550),
+# RuntimeSettings.getint(self.document.runtime_section, 'height', 400)))
# self.SetPosition((
-# RuntimeSettings.getint(self.instance.runtime_section, 'x', -1),
-# RuntimeSettings.getint(self.instance.runtime_section, 'y', -1)))
+# RuntimeSettings.getint(self.document.runtime_section, 'x', -1),
+# RuntimeSettings.getint(self.document.runtime_section, 'y', -1)))
- perspective = RuntimeSettings.get(self.instance.runtime_section,
'aui-perspective','')
+ # Add the toolbar to the PyAUI manager
+ self._auiMgr.AddPane(self.toolbar, PyAUI.PaneInfo().
+ Name("PrimaryToolBar").Caption("GNUe Designer").
+ ToolbarPane().Top())
+
+ perspective = RuntimeSettings.get(self.document.runtime_section,
'aui-perspective','')
if perspective:
- self._mgr.LoadPerspective(perspective)
+ self._auiMgr.LoadPerspective(perspective)
- self._mgr.Update()
+ self._auiMgr.Update()
self.Show(True)
- # Removing this refresh causes a segfault??
- self.Refresh()
+ # Removing this refresh causes a segfault,
+ # but the PyAUI examples don't have it??
+ self.Layout()
+
+
+ def createEditor(self, object, baseclass):
+ """
+ Create a new editor instance for a GObject
+
+ object: GObject instance
+ baseclass: a ToolBase-derived class that will be instantiated
+ """
+ tool = baseclass(object, self.document, self.editNotebook)
+
+ if tool.icon in self._editorIconList:
+ iconIndex = self._editorIconList.index(tool.icon)
+ else:
+ icon = self.document.app.ui.getIcon('editor_' + tool.icon,16,16)
+ if not icon:
+ print "WARNING: No icon named editor_%s-%sx%s.png" % (tool.icon, 16,16)
+ iconIndex = -1
+ else:
+ iconIndex = len(self._editorIconList)
+ self._editorIconList.append(tool.icon)
+ print "Adding icon for %s" % tool.icon
+ print icon.GetWidth(), icon.GetHeight()
+ self._editorIcons.Add(icon)
+
+ object._editorComponent = tool
+ page = self.editNotebook.AddPage(tool, tool._caption, False, iconIndex)
+
+ def close(self):
+ self.Destroy()
+
+ def setStatus(self, text):
+ self.statusbar.SetStatusText(text)
+
+
# -------------------------------------------------------------------------
- #
+ # Create the tools
# -------------------------------------------------------------------------
def initTools(self):
self.tools = []
@@ -133,16 +184,41 @@
# Create a center notebook pane
self.editNotebook = notebook = NotebookCtrl.NotebookCtrl(
self,-1)
- notebook.SetMinSize((200,200))
- self._mgr.AddPane(notebook,
PyAUI.PaneInfo().Name('Editor').Caption('Editor').CenterPane())
+ notebook.SetImageList(self._editorIcons)
+ notebook.EnableHiding()
+ notebook.SetHighlightSelection()
+ #notebook.SetUseFocusIndicator()
+ notebook.SetDrawX(style=2)
+ #notebook.SetImageToCloseButton()
+ #notebook.SetTabHeight(20)
+ notebook.EnableTabGradients()
+ self._auiMgr.AddPane(notebook, PyAUI.PaneInfo().Name('Editor').\
+ Caption('Editor').CenterPane())
#.MaxSize(10000,10000).MinSize(100,50))
-
+ ##TODO: Experimenting with tabs at the top...
+ ##TODO: Commenting out until
+ ##notebooktabs = wx.Panel(self, -1)
+ ##self._auiMgr.AddPane(notebooktabs, PyAUI.PaneInfo().Name('Notebook
Tabs').\
+ ## Caption('Pages').CaptionVisible(False).Top()) #
.Floatable(False).Movable(False))
+ ##
+ ### This uses internal knowledge of NotebookCtrl to reparent the
+ ### tab controls to their own dock
+ ##notebook.nb.Reparent(notebooktabs)
+ ##notebook.sizer.Remove(notebook.nb)
+ ##box = wx.BoxSizer(wx.VERTICAL)
+ ##box.Add(notebook.nb, 2, wx.EXPAND)
+ ##
+ ##notebooktabs.SetAutoLayout(True)
+ ##notebooktabs.SetSizer(box)
+ ##notebooktabs.Layout()
+
+
#
# Add each tool
#
leftrow = 0
rightrow = 0
- for id, title, baseclass, hotkey, group in self.instance._toolCache:
+ for id, title, baseclass, hotkey, group in self.document._toolCache:
assert gDebug(2,'Adding tool %s [%s]' % (title,id))
@@ -152,22 +228,24 @@
pos, indx = pos.split('-')
indx = int(indx)
- tool = baseclass(id, title, self.instance, self.instance.rootObject,
self)
+ tool = baseclass(id, title, self.document, self.document.rootObject,
self)
- tool._docked = RuntimeSettings.getint(self.instance.runtime_section,
'%s-docked' % id, pos != 'frame')
- tool._dock_location = RuntimeSettings.get(self.instance.runtime_section,
'%s-location' % id, (pos == 'frame' and 'left' or pos))
- tool._dock_index = RuntimeSettings.getint(self.instance.runtime_section,
'%s-index' % id, indx)
- tool._visible = RuntimeSettings.getint(self.instance.runtime_section,
'%s-visible' % id, tool.default_visible)
- tool._frame_x = RuntimeSettings.getint(self.instance.runtime_section,
'%s-frame-x' % id, -1)
- tool._frame_y = RuntimeSettings.getint(self.instance.runtime_section,
'%s-frame-y' % id, -1)
- tool._frame_width =
RuntimeSettings.getint(self.instance.runtime_section, '%s-frame-width' % id,
200)
- tool._frame_height =
RuntimeSettings.getint(self.instance.runtime_section, '%s-frame-height' % id,
150)
+ # TODO: this isn't compatable with PyAUI
+ tool._docked = RuntimeSettings.getint(self.document.runtime_section,
'%s-docked' % id, pos != 'frame')
+ tool._dock_location = RuntimeSettings.get(self.document.runtime_section,
'%s-location' % id, (pos == 'frame' and 'left' or pos))
+ tool._dock_index = RuntimeSettings.getint(self.document.runtime_section,
'%s-index' % id, indx)
+ tool._visible = RuntimeSettings.getint(self.document.runtime_section,
'%s-visible' % id, tool.default_visible)
+ tool._frame_x = RuntimeSettings.getint(self.document.runtime_section,
'%s-frame-x' % id, -1)
+ tool._frame_y = RuntimeSettings.getint(self.document.runtime_section,
'%s-frame-y' % id, -1)
+ tool._frame_width =
RuntimeSettings.getint(self.document.runtime_section, '%s-frame-width' % id,
200)
+ tool._frame_height =
RuntimeSettings.getint(self.document.runtime_section, '%s-frame-height' % id,
150)
appd = (id, title, baseclass, hotkey, pos)
- tool.SetMinSize((40,40))
-
- toolinfo = PyAUI.PaneInfo().Name(title).Caption(title)
+ toolinfo = PyAUI.PaneInfo().Name(title).Caption(title) #.\
+ #MinSize(100,100)).PinButton().MinimizeButton().CloseButton().\
+ #Floatable().Dockable().MaxSize(10000,10000)
+
if tool._docked:
# Docked type
if tool._dock_location == 'right':
@@ -181,18 +259,18 @@
if not tool._visible:
toolinfo.Hide()
- self._mgr.AddPane(tool, toolinfo)
+ self._auiMgr.AddPane(tool, toolinfo)
# Keep track of the tools we created
self.tools.append(tool)
# Add ourselves to the Window menu
- self.instance.menubar.addAction(location='View', text=title,
event='Tool:' + id,
+ self.document.menubar.addAction(location='View', text=title,
event='Tool:' + id,
grouping=group, canToggle=1, canDisable=0,
icon=None, hotkey=hotkey)
- self.instance.__dict__[id] = tool
+ self.document.__dict__[id] = tool
# if tool._visible:
# instance.dispatchEvent('Show:Tool:%s' % id)
@@ -200,21 +278,10 @@
# instance.dispatchEvent('Hide:Tool:%s' % id)
#
- def createEditor(self, object, id, title, baseclass):
- """
- Create a new editor instance for a GObject
- """
- tool = baseclass(object, id, title, self.instance,
- self.instance.rootObject, self.editNotebook)
- print " ** Adding %s" % title
- object._editorComponent = tool
- page = self.editNotebook.AddPage(tool, tool._caption, False, -1)
-
-
# -------------------------------------------------------------------------
- #
+ # Runtime settings support
# -------------------------------------------------------------------------
# Used by RuntimeSettings
def getRuntimeSettings(self):
@@ -227,11 +294,61 @@
return settings
- # -------------------------------------------------------------------------
- #
- # -------------------------------------------------------------------------
- def close(self):
- self.Destroy()
- def setStatus(self, text):
- self.statusbar.SetStatusText(text)
+ #==========================================================================
+ # Private Methods
+ #==========================================================================
+ def __init__(self, instance):
+ wx.Frame.__init__(self, None, -1, "", style=wx.DEFAULT_FRAME_STYLE |
+ wx.SUNKEN_BORDER |
+ wx.CLIP_CHILDREN)
+
+ self.document = instance
+
+
+ # Setup PyAUI (the docking framework)
+ self._auiMgr = PyAUI.FrameManager(self)
+ self._auiMgr.SetFrame(self)
+ self._auiMgr.SetDockArt(MyDockArt())
+
+ # Set our icon
+ icon = Goat.getGoatIcon()
+ self.SetIcon(icon)
+
+ # Just a sane default...
+ self.SetMinSize(wx.Size(400, 300))
+
+ # Create the status bar
+ self.statusbar = self.CreateStatusBar()
+ self.SetStatusText(_('Welcome to GNUe Designer.'))
+
+ # Add the primary tool bar to the tool pane
+ # DO NOT CALL self.SetToolbar, as it botches PyAUI
+ self.toolbar = PrimaryToolBar(self, self.document)
+
+ # Let our base instance class handle closing the instance
+ # TODO: This should actually catch the event and issue a GNUe event
+ wx.EVT_CLOSE(self, self.document._OnClose)
+
+ # I think PyAUI requires this...
+ # (at least the demo code does)
+ self.Bind(wx.EVT_ERASE_BACKGROUND, self._onEraseBackground)
+
+ # Miscellaneous variables used by other functions in this class...
+
+ # Create an icon list for use by createEditor
+ self._editorIcons = wx.ImageList(16, 16, True, 0)
+ self._editorIconList = []
+
+
+ def _onEraseBackground(self, event):
+ event.Skip()
+
+
+#============================================================================
+# Our own PyAUI dock decorator
+#============================================================================
+class MyDockArt(PyAUI.DefaultDockArt):
+ def __init__(self, *arg, **parm):
+ PyAUI.DefaultDockArt.__init__(self, *arg, **parm)
+ self.SetFont(PyAUI.AUI_ART_CAPTION_FONT, wx.Font(9, wx.DEFAULT, wx.NORMAL,
wx.NORMAL, False))
\ No newline at end of file
Modified: trunk/gnue-designer/src/uidrivers/wx/MenuBar.py
===================================================================
--- trunk/gnue-designer/src/uidrivers/wx/MenuBar.py 2006-03-06 20:23:30 UTC
(rev 8209)
+++ trunk/gnue-designer/src/uidrivers/wx/MenuBar.py 2006-03-07 00:04:31 UTC
(rev 8210)
@@ -33,7 +33,7 @@
class MenuBar(wx.MenuBar):
def __init__(self, instance):
wx.MenuBar.__init__(self)
- self.instance = instance
+ self.document = instance
self._locationToWx= {}
@@ -64,18 +64,18 @@
item = wx.MenuItem(menu, mid, text, help,
(canToggle and [wx.ITEM_CHECK] or [wx.ITEM_NORMAL])[0])
if canToggle:
- wx.EVT_MENU(self.instance.base.ui, mid,
- lambda event, l=self.instance, m=item, e=action, x=eventdata:
+ wx.EVT_MENU(self.document.ui, mid,
+ lambda event, l=self.document, m=item, e=action, x=eventdata:
l.dispatchEvent('%s:%s' % (m.IsChecked() and 'Show' or
'Hide',e), **x))
- self.instance.registerEventListeners( {
+ self.document.registerEventListeners( {
'Show:%s' % action: lambda event, m=item: m.Check(1),
'Hide:%s' % action: lambda event, m=item: m.Check(0) })
else:
- wx.EVT_MENU(self.instance.base.ui, mid,
- lambda event, l=self.instance, e=action, x=eventdata:
l.dispatchEvent(e, **x))
+ wx.EVT_MENU(self.document.ui, mid,
+ lambda event, l=self.document, e=action, x=eventdata:
l.dispatchEvent(e, **x))
if canDisable:
- self.instance.registerEventListeners( {
+ self.document.registerEventListeners( {
'Enable:%s' % action: lambda event, m=item: m.Enable(1),
'Disable:%s' % action: lambda event, m=item: m.Enable(0) })
menu.AppendItem(item)
Modified: trunk/gnue-designer/src/uidrivers/wx/uihelpers/GridCellEditors.py
===================================================================
--- trunk/gnue-designer/src/uidrivers/wx/uihelpers/GridCellEditors.py
2006-03-06 20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/uidrivers/wx/uihelpers/GridCellEditors.py
2006-03-07 00:04:31 UTC (rev 8210)
@@ -95,16 +95,16 @@
def IsAcceptedKey(self, evt):
return (not (evt.ControlDown() or evt.AltDown()) and
- evt.GetKeyCode() != WXK_SHIFT)
+ evt.GetKeyCode() != wx.WXK_SHIFT)
def StartingKey(self, evt):
assert gDebug(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)
+ if key in [wx.WXK_NUMPAD0, wx.WXK_NUMPAD1, wx.WXK_NUMPAD2, wx.WXK_NUMPAD3,
wx.WXK_NUMPAD4,
+ wx.WXK_NUMPAD5, wx.WXK_NUMPAD6, wx.WXK_NUMPAD7, wx.WXK_NUMPAD8,
wx.WXK_NUMPAD9]:
+ ch = ch = chr(ord('0') + key - wx.WXK_NUMPAD0)
elif key < 256 and key >= 0 and chr(key):
ch = chr(key)
@@ -148,9 +148,9 @@
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)
+ if key in [wx.WXK_NUMPAD0, wx.WXK_NUMPAD1, wx.WXK_NUMPAD2, wx.WXK_NUMPAD3,
wx.WXK_NUMPAD4,
+ wx.WXK_NUMPAD5, wx.WXK_NUMPAD6, wx.WXK_NUMPAD7, wx.WXK_NUMPAD8,
wx.WXK_NUMPAD9]:
+ ch = ch = chr(ord('0') + key - wx.WXK_NUMPAD0)
elif key < 256 and key >= 0 and chr(key):
ch = chr(key)
@@ -223,9 +223,9 @@
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)
+ if key in [wx.WXK_NUMPAD0, wx.WXK_NUMPAD1, wx.WXK_NUMPAD2, wx.WXK_NUMPAD3,
wx.WXK_NUMPAD4,
+ wx.WXK_NUMPAD5, wx.WXK_NUMPAD6, wx.WXK_NUMPAD7, wx.WXK_NUMPAD8,
wx.WXK_NUMPAD9]:
+ ch = ch = chr(ord('0') + key - wx.WXK_NUMPAD0)
elif key < 256 and key >= 0 and chr(key):
ch = chr(key)
@@ -285,9 +285,9 @@
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)
+ if key in [wx.WXK_NUMPAD0, wx.WXK_NUMPAD1, wx.WXK_NUMPAD2, wx.WXK_NUMPAD3,
wx.WXK_NUMPAD4,
+ wx.WXK_NUMPAD5, wx.WXK_NUMPAD6, wx.WXK_NUMPAD7, wx.WXK_NUMPAD8,
wx.WXK_NUMPAD9]:
+ ch = ch = chr(ord('0') + key - wx.WXK_NUMPAD0)
elif key < 256 and key >= 0 and chr(key):
ch = chr(key)
Modified: trunk/gnue-designer/src/uidrivers/wx/uihelpers/NotebookCtrl.py
===================================================================
--- trunk/gnue-designer/src/uidrivers/wx/uihelpers/NotebookCtrl.py
2006-03-06 20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/uidrivers/wx/uihelpers/NotebookCtrl.py
2006-03-07 00:04:31 UTC (rev 8210)
@@ -1,3 +1,5 @@
+## NOTE: This contains a one-line patch at line 2030 (in the orignal source).
+
# --------------------------------------------------------------------------- #
# NOTEBOOKCTRL Control wxPython IMPLEMENTATION
# Python Code By:
@@ -2028,7 +2030,7 @@
width, pom = dc.GetTextExtent(self.GetPageText(ii))
if self.GetPageImage(ii) >= 0:
- bmp = self.GetImageList().GetBitmap(ii)
+ bmp = self.GetImageList().GetBitmap(self.GetPageImage(ii))
if self._style & NC_FIXED_WIDTH:
width = maxwidth
@@ -4816,7 +4818,7 @@
self.bsizer.Show(selection, True)
self.bsizer.Layout()
- self._showcolumns = show
+ self._showcolumns = False # show
self.bsizer.Layout()
self.sizer.Layout()
Modified: trunk/gnue-designer/src/uidrivers/wx/uihelpers/PyAUI.py
===================================================================
--- trunk/gnue-designer/src/uidrivers/wx/uihelpers/PyAUI.py 2006-03-06
20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/uidrivers/wx/uihelpers/PyAUI.py 2006-03-07
00:04:31 UTC (rev 8210)
@@ -1637,7 +1637,7 @@
def DrawResizeHint(dc, rect):
- print "drawing resize hint in rect:", rect
+ ##print "drawing resize hint in rect:", rect
stipple = PaneCreateStippleBitmap()
brush = wx.BrushFromBitmap(stipple)
#brush.SetStipple(stipple)
@@ -2043,6 +2043,10 @@
self.Bind(EVT_AUI_PANEBUTTON, self.OnPaneButton)
+ def SetDockArt(self, art):
+ assert isinstance(art, DefaultDockArt)
+ self._art = art
+
def GetPaneByWidget(self, window):
"""
This version of GetPane() looks up a pane based on a
@@ -4422,10 +4426,10 @@
self._action_offset = wx.Point(event.GetX() - part.rect.x,
event.GetY() - part.rect.y)
self._frame.CaptureMouse()
- print "resize down:"
- print "\tRect: ", self._action_hintrect
- print "\tStart:", self._action_start
- print "\tOffset:", self._action_offset
+ #print "resize down:"
+ #print "\tRect: ", self._action_hintrect
+ #print "\tStart:", self._action_start
+ #print "\tOffset:", self._action_offset
elif part.type == DockUIPart.typePaneButton:
Modified: trunk/gnue-designer/src/uidrivers/wx/uihelpers/PythonEditor.py
===================================================================
--- trunk/gnue-designer/src/uidrivers/wx/uihelpers/PythonEditor.py
2006-03-06 20:23:30 UTC (rev 8209)
+++ trunk/gnue-designer/src/uidrivers/wx/uihelpers/PythonEditor.py
2006-03-07 00:04:31 UTC (rev 8210)
@@ -100,9 +100,9 @@
#self.faces
if wx.Platform == '__WXMSW__':
self.faces = { 'times': 'Courier New',
- 'mono' : 'Courier',
- 'helv' : 'Courier',
- 'other': 'Courier',
+ 'mono' : 'Courier New',
+ 'helv' : 'Courier New',
+ 'other': 'Courier New',
'size' : 10,
'size2': 10,
}
@@ -114,11 +114,11 @@
## 'size2': 8,
## }
else:
- self.faces = { 'times': 'Times',
+ self.faces = { 'times': 'Courier',
'mono' : 'Courier',
- 'helv' : 'Helvetica',
- 'other': 'new century schoolbook',
- 'size' : 12,
+ 'helv' : 'Courier',
+ 'other': 'Courier',
+ 'size' : 10,
'size2': 10,
}
self.SetWordChars(WORDCHARS)
@@ -443,7 +443,7 @@
# Global default styles for all languages
self.StyleSetSpec(wx_stc.STC_STYLE_DEFAULT,
"face:%(helv)s,size:%(size)d" % self.faces)
self.StyleSetSpec(wx_stc.STC_STYLE_LINENUMBER,
"back:#C0C0C0,face:%(helv)s,size:%(size2)d" % self.faces)
- self.StyleSetSpec(wx_stc.STC_STYLE_CONTROLCHAR, "face:%(other)s" %
self.faces)
+ self.StyleSetSpec(wx_stc.STC_STYLE_CONTROLCHAR, "face:%(mono)s" %
self.faces)
self.StyleSetSpec(wx_stc.STC_STYLE_BRACELIGHT,
"fore:#FFFFFF,back:#0000FF,bold")
self.StyleSetSpec(wx_stc.STC_STYLE_BRACEBAD,
"fore:#000000,back:#FF0000,bold")
@@ -451,13 +451,14 @@
# White space
self.StyleSetSpec(wx_stc.STC_P_DEFAULT,
"face:%(mono)s,size:%(size)d" % self.faces)
# Comment
- self.StyleSetSpec(wx_stc.STC_P_COMMENTLINE,
"fore:#007F00,back:#E8FFE8,italic,face:%(other)s,size:%(size)d" % self.faces)
+ #self.StyleSetSpec(wx_stc.STC_P_COMMENTLINE,
"fore:#007F00,back:#E8FFE8,italic,face:%(other)s,size:%(size)d" % self.faces)
+ self.StyleSetSpec(wx_stc.STC_P_COMMENTLINE,
"fore:#007F00,face:%(mono)s,size:%(size)d" % self.faces)
# Number
self.StyleSetSpec(wx_stc.STC_P_NUMBER,
"fore:#007F7F,size:%(size)d" % self.faces)
# String
- self.StyleSetSpec(wx_stc.STC_P_STRING,
"fore:#7F007F,face:%(times)s,size:%(size)d" % self.faces)
+ self.StyleSetSpec(wx_stc.STC_P_STRING,
"fore:#7F007F,face:%(mono)s,size:%(size)d" % self.faces)
# Single quoted string
- self.StyleSetSpec(wx_stc.STC_P_CHARACTER,
"fore:#7F007F,face:%(times)s,size:%(size)d" % self.faces)
+ self.StyleSetSpec(wx_stc.STC_P_CHARACTER,
"fore:#7F007F,face:%(mono)s,size:%(size)d" % self.faces)
# Keyword
self.StyleSetSpec(wx_stc.STC_P_WORD,
"fore:#00007F,bold,size:%(size)d" % self.faces)
# Triple quotes
@@ -465,7 +466,7 @@
# Triple double quotes
self.StyleSetSpec(wx_stc.STC_P_TRIPLEDOUBLE,
"fore:#7F0000,size:%(size)d" % self.faces)
# Class name definition
- self.StyleSetSpec(wx_stc.STC_P_CLASSNAME,
"fore:#0000FF,bold,underline,size:%(size)d" % self.faces)
+ self.StyleSetSpec(wx_stc.STC_P_CLASSNAME,
"fore:#0000FF,bold,size:%(size)d" % self.faces)
# Function or method name definition
self.StyleSetSpec(wx_stc.STC_P_DEFNAME,
"fore:#007F7F,bold,size:%(size)d" % self.faces)
# Operators
@@ -473,7 +474,7 @@
# Identifiers
self.StyleSetSpec(wx_stc.STC_P_IDENTIFIER, "")
# Comment-blocks
- self.StyleSetSpec(wx_stc.STC_P_COMMENTBLOCK,
"fore:#990000,back:#C0C0C0,italic,size:%(size)d" % self.faces)
+ self.StyleSetSpec(wx_stc.STC_P_COMMENTBLOCK,
"fore:#990000,size:%(size)d" % self.faces)
# End of line where string is not closed
self.StyleSetSpec(wx_stc.STC_P_STRINGEOL,
"fore:#000000,face:%(mono)s,back:#E0C0E0,eol,size:%(size)d" % self.faces)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnue] r8210 - in trunk/gnue-designer: images src src/base src/base/tools src/forms src/forms/LayoutEditor src/forms/LayoutEditor/renderers/Base src/forms/events src/navigator src/reports src/reports/Char src/reports/Standard src/schema src/schema/DiaEditor src/templates/forms src/templates/reports src/templates/schema src/uidrivers/wx src/uidrivers/wx/uihelpers,
jcater <=