/[papo]/gnue/designer/src/forms/wizards/AddDropDown.py
ViewVC logotype

Diff of /gnue/designer/src/forms/wizards/AddDropDown.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by charlie, Tue Aug 27 20:39:55 2002 UTC revision 1.5 by styxman, Fri Nov 8 16:46:03 2002 UTC
# Line 60  class AddDropDownWizard(FormPrePositioni Line 60  class AddDropDownWizard(FormPrePositioni
60      self.current = current      self.current = current
61      self.x = x      self.x = x
62      self.y = y      self.y = y
63      self.width = 10      self.width = width
64      self.height = 1      self.height = height
65        self.__getExistingDatasources()
66    
67    
68    ###############    ###############
# Line 72  class AddDropDownWizard(FormPrePositioni Line 72  class AddDropDownWizard(FormPrePositioni
72    def GetStep(self, stepCode):    def GetStep(self, stepCode):
73    
74      if stepCode == '1':      if stepCode == '1':
75        if self.variables['datasource'] == sourcesOfData[0]:        if self.variables['datasource'] == 0:
76          stepCode = '1:new'          stepCode = '1:new'
77        elif self.variables['datasource'] == sourcesOfData[1]:        elif self.variables['datasource'] == 1:
78          stepCode = '1:reuse'          stepCode = '1:reuse'
79        else:        else:
80          stepCode = '1:fixed'          stepCode = '1:fixed'
# Line 87  class AddDropDownWizard(FormPrePositioni Line 87  class AddDropDownWizard(FormPrePositioni
87        if self.__firstConnection:        if self.__firstConnection:
88          self.variables['connection'] == self.__firstConnection          self.variables['connection'] == self.__firstConnection
89    
90          if len (self.__datasourceMap):
91              set=((0,'Create a new datasource'),
92                   (1,'Use an existing datasource'),
93                   (2,'Specify a static list of valid choices' )
94                   )
95          else:
96              set=((0,'Create a new datasource'),
97                   (2,'Specify a static list of valid choices' )
98                   )
99    
100    
101        return   { 'title': 'Add Dropdown Entry',        return   { 'title': 'Add Dropdown Entry',
102                   'content': (WizardText('To create your dropdown, I need to know some basic information. \n'                   'content': (WizardText('To create your dropdown, I need to know some basic information. '
103                                          'First, what field will store the dropdown\'s value?'),                                          'First, what field will store the dropdown\'s value?'),
104                               WizardInput('name', label='Field name:', required=1,                               WizardInput('name', label='Field name:', required=1,
105                                           size=40),                                           size=40),
106                               WizardText('Where will this dropdown pull its data?'),                               WizardText('Where will this dropdown pull its data?'),
107                               WizardInput('datasource', label='Source:', required=1,                               WizardInput('datasource', label='Source:', required=1,
108                                           maxSelections=-1, orderable=1,                                           maxSelections=1,
109                                           set=((0,'Create a new datasource'),                                           set=set)
                                               (1,'Use an existing datasource'),  
                                               (2,'Specify a static list of valid choices' )))  
110                              ),                              ),
111                   'prev': None,                   'prev': None,
112                   'next': '1' }                   'next': '1' }
# Line 154  class AddDropDownWizard(FormPrePositioni Line 163  class AddDropDownWizard(FormPrePositioni
163        return   { 'title': 'Datasource Connection',        return   { 'title': 'Datasource Connection',
164                   'content': (WizardText('What connection should this form use to connect to the \ndatabase?'),                   'content': (WizardText('What connection should this form use to connect to the \ndatabase?'),
165                               WizardInput('connection',label='Connection:', required=1,                               WizardInput('connection',label='Connection:', required=1,
166                                           set=self.__GetExistingDatasources()),                                           set=self.__getExistingDatasources()),
167                               WizardText('You may be asked to login to this connection.')),                               WizardText('You may be asked to login to this connection.')),
168                   'prev': '0',                   'prev': '0',
169                   'next': '2:reuse' }                   'next': '2:reuse' }
# Line 259  class AddDropDownWizard(FormPrePositioni Line 268  class AddDropDownWizard(FormPrePositioni
268          except ValueError:          except ValueError:
269            pass            pass
270          ssr = self.AddElement('staticsetrow', ss)          ssr = self.AddElement('staticsetrow', ss)
271          self.AddElement('staticsetfield',ssr,{'_content_': key})          self.AddElement('staticsetfield',ssr,{'name': 'key','value': key})
272          self.AddElement('staticsetfield',ssr,{'_content_': descr})          self.AddElement('staticsetfield',ssr,{'name': 'descr','value': descr})
273    
274    
275      #      #
276      # Create the dropdown      # Create the dropdown
277      #      #
278    
279      # TODO: Make sure self.current produces a Block      # Make sure we find a Block
280      self.AddElement('datasource', self.current.findChildOfType('GFBlock'),      block = self.current.findParentOfType('GFBlock')
281        if not block:
282          block = self.current.findParentOfType('GFPage').findChildOfType('GFBlock')
283          if not block:
284            # Create a block
285            block = self.AddElement('block', self.current.findParentOfType('GFPage'))
286    
287        self.AddElement('entry', self.current.findChildOfType('GFBlock'),
288                      { 'name': 'fld%s' % self.variables['name'],                      { 'name': 'fld%s' % self.variables['name'],
289                        'field': self.variables['name'],                        'field': self.variables['name'],
290                          'style': 'dropdown',
291                        'x': self.x,                        'x': self.x,
292                        'y': self.y,                        'y': self.y,
293                        'width': self.width or 10,                        'width': self.width or 10,
294                        'height': 1,                        'height': 1,
295                        'fk_source': datasource.name,                        'fk_source': datasource.name,
296                        'fk_key': key,                        'fk_key': keyfield,
297                        'fk_description': descr } )                        'fk_description': descrfield } )
298    
299    
300      return 1      return 1
# Line 298  class AddDropDownWizard(FormPrePositioni Line 315  class AddDropDownWizard(FormPrePositioni
315          self.__datasourceMap[child.name] = child          self.__datasourceMap[child.name] = child
316          if not self.__firstConnection:          if not self.__firstConnection:
317            self.__firstConnection = child.database            self.__firstConnection = child.database
318        return self.__datasourceSet
319    
320    
321    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26