commit-gnue
[Top][All Lists]
Advanced

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

gnue/designer/src DataSourceEditor.py Incubator...


From: Jason Cater
Subject: gnue/designer/src DataSourceEditor.py Incubator...
Date: Tue, 15 Jan 2002 14:08:02 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/01/15 14:08:01

Modified files:
        designer/src   : DataSourceEditor.py Incubator.py 
                         TriggerEditor.py 

Log message:
        start of schema introspection in designer; added fallback text editor

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/DataSourceEditor.py.diff?tr1=1.1&tr2=1.2&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/Incubator.py.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/TriggerEditor.py.diff?tr1=1.11&tr2=1.12&r1=text&r2=text

Patches:
Index: gnue/designer/src/DataSourceEditor.py
diff -c gnue/designer/src/DataSourceEditor.py:1.1 
gnue/designer/src/DataSourceEditor.py:1.2
*** gnue/designer/src/DataSourceEditor.py:1.1   Mon Jan 14 18:19:29 2002
--- gnue/designer/src/DataSourceEditor.py       Tue Jan 15 14:08:01 2002
***************
*** 31,36 ****
--- 31,37 ----
  from wxPython.wx import *
  from gnue.common import GDebug, GConfig, GDataSource
  import RuntimeSettings
+ import Incubator
  
  class DataSourceEditor(wxPanel):
    def __init__(self, parentWindow, instance, rootObject):
***************
*** 44,50 ****
      self.splitter = wxSplitterWindow(self, -1, style=wxSP_3D)
  
      self.list = wxListCtrl(self.splitter, -1, pos=wxPoint(0,0),
!              style=wxLC_REPORT|wxLC_EDIT_LABELS|wxLC_HRULES|wxLC_VRULES)
  
      self.list.InsertColumn(0,'Name')
      self.list.InsertColumn(1,'Source')
--- 45,52 ----
      self.splitter = wxSplitterWindow(self, -1, style=wxSP_3D)
  
      self.list = wxListCtrl(self.splitter, -1, pos=wxPoint(0,0),
!              style=wxLC_REPORT|wxLC_EDIT_LABELS|
!                    wxLC_HRULES|wxLC_VRULES|wxLC_SINGLE_SEL)
  
      self.list.InsertColumn(0,'Name')
      self.list.InsertColumn(1,'Source')
***************
*** 54,89 ****
  
      self.properties = wxPanel(self.notebook, -1)
      self.fields = wxPanel(self.notebook, -1)
  
      self.notebook.AddPage(self.properties, 'Properties')
      self.notebook.AddPage(self.fields, 'References')
  
      self.splitter.SplitHorizontally(self.list, self.notebook,200)
  
- 
      EVT_SIZE(self, self.OnSize)
  
!     self.datasources = {}
  
      instance.rootObject.walk (self.initialInventory)
      instance.rootObject.walk (self.inventoryObject)
  
      self.splitter.SetSize(self.GetSize())
  
      self.finalized = 0
      RuntimeSettings.registerRuntimeSettingHandler(self.instance, self)
  
  
    def initialInventory(self, object):
      if isinstance(object, GDataSource.GDataSource):
!       self.datasources[string.lower(object.name)] = object
  
  
    def inventoryObject(self, object):
      if isinstance(object, GDataSource.GDataSource):
        if hasattr(object,'master') and len(object.master):
          try:
!           object.__master = self.datasources[string.lower(object.master)]
          except KeyError:
            # TODO: Something better than this
            print "DataSource %s references non-existent master %s" % \
--- 56,102 ----
  
      self.properties = wxPanel(self.notebook, -1)
      self.fields = wxPanel(self.notebook, -1)
+     self.schemas = SchemaViewer(self, self.notebook)
  
      self.notebook.AddPage(self.properties, 'Properties')
      self.notebook.AddPage(self.fields, 'References')
+     self.notebook.AddPage(self.schemas, 'Schema')
  
      self.splitter.SplitHorizontally(self.list, self.notebook,200)
  
      EVT_SIZE(self, self.OnSize)
  
!     self.datasourceMap = {}
!     self.datasources = []
! 
!     self.current = None
  
      instance.rootObject.walk (self.initialInventory)
      instance.rootObject.walk (self.inventoryObject)
  
      self.splitter.SetSize(self.GetSize())
  
+     EVT_LIST_ITEM_SELECTED(self, self.list.GetId(), self.OnDSSelected)
+     self.onSetCurrentObject(self.current, "")
+ 
      self.finalized = 0
      RuntimeSettings.registerRuntimeSettingHandler(self.instance, self)
  
  
    def initialInventory(self, object):
      if isinstance(object, GDataSource.GDataSource):
!       self.datasourceMap[string.lower(object.name)] = object
!       self.datasourceMap[id(object)] = object
!       self.datasources.append(object)
!       if self.current is None:
!         self.current = object
  
  
    def inventoryObject(self, object):
      if isinstance(object, GDataSource.GDataSource):
        if hasattr(object,'master') and len(object.master):
          try:
!           object.__master = self.datasourceMap[string.lower(object.master)]
          except KeyError:
            # TODO: Something better than this
            print "DataSource %s references non-existent master %s" % \
***************
*** 116,122 ****
        self.propBar.setCurrentObject(object)
  
      if handler != __name__:
!       pass
  
  
    def onCreateObject (self, object, handler):
--- 129,142 ----
        self.propBar.setCurrentObject(object)
  
      if handler != __name__:
!       if isinstance(object, GDataSource.GDataSource):
! 
!         self.current = object
!         self.list.SetItemState ( object.__listIndex,
!                                  wxLIST_STATE_SELECTED,
!                                  wxLIST_STATE_SELECTED)
! 
!         self.list.EnsureVisible(object.__listIndex)
  
  
    def onCreateObject (self, object, handler):
***************
*** 136,142 ****
      if handler != __name__:
  
        if isinstance(object, GDataSource.GDataSource):
!         # TODO: Maintain self.datasources
  
  
          index = object.__listIndex
--- 156,162 ----
      if handler != __name__:
  
        if isinstance(object, GDataSource.GDataSource):
!         # TODO: Maintain self.datasourceMap
  
  
          index = object.__listIndex
***************
*** 151,159 ****
    def onDeleteObject (self, object, handler):
      if object == None:
        return
!     if handler != __name__:
!       if isinstance(object, GDataSource.GDataSource):
!         del self.datasources[string.lower(object.name)]
  
  
    def OnSize(self, event):
--- 171,194 ----
    def onDeleteObject (self, object, handler):
      if object == None:
        return
! 
!     if isinstance(object, GDataSource.GDataSource):
! 
!       index = object.__listIndex
! 
!       i = j = 0
!       for datasource in self.datasources:
!         if datasource == object: j = i
!         if datasource.__listIndex > index:
!           datasource.__listIndex -= 1
!           i += 1
! 
! 
!       self.datasources.pop(j)
!       self.list.DeleteItem(index)
! 
!       del self.datasourceMap[string.lower(object.name)]
!       del self.datasourceMap[id(object)]
  
  
    def OnSize(self, event):
***************
*** 185,190 ****
--- 220,230 ----
          RuntimeSettings.getint(
             self.runtime_section, "col%s" % i, -2))
  
+     for i in range(3):  # Should be the number of columns in the list
+       self.schemas.list.SetColumnWidth(i,
+         RuntimeSettings.getint(
+            self.runtime_section, "schemaCol%s" % i, -2))
+ 
  
    def saveRuntimeSettings(self):
      sash = self.GetPositionTuple()
***************
*** 194,206 ****
--- 234,271 ----
                'visibletab': self.notebook.GetSelection()
               }
  
+     # Save the top-level list column sizes
      for i in range(3):  # Should be the number of columns in the list
        settings["col%s" % i] = self.list.GetColumnWidth(i)
  
+     # Save the schema viewer column sizes
+     for i in range(SCH_COLUMNS):
+       settings["schemaCol%s" % i] = self.schemas.list.GetColumnWidth(i)
+ 
      return ( self.runtime_section,
               settings )
  
  
+   # A Datasource was selected in the menu
+   def OnDSSelected(self, event):
+     self.current = self.datasourceMap[event.GetData()]
+ 
+ 
+   def OnAddDSSelected(self, event):
+ 
+     attributes = {}
+     if self.current is not None:
+       attributes['database'] = \
+           hasattr(self.current,'database') and self.current.database or ''
+ 
+     Incubator.createObject(self.instance, self.rootObject, 'datasource',
+                            parent=self.rootObject, attributes=attributes)
+ 
+ 
+   def OnDeleteDSSelected(self, event):
+ 
+     if self.current is not None:
+       self.instance.onDeleteObject(self.current, __name__)
  
  
  
***************
*** 210,228 ****
      wxToolBar.__init__(self, parent, -1, style=wxTB_DOCKABLE)
      self.editor = editor
      parent.SetToolBar(self)
  
!     self.AddSimpleTool(203,
          wxImage(os.environ['INSTALL_PREFIX']+'/'+GConfig.get('tb_insert'),
                  wxBITMAP_TYPE_PNG).ConvertToBitmap(),
          "Create Data Source",
!         "Create Data Source")
  
!     self.AddSimpleTool(203,
          wxImage(os.environ['INSTALL_PREFIX']+'/'+GConfig.get('tb_delete'),
                  wxBITMAP_TYPE_PNG).ConvertToBitmap(),
          "Delete Data Source",
!         "Delete Data Source")
  
  
  
  
--- 275,340 ----
      wxToolBar.__init__(self, parent, -1, style=wxTB_DOCKABLE)
      self.editor = editor
      parent.SetToolBar(self)
+     self.connections = self.editor.instance._app.connections
+ 
+     self.addButtonId = wxNewId()
+     self.deleteButtonId = wxNewId()
  
!     self.AddSimpleTool(self.addButtonId,
          wxImage(os.environ['INSTALL_PREFIX']+'/'+GConfig.get('tb_insert'),
                  wxBITMAP_TYPE_PNG).ConvertToBitmap(),
          "Create Data Source",
!         "Create a new data source")
  
!     self.AddSimpleTool(self.deleteButtonId,
          wxImage(os.environ['INSTALL_PREFIX']+'/'+GConfig.get('tb_delete'),
                  wxBITMAP_TYPE_PNG).ConvertToBitmap(),
          "Delete Data Source",
!         "Delete the currently selected data source")
! 
!     EVT_TOOL(self, self.addButtonId, editor.OnAddDSSelected)
!     EVT_TOOL(self, self.deleteButtonId, editor.OnDeleteDSSelected)
! 
! 
!     self.dblinks = []
! 
! 
! 
! SCH_FIELD = 0
! SCH_TYPE = 1
! SCH_SIZE = 2
! SCH_NATIVE = 3
! SCH_REQ = 4
! SCH_COLUMNS = SCH_REQ + 1
  
  
+ class SchemaViewer(wxPanel):
+   def __init__(self, editor, parentWindow):
+     wxPanel.__init__(self, parentWindow, -1)
+     self.editor = editor
+ 
+     self.list = wxListCtrl(self, -1, pos=wxPoint(0,0),
+              style=wxLC_REPORT|wxLC_HRULES|wxLC_VRULES)
+ 
+     self.list.InsertColumn(SCH_FIELD, 'Field')
+     self.list.InsertColumn(SCH_TYPE,  'Base Type')
+     self.list.InsertColumn(SCH_SIZE,  'Size')
+     self.list.InsertColumn(SCH_NATIVE,'Native Type')
+     self.list.InsertColumn(SCH_REQ,   'Required')
+ 
+     EVT_SIZE(self, self.OnSize)
+ 
+ 
+   def fillList(self):
+ #    self.editor.
+     pass
+ 
+   def onSetCurrentObject(self, object, controller):
+     if isinstance(object, GDataSource.GDataSource):
+       self.current = object
+       self.fillList()
+ 
+   def OnSize(self, event):
+     self.list.SetSize(self.GetSize())
  
  
Index: gnue/designer/src/Incubator.py
diff -c gnue/designer/src/Incubator.py:1.11 gnue/designer/src/Incubator.py:1.12
*** gnue/designer/src/Incubator.py:1.11 Mon Nov 19 21:00:16 2001
--- gnue/designer/src/Incubator.py      Tue Jan 15 14:08:01 2002
***************
*** 84,90 ****
          attributes[attr] = name
  
    for attr in attributes.keys():
!     if attrs.has_key(attr): 
        o.__dict__[attr] = attributes[attr]
    o.name = name
    instance.nameMappings[o.name] = o
--- 84,90 ----
          attributes[attr] = name
  
    for attr in attributes.keys():
!     if attrs.has_key(attr):
        o.__dict__[attr] = attributes[attr]
    o.name = name
    instance.nameMappings[o.name] = o
***************
*** 93,101 ****
    instance.onSetCurrentObject(o, __name__)
  
  
! def reparentObject(instance, form, object, newParent): 
!   if object._parent == newParent: 
      return
    pass
  
  
--- 93,103 ----
    instance.onSetCurrentObject(o, __name__)
  
  
! def reparentObject(instance, form, object, newParent):
!   if object._parent == newParent:
      return
+ 
+   # TODO
    pass
  
  
Index: gnue/designer/src/TriggerEditor.py
diff -c gnue/designer/src/TriggerEditor.py:1.11 
gnue/designer/src/TriggerEditor.py:1.12
*** gnue/designer/src/TriggerEditor.py:1.11     Mon Jan 14 01:17:10 2002
--- gnue/designer/src/TriggerEditor.py  Tue Jan 15 14:08:01 2002
***************
*** 28,39 ****
  
  
  from wxPython.wx import *
- from wxPython.stc import *
  from gnue.common import GDebug, GParserHelpers, GConfig
  from gnue.forms import GFTrigger
  import keyword
  
  
  # What Mode are we in?
  NAMED_TRIGGER = 1
  EVENT_TRIGGER = 0
--- 28,39 ----
  
  
  from wxPython.wx import *
  from gnue.common import GDebug, GParserHelpers, GConfig
  from gnue.forms import GFTrigger
  import keyword
  
  
+ 
  # What Mode are we in?
  NAMED_TRIGGER = 1
  EVENT_TRIGGER = 0
***************
*** 45,51 ****
      height = int(wxSystemSettings_GetSystemMetric( wxSYS_SCREEN_Y )/3)
  
      wxPanel.__init__(self, parent, -1)
!     self.editor = PythonEditorControl(self,-1, pos=wxPoint(0,32))
      self.SetSize(parent.GetClientSize())
      self.editor.SetSize(self.GetClientSize())
      self.object = None
--- 45,58 ----
      height = int(wxSystemSettings_GetSystemMetric( wxSYS_SCREEN_Y )/3)
  
      wxPanel.__init__(self, parent, -1)
! 
!     if USE_STC:
!       EditorCtrl = PythonEditorControl
!     else:
!       EditorCtrl = FallbackPythonEditorControl
! 
!     self.editor = EditorCtrl(self,-1, pos=wxPoint(0,32))
! 
      self.SetSize(parent.GetClientSize())
      self.editor.SetSize(self.GetClientSize())
      self.object = None
***************
*** 125,131 ****
  
    def OnKillFocus(self, event):
      if self.object != None and not self.__ignoreevent:
!       self.object._children[0]._content = self.editor.GetValue()
  
    def onCreateObject (self, object, handler):
      if object == None:
--- 132,138 ----
  
    def OnKillFocus(self, event):
      if self.object != None and not self.__ignoreevent:
!       self.object._children[0]._content = self.editor.GetText()
  
    def onCreateObject (self, object, handler):
      if object == None:
***************
*** 155,167 ****
          self.namedComboBox.Delete(i)
  
  
  
  #
  # A Python Editor Control using wxPython's Scintilla support.
  # This class is largely based on demo code from wxPython
  #
  
! class PythonEditorControl(wxStyledTextCtrl):
    def __init__(self, *args, **parms):
      wxStyledTextCtrl.__init__(self, *args, **parms)
  
--- 162,180 ----
          self.namedComboBox.Delete(i)
  
  
+ try:
+  if int(GConfig.get('ForceSimpleEditor','0')):
+    raise ImportError
+  from wxPython.stc import *
+  USE_STC = 1
+ 
  
  #
  # A Python Editor Control using wxPython's Scintilla support.
  # This class is largely based on demo code from wxPython
  #
  
!  class PythonEditorControl(wxStyledTextCtrl):
    def __init__(self, *args, **parms):
      wxStyledTextCtrl.__init__(self, *args, **parms)
  
***************
*** 412,417 ****
--- 425,435 ----
    def SetEnabled(self, bool):
      self.SetReadOnly(bool)
  
+ except ImportError:
+   USE_STC = 0
+   GDebug.printMesg (1,
+       'Unable to load wxPython.stc, using fallback text editor')
+ 
  
  #
  # <cough>Hack!<cough>
***************
*** 440,443 ****
--- 458,481 ----
              'size' : 9,
              'size2': 9,
            }
+ 
+ 
+ #
+ #  This provides a "fallback" control for platforms not supporting 
wxPython.stc
+ #
+ class FallbackPythonEditorControl(wxTextCtrl):
+ 
+   def __init__(self, *args, **parms):
+     wxTextCtrl.__init__(self, *args, **parms)
+     self.GetText = self.GetValue
+     self.SetText = self.SetValue
+     self.Colourise = self.__ignore
+     self.ClearUndoBuffer = self.__ignore
+ 
+   def SetReadOnly(self, bool):
+     self.SetEditable(not bool)
+ 
+   def __ignore(self, *args, **params):
+     pass
+ 
  



reply via email to

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