[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue designer/src/TemplateParser.py designer/te...
From: |
James Thompson |
Subject: |
gnue designer/src/TemplateParser.py designer/te... |
Date: |
Thu, 28 Feb 2002 22:13:55 -0500 |
CVSROOT: /cvsroot/gnue
Module name: gnue
Changes by: James Thompson <address@hidden> 02/02/28 22:13:51
Modified files:
designer/src : TemplateParser.py
designer/templates/forms: FormBuilder.py
forms/src : GFDisplayHandler.py
Log message:
Working Form Builder Template(still need pages support)
Added Select All button to field selection lists
Removed printed tracing stuff
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/TemplateParser.py.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/templates/forms/FormBuilder.py.diff?tr1=1.2&tr2=1.3&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/forms/src/GFDisplayHandler.py.diff?tr1=1.14&tr2=1.15&r1=text&r2=text
Patches:
Index: gnue/designer/src/TemplateParser.py
diff -c gnue/designer/src/TemplateParser.py:1.9
gnue/designer/src/TemplateParser.py:1.10
*** gnue/designer/src/TemplateParser.py:1.9 Fri Jan 25 11:37:47 2002
--- gnue/designer/src/TemplateParser.py Thu Feb 28 22:13:51 2002
***************
*** 369,383 ****
--- 369,386 ----
self.delButton = wxButton(self, -1, "< Remove ")
self.upButton = wxButton(self, -1, "Move Up")
self.downButton = wxButton(self, -1, "Move Down")
+ self.selectAllButton = wxButton(self, -1, "Select All")
self.addButton.SetSize(self.downButton.GetSize())
self.delButton.SetSize(self.downButton.GetSize())
self.upButton.SetSize(self.downButton.GetSize())
+ self.selectAllButton.SetSize(self.downButton.GetSize())
self.addButton.Enable(0)
self.delButton.Enable(0)
self.upButton.Enable(0)
self.downButton.Enable(0)
+ self.selectAllButton.Enable(1)
self.list1 = wxListBox(self, -1, wxPoint(6,6), \
style=wxLB_MULTIPLE|wxLB_HSCROLL|wxLB_NEEDED_SB)
***************
*** 398,406 ****
self.delButton.SetPosition(wxPoint(lw + 12, 16 + bh))
self.upButton.SetPosition(wxPoint(lw + 12, 26 + bh*2))
self.downButton.SetPosition(wxPoint(lw + 12, 30 + bh*3))
self.list1.SetSize(wxSize(self.list1.GetSizeTuple()[0],
! 36 + bh*4))
self.list2.SetSize(self.list1.GetSize())
self.list2.SetPosition(wxPoint(lw+bw+18,6))
--- 401,410 ----
self.delButton.SetPosition(wxPoint(lw + 12, 16 + bh))
self.upButton.SetPosition(wxPoint(lw + 12, 26 + bh*2))
self.downButton.SetPosition(wxPoint(lw + 12, 30 + bh*3))
+ self.selectAllButton.SetPosition(wxPoint(lw + 12, 34 + bh*4))
self.list1.SetSize(wxSize(self.list1.GetSizeTuple()[0],
! 50 + bh*4))
self.list2.SetSize(self.list1.GetSize())
self.list2.SetPosition(wxPoint(lw+bw+18,6))
***************
*** 412,417 ****
--- 416,422 ----
EVT_BUTTON(self, self.delButton.GetId(), self.OnRemove)
EVT_BUTTON(self, self.upButton.GetId(), self.OnMoveUp)
EVT_BUTTON(self, self.downButton.GetId(), self.OnMoveDown)
+ EVT_BUTTON(self, self.selectAllButton.GetId(), self.OnSelectAll)
EVT_LISTBOX(self, self.list1.GetId(), self.OnSelectLeft)
EVT_LISTBOX(self, self.list2.GetId(), self.OnSelectRight)
***************
*** 477,482 ****
--- 482,493 ----
for i in self.list1.GetSelections():
self.list1.SetSelection(i,0)
+ def OnSelectAll(self, event):
+
+ count = self.list1.Number()
+ for count in range(count):
+ self.list1.SetSelection(count)
+ self.addButton.Enable(1)
def OnAdd(self, event):
sel = list(self.list1.GetSelections())
Index: gnue/designer/templates/forms/FormBuilder.py
diff -c gnue/designer/templates/forms/FormBuilder.py:1.2
gnue/designer/templates/forms/FormBuilder.py:1.3
*** gnue/designer/templates/forms/FormBuilder.py:1.2 Thu Feb 28 11:44:23 2002
--- gnue/designer/templates/forms/FormBuilder.py Thu Feb 28 22:13:51 2002
***************
*** 280,286 ****
return { 'title': 'Detail key fields',
'content': (WizardText('Which detail-level fields are the
foreign keys?'),
! WizardInput('detailkeys', label='Columns:',
required=1,
maxSelections=-1, orderable=1,
set=self.GetAvailableFields( \
self.variables['connection%s'
% iteration],
--- 280,286 ----
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],
***************
*** 313,319 ****
'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),
--- 313,318 ----
***************
*** 343,739 ****
# No more user input is allowed at this point.
#
def Finalize(self):
!
! ####
! #### Master block
! ####
!
! # We will use the table name as the basis for all our
! # object names. We will add a prefix based on the object
! # type to the table name. Capitalize the first letter and
! # strip all spaces...
! if len(self.variables['mastertable']) == 1:
! tableKey = string.upper(self.variables['mastertable'])
! else:
! tableKey = string.upper(self.variables['mastertable'][0]) + \
! string.replace(self.variables['mastertable'][1:],' ','_')
!
! # Is this a grid style form?
! multirecord = self.variables['masterarrangement'] == '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['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,
- { 'database': self.variables['connection'],
- 'table': self.variables['mastertable'],
- 'type': 'object',
- 'name': 'dts%s' % tableKey })
-
# Create a single page on which to place blocks and labels
page = self.AddElement('page', self.form,
! { 'name': 'pg%s' % tableKey })
!
!
! # We will need a block to hold our entries...
!
! # The basic attributes for a block
! attrs = {'name' : 'blk%s' % tableKey,
! '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)
!
! masterSchema = self.GetSourceSchema(self.variables['connection'],
! self.variables['mastertable'])
!
!
! # Create the entries and labels...
!
!
! # 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 masterSchema.getChildSchema(masterSchema):
! if field.name in self.variables['masterfields']:
! fields[field.name] = field
!
! entryQueue = []
! labelQueue = []
! largestField = 0
! largestLabel = 0
!
! # Now, let's make all the entries
! for name in self.variables['masterfields']:
!
! 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 = 1
! entryQueue[i].x = x
! entryQueue[i].y = 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, 1, 0, 1)
! fx, fy, fdx, fdy = (largestLabel + 2, 1, 0, 1)
! # Set form width
! self.form.width = largestField + largestLabel + 3
! else:
! # Labels above the entries
! lx, ly, ldx, ldy = (1, 1, 0, 3)
! 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
! labelQueue[i].x = lx
! labelQueue[i].y = ly
! ly = ly + ldy
! lx = lx + ldx
! fy = fy + fdy
! fx = fx + fdx
! self.form.height = self.form.height + fdy
!
!
! masterDataSource = datasource
!
!
! ####
! #### 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
! # type to the table name. Capitalize the first letter and
! # strip all spaces...
! if len(self.variables['detailtable']) == 1:
! tableKey = string.upper(self.variables['detailtable'])
! else:
! tableKey = string.upper(self.variables['detailtable'][0]) + \
! string.replace(self.variables['detailtable'][1:],' ','_')
!
! # Is this a grid style form?
! multirecord = self.variables['detailarrangement'] == '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['detailarrangement'] == 'left'
!
! # Create a single datasource based on user's input
! datasource = self.AddElement('datasource', self.form,
! { 'database': self.variables['connection'],
! 'table': self.variables['detailtable'],
! 'type': 'object',
! 'name': 'dts%s' % tableKey })
!
!
! # We will need a block to hold our entries...
!
! # The basic attributes for a block
! attrs = {'name' : 'blk%s' % tableKey,
! '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)
!
! detailSchema = self.GetSourceSchema(self.variables['connection'],
! self.variables['detailtable'])
!
!
! # Create the entries and labels...
!
!
! # 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 detailSchema.getChildSchema(detailSchema):
! if field.name in self.variables['detailfields']:
! fields[field.name] = field
!
! entryQueue = []
! labelQueue = []
! largestField = 0
! largestLabel = 0
!
! # Now, let's make all the entries
! for name in self.variables['detailfields']:
!
! 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 += 12
! 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
! 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:
! # 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 = max(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 = 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
! labelQueue[i].x = lx
! labelQueue[i].y = ly
! ly = ly + ldy
! 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
--- 342,536 ----
# 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
page = self.AddElement('page', self.form,
! { 'name': 'pg%s' % '1' })
! #
! # Add datasources
! #
! basey = 0
! dataSourceArray = []
! for count in range(self.variables['iterations']):
! 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
+ 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
+ self.form.height = 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
Index: gnue/forms/src/GFDisplayHandler.py
diff -c gnue/forms/src/GFDisplayHandler.py:1.14
gnue/forms/src/GFDisplayHandler.py:1.15
*** gnue/forms/src/GFDisplayHandler.py:1.14 Wed Feb 27 02:01:09 2002
--- gnue/forms/src/GFDisplayHandler.py Thu Feb 28 22:13:51 2002
***************
*** 469,475 ****
# TODO: Replace with format mask
def _buildDisplayHelper(self, val, editing):
! print "_buildDisplayHelper('%s')" % val
if val in (None,""):
return ""
--- 469,475 ----
# TODO: Replace with format mask
def _buildDisplayHelper(self, val, editing):
! #print "_buildDisplayHelper('%s')" % val
if val in (None,""):
return ""
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue designer/src/TemplateParser.py designer/te...,
James Thompson <=