Author: jmorliaguet
Date: Thu Apr 13 11:54:54 2006
New Revision: 2830

Modified:
   cpsskins/branches/jmo-perspectives/configuration/widgets/metaconfigure.py
   cpsskins/branches/jmo-perspectives/configuration/widgets/metadirectives.py
   cpsskins/branches/jmo-perspectives/configuration/widgets/widget.py
   cpsskins/branches/jmo-perspectives/elements/configure.zcml
   cpsskins/branches/jmo-perspectives/standard/filters/widget/__init__.py
   cpsskins/branches/jmo-perspectives/standard/filters/widget/widgets.py
   cpsskins/branches/jmo-perspectives/standard/filters/widget/widgets.zcml
Log:

- widgets can be registered per rendering engine. However they are called with
  the same name so that designers do not have to worry about which engine
  will be used.

- the "tableless" widgets used for rendering pageblock and cells are registered
  under the 'tableless' engine. They are called: 'pageblock_frame' and
  'cell_frame'



Modified: 
cpsskins/branches/jmo-perspectives/configuration/widgets/metaconfigure.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/configuration/widgets/metaconfigure.py   
(original)
+++ cpsskins/branches/jmo-perspectives/configuration/widgets/metaconfigure.py   
Thu Apr 13 11:54:54 2006
@@ -29,7 +29,8 @@
 
 _ = MessageFactory("cpsskins")
 
-def widget(_context=None, name=None, title=None, view=None, for_=None):
+def widget(_context=None, name=None, title=None, view=None, for_=None,
+           engine=u''):
 
     if not name:
         raise ConfigurationError("Must specify the widget's name.")
@@ -40,11 +41,15 @@
     if not view:
         raise ConfigurationError("Must specify a widget view.")
 
+    widget_name = name
+    if engine:
+        widget_name = '%s-%s' % (engine, name)
+
     # register widgets
-    provideUtility(configuration.Widget(name=name, title=title, view=view),
-                   configuration.IWidget, name)
+    provideUtility(configuration.Widget(name=name, title=title, view=view,
+                   engine=engine), configuration.IWidget, widget_name)
 
     # zope:adapter
     adapter(_context=_context, factory=(view,), provides=IWidgetView,
-            for_=(for_, IBrowserRequest), name=name)
+            for_=(for_, IBrowserRequest), name=widget_name)
 

Modified: 
cpsskins/branches/jmo-perspectives/configuration/widgets/metadirectives.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/configuration/widgets/metadirectives.py  
(original)
+++ cpsskins/branches/jmo-perspectives/configuration/widgets/metadirectives.py  
Thu Apr 13 11:54:54 2006
@@ -53,3 +53,9 @@
         required=False,
         )
 
+    engine = TextLine(
+        title=_(u"Engine"),
+        description=_(u"The rendering engine that the widget applies to."),
+        required=False,
+        )
+

Modified: cpsskins/branches/jmo-perspectives/configuration/widgets/widget.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/configuration/widgets/widget.py  
(original)
+++ cpsskins/branches/jmo-perspectives/configuration/widgets/widget.py  Thu Apr 
13 11:54:54 2006
@@ -40,13 +40,16 @@
 
     factory = Attribute(u"Widget factory")
 
+    engine = Attribute(u"The engine's name")
+
 class Widget(object):
     """A widget.
     """
     implements(IWidget)
 
-    def __init__(self, name=u'', title=u'', view=None):
+    def __init__(self, name=u'', title=u'', view=None, engine=u''):
         self.name = name
         self.title = title
         self.view = view
+        self.engine = engine
 

Modified: cpsskins/branches/jmo-perspectives/elements/configure.zcml
==============================================================================
--- cpsskins/branches/jmo-perspectives/elements/configure.zcml  (original)
+++ cpsskins/branches/jmo-perspectives/elements/configure.zcml  Thu Apr 13 
11:54:54 2006
@@ -273,7 +273,7 @@
 
     <cpsskins:format
         name="widget"
-        types="standard.table_frame"
+        types="standard.pageblock_frame"
     />
 
     <cpsskins:format
@@ -331,7 +331,7 @@
 
     <cpsskins:format
         name="widget"
-        types="standard.table_cell"
+        types="standard.cell_frame"
     />
 
     <cpsskins:format

Modified: cpsskins/branches/jmo-perspectives/standard/filters/widget/__init__.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/standard/filters/widget/__init__.py      
(original)
+++ cpsskins/branches/jmo-perspectives/standard/filters/widget/__init__.py      
Thu Apr 13 11:54:54 2006
@@ -49,12 +49,19 @@
         context = self.context
         request = info.globals.request
 
+        engine = info.globals.engine
         data = info.data
 
         types = context.types
         for type in types:
+            # look for a widget specific to the engine
             factory = queryMultiAdapter((data, request), IWidgetView,
-                                         name=type)
+                                         name='%s-%s' % (engine, type))
+            if factory is not None:
+                break
+
+            # do not specify the engine
+            factory = queryMultiAdapter((data, request), IWidgetView, 
name=type)
             if factory is not None:
                 break
 

Modified: cpsskins/branches/jmo-perspectives/standard/filters/widget/widgets.py
==============================================================================
--- cpsskins/branches/jmo-perspectives/standard/filters/widget/widgets.py       
(original)
+++ cpsskins/branches/jmo-perspectives/standard/filters/widget/widgets.py       
Thu Apr 13 11:54:54 2006
@@ -214,7 +214,7 @@
     _markup = u'<div style="overflow-x:scroll;">%(content)s</div>'
     _preview = u'<div label="box" style="overflow-x:scroll;">Box content</div>'
 
-class TableFrame(HTMLView):
+class PageBlockFrame(HTMLView):
     """Display a <table><tr> tag
     """
     _markup = u'<table summary=""><tr>%(content)s</tr></table>'
@@ -223,7 +223,7 @@
                '<td inactive="1">Sample content</td>' \
                '</tr></tbody></table>'
 
-class TableCell(HTMLView):
+class CellFrame(HTMLView):
     """Display a <td> tag
     """
     _markup = u'<td style="vertical-align:top;">%(content)s</td>'
@@ -233,17 +233,17 @@
                '<td label="cell">Cell content</td>' \
                '</tr></tbody></table>'
 
-class DivFrame(HTMLView):
+class TablelessPageBlockFrame(HTMLView):
     """Display a <div> frame
     """
     _markup = u'<div>%(content)s<br style="clear:left"/></div>' \
               '<div style="clear:left"></div>'
     _preview = u'<div label="frame box">Frame content</div>'
 
-class DivCell(HTMLView):
+class TablelessCellFrame(HTMLView):
     """Display a floating <div> cell
     """
-    _markup = u'<div style="float:left;overflow-x:hidden">%(content)s</div>'
+    _markup = u'<div style="float:left;overflow:hidden">%(content)s</div>'
     _preview = u'<div label="cell">Cell content</div>'
 
 class MonthlyCalendar(WidgetView):

Modified: 
cpsskins/branches/jmo-perspectives/standard/filters/widget/widgets.zcml
==============================================================================
--- cpsskins/branches/jmo-perspectives/standard/filters/widget/widgets.zcml     
(original)
+++ cpsskins/branches/jmo-perspectives/standard/filters/widget/widgets.zcml     
Thu Apr 13 11:54:54 2006
@@ -41,33 +41,35 @@
   />
 
 
-  <!-- Frame widget views -->
+  <!-- Page block widgets -->
 
   <widget
-      name="standard.table_frame"
-      title="Table frame"
-      view=".widgets.TableFrame"
+      name="standard.pageblock_frame"
+      title="Page block frame"
+      view=".widgets.PageBlockFrame"
   />
 
   <widget
-      name="standard.div_frame"
-      title="Div frame"
-      view=".widgets.DivFrame"
+      name="standard.pageblock_frame"
+      title="Page block frame"
+      view=".widgets.TablelessPageBlockFrame"
+      engine="tableless"
   />
 
 
-  <!-- Cell widget views -->
+  <!-- Cell widgets -->
 
   <widget
-      name="standard.table_cell"
-      title="Table cell"
-      view=".widgets.TableCell"
+      name="standard.cell_frame"
+      title="Cell frame"
+      view=".widgets.CellFrame"
   />
 
   <widget
-      name="standard.div_cell"
-      title="Div cell"
-      view=".widgets.DivCell"
+      name="standard.cell_frame"
+      title="Cell frame"
+      view=".widgets.TablelessCellFrame"
+      engine="tableless"
   />
 
   <widget
-- 
http://lists.nuxeo.com/mailman/listinfo/z3lab-checkins

Reply via email to