[Commits] (stearns) A bunch of cleanup needed for attribute editor work:

commits at osafoundation.org commits at osafoundation.org
Tue Apr 19 11:26:19 PDT 2005


Commit by: stearns
Modified files:
chandler/parcels/osaf/framework/blocks/Block.py 1.104 1.105
chandler/parcels/osaf/framework/blocks/DocumentTypes.py 1.6 1.7
chandler/parcels/osaf/framework/blocks/detail/Detail.py 1.112 1.113
chandler/parcels/osaf/framework/blocks/detail/parcel.xml 1.71 1.72
chandler/parcels/osaf/framework/webserver/servlets/repo/Repo.py 1.18 1.19

Log message:
A bunch of cleanup needed for attribute editor work:
- Remove old contact detail-view stuff (we're not using it, and maintaining it was a pain. When we eventually show contacts again, we'll use AEs, so I got rid of the obsolete stuff)
- Stop using AE-based labeling for our two existing AE-based fields; use statictext instead.

Also, for debugging:
- Add "detail" and "cpia" loggers (in Detail.py and Block.py, respectively). 
- I've added some widget to Morgen's repo browser: blocks with widgets now show the widget's attributes below the block's, and limited drill-down in widgets is supported (you can walk around the widget hierarchy, and look at Sizer info, f'rinstance). I do this by looking at the methods that widgets expose, and call any method that starts with Get, Is, Has, etc. Seems to work pretty well, surprisingly ;-)

ViewCVS links:
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/Block.py.diff?r1=text&tr1=1.104&r2=text&tr2=1.105
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/DocumentTypes.py.diff?r1=text&tr1=1.6&r2=text&tr2=1.7
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/detail/Detail.py.diff?r1=text&tr1=1.112&r2=text&tr2=1.113
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/blocks/detail/parcel.xml.diff?r1=text&tr1=1.71&r2=text&tr2=1.72
http://cvs.osafoundation.org/index.cgi/chandler/parcels/osaf/framework/webserver/servlets/repo/Repo.py.diff?r1=text&tr1=1.18&r2=text&tr2=1.19

Index: chandler/parcels/osaf/framework/blocks/Block.py
diff -u chandler/parcels/osaf/framework/blocks/Block.py:1.104 chandler/parcels/osaf/framework/blocks/Block.py:1.105
--- chandler/parcels/osaf/framework/blocks/Block.py:1.104	Wed Apr  6 18:01:02 2005
+++ chandler/parcels/osaf/framework/blocks/Block.py	Tue Apr 19 11:26:17 2005
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.104 $"
-__date__ = "$Date: 2005/04/07 01:01:02 $"
+__version__ = "$Revision: 1.105 $"
+__date__ = "$Date: 2005/04/19 18:26:17 $"
 __copyright__ = "Copyright (c) 2003-2005 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -10,6 +10,8 @@
 import logging
 import hotshot
 
+logger = logging.getLogger('cpia')
+logger.setLevel(logging.INFO)
 
 class Block(Item):
     def post (self, event, arguments):
@@ -483,15 +485,13 @@
             except AttributeError:
                 result = False
             else:
-                """
-                  Comment in this code to see which events are dispatched -- DJA
-                  ... to which blocks -- BJS
-                try:
-                    blockName = block.blockName
-                except AttributeError:
-                    blockName = "None"
-                print "Calling method: %s, blockName: %s; block: %s" % (methodName, blockName, block)
-                """
+                if __debug__ and not methodName.endswith("UpdateUI"):
+                    # show dispatched events
+                    logger.debug("Calling %s on %s (%s): %s" % \
+                                 (methodName, getattr(block, "blockName", "?"),
+                                  block, getattr(event, "arguments", 
+                                                 "(no arguments)")))
+
                 result = member (block, event)
                 if result is None:
                     result = True
@@ -638,8 +638,8 @@
         # Map from the alignmentEnum string to wx constant(s)
         flag = _wxFlagMappings[block.alignmentEnum]
 
-        # @@@ Temporary solution to allow for borders on a single side
-        numBordersSpecified = 0
+        # Each border can be 0 or not, but all the nonzero borders must be equal
+        # (The assert in CalculateWXBorder above checks this)
         if block.border.top != 0:
             flag |= wx.TOP
             numBordersSpecified += 1

Index: chandler/parcels/osaf/framework/blocks/DocumentTypes.py
diff -u chandler/parcels/osaf/framework/blocks/DocumentTypes.py:1.6 chandler/parcels/osaf/framework/blocks/DocumentTypes.py:1.7
--- chandler/parcels/osaf/framework/blocks/DocumentTypes.py:1.6	Mon Feb  7 14:53:54 2005
+++ chandler/parcels/osaf/framework/blocks/DocumentTypes.py	Tue Apr 19 11:26:17 2005
@@ -5,6 +5,9 @@
 class SizeType(object):
     __slots__ = 'width', 'height'
     
+    def __repr__(self):
+        return "(%sw, %sh)" % (self.width, self.height)
+    
 class SizeStruct(CoreTypes.Struct):
 
     def makeValue(Struct, data):
@@ -18,6 +21,9 @@
 class PositionType(object):
     __slots__ = 'x', 'y'
     
+    def __repr__(self):
+        return "(%sx, %sy)" % (self.x, self.y)
+    
 class PositionStruct(CoreTypes.Struct):
 
     def makeValue(Struct, data):
@@ -31,6 +37,9 @@
 class RectType(object):
     __slots__ = 'top', 'left', 'bottom', 'right'
 
+    def __repr__(self):
+        return "(%st, %sl, %sb, %sr)" % (self.top, self.left, self.bottom, self.right)
+
 class RectStruct(CoreTypes.Struct):
 
     def makeValue(Struct, data):
@@ -49,6 +58,9 @@
         # Make a wx color
         return wx.Color(self.red, self.green, self.blue)
 
+    def __repr__(self):
+        return "(%sr, %sg, %sb, %sa)" % (self.red, self.green, self.blue, self.alpha)
+
 class ColorStruct(CoreTypes.Struct):
 
     def makeValue(Struct, data):

Index: chandler/parcels/osaf/framework/blocks/detail/Detail.py
diff -u chandler/parcels/osaf/framework/blocks/detail/Detail.py:1.112 chandler/parcels/osaf/framework/blocks/detail/Detail.py:1.113
--- chandler/parcels/osaf/framework/blocks/detail/Detail.py:1.112	Tue Apr 12 15:04:24 2005
+++ chandler/parcels/osaf/framework/blocks/detail/Detail.py	Tue Apr 19 11:26:17 2005
@@ -1,5 +1,5 @@
-__version__ = "$Revision: 1.112 $"
-__date__ = "$Date: 2005/04/12 22:04:24 $"
+__version__ = "$Revision: 1.113 $"
+__date__ = "$Date: 2005/04/19 18:26:17 $"
 __copyright__ = "Copyright (c) 2004-2005 Open Source Applications Foundation"
 __license__ = "http://osafoundation.org/Chandler_0.1_license_terms.htm"
 
@@ -28,12 +28,16 @@
 import mx.DateTime as DateTime
 import wx
 import sets
+import logging
 
 """
 Detail.py
 Classes for the ContentItem Detail View
 """
 
+logger = logging.getLogger("detail")
+logger.setLevel(logging.INFO)
+
 class DetailRoot (ControlBlocks.ContentItemDetail):
     """
       Root of the Detail View.
@@ -487,10 +491,6 @@
     """
       Static Text that displays the name of the selected item's Attribute
     """
-    def shouldShow (self, item):
-        return not (item is None or
-                    item.isItemOf (Contacts.Contact.getKind (self.itsView)))
-
     def staticTextLabelValue (self, item):
         redirectAttr = GetRedirectAttribute(item, self.whichAttribute ())
         # lookup better names for display of some attributes
@@ -504,22 +504,13 @@
         * a label (e.g. a StaticText with "Title:")
         * an attribute value (e.g. in an EditText with the value of item.title)
       it also handles visibility of the block, depending on if the attribute
-      exists on the item or not (with a special case for contacts, which is 
-      always hidden)
+      exists on the item or not
     """ 
     def synchronizeItemDetail(self, item):
         whichAttr = self.selectedItemsAttribute
-        contactKind = Contacts.Contact.getKind (self.itsView)
-        if item is None or item.isItemOf (contactKind):
-            self.isShown = False
-        else:
-            self.isShown = item.itsKind.hasAttribute(whichAttr)
+        self.isShown = item is not None and item.itsKind.hasAttribute(whichAttr)
         self.synchronizeWidget()
 
-    def shouldShow (self, item):
-        return not (item is None or
-                    item.isItemOf (Contacts.Contact.getKind (self.itsView)))
-
 class DetailSynchronizedLabeledTextAttributeBlock (DetailSynchronizer, LabeledTextAttributeBlock):
     pass
 
@@ -913,60 +904,6 @@
         if widget.GetValue() != value:
             widget.SetValue(value)
 
-class EditHeadlineRedirectAttribute (EditRedirectAttribute):
-    """
-    An attribute-based edit field
-    Doesn't show for contacts.
-    """
-    def shouldShow (self, item):
-        # don't show if the item is a Contact
-        contactKind = Contacts.Contact.getKind (self.itsView)
-        shouldShow = not item.isItemOf (contactKind)
-        return shouldShow
-
-"""
-Classes to support Contact details
-"""
-
-class ContactFullNameEditField (EditRedirectAttribute):
-    """
-    An attribute-based edit field for contactName:fullName
-    The actual value is stored in an contactName object.
-    """
-    def saveAttributeFromWidget(self, item, widget, validate):
-        contactName = item.getAttributeValue (self.whichAttribute())
-        widgetString = widget.GetValue()
-        contactName.fullName = widgetString
-        if validate:
-            names = widgetString.split (' ')
-            if len (names) > 0:
-                contactName.firstName = names[0]
-            if len (names) > 1:
-                contactName.lastName = names[-1]
-            # put the fullName into any emailAddress objects connected to this item.
-            try:
-                item.homeSection.fullName = widgetString
-                item.homeSection.emailAddress.fullName = widgetString
-            except AttributeError:
-                pass
-            try:
-                item.workSection.fullName = widgetString
-                item.workSection.emailAddress.fullName = widgetString
-            except AttributeError:
-                pass
-
-
-    def loadAttributeIntoWidget(self, item, widget):
-        value = ''
-        try:
-            contactName = item.getAttributeValue (self.whichAttribute())
-            value = contactName.getAttributeValue ('emailAddress')
-        except AttributeError:
-            pass
-        if value == '':
-            value = item.ItemWhoString ()
-        widget.SetValue(value)
-
 class StaticEmailAddressAttribute (StaticRedirectAttributeLabel):
     """
       Static Text that displays the name of the selected item's Attribute.
@@ -1042,7 +979,7 @@
                 pass
             else:
                 showIt = True
-        # print "AcceptShareButton.shouldShow = %s" % showIt
+        # logger.debug("AcceptShareButton.shouldShow = %s" % showIt)
         return showIt
     
     def onAcceptShareEvent(self, event):

Index: chandler/parcels/osaf/framework/blocks/detail/parcel.xml
diff -u chandler/parcels/osaf/framework/blocks/detail/parcel.xml:1.71 chandler/parcels/osaf/framework/blocks/detail/parcel.xml:1.72
--- chandler/parcels/osaf/framework/blocks/detail/parcel.xml:1.71	Tue Mar 15 09:20:14 2005
+++ chandler/parcels/osaf/framework/blocks/detail/parcel.xml	Tue Apr 19 11:26:17 2005
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="iso-8859-1"?>
 
-<!-- $Revision: 1.71 $ -->
-<!-- $Date: 2005/03/15 17:20:14 $ -->
+<!-- $Revision: 1.72 $ -->
+<!-- $Date: 2005/04/19 18:26:17 $ -->
 <!-- Copyright (c) 2003-2005 Open Source Applications Foundation -->
 <!-- License: http://osafoundation.org/Chandler_0.1_license_terms.htm -->
 
@@ -40,7 +40,6 @@
 
   <CharacterStyle itsName="LabelStyle">
     <fontFamily>DefaultUIFont</fontFamily>
-    <fontStyle>bold</fontStyle>
     <fontSize>10</fontSize>
   </CharacterStyle>
   
@@ -157,14 +156,7 @@
     <rootBlocks itemref="doc:SharingActiveArea"/>
     <rootBlocks itemref="doc:NotesArea"/>
   </doc:DetailTrunkSubtree>
-
-  <!-- Contact -->
-  <doc:DetailTrunkSubtree itsName="ContactSubtree">
-    <key itemref="contact:Contact"/>
-    <rootBlocks itemref="doc:ContactFullNameArea"/>    
-    <rootBlocks itemref="doc:EmailAddressArea"/>
-  </doc:DetailTrunkSubtree>
-
+  
   <!--
   The subtree blocks
   -->
@@ -181,7 +173,6 @@
     <childrenBlocks itemref="doc:PrivateSwitchButton"/>
     <!-- Attributes -->
     <position>0.0</position>
-    <colorStyle itemref="doc:GrayBackground"/>
     <toolSize>20,20</toolSize>
     <separatorWidth>16</separatorWidth>
     <stretchFactor>0.0</stretchFactor>
@@ -251,28 +242,16 @@
     <position>0.1</position>
     <selectedItemsAttribute>whoFrom</selectedItemsAttribute>
     <stretchFactor>0.0</stretchFactor>
+    <border>5, 5, 0, 5</border>
   </ContentItemDetail>
 
-  <Button itsName="AcceptShareButton"
-                     itemClass="osaf.framework.blocks.detail.Detail.AcceptShareButton">
-    <blockName value="AcceptShareButton"/>
-    <title>Accept this sharing invitation</title>
-    <buttonKind>Text</buttonKind>
-    <position>0.88</position>
-    <stretchFactor>0.0</stretchFactor>
-    <size>80,30</size>
-    <minimumSize>220,24</minimumSize>
-    <alignmentEnum>alignCenter</alignmentEnum>
-    <event itemref="doc:AcceptShare"/>
-  </Button>
-
   <StaticText itsName="FromString">
     <blockName value="FromString"/>
     <title>from</title>
     <characterStyle itemref="doc:LabelStyle"/>
     <textAlignmentEnum>Right</textAlignmentEnum>
     <stretchFactor>0.0</stretchFactor>
-    <minimumSize>70, 24</minimumSize>
+    <minimumSize>80, 24</minimumSize>
     <border>0.0, 0.0, 0.0, 5.0</border>
   </StaticText>
   
@@ -286,14 +265,29 @@
     <minimumSize>100, 24</minimumSize>
   </EditText>
 
+  <Button itsName="AcceptShareButton"
+                     itemClass="osaf.framework.blocks.detail.Detail.AcceptShareButton">
+    <blockName value="AcceptShareButton"/>
+    <title>Accept this sharing invitation</title>
+    <buttonKind>Text</buttonKind>
+    <position>0.88</position>
+    <stretchFactor>0.0</stretchFactor>
+    <size>80,30</size>
+    <minimumSize>220,24</minimumSize>
+    <alignmentEnum>alignCenter</alignmentEnum>
+    <event itemref="doc:AcceptShare"/>
+    <border>5, 5, 0, 5</border>
+  </Button>
+
   <ContentItemDetail itsName="AttachmentArea"
                      itemClass="osaf.framework.blocks.detail.Detail.AttachmentArea">
     <blockName value="AttachmentArea"/>
     <childrenBlocks itemref="doc:AttachmentString"/>
     <childrenBlocks itemref="doc:AttachmentTextField"/>
     <!-- Attributes -->
-    <position>0.95</position>
+    <position>0.85</position>
     <stretchFactor>0.0</stretchFactor>
+    <border>5, 5, 0, 5</border>
   </ContentItemDetail>
  
   <StaticText itsName="AttachmentString">
@@ -302,8 +296,8 @@
     <characterStyle itemref="doc:LabelStyle"/>
     <textAlignmentEnum>Right</textAlignmentEnum>    
     <stretchFactor>0.0</stretchFactor>
-    <minimumSize>90, 24</minimumSize>
-    <border>0.0, 0.0, 0.0, 5.0</border>
+    <minimumSize>80, 24</minimumSize>
+    <border>0, 0, 0, 5</border>
   </StaticText>
   
   <EditText itsName="AttachmentTextField"
@@ -316,37 +310,6 @@
     <minimumSize>100, 48</minimumSize>
   </EditText>
 
-  <ContentItemDetail itsName="ContactFullNameArea"
-                     itemClass="osaf.framework.blocks.detail.Detail.DetailSynchronizedLabeledTextAttributeBlock">
-    <blockName value="ContactFullNameArea"/>
-    <childrenBlocks itemref="doc:ContactFullNameString"/>
-    <childrenBlocks itemref="doc:ContactFullNameEditField"/>
-    <!-- Attributes -->
-    <position>0.4</position>
-    <selectedItemsAttribute>contactName</selectedItemsAttribute>
-    <stretchFactor>0.0</stretchFactor>
-  </ContentItemDetail>
-
-  <StaticText itsName="ContactFullNameString">
-    <blockName value="ContactFullNameString"/>
-    <title>Full Name</title>
-    <characterStyle itemref="doc:LabelStyle"/>
-    <textAlignmentEnum>Right</textAlignmentEnum>    
-    <stretchFactor>0.0</stretchFactor>
-    <minimumSize>70, 24</minimumSize>
-    <border>0.0, 0.0, 0.0, 5.0</border>
-  </StaticText>
-  
-  <EditText itsName="ContactFullNameEditField"
-            itemClass="osaf.framework.blocks.detail.Detail.ContactFullNameEditField">
-    <blockName value="ContactFullNameEditField"/>
-    <characterStyle itemref="doc:TextStyle"/>
-    <lineStyleEnum>SingleLine</lineStyleEnum>
-    <readOnly>False</readOnly>
-    <textAlignmentEnum>Left</textAlignmentEnum>
-    <minimumSize>300, 24</minimumSize>
-  </EditText>
-
   <ContentItemDetail itsName="ToMailArea"
                      itemClass="osaf.framework.blocks.detail.Detail.DetailSynchronizedLabeledTextAttributeBlock">
     <blockName value="ToArea"/>
@@ -356,6 +319,7 @@
     <position>0.2</position>
     <selectedItemsAttribute>who</selectedItemsAttribute>
     <stretchFactor>0.0</stretchFactor>
+    <border>5, 5, 0, 5</border>
   </ContentItemDetail>
  
   <StaticText itsName="ToString">
@@ -364,8 +328,8 @@
     <characterStyle itemref="doc:LabelStyle"/>
     <textAlignmentEnum>Right</textAlignmentEnum>    
     <stretchFactor>0.0</stretchFactor>
-    <minimumSize>70, 24</minimumSize>
-    <border>0.0, 0.0, 0.0, 5.0</border>
+    <minimumSize>80, 24</minimumSize>
+    <border>0, 0, 0, 5</border>
   </StaticText>
   
   <EditText itsName="ToMailEditField"
@@ -387,6 +351,7 @@
     <position>0.3</position>
     <selectedItemsAttribute>who</selectedItemsAttribute>
     <stretchFactor>0.0</stretchFactor>
+    <border>5, 5, 0, 5</border>
   </ContentItemDetail>
  
   <StaticText itsName="ParticipantsString">
@@ -395,8 +360,8 @@
     <characterStyle itemref="doc:LabelStyle"/>
     <textAlignmentEnum>Right</textAlignmentEnum>    
     <stretchFactor>0.0</stretchFactor>
-    <minimumSize>70, 24</minimumSize>
-    <border>0.0, 0.0, 0.0, 5.0</border>
+    <minimumSize>80, 24</minimumSize>
+    <border>0, 0, 0, 5</border>
   </StaticText>
   
   <EditText itsName="ParticipantsTextField"
@@ -418,6 +383,7 @@
     <position>0.3</position>
     <selectedItemsAttribute>whoFrom</selectedItemsAttribute>
     <stretchFactor>0.0</stretchFactor>
+    <border>5, 5, 0, 5</border>
   </ContentItemDetail>
 
   <StaticText itsName="InviteString">
@@ -426,8 +392,8 @@
     <characterStyle itemref="doc:LabelStyle"/>
     <textAlignmentEnum>Right</textAlignmentEnum>    
     <stretchFactor>0.0</stretchFactor>
-    <minimumSize>70, 24</minimumSize>
-    <border>0.0, 0.0, 0.0, 5.0</border>
+    <minimumSize>80, 24</minimumSize>
+    <border>0, 0, 0, 5</border>
   </StaticText>
   
   <EditText itsName="InviteEditField"
@@ -440,10 +406,9 @@
     <minimumSize>100, 24</minimumSize>
   </EditText>
 
-
   <ContentItemDetail itsName="SharingActiveArea"
                      itemClass="osaf.framework.blocks.detail.Detail.SharingArea">
-    <blockName value="FromArea"/>
+    <blockName value="SharingActiveArea"/>
     <childrenBlocks itemref="doc:SharingActiveString"/>
     <childrenBlocks itemref="doc:EditSharingActive"/>
     <!-- Attributes -->
@@ -457,7 +422,7 @@
     <characterStyle itemref="doc:LabelStyle"/>
     <textAlignmentEnum>Right</textAlignmentEnum>    
     <stretchFactor>0.0</stretchFactor>
-    <minimumSize>70, 24</minimumSize>
+    <minimumSize>80, 24</minimumSize>
     <border>0.0, 0.0, 0.0, 5.0</border>
   </StaticText>
   
@@ -484,6 +449,7 @@
     <selectedItemsAttribute>about</selectedItemsAttribute>
     <minimumSize>300, 24</minimumSize>
     <stretchFactor>0.0</stretchFactor>
+    <border>5, 0, 0, 5</border>
   </ContentItemDetail>
  
   <StaticText itsName="StaticHeadline"
@@ -493,12 +459,12 @@
     <characterStyle itemref="doc:LabelStyle"/>
     <textAlignmentEnum>Right</textAlignmentEnum>    
     <stretchFactor>0.0</stretchFactor>
-    <minimumSize>70, 24</minimumSize>
+    <minimumSize>80, 24</minimumSize>
     <border>0.0, 0.0, 0.0, 5.0</border>
   </StaticText>
   
   <EditText itsName="EditHeadline"
-            itemClass="osaf.framework.blocks.detail.Detail.EditHeadlineRedirectAttribute">
+            itemClass="osaf.framework.blocks.detail.Detail.EditRedirectAttribute">
     <blockName value="EditHeadline"/>
     <characterStyle itemref="doc:TextStyle"/>
     <lineStyleEnum>SingleLine</lineStyleEnum>
@@ -526,39 +492,6 @@
     <viewAttribute value="about"/>
   </AEBlock>
 
-  <ContentItemDetail itsName="EmailAddressArea"
-                     itemClass="osaf.framework.blocks.detail.Detail.DetailSynchronizedLabeledTextAttributeBlock">
-    <blockName value="EmailAddressArea"/>
-    <childrenBlocks itemref="doc:StaticEmailAddress"/>
-    <childrenBlocks itemref="doc:EditEmailAddress"/>
-    <!-- Attributes -->
-    <position>0.6</position>
-    <selectedItemsAttribute>homeSection</selectedItemsAttribute>
-    <minimumSize>300, 24</minimumSize>
-    <stretchFactor>0.0</stretchFactor>
-  </ContentItemDetail>
- 
-  <StaticText itsName="StaticEmailAddress"
-              itemClass="osaf.framework.blocks.detail.Detail.StaticEmailAddressAttribute">
-    <blockName value="StaticEmailAddress"/>
-    <title>email address</title>
-    <characterStyle itemref="doc:LabelStyle"/>
-    <textAlignmentEnum>Center</textAlignmentEnum>    
-    <stretchFactor>0.0</stretchFactor>
-    <minimumSize>70, 24</minimumSize>
-    <border>0.0, 0.0, 0.0, 5.0</border>
-  </StaticText>
-  
-  <EditText itsName="EditEmailAddress"
-            itemClass="osaf.framework.blocks.detail.Detail.EditEmailAddressAttribute">
-    <blockName value="EditEmailAddress"/>
-    <characterStyle itemref="doc:TextStyle"/>
-    <lineStyleEnum>SingleLine</lineStyleEnum>
-    <readOnly>False</readOnly>
-    <textAlignmentEnum>Left</textAlignmentEnum>
-    <minimumSize>300, 24</minimumSize>
-  </EditText>
-  
   <ContentItemDetail itsName="CalendarStartTime"
                      itemClass="osaf.framework.blocks.detail.Detail.CalendarEventBlock">
     <blockName value="CalendarStartTime"/>
@@ -568,6 +501,7 @@
     <selectedItemsAttribute>startTime</selectedItemsAttribute>
     <minimumSize>300, 24</minimumSize>
     <stretchFactor>0.0</stretchFactor>
+    <border>5, 0, 0, 5</border>
   </ContentItemDetail>
  
   <StaticText itsName="StaticCalendarStartTime">
@@ -576,7 +510,7 @@
     <characterStyle itemref="doc:LabelStyle"/>
     <textAlignmentEnum>Right</textAlignmentEnum>    
     <stretchFactor>0.0</stretchFactor>
-    <minimumSize>70, 24</minimumSize>
+    <minimumSize>80, 24</minimumSize>
     <border>0.0, 0.0, 0.0, 5.0</border>
   </StaticText>
   
@@ -590,30 +524,42 @@
     <minimumSize>300, 24</minimumSize>
   </EditText>
 
-  <PresentationStyle itsName="DurationPresentation">
-    <label>OnLeft</label>
-    <labelWidth>70</labelWidth>
-    <labelBorder>5</labelBorder>
-    <labelDisplayName>duration</labelDisplayName>
-  </PresentationStyle>
+  <ContentItemDetail itsName="CalendarDurationArea"
+                       itemClass="osaf.framework.blocks.detail.Detail.CalendarEventBlock">
+    <blockName value="CalendarDurationArea"/>
+    <childrenBlocks itemref="doc:CalendarDurationLabel"/>
+    <childrenBlocks itemref="doc:CalendarDuration"/>
+    <!-- Attributes -->
+    <stretchFactor>0.0</stretchFactor>
+    <minimumSize>300, 24</minimumSize>
+    <border>5, 5, 0, 5</border>
+  </ContentItemDetail>
+
+  <StaticText itsName="CalendarDurationLabel">
+    <blockName value="CalendarDurationLabel"/>
+    <title>duration</title>
+    <characterStyle itemref="doc:LabelStyle"/>
+    <textAlignmentEnum>Right</textAlignmentEnum>    
+    <stretchFactor>0.0</stretchFactor>
+    <minimumSize>80, 24</minimumSize>
+    <border>0, 0, 0, 5</border>
+  </StaticText>
 
   <AEBlock itsName="CalendarDuration"
            itemClass="osaf.framework.blocks.detail.Detail.EditDurationAttribute">
     <blockName value="AECalendarDuration"/>
     <characterStyle itemref="doc:LabelStyle"/>
     <readOnly>False</readOnly>
-    <stretchFactor>0.0</stretchFactor>
+    <stretchFactor>1</stretchFactor>
     <minimumSize>300, 24</minimumSize>
-    <border>0, 5, 0, 0</border>
-    <presentationStyle itemref="doc:DurationPresentation"/>
     <viewAttribute value="duration"/>
   </AEBlock>
 
   <ContentItemDetail itsName="CalendarDetails">
     <blockName value="CalendarDetails"/>
-    <childrenBlocks itemref="doc:CalendarLocation"/>
+    <childrenBlocks itemref="doc:CalendarLocationArea"/>
     <childrenBlocks itemref="doc:CalendarStartTime"/>
-    <childrenBlocks itemref="doc:CalendarDuration"/>
+    <childrenBlocks itemref="doc:CalendarDurationArea"/>
     <childrenBlocks itemref="doc:CalendarAllDayArea"/>
     <childrenBlocks itemref="doc:CalendarReminderArea"/>
     <childrenBlocks itemref="doc:CalendarTransparencyArea"/>
@@ -623,13 +569,27 @@
     <position>0.8</position>
   </ContentItemDetail>
   
-  <PresentationStyle itsName="LocationPresentation">
-    <label>OnLeft</label>
-    <labelWidth>70</labelWidth>
-    <labelBorder>5</labelBorder>
-    <labelDisplayName>duration</labelDisplayName>
-  </PresentationStyle>
+  <ContentItemDetail itsName="CalendarLocationArea"
+                       itemClass="osaf.framework.blocks.detail.Detail.CalendarEventBlock">
+    <blockName value="CalendarLocationArea"/>
+    <childrenBlocks itemref="doc:CalendarLocationLabel"/>
+    <childrenBlocks itemref="doc:CalendarLocation"/>
+    <!-- Attributes -->
+    <stretchFactor>0.0</stretchFactor>
+    <minimumSize>300, 24</minimumSize>
+    <border>5, 5, 0, 5</border>
+  </ContentItemDetail>
 
+  <StaticText itsName="CalendarLocationLabel">
+    <blockName value="CalendarLocationLabel"/>
+    <title>location</title>
+    <characterStyle itemref="doc:LabelStyle"/>
+    <textAlignmentEnum>Right</textAlignmentEnum>    
+    <stretchFactor>0.0</stretchFactor>
+    <minimumSize>80, 24</minimumSize>
+    <border>0, 0, 0, 5</border>
+  </StaticText>
+  
   <AEBlock itsName="CalendarLocation"
            itemClass="osaf.framework.blocks.detail.Detail.DetailSynchronizedAttributeEditorBlock">
     <blockName value="AECalendarLocation"/>
@@ -637,8 +597,6 @@
     <readOnly>False</readOnly>
     <stretchFactor>0.0</stretchFactor>
     <minimumSize>300, 24</minimumSize>
-    <border>0, 5, 0, 0</border>
-    <presentationStyle itemref="doc:LocationPresentation"/>
     <viewAttribute value="location"/>
   </AEBlock>
 
@@ -650,6 +608,7 @@
     <!-- Attributes -->
     <stretchFactor>0.0</stretchFactor>
     <minimumSize>300, 24</minimumSize>
+    <border>5, 0, 0, 5</border>
   </ContentItemDetail>
   
   <StaticText itsName="CalDetailsAllDayLabel">
@@ -658,7 +617,7 @@
     <characterStyle itemref="doc:LabelStyle"/>
     <textAlignmentEnum>Right</textAlignmentEnum>    
     <stretchFactor>0.0</stretchFactor>
-    <minimumSize>70, 24</minimumSize>
+    <minimumSize>80, 24</minimumSize>
     <border>0.0, 0.0, 0.0, 5.0</border>
   </StaticText>
 
@@ -683,6 +642,7 @@
     <!-- Attributes -->
     <stretchFactor>0.0</stretchFactor>
     <minimumSize>300, 24</minimumSize>
+    <border>5, 0, 0, 5</border>
   </ContentItemDetail>
 
   <StaticText itsName="CalDetailsReminderLabel">
@@ -691,7 +651,7 @@
     <characterStyle itemref="doc:LabelStyle"/>
     <textAlignmentEnum>Right</textAlignmentEnum>    
     <stretchFactor>0.0</stretchFactor>
-    <minimumSize>70, 24</minimumSize>
+    <minimumSize>80, 24</minimumSize>
     <border>0.0, 0.0, 0.0, 5.0</border>
   </StaticText>
 
@@ -718,6 +678,7 @@
     <!-- Attributes -->
     <stretchFactor>0.0</stretchFactor>
     <minimumSize>300, 24</minimumSize>
+    <border>5, 0, 0, 5</border>
   </ContentItemDetail>
 
   <StaticText itsName="CalDetailsTransparencyLabel">
@@ -726,7 +687,7 @@
     <characterStyle itemref="doc:LabelStyle"/>
     <textAlignmentEnum>Right</textAlignmentEnum>    
     <stretchFactor>0.0</stretchFactor>
-    <minimumSize>70, 24</minimumSize>
+    <minimumSize>80, 24</minimumSize>
     <border>0.0, 0.0, 0.0, 5.0</border>
   </StaticText>
 
@@ -754,6 +715,7 @@
     <textAlignmentEnum>Left</textAlignmentEnum>
     <stretchFactor>3</stretchFactor>
     <minimumSize>300, 80</minimumSize>
+    <border>5, 0, 0, 0</border>
   </EditText>
 
 </core:Parcel>

Index: chandler/parcels/osaf/framework/webserver/servlets/repo/Repo.py
diff -u chandler/parcels/osaf/framework/webserver/servlets/repo/Repo.py:1.18 chandler/parcels/osaf/framework/webserver/servlets/repo/Repo.py:1.19
--- chandler/parcels/osaf/framework/webserver/servlets/repo/Repo.py:1.18	Thu Apr 14 23:47:05 2005
+++ chandler/parcels/osaf/framework/webserver/servlets/repo/Repo.py	Tue Apr 19 11:26:18 2005
@@ -4,6 +4,7 @@
 # import application.Globals as Globals
 import repository
 import application
+import re
 from repository.item.Item import Item
 from repository.schema.Kind import Kind
 from repository.schema.Types import Type
@@ -82,10 +83,48 @@
                     name = item.itsName
                     if name is None:
                         name = str(item.itsUUID)
-                    result += "<div class='path'>%s &gt; <span class='itemname'><a href=%s>%s</a></span></div>" % (path, toLink(item.itsPath), name)
+                    result += "<div class='path'>%s &gt; <span class='itemname'><a href=%s>%s</a></span> | <a href=%s>Render attributes</a></div>" % (path, toLink(item.itsPath), name, toLink(item.itsPath))
 
                     result += RenderBlock(repoView, item)
 
+                elif mode == "object":
+                    fields = []
+                    item = None
+                    itemPath = path
+                    # The path is like: //path/to/item/field/field
+                    # Separate out the fields until we find the item.
+                    while True:
+                        item = repoView.findPath(itemPath)
+                        if item is None:
+                            lastSlash = itemPath.rfind('/')
+                            if (lastSlash == -1):
+                                break;
+                            field = itemPath[(lastSlash + 1):]
+                            fields.insert(0, field)
+                            itemPath = itemPath[:lastSlash]
+                        else:
+                            break
+                        
+                    if item is None:
+                        result += "<h3>Item not found: %s</h3>" % clean(path)
+                        return str(result)
+
+                    if len(fields) == 0:
+                        # No fields - just go render the item.
+                        return RenderItem(repoView, item)
+                    
+                    # Drill down to the field we want
+                    theValue = item
+                    for f in fields:
+                        try:
+                            theValue = _getObjectValue(theValue, f)
+                        except:
+                            result += "<h3>Unable to get %s on %s</h3>" % (clean(f), clean(theValue))
+                            return str(result)
+                    result += "<div>"
+                    result += RenderObject(repoView, theValue, path)
+                    result += "</div>"
+
                 elif mode == "inheritance":
                     result += RenderInheritance(repoView)
 
@@ -835,6 +874,14 @@
             count += 1
     result += "</table>\n"
 
+    if isBlock:
+        try:
+            widget = item.widget
+        except:
+            pass
+        else:
+            result += RenderObject(repoView, widget, "%s/%s" % (item.itsPath, "widget"), "Widget")
+            
     if isKind:
 
         # Cloud info
@@ -844,6 +891,93 @@
 
     return result
 
+indexRE = re.compile(r"(.*)\[(\d+)\]")
+
+def _getObjectValue(theObject, name):
+    """ 
+    Given an object and a name, get the value.
+    If the name ends with "[\d+]", strip that off and save the index, then:
+    If it's a regular attribute (not callable), get its value.
+    If it's callable, call it and get the resulting value (we call twice if necessary: once with
+    no parameters, once with the object as a parameter).
+    Once we've got a value: if we'd gotten an index
+    """
+    index = None
+    global indexRE
+    m = indexRE.match(name)
+    if m is not None:
+        (name, index) = m.groups(1)
+    attr = getattr(theObject, name, None)
+    if attr is None or not callable(attr):
+        return attr
+    value = None
+    try:
+        value = attr(theObject)
+    except:
+        try:
+            value = attr()
+        except:
+            pass
+    if index is not None:
+        value = value[int(index)]
+    return value
+
+def RenderObject(repoView, theObject, objectPath, label="Object"):
+    result = "&nbsp;<br><table width=100% border=0 cellpadding=4 cellspacing=0>\n"
+    result += "<tr class='toprow'>\n"
+    result += "<td colspan=2><b>%s: %s</b></td>\n" % (clean(label), clean(theObject))
+    result += "</tr>\n"
+    result += "<tr class='headingsrow'>\n"
+    result += "<td valign=top><b>Attribute</b></td>\n"
+    result += "<td valign=top><b>Value</b></td>\n"
+    result += "</tr>\n"
+    count = 0
+    
+    displayedAttrs = { }
+    for name in dir(theObject):
+        if name is None or name.endswith("Tuple") or not (name.startswith('Get') or name.startswith('Has') or name.startswith('Is')):
+            continue
+        displayName = name.startswith("Get") and name[3:] or name
+        value = _getObjectValue(theObject, name)
+        if value is not None:
+            displayedAttrs[displayName] = (name, value)
+
+    keys = displayedAttrs.keys()
+    keys.sort(lambda x, y: cmp(string.lower(x), string.lower(y)))
+    for displayName in keys:
+        (name, value) = displayedAttrs[displayName]
+
+        result += oddEvenRow(count)
+        result += "<td valign=top>"
+        result += "%s" % displayName
+        result += "</td><td valign=top>"
+        try:
+            theType = TypeHandler.typeHandler(repoView, value)
+            typeName = theType.getImplementationType().__name__
+            result += "<b>(%s)</b> " % typeName
+        except:
+            result += "<b>(%s)</b> " % value.__class__.__name__
+
+        if isinstance(value, list):
+            results = []
+            for i in range(len(value)-1):
+                v = value[i]
+                if str(v).find("; proxy of C++ ") != -1:
+                    results.append("<a href=%s?mode=object>%s</a>" % (toLink("%s/%s[%d]" % (objectPath[1:], name, i)), clean(v)))
+                else:
+                    results.append("%s" % (clean(v)))
+            result += ", ".join(results) + "<br>"
+        else:            
+            if str(value).find("; proxy of C++ ") != -1:
+                result += "<a href=%s?mode=object>%s</a><br>" % (toLink("%s/%s" % (objectPath[1:], name)), clean(value))
+            else:
+                result += "%s<br>" % (clean(value))    
+        result += "</td></tr>\n"
+        count += 1
+
+    result += "</table>\n"
+    return result
+
 def getItemName(item):
     try:
         name = item.getItemDisplayName()



More information about the Commits mailing list