# HG changeset patch
# User laurent
# Date 1340878041 -7200
# Node ID 6f0e10085df92b9a45647bf41c6c65872cb99388
# Parent cdc6393705ce35f4c795518e2c6ed2754a83fb8d
Adding support for file explorer for project files
diff -r cdc6393705ce -r 6f0e10085df9 Beremiz.py
--- a/Beremiz.py Mon Jun 25 20:05:29 2012 +0200
+++ b/Beremiz.py Thu Jun 28 12:07:21 2012 +0200
@@ -562,7 +562,7 @@
ResourceEditor,
ConfigurationEditor,
DataTypeEditor))):
- return ("confnode", tab.Controler.CTNFullName())
+ return ("confnode", tab.Controler.CTNFullName(), tab.GetTagName())
elif (isinstance(tab, TextViewer) and
(tab.Controler is None or isinstance(tab.Controler, MiniTextControler))):
return ("confnode", None, tab.GetInstancePath())
@@ -941,6 +941,17 @@
else:
IDEFrame.OnProjectTreeItemActivated(self, event)
+ def ProjectTreeItemSelect(self, select_item):
+ name = self.ProjectTree.GetItemText(select_item)
+ item_infos = self.ProjectTree.GetPyData(select_item)
+ if item_infos["type"] == ITEM_CONFNODE:
+ item_infos["confnode"]._OpenView(onlyopened=True)
+ elif item_infos["type"] == ITEM_PROJECT:
+ self.CTR._OpenView(onlyopened=True)
+ else:
+ IDEFrame.ProjectTreeItemSelect(self, select_item)
+
+
def SelectProjectTreeItem(self, tagname):
if self.ProjectTree is not None:
root = self.ProjectTree.GetRootItem()
diff -r cdc6393705ce -r 6f0e10085df9 ConfigTreeNode.py
--- a/ConfigTreeNode.py Mon Jun 25 20:05:29 2012 +0200
+++ b/ConfigTreeNode.py Thu Jun 28 12:07:21 2012 +0200
@@ -405,15 +405,18 @@
self.BaseParams.setIEC_Channel(res)
return res
- def _OpenView(self, name=None):
+ def _OpenView(self, name=None, onlyopened=False):
if self.EditorType is not None:
+ app_frame = self.GetCTRoot().AppFrame
if self._View is None:
- app_frame = self.GetCTRoot().AppFrame
self._View = self.EditorType(app_frame.TabsOpened, self, app_frame)
app_frame.EditProjectElement(self._View, self.CTNName())
-
+
+ elif onlyopened:
+ app_frame.EditProjectElement(self._View, self.CTNName(), onlyopened)
+
return self._View
return None
diff -r cdc6393705ce -r 6f0e10085df9 ProjectController.py
--- a/ProjectController.py Mon Jun 25 20:05:29 2012 +0200
+++ b/ProjectController.py Thu Jun 28 12:07:21 2012 +0200
@@ -17,6 +17,7 @@
from util.misc import CheckPathPerm, GetClassImporter
from util.MiniTextControler import MiniTextControler
from util.ProcessLogger import ProcessLogger
+from util.FileManagementPanel import FileManagementPanel
from PLCControler import PLCControler
from TextViewer import TextViewer
from plcopen.structures import IEC_KEYWORDS
@@ -24,6 +25,7 @@
from util.discovery import DiscoveryDialog
from ConfigTreeNode import ConfigTreeNode
from ProjectNodeEditor import ProjectNodeEditor
+from utils.BitmapLibrary import GetBitmap
base_folder = os.path.split(sys.path[0])[0]
@@ -932,14 +934,18 @@
_IECRawCodeView = None
def _editIECrawcode(self):
self._OpenView("IEC raw code")
-
- def _OpenView(self, name=None):
+
+ _ProjectFilesView = None
+ def _OpenProjectFiles(self):
+ self._OpenView("Project files")
+
+ def _OpenView(self, name=None, onlyopened=False):
if name == "IEC code":
- if self._IEC_code_viewer is None:
+ if self._IECCodeView is None:
plc_file = self._getIECcodepath()
self._IECCodeView = TextViewer(self.AppFrame.TabsOpened, "", None, None, instancepath=name)
- #self._IECCodeViewr.Enable(False)
+ #self._IECCodeView.Enable(False)
self._IECCodeView.SetTextSyntax("ALL")
self._IECCodeView.SetKeywords(IEC_KEYWORDS)
try:
@@ -947,29 +953,46 @@
except:
text = '(* No IEC code have been generated at that time ! *)'
self._IECCodeView.SetText(text = text)
- self._IECCodeView.SetIcon(self.AppFrame.GenerateBitmap("ST"))
-
+ self._IECCodeView.SetIcon(GetBitmap("ST"))
+
self.AppFrame.EditProjectElement(self._IECCodeView, name)
-
+
+ elif onlyopened:
+ self.AppFrame.EditProjectElement(self._IECCodeView, name, onlyopened)
+
return self._IECCodeView
elif name == "IEC raw code":
- if self.IEC_raw_code_viewer is None:
+ if self._IECRawCodeView is None:
controler = MiniTextControler(self._getIECrawcodepath())
- self.IEC_raw_code_viewer = TextViewer(self.AppFrame.TabsOpened, "", None, controler, instancepath=name)
- #self.IEC_raw_code_viewer.Enable(False)
- self.IEC_raw_code_viewer.SetTextSyntax("ALL")
- self.IEC_raw_code_viewer.SetKeywords(IEC_KEYWORDS)
- self.IEC_raw_code_viewer.RefreshView()
- self.IEC_raw_code_viewer.SetIcon(self.AppFrame.GenerateBitmap("ST"))
+ self._IECRawCodeView = TextViewer(self.AppFrame.TabsOpened, "", None, controler, instancepath=name)
+ #self._IECRawCodeView.Enable(False)
+ self._IECRawCodeView.SetTextSyntax("ALL")
+ self._IECRawCodeView.SetKeywords(IEC_KEYWORDS)
+ self._IECRawCodeView.RefreshView()
+ self._IECRawCodeView.SetIcon(GetBitmap("ST"))
- self.AppFrame.EditProjectElement(self.IEC_raw_code_viewer, name)
-
- return self.IEC_raw_code_viewer
-
+ self.AppFrame.EditProjectElement(self._IECRawCodeView, name)
+
+ elif onlyopened:
+ self.AppFrame.EditProjectElement(self._IECRawCodeView, name, onlyopened)
+
+ return self._IECRawCodeView
+
+ elif name == "Project files":
+ if self._ProjectFilesView is None:
+ self._ProjectFilesView = FileManagementPanel(self.AppFrame.TabsOpened, self, name, self._getProjectFilesPath(), True)
+
+ self.AppFrame.EditProjectElement(self._ProjectFilesView, name)
+
+ elif onlyopened:
+ self.AppFrame.EditProjectElement(self._ProjectFilesView, name, onlyopened)
+
+ return self._ProjectFilesView
+
else:
- return ConfigTreeNode._OpenView(self, name)
+ return ConfigTreeNode._OpenView(self, name, onlyopened)
def OnCloseEditor(self, view):
ConfigTreeNode.OnCloseEditor(self, view)
@@ -977,6 +1000,8 @@
self._IECCodeView = None
if self._IECRawCodeView == view:
self._IECRawCodeView = None
+ if self._ProjectFilesView == view:
+ self._ProjectFilesView = None
def _Clean(self):
self._CloseView(self._IECCodeView)
@@ -1414,16 +1439,6 @@
wx.CallAfter(self.UpdateMethodsFromPLCStatus)
- def _ImportProjectFile(self):
- dialog = wx.FileDialog(self.AppFrame, _("Choose a file"), os.getcwd(), "", _("All files|*.*"), wx.OPEN)
- if dialog.ShowModal() == wx.ID_OK:
- filepath = dialog.GetPath()
- if os.path.isfile(filepath):
- shutil.copy(filepath, self._getProjectFilesPath())
- else:
- self.logger.write_error(_("No such file: %s\n") % filepath)
- dialog.Destroy()
-
StatusMethods = [
{"bitmap" : "Build",
"name" : _("Build"),
@@ -1470,10 +1485,10 @@
"name" : _("Raw IEC code"),
"tooltip" : _("Edit raw IEC code added to code generated by PLCGenerator"),
"method" : "_editIECrawcode"},
- {"bitmap" : "ImportFile",
- "name" : _("Import file"),
- "tooltip" : _("Import into project a file to be transfered with PLC"),
- "method" : "_ImportProjectFile"},
+ {"bitmap" : "ManageFolder",
+ "name" : _("Project Files"),
+ "tooltip" : _("Open a file explorer to manage project files"),
+ "method" : "_OpenProjectFiles"},
]
diff -r cdc6393705ce -r 6f0e10085df9 c_ext/CFileEditor.py
--- a/c_ext/CFileEditor.py Mon Jun 25 20:05:29 2012 +0200
+++ b/c_ext/CFileEditor.py Thu Jun 28 12:07:21 2012 +0200
@@ -4,10 +4,10 @@
import wx.grid
import wx.stc as stc
import wx.lib.buttons
-from util.misc import opjimg
from controls import CustomGrid, CustomTable
from ConfTreeNodeEditor import ConfTreeNodeEditor
+from utils.BitmapLibrary import GetBitmap
if wx.Platform == '__WXMSW__':
faces = { 'times': 'Times New Roman',
@@ -790,10 +790,10 @@
for idx, (name, panel_class) in enumerate(CFILE_PARTS):
button_id = wx.NewId()
button = FoldPanelCaption(id=button_id, name='FoldPanelCaption_%s' % name,
- label=name, bitmap=wx.Bitmap(opjimg("CollapsedIconData")),
+ label=name, bitmap=GetBitmap("CollapsedIconData"),
parent=self.ConfNodeEditor, pos=wx.Point(0, 0),
size=wx.Size(0, 20), style=wx.NO_BORDER|wx.ALIGN_LEFT)
- button.SetBitmapSelected(wx.Bitmap(opjimg("ExpandedIconData")))
+ button.SetBitmapSelected(GetBitmap("ExpandedIconData"))
button.Bind(wx.EVT_BUTTON, self.GenPanelButtonCallback(name), id=button_id)
self.MainSizer.AddWindow(button, 0, border=0, flag=wx.TOP|wx.GROW)
diff -r cdc6393705ce -r 6f0e10085df9 canfestival/canfestival.py
--- a/canfestival/canfestival.py Mon Jun 25 20:05:29 2012 +0200
+++ b/canfestival/canfestival.py Thu Jun 28 12:07:21 2012 +0200
@@ -255,8 +255,9 @@
def _ShowGeneratedMaster(self):
self._OpenView("Generated master")
- def _OpenView(self, name=None):
+ def _OpenView(self, name=None, onlyopened=False):
if name == "Generated master":
+ app_frame = self.GetCTRoot().AppFrame
if self._GeneratedMasterView is None:
buildpath = self._getBuildPath()
# Eventually create build dir
@@ -269,16 +270,17 @@
self.GetCTRoot().logger.write_error(_("Error: No Master generated\n"))
return
- app_frame = self.GetCTRoot().AppFrame
-
manager = MiniNodeManager(self, masterpath, self.CTNFullName() + ".generated_master")
self._GeneratedMasterView = MasterViewer(app_frame.TabsOpened, manager, app_frame)
app_frame.EditProjectElement(self._GeneratedMasterView, name)
+ elif onlyopened:
+ app_frame.EditProjectElement(self._IECCodeView, name, onlyopened)
+
return self._GeneratedMasterView
else:
- ConfigTreeNode._OpenView(self)
+ ConfigTreeNode._OpenView(self, name, onlyopened)
if self._View is not None:
self._View.SetBusId(self.GetCurrentLocation())
return self._View
diff -r cdc6393705ce -r 6f0e10085df9 images/FOLDER.png
Binary file images/FOLDER.png has changed
diff -r cdc6393705ce -r 6f0e10085df9 images/LeftCopy.png
Binary file images/LeftCopy.png has changed
diff -r cdc6393705ce -r 6f0e10085df9 images/ManageFolder.png
Binary file images/ManageFolder.png has changed
diff -r cdc6393705ce -r 6f0e10085df9 images/RightCopy.png
Binary file images/RightCopy.png has changed
diff -r cdc6393705ce -r 6f0e10085df9 images/icons.svg
--- a/images/icons.svg Mon Jun 25 20:05:29 2012 +0200
+++ b/images/icons.svg Thu Jun 28 12:07:21 2012 +0200
@@ -43,9 +43,9 @@
pagecolor="#ffffff"
id="base"
showgrid="false"
- inkscape:zoom="2.5600001"
- inkscape:cx="643.14253"
- inkscape:cy="778.71873"
+ inkscape:zoom="14.481548"
+ inkscape:cx="571.21601"
+ inkscape:cy="800.14078"
inkscape:window-x="0"
inkscape:window-y="24"
inkscape:current-layer="svg2"
@@ -85902,6 +85902,1777 @@
y1="198.01724"
x2="131.52188"
y2="41.586746" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
%% Build Clean editPLC HMIEditor ImportFile ImportDEF ImportSVG NetworkEdit ShowMaster ExportSlave Run ShowIECcode Stop Unknown %%
+ sodipodi:role="line">%% Build Clean editPLC HMIEditor ImportFile ManageFolder ImportDEF ImportSVG NetworkEdit ShowMaster ExportSlave Run ShowIECcode Stop Unknown %%
@@ -86290,7 +88061,7 @@
inkscape:connector-curvature="0" />
@@ -86567,7 +88338,7 @@
+ transform="translate(1922.9892,-430.1329)">
ST
@@ -86777,7 +88548,7 @@
id="g1161"
transform="matrix(0.5724346,-0.3079575,0.3079575,0.5724346,131.42904,887.47867)" />
%% Add Delete Disabled Enabled HideVars IECCDown IECCUp Maximize Minimize minus plus ShowVars %%
+ sodipodi:role="line">%% Add Delete Disabled Enabled HideVars IECCDown IECCUp Maximize Minimize minus plus ShowVars LeftCopy RightCopy%%
@@ -89490,7 +91261,7 @@
+ transform="translate(1727.0897,-400.03854)">
%% Extension Cfile Pyfile wxGlade SVGUI %%
+ sodipodi:role="line">%% Extension Cfile Pyfile wxGlade SVGUI FOLDER %%