[Formed-commits] r305 - in trunk: . formed/formed formed/formed/io formed/formed/model formed/formed/ui

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Thu Jan 22 16:57:52 CET 2009


Author: torsten
Date: 2009-01-22 16:57:51 +0100 (Thu, 22 Jan 2009)
New Revision: 305

Modified:
   trunk/ChangeLog
   trunk/formed/formed/io/document.py
   trunk/formed/formed/main.py
   trunk/formed/formed/model/nodecomponents.py
   trunk/formed/formed/ui/controls.py
Log:
Implemented new version of formedtree


Modified: trunk/ChangeLog
===================================================================
--- trunk/ChangeLog	2009-01-21 15:57:15 UTC (rev 304)
+++ trunk/ChangeLog	2009-01-22 15:57:51 UTC (rev 305)
@@ -1,3 +1,15 @@
+2009-01-22	Torsten Irländer <torsten.irlaender at intevation.de>
+
+	Implemented new XML-Format for formed xml files.
+
+	* formed/formed/model/nodecomponents.py,
+	  formed/formed/io/document.py,
+	  formed/formed/main.py,
+	  formed/formed/ui/controls.py: Introduced new "case" and "logbook"
+	  node. Under case is the definition of the formular. logbook will
+	  hold the defintion of logboog entrys. For now only the part under
+	  "case" can be modified.  
+
 2009-01-21	Torsten Irländer <torsten.irlaender at intevation.de>
 
 	Changed way how XSD-Scheme is generated	

Modified: trunk/formed/formed/io/document.py
===================================================================
--- trunk/formed/formed/io/document.py	2009-01-21 15:57:15 UTC (rev 304)
+++ trunk/formed/formed/io/document.py	2009-01-22 15:57:51 UTC (rev 305)
@@ -17,10 +17,12 @@
 import codecs
 
 from factories import DocumentFactory, SimpleCreator, NodeComponentFactory, NodeFactory
-from formed.model.nodecomponents import RootNode, Document, Leaf, Node
+from formed.model.nodecomponents import RootNode, CaseNode, LogbookNode, Document, Leaf, Node
 from formed.model.data           import *
 
 DOCUMENT_TAG        = u"document"
+CASE_TAG            = u"case"
+LOGBOOK_TAG         = u"logbook"
 PAGE_TAG            = u"page"
 GROUP_TAG           = u"group"
 MATRIX_TAG          = u"radio-matrix"
@@ -38,6 +40,8 @@
 
 namesToClasses = {
     DOCUMENT_TAG:        RootNode,
+    CASE_TAG:            CaseNode,
+    LOGBOOK_TAG:         LogbookNode,
     PAGE_TAG:            PageNode,
     GROUP_TAG:           GroupNode,
     MATRIX_TAG:          MatrixNode,
@@ -55,6 +59,8 @@
 
 factoryCreators = {
     DOCUMENT_TAG:        SimpleCreator(DocumentFactory,      RootNode),
+    CASE_TAG:            SimpleCreator(NodeFactory,          CaseNode),
+    LOGBOOK_TAG:         SimpleCreator(NodeFactory,          LogbookNode),
     PAGE_TAG:            SimpleCreator(NodeFactory,          PageNode),
     GROUP_TAG:           SimpleCreator(NodeFactory,          GroupNode),
     MATRIX_TAG:          SimpleCreator(NodeFactory,          MatrixNode),
@@ -72,6 +78,8 @@
 
 classesToTagNames = {
     RootNode:               DOCUMENT_TAG,
+    CaseNode:               CASE_TAG,
+    LogbookNode:            LOGBOOK_TAG,
     PageNode:               PAGE_TAG,
     GroupNode:              GROUP_TAG,
     MatrixNode:             MATRIX_TAG,

Modified: trunk/formed/formed/main.py
===================================================================
--- trunk/formed/formed/main.py	2009-01-21 15:57:15 UTC (rev 304)
+++ trunk/formed/formed/main.py	2009-01-22 15:57:51 UTC (rev 305)
@@ -174,7 +174,7 @@
 
     def _createChoice(self, parent):
         choiceList = [key for key in sorted(namesToClasses.iterkeys())
-            if key != "document"]
+            if key not in ['document', 'case', 'logbook']]
         choice = wx.Choice(parent, -1, choices = choiceList)
         first = choice.FindString(choiceList[0])
         choice.SetSelection(first)

Modified: trunk/formed/formed/model/nodecomponents.py
===================================================================
--- trunk/formed/formed/model/nodecomponents.py	2009-01-21 15:57:15 UTC (rev 304)
+++ trunk/formed/formed/model/nodecomponents.py	2009-01-22 15:57:51 UTC (rev 305)
@@ -16,7 +16,7 @@
 VISIT_CONTINUE        = None
 
 class NodeComponent:
-    
+
     def __init__(self):
         self.parent     = None
         self.attributes = {}
@@ -52,7 +52,7 @@
         self.attributes[key] = value
         if broadcast:
             self._broadcast("attributeChangedNodeComponent", self)
-                
+
     def getAttribute(self, key):
         return self.attributes.get(key, None)
 
@@ -331,6 +331,14 @@
         Node.__init__(self)
         self.document = document
 
+class CaseNode(Node):
+    def __init__(self):
+        Node.__init__(self)
+
+class LogbookNode(Node):
+    def __init__(self):
+        Node.__init__(self)
+
 class Leaf(NodeComponent):
     def __init__(self):
         NodeComponent.__init__(self)
@@ -356,9 +364,15 @@
 
     def __init__(self, root=None):
         Publisher.__init__(self)
-        if root is None: self.root = RootNode()
-        else:            self.root = root
-        self.root.document = self
+        if root is None: 
+            self.root = RootNode()
+            self.case = self.root.addChild(CaseNode())
+            self.logbook = self.root.addChild(LogbookNode())
+        else:
+            self.root = root
+            self.case = self.findByClassAndName(CaseNode)
+            self.logbook = self.findByClassAndName(LogbookNode)
+            self.root.document = self
 
     def importDocument(self, ndocument):
         root, nroot = self.root, ndocument.root

Modified: trunk/formed/formed/ui/controls.py
===================================================================
--- trunk/formed/formed/ui/controls.py	2009-01-21 15:57:15 UTC (rev 304)
+++ trunk/formed/formed/ui/controls.py	2009-01-22 15:57:51 UTC (rev 305)
@@ -12,7 +12,7 @@
 import wx
 import wx.lib.mixins.listctrl as listmix
 
-from formed.model.nodecomponents import Node, Document, RootNode
+from formed.model.nodecomponents import Node, Document, RootNode, CaseNode
 
 from formed.io.document import classesToTagNames
 
@@ -68,7 +68,9 @@
         if root is None or not root.IsOk():
             return None
 
-        path = path[1:]
+        path = path[2:] # ignore orginal document root node 
+                        # and start at case node
+
         if child is not None:
             path.append(child)
 
@@ -178,8 +180,8 @@
             # self.SortChildren(lastId)
 
     def _buildTree(self):
-        root = self.document.root
-
+        #root = self.document.root
+        root = self.document.case
         rootId = self.AddRoot(self._label(root))
         self.SetItemPyData(rootId, root)
         self.SetItemHasChildren(rootId, True)
@@ -267,28 +269,27 @@
         selectedId = self.GetSelection()
         if not selectedId or not selectedId.IsOk():
             document = self.document
-            if document: document.root.addChild(child)
+            if document: document.case.addChild(child)
             return
         selected = self.GetItemPyData(selectedId)
         if not selected:
             document = self.document
-            if document: document.root.addChild(child)
+            if document: document.case.addChild(child)
             return
-        if isinstance(selected, RootNode):
+        if isinstance(selected, CaseNode):
             selected.addChild(child)
             return
         parent = selected.parent
         if not parent:
             document = self.document
-            if document: document.root.addChild(child)
+            if document: document.case.addChild(child)
             return
         idx = parent.indexOfChild(selected)
         if idx < 0:
             document = self.document
-            if document: document.root.addChild(child)
+            if document: document.case.addChild(child)
             return
         parent.addChild(child, idx+1)
-        
 
 class ArrowPanel(wx.Panel, Publisher):
 



More information about the Formed-commits mailing list