예제 #1
0
    def update_file_tree(self):
        #TODO sort files
        if not self.project:
            return

        additions, deletions = self.file_tree.get_tree_changes()

        #self.Freeze()
        self.files[self.project.directory] = self.files_item

        # Remove any file/folder items that no longer exist
        for deleted_file in deletions:
            item = self.files[deleted_file]
            self.Delete(item)
            del self.files[deleted_file]
                
        cmp_alpha = lambda x : x
        cmp_ext = lambda x :  os.path.splitext(x)[1]
        
       # methods = {SORT_ALPHA : cmp_alpha, SORT_EXTENSION : cmp_ext}
        # Add any file/folder items that aren't currently in the tree
        for root, dirs, files in self.file_tree.walk(self.project.directory):
            if root not in self.files:
                parent, d = os.path.split(root)
                if d.startswith("."):
                    self.add_file(root, 'folder_wrench.png')
                else:
                    self.add_file(root, 'folder.png')
            #print self.files

            for d in dirs:
                d = os.path.join(root, d)
                if d not in self.files:
                    if d.startswith("."):
                        item = self.add_file(d, 'folder_wrench.png')
                    else:
                        item = self.add_file(d, 'folder.png')
                    self.SetItemHasChildren(item, True)
            
            
            for file in files:
                file = os.path.join(root, file)
                if file not in self.files:
                    if not self.backups_visible and file.endswith("~"):
                        continue
                    self.add_file(os.path.join(root, file), util.get_file_icon(file))
        #self.Thaw()
        self.Refresh()
예제 #2
0
    def update_file_tree(self):
        #TODO sort files
        if not self.project:
            return

        additions, deletions = self.file_tree.get_tree_changes()

        #self.Freeze()
        self.files[self.project.directory] = self.files_item

        # Remove any file/folder items that no longer exist
        for deleted_file in deletions:
            item = self.files[deleted_file]
            self.Delete(item)
            del self.files[deleted_file]

        cmp_alpha = lambda x: x
        cmp_ext = lambda x: os.path.splitext(x)[1]

        # methods = {SORT_ALPHA : cmp_alpha, SORT_EXTENSION : cmp_ext}
        # Add any file/folder items that aren't currently in the tree
        for root, dirs, files in self.file_tree.walk(self.project.directory):
            if root not in self.files:
                parent, d = os.path.split(root)
                if d.startswith("."):
                    self.add_file(root, 'folder_wrench.png')
                else:
                    self.add_file(root, 'folder.png')
            #print self.files

            for d in dirs:
                d = os.path.join(root, d)
                if d not in self.files:
                    if d.startswith("."):
                        item = self.add_file(d, 'folder_wrench.png')
                    else:
                        item = self.add_file(d, 'folder.png')
                    self.SetItemHasChildren(item, True)

            for file in files:
                file = os.path.join(root, file)
                if file not in self.files:
                    if not self.backups_visible and file.endswith("~"):
                        continue
                    self.add_file(os.path.join(root, file),
                                  util.get_file_icon(file))
        #self.Thaw()
        self.Refresh()
예제 #3
0
    def create_file_tab(self, path=None):
        if path:
            if self.controller.project:
                path = self.controller.project.absolute_path(path)
            window = self.get_file_tab(path)

            if window:
                window.SetFocus()
                self.controller.frame.statusbar.line = window.current_line(
                ) + 1
                return window
#            else:
#                print "No window for file %s" % repr(path)

            if not os.path.isfile(path):
                return None

        #self.Freeze()
        panel = wx.Panel(self)
        edit_widget = EditorControl(panel,
                                    -1,
                                    style=wx.BORDER_NONE,
                                    controller=self.controller)
        quick_find_bar = QuickFindBar(panel, edit_widget)
        panel.editor = edit_widget
        panel.find_bar = quick_find_bar
        quick_find_bar.hide()

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(edit_widget, 1, wx.EXPAND)
        sizer.Add(quick_find_bar, 0)
        panel.SetSizer(sizer)
        if path:
            edit_widget.open_file(path)

        self.AddPage(panel, edit_widget.name, True)
        idx = self.GetPageIndex(panel)
        if idx >= 0:
            self.SetPageBitmap(idx, util.get_icon(util.get_file_icon(path)))

        edit_widget.SetFocus()
        self.controller.frame.statusbar.line = edit_widget.current_line() + 1
        #edit_widget.Bind(stc.EVT_STC_MODIFIED, self.on_modified)
        self.bind_tab_events()
        self.check_tabs()
        #self.Thaw()
        return edit_widget
예제 #4
0
    def create_file_tab(self, path=None):
        if path:
            if self.controller.project:
                path = self.controller.project.absolute_path(path)
            window = self.get_file_tab(path)

            if window:
                window.SetFocus()
                self.controller.frame.statusbar.line = window.current_line()+1
                return window
#            else:
#                print "No window for file %s" % repr(path)
                
            if not os.path.isfile(path): 
                return None
        
        #self.Freeze()
        panel = wx.Panel(self)
        edit_widget = EditorControl(panel, -1, style=wx.BORDER_NONE, controller=self.controller)
        quick_find_bar = QuickFindBar(panel, edit_widget)
        panel.editor = edit_widget
        panel.find_bar = quick_find_bar
        quick_find_bar.hide()
        
        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(edit_widget, 1, wx.EXPAND)
        sizer.Add(quick_find_bar, 0)
        panel.SetSizer(sizer)
        if path:
            edit_widget.open_file(path)
        
        self.AddPage(panel, edit_widget.name, True)
        idx = self.GetPageIndex(panel)
        if idx >= 0:
            self.SetPageBitmap(idx, util.get_icon(util.get_file_icon(path)))


        edit_widget.SetFocus()
        self.controller.frame.statusbar.line = edit_widget.current_line()+1
        #edit_widget.Bind(stc.EVT_STC_MODIFIED, self.on_modified)
        self.bind_tab_events()
        self.check_tabs()
        #self.Thaw()
        return edit_widget