[Thuban-devel] Re: RfD: Support for layer specific resources

Martin Schulze joey at infodrom.org
Thu Sep 30 08:30:28 CEST 2004


Martin Schulze wrote:
> I'm attaching the solution in a patch to this mail, in case you or
> anybody else still wants to comment on it.  If not, I'll commit it
> on Friday.

As usual I forgot to attach the patch, next try...

Regards,

	Joey

-- 
This is GNU/Linux Country.  On a quiet night, you can hear Windows reboot.
-------------- next part --------------
Index: Extensions/wms/wms.py
===================================================================
RCS file: /thubanrepository/thuban/Extensions/wms/wms.py,v
retrieving revision 1.10
diff -u -r1.10 wms.py
--- Extensions/wms/wms.py	28 Sep 2004 19:54:50 -0000	1.10
+++ Extensions/wms/wms.py	29 Sep 2004 19:01:39 -0000
@@ -65,6 +65,8 @@
     return ()
 
 Thuban.UI.baserenderer.add_renderer_extension(WMSLayer, render_wms_layer)
+from Thuban.UI.propertiesdialogs import layer_properties_dialogs
+layer_properties_dialogs.add(WMSLayer, wmsProperties)
 
 
 class SelectWMSServer(wxDialog):
Index: Thuban/UI/classifier.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/classifier.py,v
retrieving revision 1.65
diff -u -r1.65 classifier.py
--- Thuban/UI/classifier.py	7 May 2004 20:20:43 -0000	1.65
+++ Thuban/UI/classifier.py	29 Sep 2004 19:01:42 -0000
@@ -685,7 +685,7 @@
                    FIELDTYPE_INT:    _("Integer"),
                    FIELDTYPE_DOUBLE: _("Decimal")}
 
-    def __init__(self, parent, name, map, layer, group = None):
+    def __init__(self, parent, name, layer, group = None):
         """Create a Properties/Classification dialog for a layer.
         The layer is part of map. If group is not None, select that
         group in the classification table.
@@ -697,7 +697,7 @@
 
         self.parent.Subscribe(MAP_REPLACED, self.map_replaced)
         self.layer = layer
-        self.map = map
+        self.map = parent.Map()
 
         self.map.Subscribe(MAP_LAYERS_REMOVED, self.map_layers_removed)
         self.layer.Subscribe(LAYER_SHAPESTORE_REPLACED,
@@ -1510,3 +1510,7 @@
 
     def _OnLeftDClick(self, event):
         self.DoEdit()
+
+from Thuban.UI.propertiesdialogs import layer_properties_dialogs
+layer_properties_dialogs.add(Layer, Classifier)
+layer_properties_dialogs.add(RasterLayer, Classifier)
Index: Thuban/UI/mainwindow.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/mainwindow.py,v
retrieving revision 1.132
diff -u -r1.132 mainwindow.py
--- Thuban/UI/mainwindow.py	18 Apr 2004 20:37:01 -0000	1.132
+++ Thuban/UI/mainwindow.py	29 Sep 2004 19:01:43 -0000
@@ -48,6 +48,7 @@
 from Thuban.UI.dock import DockFrame
 from Thuban.UI.join import JoinDialog
 from Thuban.UI.dbdialog import DBFrame, DBDialog, ChooseDBTableDialog
+from Thuban.UI.propertiesdialogs import layer_properties_dialogs
 import resource
 import Thuban.Model.resource
 
@@ -349,6 +350,23 @@
         """
         self.SetStatusText(text)
 
+    def OpenOrRaiseDialog(self, name, dialog_class, *args, **kw):
+        """
+        Open or raise a dialog.
+
+        If a dialog with the denoted name does already exist it is
+        raised.  Otherwise a new dialog, an instance of dialog_class,
+        is created, inserted into the main list and displayed.
+        """
+        dialog = self.get_open_dialog(name)
+
+        if dialog is None:
+            dialog = dialog_class(self, name, *args, **kw)
+            self.add_dialog(name, dialog)
+            dialog.Show(True)
+        else:
+            dialog.Raise()
+                          
     def save_modified_session(self, can_veto = 1):
         """If the current session has been modified, ask the user
         whether to save it and do so if requested. Return the outcome of
@@ -705,14 +723,18 @@
         self.OpenLayerProperties(layer)
 
     def OpenLayerProperties(self, layer, group = None):
-        name = "layer_properties" + str(id(layer))
-        dialog = self.get_open_dialog(name)
+        """
+        Open or raise the properties dialog.
 
-        if dialog is None:
-            dialog = Classifier(self, name, self.Map(), layer, group)
-            self.add_dialog(name, dialog)
-            dialog.Show()
-        dialog.Raise()
+        This method opens or raises the properties dialog for the
+        currently selected layer if one is defined for this layer
+        type.
+        """
+        dialog_class = layer_properties_dialogs.get(layer)
+
+        if dialog_class is not None:
+            name = "layer_properties" + str(id(layer))
+            self.OpenOrRaiseDialog(name, dialog_class, layer, group = group)
 
     def LayerJoinTable(self):
         layer = self.canvas.SelectedLayer()
--------------------------
Index: Thuban/UI/propertiesdialogs.py
===================================================================
RCS file: /thubanrepository/thuban/Thuban/UI/propertiesdialogs.py,v
diff -u -rNONE propertiesdialogs.py
--- Extensions/wms/wms.py	28 Sep 2004 19:54:50 -0000	1.10
--- Extensions/wms/wms.py	2004-08-27 17:25:15.000000000 +0200
+++ Thuban/UI/propertiesdialogs.py	2004-09-29 20:44:23.000000000 +0200
@@ -0,0 +1,3 @@
+from Thuban.Lib.classmapper import ClassMapper
+
+layer_properties_dialogs = ClassMapper()


More information about the Thuban-devel mailing list

This site is hosted by Intevation GmbH (Datenschutzerklärung und Impressum | Privacy Policy and Imprint)