--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/connectors/PYRO/dialog.py Thu May 17 09:33:58 2018 +0200
@@ -0,0 +1,69 @@
+# Copyright (C) 2018: Smarteh +# See COPYING file for copyrights details. +from __future__ import absolute_import +from __future__ import print_function +from controls.UriLocationEditor import IConnectorPanel +from zope.interface import implementer +URITypes = ["LOCAL", "PYRO", "PYROS"] +def PYRO_connector_dialog(confnodesroot): + [ID_IPTEXT, ID_PORTTEXT] = [wx.NewId() for _init_ctrls in range(2)] + @implementer(IConnectorPanel) + class PYROConnectorPanel(wx.Panel): + def __init__(self, typeConnector, parrent, *args, **kwargs): + self.type = typeConnector + wx.Panel.__init__(self, parrent, *args, **kwargs) + self.IpText = wx.TextCtrl(parent=self, id=ID_IPTEXT, size = wx.Size(200, -1)) + self.PortText = wx.TextCtrl(parent=self, id=ID_PORTTEXT, size = wx.Size(200, -1)) + def _init_sizers(self): + self.mainSizer = wx.BoxSizer(wx.VERTICAL) + self.uriSizer = wx.BoxSizer(wx.HORIZONTAL) + self.portSizer = wx.BoxSizer(wx.HORIZONTAL) + self.uriSizer.Add(wx.StaticText(self, wx.ID_ANY, "URI host:", size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) + self.uriSizer.AddSpacer((0,0)) + self.uriSizer.Add(self.IpText, proportion=1, flag=wx.ALIGN_RIGHT) + self.mainSizer.Add(self.uriSizer, border=2, flag=wx.ALL) + self.portSizer.Add(wx.StaticText(self, wx.ID_ANY, "URI port:", size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) + self.portSizer.AddSpacer((0,0)) + self.portSizer.Add(self.PortText, proportion=1, flag=wx.ALIGN_RIGHT) + self.mainSizer.Add(self.portSizer, border=2, flag=wx.ALL) + self.SetSizer(self.mainSizer) + uri_list = uri.strip().split(":") + self.IpText.SetValue(uri_list[1].strip("/")) + self.PortText.SetValue(uri_list[2]) + self.IpText.SetValue(uri_list[1].strip("/")) + self.uri = self.type+"://"+self.IpText.GetValue()+":"+self.PortText.GetValue() + return PYROConnectorPanel("PYRO", confnodesroot) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/connectors/WAMP/dialog.py Thu May 17 09:33:58 2018 +0200
@@ -0,0 +1,98 @@
+# Copyright (C) 2018: Smarteh +# See COPYING file for copyrights details. +from __future__ import absolute_import +from __future__ import print_function +from controls.UriLocationEditor import IConnectorPanel +from zope.interface import implementer +URITypes = ["WAMP", "WAMPS"] +def WAMP_connector_dialog(confnodesroot): + [ID_IPTEXT, ID_PORTTEXT, ID_REALMTEXT, ID_WAMPIDTEXT, ID_SECURECHECKBOX] = [wx.NewId() for _init_ctrls in range(5)] + @implementer(IConnectorPanel) + class WAMPConnectorPanel(wx.Panel): + def __init__(self, typeConnector, parrent, *args, **kwargs): + self.type = typeConnector + wx.Panel.__init__(self, parrent, *args, **kwargs) + self.IpText = wx.TextCtrl(parent=self, id=ID_IPTEXT, size = wx.Size(200, -1)) + self.PortText = wx.TextCtrl(parent=self, id=ID_PORTTEXT, size = wx.Size(200, -1)) + self.RealmText = wx.TextCtrl(parent=self, id=ID_REALMTEXT, size = wx.Size(200, -1)) + self.WAMPIDText = wx.TextCtrl(parent=self, id=ID_WAMPIDTEXT, size = wx.Size(200, -1)) + self.SecureCheckbox = wx.CheckBox(self, ID_SECURECHECKBOX, _("Is connection secure?")) + def _init_sizers(self): + self.mainSizer = wx.BoxSizer(wx.VERTICAL) + self.uriSizer = wx.BoxSizer(wx.HORIZONTAL) + self.portSizer = wx.BoxSizer(wx.HORIZONTAL) + self.realmSizer = wx.BoxSizer(wx.HORIZONTAL) + self.wampIDSizer = wx.BoxSizer(wx.HORIZONTAL) + self.uriSizer.Add(wx.StaticText(self, wx.ID_ANY, _("URI host:"), size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) + self.uriSizer.AddSpacer((0,0)) + self.uriSizer.Add(self.IpText, proportion=1, flag=wx.ALIGN_RIGHT) + self.mainSizer.Add(self.uriSizer, border=2, flag=wx.ALL) + self.portSizer.Add(wx.StaticText(self, wx.ID_ANY, _("URI port:"), size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) + self.portSizer.AddSpacer((0,0)) + self.portSizer.Add(self.PortText, proportion=1, flag=wx.ALIGN_RIGHT) + self.mainSizer.Add(self.portSizer, border=2, flag=wx.ALL) + self.realmSizer.Add(wx.StaticText(self, wx.ID_ANY, _("Realm:"), size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) + self.realmSizer.AddSpacer((0, 0)) + self.realmSizer.Add(self.RealmText, proportion=1, flag=wx.ALIGN_RIGHT) + self.mainSizer.Add(self.realmSizer, border=2, flag=wx.ALL) + self.wampIDSizer.Add(wx.StaticText(self, wx.ID_ANY, _("WAMP ID:"), size = wx.Size(70, -1)), proportion=0, flag=wx.ALIGN_CENTER_VERTICAL) + self.wampIDSizer.AddSpacer((0, 0)) + self.wampIDSizer.Add(self.WAMPIDText, proportion=1, flag=wx.ALIGN_RIGHT) + self.mainSizer.Add(self.wampIDSizer, border=2, flag=wx.ALL) + self.mainSizer.Add(self.SecureCheckbox, proportion=1, flag=wx.ALIGN_LEFT) + self.SetSizer(self.mainSizer) + uri_list = uri.strip().split(":") + if uri_list[0] == URITypes[1]: + self.SecureCheckbox.SetValue(True) + self.IpText.SetValue(uri_list[1].strip("/")) + wampSett = uri_list[2].split("#") + length2 = len(wampSett) + self.PortText.SetValue(wampSett[0]) + self.RealmText.SetValue(wampSett[1]) + self.WAMPIDText.SetValue(wampSett[2]) + if self.IpText.Validate(): + typeForURI = self.type + "S" if self.SecureCheckbox.GetValue() else self.type + self.uri = typeForURI + "://" + self.IpText.GetValue() + ":" + self.PortText.GetValue() + "#" + self.RealmText.GetValue() + "#" + self.WAMPIDText.GetValue() + return WAMPConnectorPanel("WAMP", confnodesroot) --- a/connectors/__init__.py Thu May 10 08:33:50 2018 +0200
+++ b/connectors/__init__.py Thu May 17 09:33:58 2018 +0200
@@ -36,6 +36,12 @@
def _GetLocalConnectorClassFactory(name):
return lambda: getattr(__import__(name, globals(), locals()), name + "_connector_factory")
+def _GetLocalConnectorClassDialog(name): + return lambda: getattr(__import__(name + '.dialog', globals(), locals(), fromlist=['dialog']), name + "_connector_dialog") +def _GetLocalConnectorURITypes(name): + return lambda: getattr(__import__(name + '.dialog', globals(), locals(), fromlist=['dialog']), "URITypes", None) _GetLocalConnectorClassFactory(name)
@@ -43,6 +49,12 @@
if (path.isdir(path.join(_base_path, name)) and
not name.startswith("__"))}
+connectors_dialog = {name: + {"function":_GetLocalConnectorClassDialog(name), "URITypes": _GetLocalConnectorURITypes(name)} + for name in listdir(_base_path) + if (path.isdir(path.join(_base_path, name)) and + not name.startswith("__"))} def ConnectorFactory(uri, confnodesroot):
@@ -68,3 +80,20 @@
# import module according to uri type
connectorclass = connectors[servicetype]()
return connectorclass(uri, confnodesroot)
+def ConnectorDialog(conn_type, confnodesroot): + if conn_type not in connectors_dialog: + connectorclass = connectors_dialog[conn_type]["function"]() + return connectorclass(confnodesroot) +def GetConnectorFromURI(uri): + for conn_type in connectors_dialog: + connectorTypes = connectors_dialog[conn_type]["URITypes"]() + if connectorTypes and uri in connectorTypes: + typeOfConnector = conn_type --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/controls/UriLocationEditor.py Thu May 17 09:33:58 2018 +0200
@@ -0,0 +1,110 @@
+from zope.interface import Interface, Attribute +from zope.interface.verify import verifyObject +from connectors import connectors_dialog, ConnectorDialog, GetConnectorFromURI +[ID_URIWIZARDDIALOG,ID_URITYPECHOICE] = [wx.NewId() for _init_ctrls in range(2)] +class IConnectorPanel(Interface): + """This is interface for panel of seperate connector type""" + uri = Attribute("""uri of connections""") + type = Attribute("""type of connector""") + """methode for set uri""" + """metohde for get uri""" +class UriLocationEditor(wx.Dialog): + def _init_ctrls(self, parent): + wx.Dialog.__init__(self, id=ID_URIWIZARDDIALOG, + name='UriLocationEditor', parent=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.PanelSizer = 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,"URI type:"), 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.PanelSizer, border=5, flag=wx.ALL) + self.mainSizer.Add(self.ButtonSizer, border=5, flag=wx.BOTTOM|wx.ALIGN_CENTER_HORIZONTAL) + self.SetSizer(self.mainSizer) + def __init__(self, parent, uri): + self.URITYPES = ["- Select URI type -"] + for connector_type, connector_function in connectors_dialog.iteritems(): + connector_function['function']() + self.URITYPES.append(connector_type) + self.logger = self.parrent.CTR.logger + self._init_ctrls(parent) + def OnTypeChoice(self, event): + self._removePanelType() + index = event.GetSelection() + self.selected = event.GetString() + self.panelType = self._getConnectorDialog(self.selected) + self.PanelSizer.Add(self.panelType) + self.mainSizer.Layout() + self.panelType.Refresh() + self._removePanelType() + uri_list = uri.strip().split(":") + uri_type = uri_list[0].upper() + type = GetConnectorFromURI(uri_type) + self.UriTypeChoice.SetStringSelection(self.selected) + self.panelType = self._getConnectorDialog(self.selected) + self.panelType.SetURI(uri) + self.PanelSizer.Add(self.panelType) + self.PanelSizer.Layout() + self.mainSizer.Layout() + self.panelType.Refresh() + if not self.selected or not self.panelType: + return self.panelType.GetURI() + def _removePanelType(self): + for i in range(self.PanelSizer.GetItemCount()): + item = self.PanelSizer.GetItem(i) + self.PanelSizer.Remove(i) + self.PanelSizer.Layout() + def _getConnectorDialog(self, connectorType): + connector = ConnectorDialog(connectorType, self) + if connector and IConnectorPanel.providedBy(connector): + if verifyObject(IConnectorPanel, connector): --- a/editors/ConfTreeNodeEditor.py Thu May 10 08:33:50 2018 +0200
+++ b/editors/ConfTreeNodeEditor.py Thu May 17 09:33:58 2018 +0200
@@ -33,7 +33,7 @@
from IDEFrame import TITLE, FILEMENU, PROJECTTREE, PAGETITLES
-from controls import TextCtrlAutoComplete
+from controls import TextCtrlAutoComplete, UriLocationEditor from dialogs import BrowseValuesLibraryDialog
from util.BitmapLibrary import GetBitmap
@@ -338,6 +338,28 @@
msizer.AddWindow(button, flag=wx.ALIGN_CENTER)
+ def UriOptions(self, event): + CTR = self.ParentWindow.CTR + CTR_BeremizRoot = CTR.BeremizRoot + CTR_AppFrame = CTR.AppFrame + uri = CTR_BeremizRoot.getURI_location().strip() + dialog = UriLocationEditor.UriLocationEditor(CTR_AppFrame, uri) + if dialog.ShowModal() == wx.ID_OK: + CTR_BeremizRoot.setURI_location(dialog.GetURI()) + if CTR._View is not None: + CTR._View.RefreshView() + if CTR_AppFrame is not None: + CTR_AppFrame.RefreshTitle() + CTR_AppFrame.RefreshFileMenu() + CTR_AppFrame.RefreshEditMenu() + CTR_AppFrame.RefreshPageTitles() def GenerateSizerElements(self, sizer, elements, path, clean=True):
@@ -484,7 +506,21 @@
element_path=element_path,
- boxsizer.AddWindow(textctrl)
+ if element_infos["name"] == "URI_location": + uriSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0) + uriSizer.AddGrowableCol(0) + uriSizer.AddGrowableRow(0) + self.EditButton = wx.Button(self.ParamsEditor, label='...', size=wx.Size(30, -1)) + self.Bind(wx.EVT_BUTTON, self.UriOptions, self.EditButton) + uriSizer.AddWindow(textctrl, flag=wx.GROW) + uriSizer.AddWindow(self.EditButton, flag=wx.GROW) + boxsizer.AddWindow(uriSizer) + boxsizer.AddWindow(textctrl) if element_infos["value"] is not None:
textctrl.ChangeValue(str(element_infos["value"]))
callback = self.GetTextCtrlCallBackFunction(textctrl, element_path)