commit-gnue
[Top][All Lists]
Advanced

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

gnue/designer/src Instance.py MenuBar.py ToolFr...


From: Jason Cater
Subject: gnue/designer/src Instance.py MenuBar.py ToolFr...
Date: Thu, 11 Jul 2002 01:39:02 -0400

CVSROOT:        /home/cvs
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/07/11 01:39:02

Modified files:
        designer/src   : Instance.py MenuBar.py ToolFrame.py 
        designer/src/forms: Instance.py 
        designer/src/forms/wizards: AddPage.py 

Log message:
        cleanup of menubar creation logic to allow for dynamically 
loaded/wizard-based/user-customizable tools/scripts

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/designer/src/Instance.py.diff?cvsroot=OldCVS&tr1=1.56&tr2=1.57&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/designer/src/MenuBar.py.diff?cvsroot=OldCVS&tr1=1.23&tr2=1.24&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/designer/src/ToolFrame.py.diff?cvsroot=OldCVS&tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/designer/src/forms/Instance.py.diff?cvsroot=OldCVS&tr1=1.10&tr2=1.11&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/designer/src/forms/wizards/AddPage.py.diff?cvsroot=OldCVS&tr1=1.1&tr2=1.2&r1=text&r2=text

Patches:
Index: gnue/designer/src/Instance.py
diff -c gnue/designer/src/Instance.py:1.56 gnue/designer/src/Instance.py:1.57
*** gnue/designer/src/Instance.py:1.56  Wed Jul 10 12:05:18 2002
--- gnue/designer/src/Instance.py       Thu Jul 11 01:39:02 2002
***************
*** 166,171 ****
--- 166,172 ----
  
      # Create the supplemental tools
      self.createTools()
+     self._menubar.buildMenu()
      self._menubar.lastToolAdded()
  
      self._app.addInstance(self)
***************
*** 194,205 ****
      GDebug.printMesg(2,'Adding tool %s [%s]' % (title,id))
      window = ToolFrame(self, title)
      control = baseclass(self, self.rootObject, window)
!     window.finalize()
      self.__dict__["%sWindow" % id] = window
      self.__dict__[id] = control
      self.__objectListeners.append(control)
  
!   
    def addToolCreate(self, title, method):
      self._menubar.addToolCreate(title, method)
  
--- 195,206 ----
      GDebug.printMesg(2,'Adding tool %s [%s]' % (title,id))
      window = ToolFrame(self, title)
      control = baseclass(self, self.rootObject, window)
! ##    window.finalize()  # Called by MenuBar now :`(
      self.__dict__["%sWindow" % id] = window
      self.__dict__[id] = control
      self.__objectListeners.append(control)
  
! 
    def addToolCreate(self, title, method):
      self._menubar.addToolCreate(title, method)
  
***************
*** 469,477 ****
  
    #################################################################
    #
-   # Return a list of the TemplateInformation dictionaries for all
-   # available templates in the specified <module> (package).
-   #
    #################################################################
  
    def loadWizards(self, package):
--- 470,475 ----
***************
*** 489,501 ****
          try:
            templates.append(dyn_import(
               '%s.%s' % (package.__name__,base)).TemplateInformation)
!         except ImportError:
!           pass
          except AttributeError:
!           GDebug.printMesg(2,_('Wizard %s for package %s is missing'+
!                            ' an \'TemplateInformation\' attribute.') %
                             (base,package.__name__))
!     return templates
  
  #
  # Helper class used by the tool-specific packages
--- 487,507 ----
          try:
            templates.append(dyn_import(
               '%s.%s' % (package.__name__,base)).TemplateInformation)
!         except ImportError, mesg:
!           GDebug.printMesg(2,"%s.%s doesn't appear to be a valid wizard" % 
(package.__name, base))
!           GDebug.printMesg(5,' --> %s' % (mesg))
          except AttributeError:
!           GDebug.printMesg(2,'Wizard %s for package %s is missing'
!                    ' an \'TemplateInformation\' attribute.' %
                             (base,package.__name__))
! 
!     for template in templates:
!       try:
!         location = template['Location']
!         if location:
!           self._menubar.addWizardLocation(location, template)
!       except ValueError:
!         continue
  
  #
  # Helper class used by the tool-specific packages
Index: gnue/designer/src/MenuBar.py
diff -c gnue/designer/src/MenuBar.py:1.23 gnue/designer/src/MenuBar.py:1.24
*** gnue/designer/src/MenuBar.py:1.23   Mon Jul  8 23:05:09 2002
--- gnue/designer/src/MenuBar.py        Thu Jul 11 01:39:02 2002
***************
*** 31,75 ****
  import MRUManager
  from ToolSupport import SupportedTools
  
- # File menu
- ID_NEW = wxNewId()
- ID_OPEN = wxNewId()
- ID_OPEN_RECENT = wxNewId()
- ID_SAVE = wxNewId()
- ID_SAVE_AS = wxNewId()
- ID_SAVE_ALL = wxNewId()
- ID_CONNECT = wxNewId()
- ID_CLOSE = wxNewId()
- ID_RELOAD = wxNewId()
- ID_EXIT = wxNewId()
- 
- # FileNew menu
- ID_NEW_FORM = wxNewId()
- ID_NEW_REPORT = wxNewId()
- ID_NEW_WIZARD = wxNewId()
- 
- # Edit menu
- ID_CUT = wxNewId()
- ID_COPY = wxNewId()
- ID_PASTE = wxNewId()
- ID_PASTE_SPECIAL = wxNewId()
- ID_DELETE = wxNewId()
- 
- # Debug menu
- ID_RUN = wxNewId()
- 
- # Help menu
- ID_ABOUT = wxNewId()
- 
  #
  #
  #
  class MainMenuBar(wxMenuBar):
    def __init__(self, frame):
       wxMenuBar.__init__(self)
  
       self._frame = frame
  
       self._file = wxMenu()
       self._fileNew = wxMenu()
       self._fileRecent = wxMenu()
--- 31,90 ----
  import MRUManager
  from ToolSupport import SupportedTools
  
  #
  #
  #
  class MainMenuBar(wxMenuBar):
    def __init__(self, frame):
       wxMenuBar.__init__(self)
+      
+      # Keep track of user-installed + sys-installed wizards/tools
+      self._menuMappings = {}
+ 
+      # So we can honor the module's requested order for the tool menu
+      self._toolMenuOrder = []
  
       self._frame = frame
  
+   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):
+      frame = self._frame
+      # File menu
+      ID_NEW = wxNewId()
+      ID_OPEN = wxNewId()
+      ID_OPEN_RECENT = wxNewId()
+      ID_SAVE = wxNewId()
+      ID_SAVE_AS = wxNewId()
+      ID_SAVE_ALL = wxNewId()
+      ID_CONNECT = wxNewId()
+      ID_CLOSE = wxNewId()
+      ID_RELOAD = wxNewId()
+      ID_EXIT = wxNewId()
+ 
+      # FileNew menu
+      ID_NEW_FORM = wxNewId()
+      ID_NEW_REPORT = wxNewId()
+      ID_NEW_WIZARD = wxNewId()
+ 
+      # Edit menu
+      ID_CUT = wxNewId()
+      ID_COPY = wxNewId()
+      ID_PASTE = wxNewId()
+      ID_PASTE_SPECIAL = wxNewId()
+      ID_DELETE = wxNewId()
+ 
+      # Debug menu
+      ID_RUN = wxNewId()
+ 
+      # Help menu
+      ID_ABOUT = wxNewId()
+ 
+ 
+ 
       self._file = wxMenu()
       self._fileNew = wxMenu()
       self._fileRecent = wxMenu()
***************
*** 105,111 ****
       EVT_MENU (frame, ID_CLOSE, frame.OnClose)
       EVT_MENU (frame, ID_EXIT, frame._app.OnExit)
  
- 
       # Set up out MRU list
       frame._app.mru.addMenu(self._fileRecent, frame)
  
--- 120,125 ----
***************
*** 155,162 ****
       self._edit.Enable(ID_PASTE_SPECIAL,0)
       self._edit.Enable(ID_DELETE,0)
  
       self._tools = wxMenu()
!      self._toolsCreate = None
  
       self._debug = wxMenu()
       self._debug.Append(ID_RUN, _('&Run'), _("Run the current form"))
--- 169,190 ----
       self._edit.Enable(ID_PASTE_SPECIAL,0)
       self._edit.Enable(ID_DELETE,0)
  
+ 
       self._tools = wxMenu()
!      for location in self._toolMenuOrder:
! 
!        # Grab our ToolRunner (or WizardRunner if tool was replaced???)
!        # and delete the reference.
!        tool = self._menuMappings[location]
!        del self._menuMappings[location]
! 
!        menu = wxMenuItem(self._tools, tool.wxId, tool.title,
!                          tool.tooltip, tool.checkable)
!        tool.menu = menu
!        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"))
***************
*** 168,198 ****
       self.Append(self._tools, _('&Tools'))
       self.Append(self._help, _('&Help'))
  
- 
    def addTool(self, toolFrame, title):
! 
!     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 addToolCreate(self, title, method):
!     if not self._toolsCreate:
!       wid = wxNewId()
!       self._toolsCreate = wxMenu()
!       self._tools.AppendSeparator()
!       self._tools.AppendMenu(wid, _('&Insert'), self._toolsCreate)
! 
!     wid = wxNewId()
!     menu = wxMenuItem(self._toolsCreate, wid,
!           '&%s' % title)
!     self._toolsCreate.AppendItem(menu)
!     EVT_MENU(self._frame, wid, method)
  
  
    def lastToolAdded(self):
!    self._tools.AppendSeparator()
  
  
--- 196,248 ----
       self.Append(self._tools, _('&Tools'))
       self.Append(self._help, _('&Help'))
  
    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
! 
! 
! class ToolRunner:
!   def __init__(self, toolFrame, title):
!      self.toolFrame = toolFrame
! 
!      self.wxId = wxNewId()
!      self.title = title
!      self.checkable = 1
!      self.tooltip = _("Show or hide the %s") % title
  
+   def run(self, event):
+     self.toolFrame.OnMenuSelected(event)
  
+   def finalize(self):
+     self.toolFrame.finalize()
Index: gnue/designer/src/ToolFrame.py
diff -c gnue/designer/src/ToolFrame.py:1.11 gnue/designer/src/ToolFrame.py:1.12
*** gnue/designer/src/ToolFrame.py:1.11 Wed Jul  3 11:33:18 2002
--- gnue/designer/src/ToolFrame.py      Thu Jul 11 01:39:02 2002
***************
*** 56,63 ****
      self.instance = instance
  
      # Add ourselves to the Window menu
!     menuID = wxNewId()
!     self.menu = self.instance._menubar.addTool(self, title)
  
      EVT_CLOSE(self, self.OnClose)
  
--- 56,62 ----
      self.instance = instance
  
      # Add ourselves to the Window menu
!     self.menutool = self.instance._menubar.addTool(self, title)
  
      EVT_CLOSE(self, self.OnClose)
  
***************
*** 89,116 ****
                'y': y,
                'height': height,
                'width': width,
!               'visible': self._menu.IsChecked() } )
  
  
    # This event is set by MenuBar.addTool
    # Called whenever menu item is selected
    def OnMenuSelected(self, event):
!     if self._menu.IsChecked():
        self.show()
      else:
        self.hide()
  
    def show(self):
!     self._menu.SetHelp(_("Hide the %s window")  % self.title)
!     self._menu.Check(1)
      self.Show(1)
  
!   def hide(self): 
!     self._menu.SetHelp(_("Show the %s window") % self.title)
!     self._menu.Check(0)
      self.Show(0)
  
!   def OnClose(self, event): 
      self.hide()
      event.Veto()
  
--- 88,115 ----
                'y': y,
                'height': height,
                'width': width,
!               'visible': self.menutool.menu.IsChecked() } )
  
  
    # This event is set by MenuBar.addTool
    # Called whenever menu item is selected
    def OnMenuSelected(self, event):
!     if self.menutool.menu.IsChecked():
        self.show()
      else:
        self.hide()
  
    def show(self):
!     self.menutool.menu.SetHelp(_("Hide the %s window")  % self.title)
!     self.menutool.menu.Check(1)
      self.Show(1)
  
!   def hide(self):
!     self.menutool.menu.SetHelp(_("Show the %s window") % self.title)
!     self.menutool.menu.Check(0)
      self.Show(0)
  
!   def OnClose(self, event):
      self.hide()
      event.Veto()
  
Index: gnue/designer/src/forms/Instance.py
diff -c gnue/designer/src/forms/Instance.py:1.10 
gnue/designer/src/forms/Instance.py:1.11
*** gnue/designer/src/forms/Instance.py:1.10    Tue Jul  9 00:03:45 2002
--- gnue/designer/src/forms/Instance.py Thu Jul 11 01:39:02 2002
***************
*** 104,114 ****
      self.addTool('datasourceEditor', _('Data Source Editor'), 
DataSourceEditor)
      self.addTool('schemaViewer', _('Schema Navigator'), SchemaViewer)
  
- ##    self.addToolCreate(_('DataSource'), self.insertDataSourceTool)
- ##    self.addToolCreate(_('Page'), self.insertPageTool)
- ##    self.addToolCreate(_('Block'), self.insertBlockTool)
- ##    self.addToolCreate(_('Field'), self.insertFieldTool)
- 
      self.loadWizards(wizards)
  
  
--- 104,109 ----
Index: gnue/designer/src/forms/wizards/AddPage.py
diff -c gnue/designer/src/forms/wizards/AddPage.py:1.1 
gnue/designer/src/forms/wizards/AddPage.py:1.2
*** gnue/designer/src/forms/wizards/AddPage.py:1.1      Tue Jul  9 00:03:45 2002
--- gnue/designer/src/forms/wizards/AddPage.py  Thu Jul 11 01:39:02 2002
***************
*** 94,100 ****
          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
--- 94,100 ----
          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
***************
*** 115,122 ****
      #
      if step == '0':
  
!       return   { 'title': 'Basic Form Information',
!                  'content': (WizardText('Welcome to the sample form 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.'),
--- 115,122 ----
      #
      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.'),
***************
*** 350,359 ****
    # 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
--- 350,355 ----
***************
*** 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],
--- 367,373 ----
          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],
***************
*** 561,571 ****
  TemplateInformation = {
      'Product': 'forms',
      'BaseClass' : PageBuilderWizard,
!     'Name' : 'Multi-Block, Page form building template',
      'Description' : 'Creates a page containing arbitrary number of blocks',
      'Version' : '0.0.1',
      'Author' : 'The GNUe Designer Team',
      'Behavior': WIZARD,
!     'Menu' : 'Add/Page'
  }
  
--- 557,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'
  }
  



reply via email to

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