commit-gnue
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

gnue/designer/src/forms/wizards AddBlock.py


From: Jason Cater
Subject: gnue/designer/src/forms/wizards AddBlock.py
Date: Thu, 06 Mar 2003 11:07:38 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    03/03/06 11:07:37

Modified files:
        designer/src/forms/wizards: AddBlock.py 

Log message:
        Improved AddBlock wizard to ask about datasources

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/forms/wizards/AddBlock.py.diff?tr1=1.7&tr2=1.8&r1=text&r2=text

Patches:
Index: gnue/designer/src/forms/wizards/AddBlock.py
diff -c gnue/designer/src/forms/wizards/AddBlock.py:1.7 
gnue/designer/src/forms/wizards/AddBlock.py:1.8
*** gnue/designer/src/forms/wizards/AddBlock.py:1.7     Thu Mar  6 01:58:21 2003
--- gnue/designer/src/forms/wizards/AddBlock.py Thu Mar  6 11:07:36 2003
***************
*** 38,44 ****
    # The template parser will initially
    # call GetStep(FIRST_STEP).
    FIRST_STEP = '0'
!   
  
    ###############
    #
--- 38,44 ----
    # The template parser will initially
    # call GetStep(FIRST_STEP).
    FIRST_STEP = '0'
! 
  
    ###############
    #
***************
*** 47,69 ****
    def Start(self, root, current):
      self.form = root
      self.current = current
  
    ###############
    #
    # Return the markup for a specific page
    #
!   def GetStep(self, step):
!     print step
      #
      # Step #0 / Get Name
      #
!     if step == '0':
  
!       content = [WizardText('This will insert a new block.'),
!                  WizardInput('name',label='Object Name:',required=1,size=20)]
!       return   { 'title': 'Add Block',
                   'content': content,
                   'prev': None,
                   'next': None }
  
    ###############
--- 47,147 ----
    def Start(self, root, current):
      self.form = root
      self.current = current
+     self.variables['rows'] = '1'
+ 
+     self.__getExistingDatasources()
+ 
  
    ###############
    #
    # Return the markup for a specific page
    #
!   def GetStep(self, stepCode):
! 
!     if stepCode == '1':
!       if self.variables['datasource'] == 0:
!         stepCode = '1:new'
!       elif self.variables['datasource'] == 1:
!         stepCode = '1:reuse'
!       else:
!         stepCode = '1:none'
! 
      #
      # Step #0 / Get Name
      #
!     if stepCode == '0':
  
!       if self.__firstConnection:
!         self.variables['connection'] = self.__firstConnection
! 
!       if len (self.__datasourceMap):
!           set=((0,_('Create a new datasource')),
!                (1,_('Use an existing datasource')),
!                (2,_('Create an unbound block (no datasource)') )
!                )
!       else:
!           set=((0,_('Create a new datasource')),
!                (2,_('Create an unbound block (no datasource)') )
!                )
! 
!       content = [WizardText(_('This will insert a new block.')),
!                  WizardInput('name',label=_('Object 
Name:'),required=1,size=20),
!                  WizardText(_('Where will this dropdown pull its data?')),
!                  WizardInput('datasource', label=_('Source:'), required=1,
!                                          maxSelections=1,
!                                          set=set),
!                  WizardText(_('How many rows should this block display at 
once?')),
!                  WizardInput('rows', label=_('Rows Displayed:'), required=1,
!                                 typecast=whole
!                              ) ]
! 
!       return   { 'title': _('Add Block'),
                   'content': content,
                   'prev': None,
+                  'next': '1' }
+ 
+     #
+     # Step #2 [New Datasource] / Get Connection
+     #
+     elif stepCode == '1:new':
+       return   { 'title': _('Datasource Connection'),
+                  'content': (WizardText('What connection should this form use 
to connect to the \ndatabase?'),
+                              WizardInput('connection',label='Connection:', 
required=1,
+                                          set=self.GetAvailableConnections()),
+                              WizardText('You may be asked to login to this 
connection.')),
+                  'prev': '0',
+                  'next': '2:new' }
+ 
+     #
+     # Step #3 [New Datasource] / Get Table
+     #
+     elif stepCode == '2:new':
+       return   { 'title': 'Select Validator Table/Source',
+                  'content': (WizardText('Now, please select the table the 
dropdown will\nuse to populate its data set.'),
+                              WizardInput('table', label='Table:', required=1, 
lines=5,
+                                          
set=self.GetAvailableSources(self.variables['connection'])), ),
+                  'prev': '1:new',
+                  'next': None }
+ 
+ 
+     #
+     # Step #2 [reuse Datasource] / Get DataSource
+     #
+     elif stepCode == '1:reuse':
+       return   { 'title': 'Datasource Connection',
+                  'content': (WizardText('Which existing datasource should be 
used?'),
+                              WizardInput('source',label='Datasource:', 
required=1,
+                                          
set=self.__getExistingDatasources())),
+                  'prev': '0',
+                  'next': None }
+ 
+     #
+     # Step #2 [no DAtasource]
+     #
+     elif stepCode == '1:new':
+       return   { 'title': _('Done'),
+                  'content': (WizardText('We now have enough information to 
create your block.'),),
+                  'prev': '0',
                   'next': None }
  
    ###############
***************
*** 72,83 ****
    #
    def Finalize(self):
  
!     attrs = {'name': self.GetUniqueName(self.variables['name'] or 'Block1')}
      # Find form...
      logic = self.current['logic']
      block = self.AddElement('block', logic, attrs)
  
      return 1
  
  
  
--- 150,208 ----
    #
    def Finalize(self):
  
!     attrs = {'name': self.GetUniqueName(self.variables['name'] or 'Block1'),
!              'rows': int(self.variables['rows'])}
      # Find form...
      logic = self.current['logic']
+ 
+ 
+ 
+     #
+     # Set up or retrieve our datasource
+     #
+ 
+     # Create new datasource
+     if self.variables['datasource'] == 0:
+       datasource = self.AddElement('datasource', self.form,
+         { 'name': self.GetUniqueName("dts_%s_%s" % (self.variables['table'],
+                                      self.variables['name'])),
+           'connection': self.variables['connection'],
+           'prequery': 1,
+           'table': self.variables['table'] } )
+       attrs['datasource'] = datasource.name
+ 
+     # Reuse existing datasource
+     elif self.variables['datasource'] == 1:
+       datasource = self.__datasourceMap[self.variables['source']]
+       attrs['source'] = datasource.name
+ 
+     # Create a "static" datasource
+     else:
+       datasource = None
+ 
+ 
      block = self.AddElement('block', logic, attrs)
  
      return 1
+ 
+ 
+ 
+   ###############
+   #
+   # Internal stuff
+   # Get a list of all existing datasources
+   #
+   def __getExistingDatasources(self):
+     self.__firstConnection = None
+     self.__datasourceSet = []
+     self.__datasourceMap = {}
+     for child in self.form.findChildrenOfType('GFDataSource'):
+       if hasattr(child,'table'):
+         self.__datasourceSet.append((child.name,"%s (%s)" % (child.name, 
child.table)))
+         self.__datasourceMap[child.name] = child
+         if not self.__firstConnection:
+           self.__firstConnection = child.database
+     return self.__datasourceSet
  
  
  




reply via email to

[Prev in Thread] Current Thread [Next in Thread]