Changeset 4074

Show
Ignore:
Timestamp:
05/05/08 14:34:28 (3 months ago)
Author:
ed
Message:

Incremental commit

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/ed-ide/Studio.py

    r4063 r4074  
    1313from components.MenuDesigner import MenuDesigner 
    1414from components.ReportDesigner import ReportDesigner 
    15 from components.TextEditor import TextEditor 
     15from components.TextEditor import TextEditorPage 
    1616 
    17 class StudioForm(dabo.ui.dForm): 
     17class ProjectTree(dabo.ui.dTreeView): 
     18    def beforeInit(self): 
     19        self.controller = None 
     20 
     21    def onContextMenu(self, evt): 
     22        nd = self.getNodeUnderMouse() 
     23        if not nd: 
     24            return 
     25        # Full path is in the ToolTipText 
     26        pth = nd.ToolTipText 
     27        if os.path.isfile(pth): 
     28            self._context = dict(node=nd, filepath=pth) 
     29            pop = self.createContextMenu(pth) 
     30            self.showContextMenu(pop) 
     31 
     32 
     33    def createContextMenu(self, pth): 
     34        pop = dabo.ui.dMenu() 
     35        pop.append(_("Edit"), OnHit=self.onEditFile) 
     36        return pop 
     37 
     38 
     39    def onEditFile(self, evt): 
     40        if not self._context: 
     41            print "WASSIP with dat?" 
     42            return 
     43        nd = self._context["node"] 
     44        pth = self._context["filepath"] 
     45        if pth.endswith(".py"): 
     46            self.controller.editFile(pth)            
     47 
     48 
     49 
     50class StudioForm(dabo.ui.dSplitForm): 
    1851    def initProperties(self): 
    1952        self.Caption = _("Dabo Developer Studio") 
     53        self.Orientation = "h" 
    2054 
    21 #   def afterInit(self):     
    22 #       self.tree = dabo.ui.dTreeView(self.Panel1) 
    23 #       self.tree.makeDirTree("/Users/ed/apps/billing", ignored="*pyc", expand=True) 
     55 
     56    def afterInit(self): 
     57        dabo.ui.setAfter(self.Splitter, "SashPercent", 30) 
     58        pnl1 = self.Panel1 
     59        pnl1.Sizer.Orientation = "v" 
     60        btn = dabo.ui.dButton(pnl1, Caption="Open Project", OnHit=self.onOpenProject) 
     61        pnl1.Sizer.append(btn, halign="center", border=30) 
     62        self.tree = ProjectTree(pnl1) 
     63        self.tree.controller = self 
     64        pnl1.Sizer.append1x(self.tree) 
     65        pnl2 = self.Panel2 
     66        self.pgfEditors = dabo.ui.dPageFrame(pnl2, PageCount=0) 
     67        pnl2.Sizer.append1x(self.pgfEditors) 
     68 
     69 
     70    def editFile(self, pth): 
     71        pg = self.pgfEditors.appendPage(TextEditorPage) 
     72        pg.openFile(pth) 
     73        self.pgfEditors.SelectedPage = pg 
     74 
     75 
     76    def onOpenProject(self, evt): 
     77        self.openProject() 
     78 
     79 
     80    def openProject(self): 
     81        pjd = dabo.ui.getDirectory(_("Select Project Base")) 
     82        if pjd: 
     83            self.tree.makeDirTree(pjd, ignored=["*pyc", "*~"], expand=False) 
     84            self.tree.getRootNode().Expanded = True 
    2485 
    2586