URI Editor Dialog : moved it to /dialog, and fixed naming.
authorEdouard Tisserant
Thu, 08 Nov 2018 11:14:06 +0100
changeset 2330 8c18b1a3e2bf
parent 2329 e5703dc8848e
child 2331 91ae5a11a462
URI Editor Dialog : moved it to /dialog, and fixed naming.
controls/UriLocationEditor.py
dialogs/UriEditor.py
dialogs/__init__.py
editors/ConfTreeNodeEditor.py
--- a/controls/UriLocationEditor.py	Thu Nov 08 09:39:06 2018 +0100
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,79 +0,0 @@
-from __future__ import absolute_import
-
-import wx
-from connectors import ConnectorSchemes, EditorClassFromScheme
-
-
-[ID_URIWIZARDDIALOG, ID_URITYPECHOICE] = [wx.NewId() for _init_ctrls in range(2)]
-
-class UriLocationEditor(wx.Dialog):
-    def _init_ctrls(self, parent):
-        self.UriTypeChoice = wx.Choice(parent=self, id=ID_URIWIZARDDIALOG, choices=self.URITYPES)
-        self.UriTypeChoice.SetSelection(0)
-        self.Bind(wx.EVT_CHOICE, self.OnTypeChoice, self.UriTypeChoice)
-        self.editor_sizer = wx.BoxSizer(wx.HORIZONTAL)
-        self.ButtonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
-
-    def _init_sizers(self):
-        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
-        typeSizer = wx.BoxSizer(wx.HORIZONTAL)
-        typeSizer.Add(wx.StaticText(self, wx.ID_ANY, _("Scheme :")), border=5, flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL)
-        typeSizer.Add(self.UriTypeChoice, border=5, flag=wx.ALL)
-        self.mainSizer.Add(typeSizer)
-
-        self.mainSizer.Add(self.editor_sizer, border=5, flag=wx.ALL)
-        self.mainSizer.Add(self.ButtonSizer, border=5, flag=wx.BOTTOM | wx.ALIGN_CENTER_HORIZONTAL)
-        self.SetSizer(self.mainSizer)
-        self.Layout()
-        self.Fit()
-
-    def __init__(self, parent, uri):
-        wx.Dialog.__init__(self, id=ID_URIWIZARDDIALOG,
-                           name='UriLocationEditor', parent=parent,
-                           title=_('URI Editor'))
-        self.URITYPES = [_("- Select URI Scheme -")] + ConnectorSchemes()
-        self._init_ctrls(parent)
-        self._init_sizers()
-        self.scheme = None
-        self.scheme_editor = None
-        self.SetURI(uri)
-        self.CenterOnParent()
-
-    def OnTypeChoice(self, event):
-        index = event.GetSelection()
-        self._replaceSchemeEditor(event.GetString() if index > 0 else None)
-
-    def SetURI(self, uri):
-        try:
-            scheme, loc = uri.strip().split("://",1)
-        except:
-            return None
-        scheme = scheme.upper()
-        if scheme in ConnectorSchemes():
-            self.UriTypeChoice.SetStringSelection(scheme)
-            self._replaceSchemeEditor(scheme)
-            self.scheme_editor.SetLoc(loc)
-
-    def GetURI(self):
-        if self.scheme_editor is None:
-            return None
-        else:
-            return self.scheme+"://"+self.scheme_editor.GetLoc()
-
-    def _replaceSchemeEditor(self, scheme):
-        self.scheme = scheme
-       
-        if self.scheme_editor is not None:
-            self.editor_sizer.Detach(self.scheme_editor)
-            self.scheme_editor.Destroy()
-            self.scheme_editor = None
-
-        EditorClass = EditorClassFromScheme(scheme)
-        if EditorClass is not None:
-            self.scheme_editor = EditorClass(scheme,self)
-            self.editor_sizer.Add(self.scheme_editor)
-            self.scheme_editor.Refresh()
-        self.editor_sizer.Layout()
-        self.mainSizer.Layout()
-        self.Fit()
-
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/dialogs/UriEditor.py	Thu Nov 08 11:14:06 2018 +0100
@@ -0,0 +1,79 @@
+from __future__ import absolute_import
+
+import wx
+from connectors import ConnectorSchemes, EditorClassFromScheme
+
+
+[ID_URIWIZARDDIALOG, ID_URITYPECHOICE] = [wx.NewId() for _init_ctrls in range(2)]
+
+class UriEditor(wx.Dialog):
+    def _init_ctrls(self, parent):
+        self.UriTypeChoice = wx.Choice(parent=self, id=ID_URIWIZARDDIALOG, choices=self.URITYPES)
+        self.UriTypeChoice.SetSelection(0)
+        self.Bind(wx.EVT_CHOICE, self.OnTypeChoice, self.UriTypeChoice)
+        self.editor_sizer = wx.BoxSizer(wx.HORIZONTAL)
+        self.ButtonSizer = self.CreateButtonSizer(wx.OK | wx.CANCEL)
+
+    def _init_sizers(self):
+        self.mainSizer = wx.BoxSizer(wx.VERTICAL)
+        typeSizer = wx.BoxSizer(wx.HORIZONTAL)
+        typeSizer.Add(wx.StaticText(self, wx.ID_ANY, _("Scheme :")), border=5, flag=wx.ALIGN_CENTER_VERTICAL | wx.ALL)
+        typeSizer.Add(self.UriTypeChoice, border=5, flag=wx.ALL)
+        self.mainSizer.Add(typeSizer)
+
+        self.mainSizer.Add(self.editor_sizer, border=5, flag=wx.ALL)
+        self.mainSizer.Add(self.ButtonSizer, border=5, flag=wx.BOTTOM | wx.ALIGN_CENTER_HORIZONTAL)
+        self.SetSizer(self.mainSizer)
+        self.Layout()
+        self.Fit()
+
+    def __init__(self, parent, uri):
+        wx.Dialog.__init__(self, id=ID_URIWIZARDDIALOG,
+                           name='UriEditor', parent=parent,
+                           title=_('URI Editor'))
+        self.URITYPES = [_("- Select URI Scheme -")] + ConnectorSchemes()
+        self._init_ctrls(parent)
+        self._init_sizers()
+        self.scheme = None
+        self.scheme_editor = None
+        self.SetURI(uri)
+        self.CenterOnParent()
+
+    def OnTypeChoice(self, event):
+        index = event.GetSelection()
+        self._replaceSchemeEditor(event.GetString() if index > 0 else None)
+
+    def SetURI(self, uri):
+        try:
+            scheme, loc = uri.strip().split("://",1)
+        except:
+            return None
+        scheme = scheme.upper()
+        if scheme in ConnectorSchemes():
+            self.UriTypeChoice.SetStringSelection(scheme)
+            self._replaceSchemeEditor(scheme)
+            self.scheme_editor.SetLoc(loc)
+
+    def GetURI(self):
+        if self.scheme_editor is None:
+            return None
+        else:
+            return self.scheme+"://"+self.scheme_editor.GetLoc()
+
+    def _replaceSchemeEditor(self, scheme):
+        self.scheme = scheme
+       
+        if self.scheme_editor is not None:
+            self.editor_sizer.Detach(self.scheme_editor)
+            self.scheme_editor.Destroy()
+            self.scheme_editor = None
+
+        EditorClass = EditorClassFromScheme(scheme)
+        if EditorClass is not None:
+            self.scheme_editor = EditorClass(scheme,self)
+            self.editor_sizer.Add(self.scheme_editor)
+            self.scheme_editor.Refresh()
+        self.editor_sizer.Layout()
+        self.mainSizer.Layout()
+        self.Fit()
+
--- a/dialogs/__init__.py	Thu Nov 08 09:39:06 2018 +0100
+++ b/dialogs/__init__.py	Thu Nov 08 11:14:06 2018 +0100
@@ -49,3 +49,4 @@
 from dialogs.FindInPouDialog import FindInPouDialog
 from dialogs.BrowseValuesLibraryDialog import BrowseValuesLibraryDialog
 from dialogs.DiscoveryDialog import DiscoveryDialog
+from dialogs.UriEditor import UriEditor
--- a/editors/ConfTreeNodeEditor.py	Thu Nov 08 09:39:06 2018 +0100
+++ b/editors/ConfTreeNodeEditor.py	Thu Nov 08 11:14:06 2018 +0100
@@ -33,8 +33,8 @@
 
 from IDEFrame import TITLE, FILEMENU, PROJECTTREE, PAGETITLES
 
-from controls import TextCtrlAutoComplete, UriLocationEditor
-from dialogs import BrowseValuesLibraryDialog
+from controls import TextCtrlAutoComplete
+from dialogs import BrowseValuesLibraryDialog, UriEditor
 from util.BitmapLibrary import GetBitmap
 
 if wx.Platform == '__WXMSW__':
@@ -345,7 +345,7 @@
 
         # Get connector uri
         uri = CTR_BeremizRoot.getURI_location().strip()
-        dialog = UriLocationEditor.UriLocationEditor(CTR_AppFrame, uri)
+        dialog = UriEditor(CTR_AppFrame, uri)
 
         if dialog.ShowModal() == wx.ID_OK:
             CTR_BeremizRoot.setURI_location(dialog.GetURI())