[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/designer src/Designer.py src/Instance.py s...
From: |
Jason Cater |
Subject: |
gnue/designer src/Designer.py src/Instance.py s... |
Date: |
Fri, 19 Jul 2002 19:21:15 -0400 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: Jason Cater <address@hidden> 02/07/19 19:21:15
Modified files:
designer/src : Designer.py Instance.py MenuBar.py
TemplateBase.py TemplateParser.py
designer/src/forms/LayoutEditor: LayoutEditor.py
designer/src/forms/wizards: AddPage.py
designer/templates: __init__.py
designer/templates/forms: FormBuilder.py Simple.py
SimpleDetail.py
designer/templates/schema: Introspection.py
Log message:
implemented dynamic menu, etc, for plugin support; added Add Page and
Block Builder plugins
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/Designer.py.diff?tr1=1.47&tr2=1.48&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/Instance.py.diff?tr1=1.58&tr2=1.59&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/MenuBar.py.diff?tr1=1.26&tr2=1.27&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/TemplateBase.py.diff?tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/TemplateParser.py.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/forms/LayoutEditor/LayoutEditor.py.diff?tr1=1.26&tr2=1.27&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/forms/wizards/AddPage.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/templates/__init__.py.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/templates/forms/FormBuilder.py.diff?tr1=1.5&tr2=1.6&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/templates/forms/Simple.py.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/templates/forms/SimpleDetail.py.diff?tr1=1.3&tr2=1.4&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/templates/schema/Introspection.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
Patches:
Index: gnue/designer/src/Designer.py
diff -c gnue/designer/src/Designer.py:1.47 gnue/designer/src/Designer.py:1.48
*** gnue/designer/src/Designer.py:1.47 Fri Jul 19 00:56:07 2002
--- gnue/designer/src/Designer.py Fri Jul 19 19:21:12 2002
***************
*** 150,161 ****
instance = self.newInstance(product)
root = templateSupport.createRootObject(instance)
! if TemplateParser.TemplateParser(instance, root,
instance, templateInformation).run():
!
! self.newInstance(product, buffer=StringIO(root.dumpXML()))
!
! instance.Close()
def isFileOpened(self, location):
--- 150,158 ----
instance = self.newInstance(product)
root = templateSupport.createRootObject(instance)
! if not TemplateParser.TemplateParser(instance, root,
instance, templateInformation).run():
! instance.Close()
def isFileOpened(self, location):
Index: gnue/designer/src/Instance.py
diff -c gnue/designer/src/Instance.py:1.58 gnue/designer/src/Instance.py:1.59
*** gnue/designer/src/Instance.py:1.58 Thu Jul 11 10:32:10 2002
--- gnue/designer/src/Instance.py Fri Jul 19 19:21:12 2002
***************
*** 167,173 ****
# Create the supplemental tools
self.createTools()
self._menubar.buildMenu()
- self._menubar.lastToolAdded()
self._app.addInstance(self)
--- 167,172 ----
Index: gnue/designer/src/MenuBar.py
diff -c gnue/designer/src/MenuBar.py:1.26 gnue/designer/src/MenuBar.py:1.27
*** gnue/designer/src/MenuBar.py:1.26 Fri Jul 19 00:56:07 2002
--- gnue/designer/src/MenuBar.py Fri Jul 19 19:21:12 2002
***************
*** 48,54 ****
def addWizardLocation(self, location, template):
#print "Adding %s" % location
! self._menuMappings[location] = template
# Called after all the addWizardLocation's have been run
def buildMenu(self):
--- 48,56 ----
def addWizardLocation(self, location, template):
#print "Adding %s" % location
! self._menuMappings[location] = WizardRunner(template,
! string.split(location,'|')[-1],
! self._frame)
# Called after all the addWizardLocation's have been run
def buildMenu(self):
***************
*** 131,138 ****
self._fileNew.Append(id, '&%s' % tool.properties.nickname,
_('Create a new %s') % string.lower(tool.properties.nickname))
EVT_MENU (frame, id, frame.OnNew)
!
!
## self._fileNew.Append(ID_NEW_FORM,_('&Form'), _("Create a new form"))
## self._fileNew.Append(ID_NEW_REPORT,_('&Report'), _("Create a new
report"))
--- 133,139 ----
self._fileNew.Append(id, '&%s' % tool.properties.nickname,
_('Create a new %s') % string.lower(tool.properties.nickname))
EVT_MENU (frame, id, frame.OnNew)
!
## self._fileNew.Append(ID_NEW_FORM,_('&Form'), _("Create a new form"))
## self._fileNew.Append(ID_NEW_REPORT,_('&Report'), _("Create a new
report"))
***************
*** 184,242 ****
self._tools.AppendItem(menu)
EVT_MENU(frame, tool.wxId, tool.run)
tool.finalize()
self._debug = wxMenu()
self._debug.Append(ID_RUN, _('&Run'), _("Run the current form"))
EVT_MENU (frame, ID_RUN, frame.OnDebugRun)
! menumap = { 'File': (self._file,[]),
! 'File|New': (self._fileNew,[]),
! 'Edit': (self._edit,[]),
! 'Debug': (self._debug,[]),
! 'Tools': (self._tools,[]),
! 'Help': (self._help, []) }
basemenuorder = ['File','Edit','Debug','Tools']
- menuorder = []
! # Add everything
! for name in basemenuorder + menuorder + ['Help']:
! print menumap[name][0]
self.Append(menumap[name][0], '&' + name)
def addTool(self, toolFrame, title):
location = 'Tools|%s' % title
self._menuMappings[location] = ToolRunner(toolFrame, title)
self._toolMenuOrder.append(location)
return self._menuMappings[location]
! ## toolFrame._wxMenuID = wxNewId()
! ## toolFrame._menu = wxMenuItem(self._tools, toolFrame._wxMenuID,
! ## '&%s' % title, _("Show or hide the %s") % title, 1)
! ## self._tools.AppendItem(toolFrame._menu)
! ## EVT_MENU(self._frame, toolFrame._wxMenuID, toolFrame.OnMenuSelected)
- def lastToolAdded(self):
- self._tools.AppendSeparator()
class WizardRunner:
! def __init__(self, template, title):
self.template = template
self.wxId = wxNewId()
self.title = title
self.checkable = 0
try:
! self.tooltip = TemplateInformation['Description']
except KeyError:
self.tooltip = ""
def run(self, event):
! print "TODO: WizardRunner.run()"
!
def finalize(self):
pass
--- 185,294 ----
self._tools.AppendItem(menu)
EVT_MENU(frame, tool.wxId, tool.run)
tool.finalize()
+
+ self._tools.AppendSeparator()
self._debug = wxMenu()
self._debug.Append(ID_RUN, _('&Run'), _("Run the current form"))
EVT_MENU (frame, ID_RUN, frame.OnDebugRun)
! menumap = { '': (self, {}),
! 'File': (self._file,{}),
! 'File|New': (self._fileNew,{}),
! 'Edit': (self._edit,{}),
! 'Debug': (self._debug,{}),
! 'Tools': (self._tools,{}),
! 'Help': (self._help, {})}
basemenuorder = ['File','Edit','Debug','Tools']
! for location in self._menuMappings.keys():
! last = None
! nav = string.split(location,'|')
! partial = ""
! lastpartial = ""
! for loc in nav[:-1]:
! lastpartial = partial
! partial += (partial and '|' or "") + loc
! if not menumap.has_key(partial):
! menumap[partial] = (wxMenu(), {})
! menumap[lastpartial][1][loc] = (1, menumap[partial][0])
!
! menumap[partial][1][nav[-1]] = (0, location)
!
!
! # Add all the base menus first...
! for name in basemenuorder:
self.Append(menumap[name][0], '&' + name)
+
+ # Next, add all the customizations
+ locsort = menumap.keys()
+ locsort.sort()
+ for location in locsort:
+ menu, submenus = menumap[location]
+ mm = submenus.keys()
+ mm.sort()
+ for menuitem in mm:
+ isMenu, data = submenus[menuitem]
+ if isMenu:
+ # data is a wxMenu instance
+ menu.AppendMenu(wxNewId(), '&' + menuitem, data)
+ else:
+ # Data is a location pointer
+ wizard = self._menuMappings[data]
+ menu.Append(wizard.wxId, wizard.title, wizard.tooltip)
+ EVT_MENU(frame, wizard.wxId, wizard.run)
+
+
+ # Add the Help menu
+ self.Append(menumap['Help'][0], '&Help')
+
+
+ def __createMenuStructure(location, data):
+ for loc, isMenu, data in menumap[name][1]:
+ if isMenu:
+ menu.AppendMenu(wxNewId(), "&%s" % loc, data)
+ else:
+ pass
+
+
+
def addTool(self, toolFrame, title):
location = 'Tools|%s' % title
self._menuMappings[location] = ToolRunner(toolFrame, title)
self._toolMenuOrder.append(location)
return self._menuMappings[location]
!
! #
! # Convenience methods to make the main menu bar appear to be a menu
container
! #
+ def AppendMenu(self, wxId, text, menu):
+ self.Append(menu, text)
+ import TemplateParser
class WizardRunner:
! def __init__(self, template, title, instance):
self.template = template
+ self.instance = instance
self.wxId = wxNewId()
self.title = title
self.checkable = 0
try:
! self.tooltip = template['Description']
except KeyError:
self.tooltip = ""
def run(self, event):
! TemplateParser.TemplateParser(self.instance, self.instance.rootObject,
! self.instance, self.template).run()
!
def finalize(self):
pass
Index: gnue/designer/src/TemplateBase.py
diff -c gnue/designer/src/TemplateBase.py:1.10
gnue/designer/src/TemplateBase.py:1.11
*** gnue/designer/src/TemplateBase.py:1.10 Fri Jun 28 00:03:37 2002
--- gnue/designer/src/TemplateBase.py Fri Jul 19 19:21:12 2002
***************
*** 116,123 ****
--- 116,133 ----
o = self.parser.elements[tag]['BaseClass'](parent)
for attr in attributes.keys():
o.__dict__[attr] = attributes[attr]
+ o._buildObject()
+ self.parser.instance.onCreateObject(o, __name__)
return o
+ def ModifyElement(self, element, **modifications):
+ element.__dict__.update(modifications)
+ self.parser.instance.onModifyObject(o, __name__)
+ mods = []
+ for attr in modifications.keys():
+ mods.append((attr, modifications[attr]))
+ self.parser.instance.onModifyObject(o, __name__, mods)
+
def GetAvailableConnections(self):
rv = []
***************
*** 130,138 ****
return rv
! def GetTemporaryConnection(self, connection_name):
! if not self.__cachedConnections.has_key(connection_name):
self.__cachedConnections[connection_name] = \
self._connections.getDataObject(connection_name, 'object')
self.__cachedConnections[connection_name].database = connection_name
--- 140,148 ----
return rv
! def GetTemporaryConnection(self, connection_name):
! if not self.__cachedConnections.has_key(connection_name):
self.__cachedConnections[connection_name] = \
self._connections.getDataObject(connection_name, 'object')
self.__cachedConnections[connection_name].database = connection_name
Index: gnue/designer/src/TemplateParser.py
diff -c gnue/designer/src/TemplateParser.py:1.14
gnue/designer/src/TemplateParser.py:1.15
*** gnue/designer/src/TemplateParser.py:1.14 Wed Jul 3 11:30:30 2002
--- gnue/designer/src/TemplateParser.py Fri Jul 19 19:21:12 2002
***************
*** 31,41 ****
from gnue.common import dyn_import
class TemplateParser:
! def __init__(self, instance, rootObject, parent, templateInformation):
self.parent = parent
self.instance = instance
self.templateInformation = templateInformation
self.rootObject = rootObject
self.elements =
dyn_import('gnue.designer.%s.Incubator'%templateInformation['Product']).elements
--- 31,43 ----
from gnue.common import dyn_import
class TemplateParser:
! def __init__(self, instance, rootObject, parent,
! templateInformation, currentObject=None):
self.parent = parent
self.instance = instance
self.templateInformation = templateInformation
self.rootObject = rootObject
+ self.currentObject = currentObject
self.elements =
dyn_import('gnue.designer.%s.Incubator'%templateInformation['Product']).elements
***************
*** 44,50 ****
self.template = self.templateInformation['BaseClass'](self)
! self.template.Start(self.rootObject)
# If this is simply a template and not a wizard,
# generate the results and get out of Dodge.
--- 46,52 ----
self.template = self.templateInformation['BaseClass'](self)
! self.template.Start(self.rootObject, self.currentObject or
self.rootObject)
# If this is simply a template and not a wizard,
# generate the results and get out of Dodge.
Index: gnue/designer/src/forms/LayoutEditor/LayoutEditor.py
diff -c gnue/designer/src/forms/LayoutEditor/LayoutEditor.py:1.26
gnue/designer/src/forms/LayoutEditor/LayoutEditor.py:1.27
*** gnue/designer/src/forms/LayoutEditor/LayoutEditor.py:1.26 Fri Jun 28
00:03:38 2002
--- gnue/designer/src/forms/LayoutEditor/LayoutEditor.py Fri Jul 19
19:21:12 2002
***************
*** 182,189 ****
# TODO: adjust label width to match new length...this shouldn't be here
if object._type == 'GFLabel':
mods = []
! for modification in modifications:
! field, value = modification
if field=='text':
#TODO: this will butcher align=center setups
if (not hasattr(object,'alignment')) or ( object.alignment ==
'left'):
--- 182,188 ----
# TODO: adjust label width to match new length...this shouldn't be here
if object._type == 'GFLabel':
mods = []
! for field, value in modifications:
if field=='text':
#TODO: this will butcher align=center setups
if (not hasattr(object,'alignment')) or ( object.alignment ==
'left'):
Index: gnue/designer/src/forms/wizards/AddPage.py
diff -c gnue/designer/src/forms/wizards/AddPage.py:1.3
gnue/designer/src/forms/wizards/AddPage.py:1.4
*** gnue/designer/src/forms/wizards/AddPage.py:1.3 Fri Jul 19 00:56:07 2002
--- gnue/designer/src/forms/wizards/AddPage.py Fri Jul 19 19:21:12 2002
***************
*** 30,35 ****
--- 30,36 ----
from gnue.designer.forms.TemplateSupport import *
+ from gnue.designer import VERSION
import string
#
***************
*** 47,53 ****
#
! class PageBuilderWizard(FormTemplate):
# The first step in our wizard.
--- 48,54 ----
#
! class AddPageWizard(FormTemplate):
# The first step in our wizard.
***************
*** 60,329 ****
#
# Initialize any runtime variables
#
! def Start(self, form):
! self.form = form
! self.form.height = 0
!
! # The first table can never have a master
! self.variables['hasmaster0'] = '0'
! self.variables['newPage0'] = '0'
###############
#
# Return the markup for a specific page
#
! def GetStep(self, stepCode):
!
! try:
! step, iteration = string.split(stepCode,':')
! iteration = int(iteration)
! except ValueError:
! step = stepCode
!
! # Add another? loop logic
! if step == '1or8':
!
! self.variables['newPage%s' % iteration] = self.variables['newPage']
! # If continue is set to 1, then go to step 1; otherwise, step 8
! if self.variables['continue'] == '1':
!
! step = '1'
!
! # If we are reusing the same connection, record that now and skip a
step
! if self.variables['singleconnection'] == '1':
! self.variables['connection%s' % iteration] =
self.variables['connection0']
! step = '2'
!
!
! else:
! # We are done... record the total number of children
! self.variables['iterations'] = iteration
! step = '8'
!
!
! # Has Master? loop logic
! if step == '4or7':
! if self.variables['hasmaster%s' % iteration] == '1':
! step = '4'
! else:
! step = '7'
!
#
! # Step #0 / Get Title, et al
#
if step == '0':
! return { 'title': 'Add Page',
! 'content': (WizardText('Welcome to the "add page" wizard.'),
! WizardText('To create your form, I need to know
some basic information. \n'
! 'First, what shall I call your form?
This name will appear in \n'
! 'the title bar.'),
! WizardInput('title', label='Form Title:',
required=1,
! size=40),
! ),
! 'prev': None,
! 'next': '1:0' }
!
! #
! # Step #1 / Get Connection
! #
! if step == '1':
!
! if iteration == 0:
! # first time through ask about reusing same connection
! return { 'title': 'Connection Information',
! 'content': (WizardText('What connection contains the
table you wish to\nthe form?'),
!
WizardInput('connection%s'%iteration,label='Connection:', required=1,
!
set=self.GetAvailableConnections()),
! WizardInput('singleconnection',
! label='Reuse this connection for all
tables?',
! required=1,set=(('1','Yes'),
! ('0','No')
! )),
! WizardText('You may be asked to login to this
connection.'),
! ),
! 'prev': '0', # Loop back
! 'next': '2:%s' % iteration }
!
! else:
!
! return { 'title': 'Connection Information',
! 'content': (WizardText('What connection contains the
table you wish to\nthe form?'),
!
WizardInput('connection%s'%iteration,label='Connection:', required=1,
!
set=self.GetAvailableConnections()),
! WizardText('You may be asked to login to this
connection.'),
! ),
! 'prev': '7:%s' % (iteration - 1), # Loop back
! 'next': '2:%s' % iteration }
!
!
! #
! # Step #2 / Get Table
! #
! elif step == '2':
!
! # If using the same connection for all tables, skip question on Prev
! if iteration and self.variables['singleconnection'] == '1':
! prev = '1'
! elif iteration:
! prev = '7'
! else:
! prev = '0'
!
! # Do not ask about master/detail if we're iteration #1
! if iteration:
! return { 'title': 'Select Table/Source',
! 'content': (WizardText('Now, please select a table for
your form.'),
! WizardInput('table%s' % iteration,
! label='Table:', required=1,
lines=5,
!
set=self.GetAvailableSources(self.variables['connection%s'%iteration])),
! WizardInput('hasmaster%s' % iteration,
! label='Will this table have a
master?',
! required=1,set=(('0','No'),
! ('1','Yes'),
! )),
! ),
! 'prev': '%s:%s' % (prev,iteration),
! 'next': '3:%s' % iteration }
!
! else:
! return { 'title': 'Select Table/Source',
! 'content': (WizardText('Now, please select a table for
your form.'),
! WizardInput('table%s' % iteration,
! label='Table:', required=1,
lines=5,
!
set=self.GetAvailableSources(self.variables['connection%s'%iteration])),
! ),
! 'prev': '%s:%s' % (prev,iteration),
! 'next': '3:%s' % iteration }
!
!
! #
! # Step #3 / Select fields to include
! #
! elif step == '3':
!
!
! return { 'title': 'Select Fields to Include',
! 'content': (WizardText('Which fields shall I include in your
form as entries?'),
! WizardInput('tablefields%s' % iteration,
! label='Columns:', required=1,
! maxSelections=-1, orderable=1,
! set=self.GetAvailableFields( \
!
self.variables['connection%s'%iteration],
! self.variables['table%s' %
iteration])),
! WizardInput('tablearrangement%s' % iteration,
! label='Arrangement Method:',
! required=1,
! set=(('left','Single Record with
Labels to Left'),
! ('above','Single Record with
Labels Above'),
! ('grid','Grid Format')))),
! 'prev': '2:%s' % iteration,
! 'next': '4or7:%s' % iteration }
!
!
! #
! # Step #4 / Select Master Table
! #
! elif step == '4':
!
! set = []
! tables = {}
! for i in range(iteration):
!
! table = self.variables['table%s' % i]
! # Append a "#2" to the table name if multiple sources use same table
! if tables.has_key(table):
! tables[table] += 1
! table += ' #%s' % tables[table]
! else:
! tables[table] = 1
! set.append( (i, table ) )
!
!
!
! # NOTE: mastertable# will be set to a NUMBER corresponding to the
datasource to
! # use. It is NOT set to an actual name! (i.e., the table to use
is
! # self.variables['table%s' % mastertable#]
!
! return { 'title': 'Link to Master Table',
! 'content': (WizardText('Now, please select the table to be
the master of %s.' % self.variables['table%s'%iteration]),
! WizardInput('mastertable%s'%iteration,
label='Master Table:', required=1, lines=5,
! set=set), ),
! 'prev': '3:%s' % iteration,
! 'next': '5:%s' % iteration }
!
!
! #
! # Step #6 / Get Master Columns (primary keys)
! #
! elif step == '5':
!
!
! return { 'title': 'Master key fields',
! 'content': (WizardText('Which master-level fields are the
primary keys?'),
! WizardInput('masterkeys%s' % iteration,
label='Columns:', required=1,
! maxSelections=-1, orderable=1,
! set=self.GetAvailableFields( \
! self.variables['connection%s'
% self.variables['mastertable%s' % iteration]],
! self.variables['table%s' %
self.variables['mastertable%s' % iteration]]))),
! 'prev': '4:%s' % iteration,
! 'next': '6:%s' % iteration }
!
!
! #
! # Step #6 / Get Detail Columns (detail keys)
! #
! elif step == '6':
!
! # TODO: If the table changed between steps,
! # TODO: variables['fields'] should be cleared.
!
! return { 'title': 'Detail key fields',
! 'content': (WizardText('Which detail-level fields are the
foreign keys?'),
! WizardInput('detailkeys%s' % iteration,
label='Columns:', required=1,
! maxSelections=-1, orderable=1,
! set=self.GetAvailableFields( \
! self.variables['connection%s'
% iteration],
! self.variables['table%s' %
iteration]))),
! 'prev': '5:%s' % iteration,
! 'next': '7:%s' % iteration }
!
! #
! #
! # Step #7 / Get Master Columns to Include
! #
! elif step == '7':
!
! # If current table has no master, then skip the master/detail stuff
! if self.variables['hasmaster%s' % iteration] == '0':
! prev = '3'
! else:
! prev = '6'
!
!
! # TODO: If the table changed between steps,
! # TODO: variables['fields'] should be cleared.
!
! return { 'title': 'Add Another Table?',
! 'content': (WizardInput('continue', label='Add Another
Table?',
! required=1,set=(('1','Yes'),
! ('0','No')
! )),
! WizardInput('newPage', label='If yes, put this
table on a new page?',
! required=1,set=(('0','No'),
! ('1','Yes')
! )),),
! 'prev': '%s:%s' % (prev,iteration),
! 'next': '1or8:%s' % (iteration+1) }
!
! elif step == '8':
! return { 'title': "That's it!",
! 'content': (WizardText('Click finish to create your
form?'),),
! 'prev': '7:%s' % (iteration-1),
'next': None }
--- 61,94 ----
#
# Initialize any runtime variables
#
! def Start(self, root, current):
! self.form = root
! self.current = current
!
!
###############
#
# Return the markup for a specific page
#
! def GetStep(self, step):
#
! # Step #0 / Get Name
#
if step == '0':
! content = [WizardText('This will insert a new page.'),
! WizardInput('name',label='Object Name:',required=1,size=20)]
! if hasattr(self.form,'tabbed') and self.form.tabbed:
! content.append(WizardInput('caption', label='Tab Caption: ',
required=1,
! size=20))
! return { 'title': 'Add Page',
! 'content': content,
! 'prev': None,
'next': None }
***************
*** 351,550 ****
#
def Finalize(self):
- # Create a single page on which to place blocks and labels
- pageCounter = 1
- page = self.AddElement('page', self.form,
- { 'name': 'pg%s' % pageCounter })
! #
! # Add datasources
! #
! basey = 0
! dataSourceArray = []
! for count in range(self.variables['iterations']):
! if self.variables['newPage%s' % count] == '1':
! pageCounter += 1
! page = self.AddElement('page', self.form,
! { 'name': 'pg%s' % pageCounter })
! basey=0
!
! tableKey = string.upper(self.variables['table%s' % count])
! datasource = self.AddElement('datasource', self.form,
! { 'database':
self.variables['connection%s' % count],
! 'table': self.variables['table%s' %
count],
! 'type': 'object',
! 'name': 'dts%s%s' % (tableKey,count) })
!
! # Is this a grid style block?
! multirecord = self.variables['tablearrangement%s' % count] == 'grid'
!
! # Will labels appear above or to the left of the entries?
! # Note: this results in false for both "grid" and "above"
! leftlabels = self.variables['tablearrangement%s' % count] == 'left'
!
! # The basic attributes for a block
! attrs = {'name' : 'blk%s%s' % (tableKey,count),
! 'datasource': datasource.name}
!
! # If this is a multirecord form, set rows at the block level.
! if multirecord:
! attrs['rows'] = 10
!
! # Create the block
! block = self.AddElement('block', page, attrs)
!
! tableSchema = self.GetSourceSchema(self.variables['connection%s' %
count],
! self.variables['table%s' % count])
!
! # Make a map of all the field schemas we will need
! # We will not actually create the entries at this point
! # because we want to keep in the order that the user
! # specified
! fields = {}
! for field in tableSchema.getChildSchema(tableSchema):
! if field.name in self.variables['tablefields%s' % count]:
! fields[field.name] = field
!
! entryQueue = []
! labelQueue = []
! largestField = 0
! largestLabel = 0
!
! # Now, let's make all the entries
! for name in self.variables['tablefields%s' % count]:
!
! field = fields[name]
! # We will use the field name as the basis for all our
! # entry and label names. Capitalize the first letter
! # and strip all spaces...
! if len(field.name) == 1:
! fieldKey = string.upper(field.name)
! else:
! fieldKey = string.join(string.split(string.capwords( \
! string.replace(field.name,'_',' '))),'')
!
! # Create a label. If the schema specified a label for a field,
! # use that as is. If not, use the field name, replacing any '_'
! # with spaces and tacking on a colon.
! text = hasattr(field,'label') and label or \
! string.capwords(string.replace(field.name,'_',' ')) + ':'
!
! labelQueue.append(self.AddElement('label', page,
! {'x':1, 'y': 1,
! 'name': "lbl%s" % fieldKey,
! 'text': text,
! 'width': len(text)}))
!
! # Keep track of the greatest label width
! largestLabel = largestLabel < len(text) and len(text) or largestLabel
!
!
! # Create an entry for this field.
!
! attrs={'x':1, 'y': 1,
! 'name': "inp%s" % fieldKey,
! 'field': field.name,
! 'typecast': field.datatype,
! 'width': 10}
!
! # If we have a length for the field, use this as the max_length
! # for the entry. Also, adjust the display width if necessary.
! if hasattr(field,'length'):
! attrs['max_length'] = field.length
! if field.length < 25:
! attrs['width'] = field.length
! else:
! attrs['width'] = 25
!
! # Keep track of the greatest field width
! largestField = largestField < attrs['width'] and \
! attrs['width'] or largestField
!
! # Create the entry element
! entryQueue.append(self.AddElement('entry', block, attrs))
!
!
! # Rearrange the fields and labels to snugly fit the screen
! # based on the layout arrangement selected by the user.
!
! # Grid/multirecord layout
! if multirecord:
!
! self.form.height = 13
! self.form.width = 1
! x = 1
!
! for i in range(len(entryQueue)):
! labelQueue[i].x = x
! labelQueue[i].y = basey + 1
! entryQueue[i].x = x
! entryQueue[i].y = basey + 2
!
! # If label width is larger than entry width, center the entry
! if entryQueue[i].width < labelQueue[i].width:
! entryQueue[i].x = entryQueue[i].x + \
! int((labelQueue[i].width - entryQueue[i].width)/2)
!
!
! # Calculate the starting x for the next label/entry
! dx = (entryQueue[i].width < labelQueue[i].width and \
! labelQueue[i].width or entryQueue[i].width) + 1
!
! # Increase the form width accordingly
! self.form.width = self.form.width + dx
! x = x + dx
!
! # Single Record layout (regardless of label location)
! else:
!
! # Assign the starting (x,y) values for labels (l) and fields (f)
! # as well as the delta (x,y) values.
! if leftlabels:
! # Labels to the left of the entries
! lx, ly, ldx, ldy = (1, basey + 1, 0, 1)
! fx, fy, fdx, fdy = (largestLabel + 2, basey + 1, 0, 1)
!
! # Set form width
! self.form.width = largestField + largestLabel + 3
!
! else:
! # Labels above the entries
! lx, ly, ldx, ldy = (1, basey +1, 0, 3)
! fx, fy, fdx, fdy = (1, basey +2, 0, 3)
!
! # Set the form width
! self.form.width = 2 + (largestField > largestLabel and largestField
\
! or largestLabel)
!
! # Rearrange
! if self.form.height < fy+2-fdy:
! self.form.height = fy+2-fdy
!
! for i in range(len(entryQueue)):
! entryQueue[i].x = fx
! entryQueue[i].y = fy
! labelQueue[i].x = lx
! labelQueue[i].y = ly
! ly = ly + ldy
! lx = lx + ldx
! fy = fy + fdy
! fx = fx + fdx
!
! if self.form.height < self.form.height + fdy:
! self.form.height += fdy
!
! basey = self.form.height - 1
!
! dataSourceArray.append(datasource)
!
! ####
! #### Set detail datasource to point towards master
! ####
! if self.variables['hasmaster%s' % count] == '1':
! master = int(self.variables['mastertable%s' % count])
! datasource.master = dataSourceArray[master].name #
masterDataSource.name
! datasource.masterlink =
string.join(self.variables['masterkeys%s'%count],',')
! datasource.detaillink =
string.join(self.variables['detailkeys%s'%count],',')
return 1
--- 116,130 ----
#
def Finalize(self):
! attrs = {'name': self.variables['name'] or 'Page_1'}
!
! try:
! attrs['caption'] = self.variables['caption'] or 'New Tab'
! except KeyError:
! pass
!
! page = self.AddElement('page', self.form, attrs)
return 1
***************
*** 556,567 ****
#
TemplateInformation = {
'Product': 'forms',
! 'BaseClass' : PageBuilderWizard,
! 'Name' : 'Multi-Block form building template',
! 'Description' : 'Creates a page containing arbitrary number of blocks',
! 'Version' : '0.0.1',
'Author' : 'The GNUe Designer Team',
'Behavior': WIZARD,
! 'Location' : 'Tools|Add|Page'
}
--- 136,147 ----
#
TemplateInformation = {
'Product': 'forms',
! 'BaseClass' : AddPageWizard,
! 'Name' : 'Add Page',
! 'Description' : 'Inserts a blank page',
! 'Version' : VERSION,
'Author' : 'The GNUe Designer Team',
'Behavior': WIZARD,
! 'Location' : 'Tools|Insert|Blank Page'
}
Index: gnue/designer/templates/__init__.py
diff -c gnue/designer/templates/__init__.py:1.7
gnue/designer/templates/__init__.py:1.8
*** gnue/designer/templates/__init__.py:1.7 Thu Jul 18 14:18:32 2002
--- gnue/designer/templates/__init__.py Fri Jul 19 19:21:12 2002
***************
*** 68,74 ****
for dir in dircache.listdir(basedir):
base = string.split(dir,'.')[0]
if not dir[0] in ('.','_') and not base in processed:
- print "FOO: ",dir
processed.append(base)
try:
templates.append(dyn_import(
--- 68,73 ----
Index: gnue/designer/templates/forms/FormBuilder.py
diff -c gnue/designer/templates/forms/FormBuilder.py:1.5
gnue/designer/templates/forms/FormBuilder.py:1.6
*** gnue/designer/templates/forms/FormBuilder.py:1.5 Fri Jun 28 00:03:38 2002
--- gnue/designer/templates/forms/FormBuilder.py Fri Jul 19 19:21:14 2002
***************
*** 1,6 ****
#
- # Copyright 2001 Free Software Foundation
- #
# This file is part of GNU Enterprise.
#
# GNU Enterprise is free software; you can redistribute it
--- 1,4 ----
***************
*** 18,23 ****
--- 16,23 ----
# write to the Free Software Foundation, Inc., 59 Temple Place
# - Suite 330, Boston, MA 02111-1307, USA.
#
+ # Copyright 2001-2002 Free Software Foundation
+ #
# FILE:
# Simple.py
#
***************
*** 60,68 ****
#
# Initialize any runtime variables
#
! def Start(self, form):
self.form = form
- self.form.height = 0
# The first table can never have a master
self.variables['hasmaster0'] = '0'
--- 60,67 ----
#
# Initialize any runtime variables
#
! def Start(self, form, current):
self.form = form
# The first table can never have a master
self.variables['hasmaster0'] = '0'
***************
*** 350,360 ****
# No more user input is allowed at this point.
#
def Finalize(self):
- #
- # Set the basic attributes of the form
- #
- self.form.title = self.variables['title']
-
# Create a single page on which to place blocks and labels
pageCounter = 1
page = self.AddElement('page', self.form,
--- 349,354 ----
***************
*** 371,377 ****
page = self.AddElement('page', self.form,
{ 'name': 'pg%s' % pageCounter })
basey=0
!
tableKey = string.upper(self.variables['table%s' % count])
datasource = self.AddElement('datasource', self.form,
{ 'database':
self.variables['connection%s' % count],
--- 365,371 ----
page = self.AddElement('page', self.form,
{ 'name': 'pg%s' % pageCounter })
basey=0
!
tableKey = string.upper(self.variables['table%s' % count])
datasource = self.AddElement('datasource', self.form,
{ 'database':
self.variables['connection%s' % count],
***************
*** 408,414 ****
for field in tableSchema.getChildSchema(tableSchema):
if field.name in self.variables['tablefields%s' % count]:
fields[field.name] = field
!
entryQueue = []
labelQueue = []
largestField = 0
--- 402,408 ----
for field in tableSchema.getChildSchema(tableSchema):
if field.name in self.variables['tablefields%s' % count]:
fields[field.name] = field
!
entryQueue = []
labelQueue = []
largestField = 0
***************
*** 471,481 ****
# Rearrange the fields and labels to snugly fit the screen
# based on the layout arrangement selected by the user.
# Grid/multirecord layout
if multirecord:
! self.form.height = 13
! self.form.width = 1
x = 1
for i in range(len(entryQueue)):
--- 465,478 ----
# Rearrange the fields and labels to snugly fit the screen
# based on the layout arrangement selected by the user.
+ height = 0
+ width = 0
+
# Grid/multirecord layout
if multirecord:
! height = 13
! width = 1
x = 1
for i in range(len(entryQueue)):
***************
*** 495,501 ****
labelQueue[i].width or entryQueue[i].width) + 1
# Increase the form width accordingly
! self.form.width = self.form.width + dx
x = x + dx
# Single Record layout (regardless of label location)
--- 492,498 ----
labelQueue[i].width or entryQueue[i].width) + 1
# Increase the form width accordingly
! width += dx
x = x + dx
# Single Record layout (regardless of label location)
***************
*** 509,515 ****
fx, fy, fdx, fdy = (largestLabel + 2, basey + 1, 0, 1)
# Set form width
! self.form.width = largestField + largestLabel + 3
else:
# Labels above the entries
--- 506,512 ----
fx, fy, fdx, fdy = (largestLabel + 2, basey + 1, 0, 1)
# Set form width
! width = largestField + largestLabel + 3
else:
# Labels above the entries
***************
*** 517,529 ****
fx, fy, fdx, fdy = (1, basey +2, 0, 3)
# Set the form width
! self.form.width = 2 + (largestField > largestLabel and largestField
\
or largestLabel)
# Rearrange
! if self.form.height < fy+2-fdy:
! self.form.height = fy+2-fdy
!
for i in range(len(entryQueue)):
entryQueue[i].x = fx
entryQueue[i].y = fy
--- 514,526 ----
fx, fy, fdx, fdy = (1, basey +2, 0, 3)
# Set the form width
! width = 2 + (largestField > largestLabel and largestField \
or largestLabel)
# Rearrange
! if height < fy+2-fdy:
! height = fy+2-fdy
!
for i in range(len(entryQueue)):
entryQueue[i].x = fx
entryQueue[i].y = fy
***************
*** 533,543 ****
lx = lx + ldx
fy = fy + fdy
fx = fx + fdx
!
! if self.form.height < self.form.height + fdy:
! self.form.height += fdy
!
! basey = self.form.height - 1
dataSourceArray.append(datasource)
--- 530,540 ----
lx = lx + ldx
fy = fy + fdy
fx = fx + fdx
!
! if height < height + fdy:
! height += fdy
!
! basey = height - 1
dataSourceArray.append(datasource)
***************
*** 549,554 ****
--- 546,557 ----
datasource.master = dataSourceArray[master].name #
masterDataSource.name
datasource.masterlink =
string.join(self.variables['masterkeys%s'%count],',')
datasource.detaillink =
string.join(self.variables['detailkeys%s'%count],',')
+
+ #
+ # Set the basic attributes of the form
+ #
+ self.ModifyElement(self.form, title=self.variables['title'],
+ width=width, height=height)
return 1
Index: gnue/designer/templates/forms/Simple.py
diff -c gnue/designer/templates/forms/Simple.py:1.9
gnue/designer/templates/forms/Simple.py:1.10
*** gnue/designer/templates/forms/Simple.py:1.9 Fri Jun 28 00:03:38 2002
--- gnue/designer/templates/forms/Simple.py Fri Jul 19 19:21:14 2002
***************
*** 55,61 ****
#
# Initialize any runtime variables
#
! def Start(self, form):
self.form = form
--- 55,61 ----
#
# Initialize any runtime variables
#
! def Start(self, form, current):
self.form = form
***************
*** 169,175 ****
leftlabels = self.variables['arrangement'] == 'left'
# Set the basic attributes of the form
! self.form.title = self.variables['title']
# Create a single datasource based on user's input
datasource = self.AddElement('datasource', self.form,
--- 169,175 ----
leftlabels = self.variables['arrangement'] == 'left'
# Set the basic attributes of the form
! self.ModifyElement(self.form, title=self.variables['title'])
# Create a single datasource based on user's input
datasource = self.AddElement('datasource', self.form,
***************
*** 277,284 ****
# Grid/multirecord layout
if multirecord:
! self.form.height = 13
! self.form.width = 1
x = 1
for i in range(len(entryQueue)):
--- 277,284 ----
# Grid/multirecord layout
if multirecord:
! height = 13
! width = 1
x = 1
for i in range(len(entryQueue)):
***************
*** 298,304 ****
labelQueue[i].width or entryQueue[i].width) + 1
# Increase the form width accordingly
! self.form.width = self.form.width + dx
x = x + dx
# Single Record layout (regardless of label location)
--- 298,304 ----
labelQueue[i].width or entryQueue[i].width) + 1
# Increase the form width accordingly
! width += dx
x = x + dx
# Single Record layout (regardless of label location)
***************
*** 312,318 ****
fx, fy, fdx, fdy = (largestLabel + 2, 1, 0, 1)
# Set form width
! self.form.width = largestField + largestLabel + 3
else:
# Labels above the entries
--- 312,318 ----
fx, fy, fdx, fdy = (largestLabel + 2, 1, 0, 1)
# Set form width
! width = largestField + largestLabel + 3
else:
# Labels above the entries
***************
*** 320,330 ****
fx, fy, fdx, fdy = (1, 2, 0, 3)
# Set the form width
! self.form.width = 2 + (largestField > largestLabel and largestField \
or largestLabel)
# Rearrange
! self.form.height = fy+2-fdy
for i in range(len(entryQueue)):
entryQueue[i].x = fx
entryQueue[i].y = fy
--- 320,330 ----
fx, fy, fdx, fdy = (1, 2, 0, 3)
# Set the form width
! width = 2 + (largestField > largestLabel and largestField \
or largestLabel)
# Rearrange
! height = fy+2-fdy
for i in range(len(entryQueue)):
entryQueue[i].x = fx
entryQueue[i].y = fy
***************
*** 334,341 ****
lx = lx + ldx
fy = fy + fdy
fx = fx + fdx
! self.form.height = self.form.height + fdy
# That's it... we're done.
return 1
--- 334,342 ----
lx = lx + ldx
fy = fy + fdy
fx = fx + fdx
! height = self.form.height + fdy
+ self.ModifyElement(self.form, width=width, height=height)
# That's it... we're done.
return 1
Index: gnue/designer/templates/forms/SimpleDetail.py
diff -c gnue/designer/templates/forms/SimpleDetail.py:1.3
gnue/designer/templates/forms/SimpleDetail.py:1.4
*** gnue/designer/templates/forms/SimpleDetail.py:1.3 Fri Jun 28 00:03:38 2002
--- gnue/designer/templates/forms/SimpleDetail.py Fri Jul 19 19:21:14 2002
***************
*** 47,53 ****
#
# Initialize any runtime variables
#
! def Start(self, form):
self.form = form
--- 47,53 ----
#
# Initialize any runtime variables
#
! def Start(self, form, current):
self.form = form
***************
*** 246,252 ****
leftlabels = self.variables['masterarrangement'] == 'left'
# Set the basic attributes of the form
! self.form.title = self.variables['title']
# Create a single datasource based on user's input
datasource = self.AddElement('datasource', self.form,
--- 246,252 ----
leftlabels = self.variables['masterarrangement'] == 'left'
# Set the basic attributes of the form
! self.ModifyElement(form, title=self.variables['title'])
# Create a single datasource based on user's input
datasource = self.AddElement('datasource', self.form,
***************
*** 354,361 ****
# Grid/multirecord layout
if multirecord:
! self.form.height = 13
! self.form.width = 1
x = 1
for i in range(len(entryQueue)):
--- 354,361 ----
# Grid/multirecord layout
if multirecord:
! height = 13
! width = 1
x = 1
for i in range(len(entryQueue)):
***************
*** 375,381 ****
labelQueue[i].width or entryQueue[i].width) + 1
# Increase the form width accordingly
! self.form.width = self.form.width + dx
x = x + dx
# Single Record layout (regardless of label location)
--- 375,381 ----
labelQueue[i].width or entryQueue[i].width) + 1
# Increase the form width accordingly
! width += dx
x = x + dx
# Single Record layout (regardless of label location)
***************
*** 389,395 ****
fx, fy, fdx, fdy = (largestLabel + 2, 1, 0, 1)
# Set form width
! self.form.width = largestField + largestLabel + 3
else:
# Labels above the entries
--- 389,395 ----
fx, fy, fdx, fdy = (largestLabel + 2, 1, 0, 1)
# Set form width
! width = largestField + largestLabel + 3
else:
# Labels above the entries
***************
*** 397,407 ****
fx, fy, fdx, fdy = (1, 2, 0, 3)
# Set the form width
! self.form.width = 2 + (largestField > largestLabel and largestField \
or largestLabel)
# Rearrange
! self.form.height = fy+2-fdy
for i in range(len(entryQueue)):
entryQueue[i].x = fx
entryQueue[i].y = fy
--- 397,407 ----
fx, fy, fdx, fdy = (1, 2, 0, 3)
# Set the form width
! width = 2 + (largestField > largestLabel and largestField \
or largestLabel)
# Rearrange
! height = fy+2-fdy
for i in range(len(entryQueue)):
entryQueue[i].x = fx
entryQueue[i].y = fy
***************
*** 411,417 ****
lx = lx + ldx
fy = fy + fdy
fx = fx + fdx
! self.form.height = self.form.height + fdy
masterDataSource = datasource
--- 411,417 ----
lx = lx + ldx
fy = fy + fdy
fx = fx + fdx
! height = height + fdy
masterDataSource = datasource
***************
*** 421,427 ****
#### Detail block
####
! basey = self.form.height - 1
# We will use the table name as the basis for all our
# object names. We will add a prefix based on the object
--- 421,427 ----
#### Detail block
####
! basey = height - 1
# We will use the table name as the basis for all our
# object names. We will add a prefix based on the object
***************
*** 542,548 ****
# Grid/multirecord layout
if multirecord:
! self.form.height += 12
form_width = 1
x = 1
--- 542,548 ----
# Grid/multirecord layout
if multirecord:
! height += 12
form_width = 1
x = 1
***************
*** 567,573 ****
form_width = form_width + dx
x = x + dx
! self.form.width = max(self.form.width, form_width)
# Single Record layout (regardless of label location)
else:
--- 567,573 ----
form_width = form_width + dx
x = x + dx
! width = max(width, form_width)
# Single Record layout (regardless of label location)
else:
***************
*** 580,586 ****
fx, fy, fdx, fdy = (largestLabel + 2, basey + 1, 0, 1)
# Set form width
! self.form.width = max(self.form.width,largestField + largestLabel + 3)
else:
# Labels above the entries
--- 580,586 ----
fx, fy, fdx, fdy = (largestLabel + 2, basey + 1, 0, 1)
# Set form width
! width = max(width,largestField + largestLabel + 3)
else:
# Labels above the entries
***************
*** 588,597 ****
fx, fy, fdx, fdy = (1, basey + 2, 0, 3)
# Set the form width
! self.form.width = max(self.form.width, 2 + max(largestField,
largestLabel))
# Rearrange
! self.form.height += 1
for i in range(len(entryQueue)):
entryQueue[i].x = fx
entryQueue[i].y = fy
--- 588,597 ----
fx, fy, fdx, fdy = (1, basey + 2, 0, 3)
# Set the form width
! width = max(width, 2 + max(largestField, largestLabel))
# Rearrange
! height += 1
for i in range(len(entryQueue)):
entryQueue[i].x = fx
entryQueue[i].y = fy
***************
*** 601,617 ****
lx = lx + ldx
fy = fy + fdy
fx = fx + fdx
! self.form.height = self.form.height + fdy
####
#### Set detail datasource to point towards master
####
! datasource.master = masterDataSource.name
! datasource.masterlink = string.join(self.variables['masterkeys'],',')
! datasource.detaillink = string.join(self.variables['detailkeys'],',')
# That's it... we're done.
return 1
--- 601,623 ----
lx = lx + ldx
fy = fy + fdy
fx = fx + fdx
! height += fdy
####
#### Set detail datasource to point towards master
####
! self.ModifyElement(datasource, master=masterDataSource.name,
! masterlink=string.join(self.variables['masterkeys'],','),
! detaillink=string.join(self.variables['detailkeys'],','))
+
+ ####
+ #### Set form width & height
+ ####
+
+ self.ModifyElement(self.form, height=height, width=width)
# That's it... we're done.
return 1
Index: gnue/designer/templates/schema/Introspection.py
diff -c gnue/designer/templates/schema/Introspection.py:1.1
gnue/designer/templates/schema/Introspection.py:1.2
*** gnue/designer/templates/schema/Introspection.py:1.1 Fri Jun 28 00:04:38 2002
--- gnue/designer/templates/schema/Introspection.py Fri Jul 19 19:21:15 2002
***************
*** 52,58 ****
#
# Initialize any runtime variables
#
! def Start(self, root):
self.root = root
--- 52,58 ----
#
# Initialize any runtime variables
#
! def Start(self, root, current):
self.root = root
***************
*** 121,128 ****
#
def Finalize(self):
! # Set the basic attributes of the form
! self.root.title = self.variables['title']
conn = self.variables['connection']
--- 121,128 ----
#
def Finalize(self):
! # Set the basic attributes of the schema
! self.ModifyElement(self.root, title=self.variables['title'])
conn = self.variables['connection']
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/designer src/Designer.py src/Instance.py s...,
Jason Cater <=