commit-gnue
[Top][All Lists]
Advanced

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

gnue/designer/src DataSourceEditor.py Instance....


From: Jason Cater
Subject: gnue/designer/src DataSourceEditor.py Instance....
Date: Mon, 21 Jan 2002 15:33:48 -0500

CVSROOT:        /cvsroot/gnue
Module name:    gnue
Changes by:     Jason Cater <address@hidden>    02/01/21 15:33:48

Modified files:
        designer/src   : DataSourceEditor.py Instance.py LayoutEditor.py 
Added files:
        designer/src   : SchemaViewer.py 
        designer/src/forms: LayoutEditorTools.py 

Log message:
        added a Schema Navigator; modified Data Source Editor to allow multiple 
fields to be dropped onto the Layout grid; implemented a 'calculate unique 
name' system; misc bug fixes

CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/SchemaViewer.py?rev=1.1
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/DataSourceEditor.py.diff?tr1=1.16&tr2=1.17&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/Instance.py.diff?tr1=1.41&tr2=1.42&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/LayoutEditor.py.diff?tr1=1.36&tr2=1.37&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/gnue/designer/src/forms/LayoutEditorTools.py?rev=1.1

Patches:
Index: gnue/designer/src/DataSourceEditor.py
diff -c gnue/designer/src/DataSourceEditor.py:1.16 
gnue/designer/src/DataSourceEditor.py:1.17
*** gnue/designer/src/DataSourceEditor.py:1.16  Fri Jan 18 22:02:55 2002
--- gnue/designer/src/DataSourceEditor.py       Mon Jan 21 15:33:48 2002
***************
*** 41,48 ****
      self.connections = self.instance._app.connections
      self.runtime_section = "DataSourceEditor"
  
!     self.toolBar = ToolBar(self, parentWindow)
  
      self.splitter = wxSplitterWindow(self, -1, style=wxSP_3D)
  
      self.list = wxListCtrl(self.splitter, -1, pos=wxPoint(0,0),
--- 41,50 ----
      self.connections = self.instance._app.connections
      self.runtime_section = "DataSourceEditor"
  
! ##    self.toolBar = ToolBar(self, parentWindow)
  
+     self.combopanel = wxPanel(self, -1, pos=wxPoint(0,0))
+     
      self.splitter = wxSplitterWindow(self, -1, style=wxSP_3D)
  
      self.list = wxListCtrl(self.splitter, -1, pos=wxPoint(0,0),
***************
*** 426,432 ****
  
      if not hasattr(self.current,'table'):
        return
!       
      mastertable = self.current.table
  
      self.lines = {}
--- 428,434 ----
  
      if not hasattr(self.current,'table'):
        return
! 
      mastertable = self.current.table
  
      self.lines = {}
***************
*** 536,548 ****
     try:
      conn = self.editor.current.database
  
!     # TODO: This is very, very temporary...
!     # TODO: Designer shouldn't care about gconnection's internal
!     # TODO: attributes.  AS SOON AS common goes to 0.3.0, create
!     # TODO: an isConnectionActive(conn_name) method in GConnections
!     # TODO: and reuse here.
! 
!     if not self.editor.connections._openConnections.has_key(conn) and \
         not int(GConfig.get("AutoConnect","0")):
  
        # TODO: Some other form of feedback
--- 538,544 ----
     try:
      conn = self.editor.current.database
  
!     if not self.editor.connections.isConnectionActive(conn) and \
         not int(GConfig.get("AutoConnect","0")):
  
        # TODO: Some other form of feedback
***************
*** 605,639 ****
  
    def OnBeginDrag(self, event):
  
!     #object = self.schemaMap[event.GetIndex()] # Bah! this always returns 0
!     object = self.schemaMap[self.list.HitTest(event.GetPoint())[0]]
!     attributes = {
!         "datasource": self.current.name,
!         "name": "fld%s" % (
!                    string.join(string.split(string.capwords( \
!                    string.replace(object.name,'_',' '))),'')),
!         "field": object.name,
!         "datatype": object.datatype,
!         "required" : object.required,
!       }
! 
!     if object.length:
!       attributes['max_length'] = object.length
!       attributes['width'] = object.length < 30 and object.length or 30
! 
! 
!     if hasattr(object, 'label') and len(object.label):
!       label = object.label
!     elif len(object.name) == 1:
!       label = string.upper(object.name)
!     else:
!       label = string.join(string.split(string.capwords( \
!                    string.replace(object.name,'_',' '))),' ')
! 
!     data = { "Type" : "entry",
!              "Attributes": attributes,
!              "Label": label
!            }
  
      do = wxCustomDataObject(wxCustomDataFormat("GNUeDesVisualElement"))
      do.SetData(cPickle.dumps(data,1))
--- 601,647 ----
  
    def OnBeginDrag(self, event):
  
!     data = []
! 
!     item = -1
!     # Cycle through each selected item
!     while 1:
!       item = self.list.GetNextItem(item,
!                                    wxLIST_NEXT_ALL,
!                                    wxLIST_STATE_SELECTED);
!       if item == -1:
!         break
! 
!       object = self.schemaMap[item]
! 
!       attributes = {
!           "datasource": self.current.name,
!           "name": self.editor.instance.getUniqueName(
!                     "fld%s" % (
!                      string.join(string.split(string.capwords( \
!                        string.replace(object.name,'_',' '))),''))),
!           "field": object.name,
!           "datatype": object.datatype,
!           "required" : object.required,
!         }
! 
!       if hasattr(object,'length') and object.length:
!         attributes['max_length'] = object.length
!         attributes['width'] = object.length < 30 and object.length or 30
! 
! 
!       if hasattr(object, 'label') and len(object.label):
!         label = object.label
!       elif len(object.name) == 1:
!         label = string.upper(object.name)
!       else:
!         label = string.join(string.split(string.capwords( \
!                      string.replace(object.name,'_',' '))),' ')
! 
!       data.append({ "Type" : "entry",
!                     "Attributes": attributes,
!                     "Label": label})
! 
  
      do = wxCustomDataObject(wxCustomDataFormat("GNUeDesVisualElement"))
      do.SetData(cPickle.dumps(data,1))
Index: gnue/designer/src/Instance.py
diff -c gnue/designer/src/Instance.py:1.41 gnue/designer/src/Instance.py:1.42
*** gnue/designer/src/Instance.py:1.41  Tue Jan 15 18:12:56 2002
--- gnue/designer/src/Instance.py       Mon Jan 21 15:33:48 2002
***************
*** 36,41 ****
--- 36,42 ----
  from PropertyEditor import PropertyToolFrame
  from TriggerEditor import TriggerEditor
  from DataSourceEditor import DataSourceEditor
+ from SchemaViewer import SchemaViewer
  import RuntimeSettings
  from ToolFrame import ToolFrame
  from gnue.designer import VERSION, PACKAGE
***************
*** 150,155 ****
--- 151,161 ----
                                               self, self.rootObject)
      self.datasourceEditorWindow.finalize()
  
+     self.schemaViewerWindow = ToolFrame(self, "Schema Navigator")
+     self.schemaViewer = SchemaViewer(self.schemaViewerWindow,
+                                      self, self.rootObject)
+     self.schemaViewerWindow.finalize()
+ 
      self.propertyEditorWindow = PropertyToolFrame(self, "Property Inspector")
      self.propertyEditor = self.propertyEditorWindow.propertyEditor
      self.propertyEditorWindow.finalize()
***************
*** 220,226 ****
      self.rootObject.height = 12
      self.rootObject.width = 40
      page = GFObjects.GFPage(self.rootObject)
!     GFObjects.GFBlock(page)
      self.makeClean()
      self._isNew = 1
  
--- 226,232 ----
      self.rootObject.height = 12
      self.rootObject.width = 40
      page = GFObjects.GFPage(self.rootObject)
! ##    GFObjects.GFBlock(page)
      self.makeClean()
      self._isNew = 1
  
***************
*** 273,279 ****
              object.name[:3] == "__<" and \
              object.name[-3:] == ">__")):
            object.name = self.getNextGenericName(object.getObjectType()[2:])
!         self.nameMappings[object.name] = object
  
      if isinstance(object, GFObjects.GFPage) and \
          object._parent == self.rootObject:
--- 279,285 ----
              object.name[:3] == "__<" and \
              object.name[-3:] == ">__")):
            object.name = self.getNextGenericName(object.getObjectType()[2:])
!         self.nameMappings[string.lower(object.name)] = object
  
      if isinstance(object, GFObjects.GFPage) and \
          object._parent == self.rootObject:
***************
*** 324,333 ****
          self._lastGenericNameSeq[string.lower(type)] = 1
        name = "%s%s_%s" % (string.upper(type[0]), \
            string.lower(type[1:]), 
self._lastGenericNameSeq[string.lower(type)])
!       if not self.nameMappings.has_key(name):
          break
  
      return name
  
    def saveForm(self):
      location = self._path
--- 330,354 ----
          self._lastGenericNameSeq[string.lower(type)] = 1
        name = "%s%s_%s" % (string.upper(type[0]), \
            string.lower(type[1:]), 
self._lastGenericNameSeq[string.lower(type)])
!       if not self.nameMappings.has_key(string.lower(name)):
          break
  
      return name
+ 
+   def getUniqueName(self, n):
+     name = string.lower(n)
+     while self.nameMappings.has_key(name):
+       if '_' in name:
+         nameparts = string.split(name,'_')
+         try:
+           nameparts[-1] = str(int(nameparts[-1]) + 1)
+           name = string.join(nameparts,'_')
+         except ValueError:
+           name += '_1'
+       else:
+         name += '_1'
+     return name
+ 
  
    def saveForm(self):
      location = self._path
Index: gnue/designer/src/LayoutEditor.py
diff -c gnue/designer/src/LayoutEditor.py:1.36 
gnue/designer/src/LayoutEditor.py:1.37
*** gnue/designer/src/LayoutEditor.py:1.36      Fri Jan 18 18:05:52 2002
--- gnue/designer/src/LayoutEditor.py   Mon Jan 21 15:33:48 2002
***************
*** 756,793 ****
      if hasattr(object, 'x'): 
        self.xEditor.SetValue(object.x)
  #      self.xEditor.SetEditable(1)
!     else: 
        self.xEditor.SetValue(0)
  #      self.xEditor.SetEditable(0)
  
!     if hasattr(object, 'y'): 
        self.yEditor.SetValue(object.y)
  #      self.yEditor.SetEditable(1)
!     else: 
        self.yEditor.SetValue(0)
  #      self.yEditor.SetEditable(0)
  
!     if hasattr(object, 'width'): 
        self.wEditor.SetValue(object.width)
  #      self.wEditor.SetEditable(1)
      else:
        self.wEditor.SetValue(0)
  #      self.wEditor.SetEditable(0)
  
!     if hasattr(object, 'height'): 
        self.hEditor.SetValue(object.height)
  #      self.hEditor.SetEditable(1)
!     else: 
        self.hEditor.SetValue(0)
  #      self.hEditor.SetEditable(0)
  
!     if hasattr(object, 'name'): 
        self.nameEditor.SetValue(object.name)
        self.nameEditor.SetEditable(0)
!     else: 
        self.nameEditor.SetValue(0)
        self.nameEditor.SetEditable(0)
!     
    def onModifyObject (self, object, handler, modifications):
      if object == None: 
        return
--- 756,793 ----
      if hasattr(object, 'x'): 
        self.xEditor.SetValue(object.x)
  #      self.xEditor.SetEditable(1)
!     else:
        self.xEditor.SetValue(0)
  #      self.xEditor.SetEditable(0)
  
!     if hasattr(object, 'y'):
        self.yEditor.SetValue(object.y)
  #      self.yEditor.SetEditable(1)
!     else:
        self.yEditor.SetValue(0)
  #      self.yEditor.SetEditable(0)
  
!     if hasattr(object, 'width'):
        self.wEditor.SetValue(object.width)
  #      self.wEditor.SetEditable(1)
      else:
        self.wEditor.SetValue(0)
  #      self.wEditor.SetEditable(0)
  
!     if hasattr(object, 'height'):
        self.hEditor.SetValue(object.height)
  #      self.hEditor.SetEditable(1)
!     else:
        self.hEditor.SetValue(0)
  #      self.hEditor.SetEditable(0)
  
!     if hasattr(object, 'name'):
        self.nameEditor.SetValue(object.name)
        self.nameEditor.SetEditable(0)
!     else:
        self.nameEditor.SetValue(0)
        self.nameEditor.SetEditable(0)
! 
    def onModifyObject (self, object, handler, modifications):
      if object == None: 
        return
***************
*** 859,957 ****
      if self.GetData():
        # convert it back to our format
        data = self.data.GetData()
!       params = cPickle.loads(data)
  
!       x = int(x / self.editor.gridWidth)
!       y = int(y / self.editor.gridHeight)
  
!       attributes = params['Attributes']
  
-       # Entry types require a "block".. find or create one
-       if params['Type'] in ('entry',):
-         try:
-           parent = params['Block']
-         except KeyError:
-           # Find the parent block
- 
-           parent = None
-           datasource = string.lower(attributes['datasource'])
- 
-           for child in self.editor.page._children:
-             if child._type == 'GFBlock' and \
-               string.lower(child.datasource) == datasource:
-               parent = child
-               break
- 
-           if parent is None:
-             dlg = wxMessageDialog(NULL,
-               "The current page does not have a block\n"
-               "corresponding to Data Source %s.\n"
-               "Create a new block on the current page?" % \
-                    attributes['datasource'],
-               "No Target Block Found", style=wxYES_NO|wxICON_WARNING)
-             save = dlg.ShowModal()
-             dlg.Destroy()
-             if save == wxID_NO:
-               return d # TODO: This should actually return a failure
- 
-             # Create a parent block
-             parent = Incubator.createObject(
-                         self.editor._instance,
-                         self.editor._instance.rootObject,
-                         'block',
-                         parent=self.editor.page,
-                         attributes={'datasource':datasource})
- 
-         createLabels = string.lower(GConfig.get("CreateLabelsOnDrop","left"))
- 
-         if createLabels != "no":
-           label = params["Label"] + ":"
- 
-           # Figure out the position of the label
-           # If the entry is for a multirow block,
-           # we assume that the label goes above.
-           if createLabels == "left" and\
-              not(hasattr(parent,'rows') and parent.rows > 1 or 0):
-             lx = x - len(label) - 1
-             if lx < 0:
-               x = len(label) + 1
-               lx = 0
-             ly = y
-           else:  # "above"
-             lx = x
-             ly = y - 1
- 
-             if ly < 0:
-               ly = 0
-               y += 1
- 
-           # Create a label
-           Incubator.createObject(
-                   self.editor._instance,
-                   self.editor._instance.rootObject,
-                   'label',
-                   parent=self.editor.page,
-                   attributes={'x': lx,
-                               'y': ly,
-                               'width': len(label),
-                               'text': label })
- 
-       else:
-         parent = self.editor.page
- 
- 
-       attributes['x'] = x
-       attributes['y'] = y
- 
-       #
-       # Create our new object
-       #
-       Incubator.createObject(
-               self.editor._instance,
-               self.editor._instance.rootObject,
-               params['Type'],
-               parent=parent,
-               attributes=attributes)
  
      return d  # what is returned signals the source what to do
                # with the original data (move, copy, etc.)  In this
--- 859,983 ----
      if self.GetData():
        # convert it back to our format
        data = self.data.GetData()
!       unpickled = cPickle.loads(data)
! 
! 
!       nextY = int(y / self.editor.gridHeight)
  
!       for params in unpickled:
  
!         x = int(x / self.editor.gridWidth)
!         y = nextY
! 
!         attributes = params['Attributes']
! 
!         # Entry types require a "block".. find or create one
!         if params['Type'] in ('entry',):
!           try:
!             parent = params['Block']
!           except KeyError:
!             # Find the parent block
! 
!             parent = None
! 
!             if  not attributes.has_key('block') and \
!                 attributes.has_key('datasource'):
! 
!               datasource = string.lower(attributes['datasource'])
! 
!               for child in self.editor.page._children:
!                 if child._type == 'GFBlock' and \
!                   hasattr(child,'datasource') and \
!                   string.lower(child.datasource) == datasource:
!                   parent = child
!                   break
! 
!               if parent is None:
!                 dlg = wxMessageDialog(NULL,
!                   "The current page does not have a block\n"
!                   "corresponding to Data Source %s.\n"
!                   "Create a new block on the current page?" % \
!                        attributes['datasource'],
!                   "No Target Block Found", style=wxYES_NO|wxICON_WARNING)
!                 save = dlg.ShowModal()
!                 dlg.Destroy()
!                 if save == wxID_NO:
!                   return d # TODO: This should actually return a failure
! 
!                 # Create a parent block
!                 parent = Incubator.createObject(
!                             self.editor._instance,
!                             self.editor._instance.rootObject,
!                             'block',
!                             parent=self.editor.page,
!                             attributes={'datasource':datasource})
!             else:
!               for child in self.editor.page._children:
!                 if child._type == 'GFBlock' and \
!                    child.name == attributes['block']:
! 
!                   parent = child
!                   break
! 
! 
!           createLabels = 
string.lower(GConfig.get("CreateLabelsOnDrop","left"))
! 
!           if createLabels != "no":
!             label = params["Label"] + ":"
! 
!             # Figure out the position of the label
!             # If the entry is for a multirow block,
!             # we assume that the label goes above.
!             if createLabels == "left" and\
!                not(hasattr(parent,'rows') and parent.rows > 1 or 0):
!               lx = x - len(label) - 1
!               if lx < 0:
!                 x = len(label) + 1
!                 lx = 0
!               ly = y
!             else:  # "above"
!               nextY += 1
!               lx = x
!               ly = y - 1
! 
!               if ly < 0:
!                 ly = 0
!                 y += 1
! 
!             # Create a label
!             Incubator.createObject(
!                     self.editor._instance,
!                     self.editor._instance.rootObject,
!                     'label',
!                     parent=self.editor.page,
!                     attributes={'x': lx,
!                                 'y': ly,
!                                 'width': len(label),
!                                 'text': label })
!           nextY += 1
! 
!         elif params['Type'] in ('datasource',):
!           parent = self.editor.rootObject
! 
!         elif params['Type'] in ('block',):
!           parent = self.editor.page
!         else:
!           parent = self.editor.page
!           nextY += 1
! 
!         attributes['x'] = x
!         attributes['y'] = y
! 
!         #
!         # Create our new object
!         #
!         Incubator.createObject(
!                 self.editor._instance,
!                 self.editor._instance.rootObject,
!                 params['Type'],
!                 parent=parent,
!                 attributes=attributes)
  
  
      return d  # what is returned signals the source what to do
                # with the original data (move, copy, etc.)  In this



reply via email to

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