]> git.saurik.com Git - wxWidgets.git/blobdiff - wxPython/samples/ide/activegrid/tool/ProjectEditor.py
Applied patch [ 1212020 ] MediaCtrl DirectShow drawing and sample
[wxWidgets.git] / wxPython / samples / ide / activegrid / tool / ProjectEditor.py
index cb407d83187dd2d7de4cec6fbe4bd405a013dd53..56331050ec72ea0d4e9bb4db22bff32edb57a2f7 100644 (file)
@@ -23,9 +23,11 @@ import sys
 import activegrid.util.xmlmarshaller
 import UICommon
 import Wizard
+import SVNService
 from IDE import ACTIVEGRID_BASE_IDE
 if not ACTIVEGRID_BASE_IDE:
     import ProcessModelEditor
+from SVNService import SVN_INSTALLED
 
 _ = wx.GetTranslation
 
@@ -127,6 +129,8 @@ class ProjectDocument(wx.lib.docview.Document):
         for path in paths:
             if path.startswith(curPath):
                 path = "." + path[curPathLen:]  # use relative path
+                if os.sep != '/':
+                    path = path.replace(os.sep, '/', -1)  # always save out with '/' as path separator for cross-platform compatibility.
             else:
                 pass                            # use absolute path
             newFilePaths.append(path)
@@ -909,7 +913,16 @@ class ProjectView(wx.lib.docview.View):
     def GetSelectedFile(self):
         for item in self._treeCtrl.GetSelections():
             return self._GetItemFile(item)
+
             
+    def GetSelectedFiles(self):
+        filenames = []
+        for item in self._treeCtrl.GetSelections():
+            filename = self._GetItemFile(item)
+            if filename and filename not in filenames:
+                filenames.append(filename)
+        return filenames
+
 
     def AddProjectToView(self, document):
         rootItem = self._treeCtrl.GetRootItem()
@@ -927,6 +940,17 @@ class ProjectView(wx.lib.docview.View):
             document.GetCommandProcessor().SetEditMenu(wx.GetApp().GetEditMenu(self._GetParentFrame()))
 
 
+    def HasFocus(self):
+        winWithFocus = wx.Window.FindFocus()
+        if not winWithFocus:
+            return False
+        while winWithFocus:
+            if winWithFocus == self._treeCtrl:
+                return True
+            winWithFocus = winWithFocus.GetParent()
+        return False
+
+
     #----------------------------------------------------------------------------
     # Control events
     #----------------------------------------------------------------------------
@@ -980,19 +1004,19 @@ class ProjectView(wx.lib.docview.View):
 
 
     def OnAddDirToProject(self, event):
-        frame = wx.Dialog(None, -1, _("Add All Files from Directory to Project"), size= (320,200))
-        borderSizer = wx.BoxSizer(wx.HORIZONTAL)
-
+        frame = wx.Dialog(None, -1, _("Add Directory Files to Project"), size= (320,200))
         contentSizer = wx.BoxSizer(wx.VERTICAL)
+        
+        flexGridSizer = wx.FlexGridSizer(cols = 2, vgap=HALF_SPACE, hgap=HALF_SPACE)
+        flexGridSizer.Add(wx.StaticText(frame, -1, _("Directory:")), 0, wx.ALIGN_CENTER_VERTICAL, 0)
         lineSizer = wx.BoxSizer(wx.HORIZONTAL)
-        lineSizer.Add(wx.StaticText(frame, -1, _("Directory:")), 0, wx.ALIGN_CENTER | wx.RIGHT, HALF_SPACE)
-        dirCtrl = wx.TextCtrl(frame, -1, os.path.dirname(self.GetDocument().GetFilename()), size=(200,-1))
+        dirCtrl = wx.TextCtrl(frame, -1, os.path.dirname(self.GetDocument().GetFilename()), size=(250,-1))
         dirCtrl.SetToolTipString(dirCtrl.GetValue())
-        lineSizer.Add(dirCtrl, 0, wx.LEFT, HALF_SPACE)
-        findDirButton = wx.Button(frame, -1, "Browse...")
-        lineSizer.Add(findDirButton, 0, wx.LEFT, HALF_SPACE)
-        contentSizer.Add(lineSizer, 0, wx.BOTTOM, SPACE)
-        
+        lineSizer.Add(dirCtrl, 1, wx.ALIGN_CENTER_VERTICAL|wx.EXPAND)
+        findDirButton = wx.Button(frame, -1, _("Browse..."))
+        lineSizer.Add(findDirButton, 0, wx.LEFT|wx.ALIGN_CENTER_VERTICAL, HALF_SPACE)
+        flexGridSizer.Add(lineSizer, 1, wx.EXPAND)
+                
         def OnBrowseButton(event):
             dlg = wx.DirDialog(frame, _("Choose a directory:"), style=wx.DD_DEFAULT_STYLE)
             dir = dirCtrl.GetValue()
@@ -1022,28 +1046,26 @@ class ProjectView(wx.lib.docview.View):
             choices.append(descr)
             allfilter = allfilter + template.GetFileFilter()
         choices.insert(0, _("All (%s)") % allfilter)
-        filterChoice = wx.Choice(frame, -1, size=(210, -1), choices=choices)
+        filterChoice = wx.Choice(frame, -1, size=(250, -1), choices=choices)
         filterChoice.SetSelection(0)
         filterChoice.SetToolTipString(_("Select file type filter."))
-        lineSizer = wx.BoxSizer(wx.HORIZONTAL)
-        lineSizer.Add(wx.StaticText(frame, -1, _("Files of type:")), 0, wx.ALIGN_CENTER | wx.RIGHT, HALF_SPACE)
-        lineSizer.Add(filterChoice, 1, wx.LEFT, HALF_SPACE)
-        contentSizer.Add(lineSizer, 0, wx.BOTTOM|wx.EXPAND, SPACE)
+        flexGridSizer.Add(wx.StaticText(frame, -1, _("Files of type:")), 0, wx.ALIGN_CENTER_VERTICAL)
+        flexGridSizer.Add(filterChoice, 1, wx.EXPAND)
+        
+        contentSizer.Add(flexGridSizer, 0, wx.ALL|wx.EXPAND, SPACE)
         
         subfolderCtrl = wx.CheckBox(frame, -1, _("Add files from subdirectories"))
         subfolderCtrl.SetValue(True)
-        contentSizer.Add(subfolderCtrl, 0, wx.BOTTOM, SPACE)
-
-        borderSizer.Add(contentSizer, 0, wx.TOP|wx.BOTTOM|wx.LEFT, SPACE)
+        contentSizer.Add(subfolderCtrl, 0, wx.LEFT|wx.ALIGN_CENTER_VERTICAL, SPACE)
 
-        buttonSizer = wx.BoxSizer(wx.VERTICAL)
+        buttonSizer = wx.BoxSizer(wx.HORIZONTAL)
         findBtn = wx.Button(frame, wx.ID_OK, _("Add"))
         findBtn.SetDefault()
-        buttonSizer.Add(findBtn, 0, wx.BOTTOM, HALF_SPACE)
+        buttonSizer.Add(findBtn, 0, wx.RIGHT, HALF_SPACE)
         buttonSizer.Add(wx.Button(frame, wx.ID_CANCEL), 0)
-        borderSizer.Add(buttonSizer, 0, wx.ALL, SPACE)
+        contentSizer.Add(buttonSizer, 0, wx.ALL|wx.ALIGN_RIGHT, SPACE)
 
-        frame.SetSizer(borderSizer)
+        frame.SetSizer(contentSizer)
         frame.Fit()
 
         status = frame.ShowModal()
@@ -1180,7 +1202,10 @@ class ProjectView(wx.lib.docview.View):
         else:  # Project context
             itemIDs = [wx.ID_CLOSE, wx.ID_SAVE, wx.ID_SAVEAS, None]
         menuBar = self._GetParentFrame().GetMenuBar()
-        itemIDs = itemIDs + [ProjectService.ADD_FILES_TO_PROJECT_ID, ProjectService.ADD_ALL_FILES_TO_PROJECT_ID, ProjectService.REMOVE_FROM_PROJECT, None, wx.ID_UNDO, wx.ID_REDO, None, wx.ID_CUT, wx.ID_COPY, wx.ID_PASTE, wx.ID_CLEAR, None, wx.ID_SELECTALL, ProjectService.RENAME_ID, ProjectService.DELETE_FILE_ID, None, wx.lib.pydocview.FilePropertiesService.PROPERTIES_ID]
+        itemIDs = itemIDs + [ProjectService.ADD_FILES_TO_PROJECT_ID, ProjectService.ADD_ALL_FILES_TO_PROJECT_ID, ProjectService.REMOVE_FROM_PROJECT]
+        if SVN_INSTALLED:
+            itemIDs = itemIDs + [None, SVNService.SVNService.SVN_UPDATE_ID, SVNService.SVNService.SVN_CHECKIN_ID, SVNService.SVNService.SVN_REVERT_ID]
+        itemIDs = itemIDs + [None, wx.ID_UNDO, wx.ID_REDO, None, wx.ID_CUT, wx.ID_COPY, wx.ID_PASTE, wx.ID_CLEAR, None, wx.ID_SELECTALL, ProjectService.RENAME_ID, ProjectService.DELETE_FILE_ID, None, wx.lib.pydocview.FilePropertiesService.PROPERTIES_ID]
         for itemID in itemIDs:
             if not itemID:
                 menu.AppendSeparator()
@@ -1386,8 +1411,9 @@ class ProjectView(wx.lib.docview.View):
                         findFile.Destroy()
                         if newpath:
                             # update Project Model with new location
-                            self.GetDocument().RemoveFile(filepath)
-                            self.GetDocument().AddFile(newpath)
+                            project = self._GetItemProject(item)
+                            project.RemoveFile(filepath)
+                            project.AddFile(newpath)
                             filepath = newpath
 
                     doc = self.GetDocumentManager().CreateDocument(filepath, wx.lib.docview.DOC_SILENT)
@@ -1497,7 +1523,7 @@ class ProjectView(wx.lib.docview.View):
                 else:
                     if self._treeCtrl.GetLongFilename(child) == longFileName:
                         return child
-                (child, cookie2) = self._treeCtrl.GetNextChild(project, cookie)
+                (child, cookie2) = self._treeCtrl.GetNextChild(project, cookie2)
             (project, cookie) = self._treeCtrl.GetNextChild(rootItem, cookie)
         return None
 
@@ -1616,9 +1642,8 @@ class ProjectPropertiesDialog(wx.Dialog):
         sizer.Add(notebook, 0, wx.ALL | wx.EXPAND, SPACE)
         sizer.Add(self.CreateButtonSizer(wx.OK), 0, wx.ALIGN_RIGHT | wx.RIGHT | wx.BOTTOM, HALF_SPACE)
 
-        sizer.Fit(self)
-        self.SetDimensions(-1, -1, 310, -1, wx.SIZE_USE_EXISTING)
         self.SetSizer(sizer)
+        sizer.Fit(self)
         self.Layout()
 
 
@@ -1744,7 +1769,7 @@ class ProjectService(Service.Service):
                 wx.EVT_MENU(frame, ProjectService.ADD_FILES_TO_PROJECT_ID, frame.ProcessEvent)
                 wx.EVT_UPDATE_UI(frame, ProjectService.ADD_FILES_TO_PROJECT_ID, frame.ProcessUpdateUIEvent)
             if not menuBar.FindItemById(ProjectService.ADD_ALL_FILES_TO_PROJECT_ID):
-                projectMenu.Append(ProjectService.ADD_ALL_FILES_TO_PROJECT_ID, _("Add All Files to Project..."), _("Adds a directory's documents to the current project"))
+                projectMenu.Append(ProjectService.ADD_ALL_FILES_TO_PROJECT_ID, _("Add Directory Files to Project..."), _("Adds a directory's documents to the current project"))
                 wx.EVT_MENU(frame, ProjectService.ADD_ALL_FILES_TO_PROJECT_ID, frame.ProcessEvent)
                 wx.EVT_UPDATE_UI(frame, ProjectService.ADD_ALL_FILES_TO_PROJECT_ID, frame.ProcessUpdateUIEvent)
             if not menuBar.FindItemById(ProjectService.ADD_CURRENT_FILE_TO_PROJECT_ID):