- Timestamp:
- 06/15/08 11:43:22 (2 months ago)
- Files:
-
- branches/ed-ide/Studio.py (modified) (10 diffs)
- branches/ed-ide/components/CxnEditor/CxnEditor.py (modified) (25 diffs)
- branches/ed-ide/components/CxnEditor/__init__.py (modified) (1 diff)
- branches/ed-ide/components/TextEditor/__init__.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/ed-ide/Studio.py
r4081 r4138 11 11 import components 12 12 from components.ClassDesigner import ClassDesigner 13 from components.CxnEditor import CxnEditor 13 from components.CxnEditor import CxnEditorPage 14 14 from components.MenuDesigner import MenuDesigner 15 15 from components.ReportDesigner import ReportDesigner 16 16 from components.TextEditor import TextEditorPage 17 18 17 19 18 20 class ProjectTree(dabo.ui.dTreeView): … … 43 45 nd = self._context["node"] 44 46 pth = self._context["filepath"] 45 if pth.endswith(".py"): 46 self.controller.editFile(pth) 47 47 self.controller.editFile(pth) 48 48 49 49 50 class StudioToolBar(dabo.ui.dToolBar): … … 67 68 68 69 70 69 71 class StudioForm(dabo.ui.dDockForm): 70 72 def initProperties(self): … … 86 88 ShowCaption=False, ShowGripper=True, BottomDockable=False, 87 89 LeftDockable=False, RightDockable=False) 88 self.toolbar.Sizer = dabo.ui.dSizer("h") 90 self.toolbar.Sizer = dabo.ui.dSizer("h", DefaultSpacing=10) 91 # Automatically add child controls to the toolbar sizer 92 self.toolbar.bindEvent(dEvents.ChildBorn, self.onToolbarItemAdded) 89 93 cp = self.CenterPanel 90 94 csz = cp.Sizer = dabo.ui.dSizer("v") … … 93 97 self._toolSets = {None: []} 94 98 self._currentToolBar = None 95 self.pgfEditors = dabo.ui.dPageFrame(self.CenterPanel, PageCount=0) 99 dabo.ui.setAfter(self, "CurrentToolBar", None) 100 self.pgfEditors = dabo.ui.dDockTabs(self.CenterPanel, PageCount=0) 96 101 csz.append1x(self.pgfEditors) 97 102 … … 99 104 self.registerComponents() 100 105 self.registerPlugins() 106 107 self._currentProject = None 108 # See if there is a saved project 109 proj = self.PreferenceManager.lastOpenedProject 110 print "LAST", proj 111 if isinstance(proj, basestring) and os.path.exists(proj): 112 self.openProject(proj) 101 113 102 114 # Make sure that all components are visible 103 115 dabo.ui.callAfter(self._showAllPanels) 116 117 118 def onToolbarItemAdded(self, evt): 119 self.toolbar.Sizer.append(evt.child) 104 120 105 121 … … 116 132 try: 117 133 comp.register(self) 118 except AttributeError: 134 except AttributeError, e: 135 print "ERR", e 119 136 dabo.errorLog.write(_("Component '%s' lacks a 'register()' method.") % comp) 120 137 … … 129 146 130 147 def editFile(self, pth): 131 pg = self.pgfEditors.appendPage(TextEditorPage) 132 pg.openFile(pth) 133 self.pgfEditors.SelectedPage = pg 134 self.CurrentToolBar = "TextEditor" 148 if pth.endswith(".py"): 149 pg = self.pgfEditors.appendPage(TextEditorPage) 150 pg.openFile(pth) 151 self.pgfEditors.SelectedPage = pg 152 self.CurrentToolBar = "TextEditor" 153 elif pth.endswith(".cnxml"): 154 pg = self.pgfEditors.appendPage(CxnEditorPage) 155 pg.openFile(pth) 156 self.pgfEditors.SelectedPage = pg 157 self.CurrentToolBar = "CxnEditor" 135 158 136 159 137 160 def onOpenProject(self, evt): 138 self.openProject()139 140 141 def openProject(self):142 161 pjd = dabo.ui.getDirectory(_("Select Project Base")) 143 162 if pjd: 144 self.tree.makeDirTree(pjd, ignored=["*pyc", "*~"], expand=False) 145 self.tree.getRootNode().Expanded = True 163 self.openProject(pjd) 164 165 166 def openProject(self, proj): 167 self.Application._currentProject = proj 168 self.tree.makeDirTree(proj, ignored=["*pyc", "*~"], expand=False) 169 self.tree.getRootNode().Expanded = True 146 170 147 171 … … 155 179 if val not in self._toolSets: 156 180 dabo.errorLog.write(_("Invalid toolbar specified: '%s'") % val) 157 158 181 print self._toolSets.keys() 159 182 return 160 # Hide all visible buttons161 for btn in self.toolbar.Children[::-1]:162 self.toolbar.remove(btn, False)163 183 self._currentToolBar = val 164 # Show the new button set 165 for btn in self._toolSets[self._currentToolBar]: 166 try: 167 self.toolbar.appendItem(btn) 168 except AttributeError: 169 # A control, not a tool item 170 btn.Visible = True 184 sz = self.toolbar.Sizer 185 curr = self._toolSets[self._currentToolBar] 186 for itm in self.toolbar.Children: 187 itm.Visible = (itm in curr) 188 self.toolbar.layout() 171 189 else: 172 190 self._properties["CurrentToolBar"] = val … … 178 196 179 197 198 class StudioApp(dabo.dApp): 199 def afterFinish(self): 200 # Save the current project being edited. 201 pm = self.PreferenceManager 202 print "CURR", self._currentProject 203 if self._currentProject is None: 204 pm.removePref(lastOpenedProject) 205 else: 206 pm.lastOpenedProject = self._currentProject 207 208 180 209 def main(): 181 app = dabo.dApp()210 app = StudioApp() 182 211 app.BasePrefKey = "DeveloperStudio" 183 212 app.MainFormClass = StudioForm branches/ed-ide/components/CxnEditor/CxnEditor.py
r4061 r4138 16 16 17 17 18 class EditorForm(dui.dForm): 19 def afterSetMenuBar(self): 20 self.createMenu() 21 22 18 class CxnEditorPage(dui.dPage): 23 19 def afterInit(self): 24 20 self.newFileName = "Untitled" … … 30 26 "SQLite" : None } 31 27 connKeys = ["host", "dbtype", "port", "database", "user", "password"] 28 # Create the attributes 29 for key in connKeys: 30 setattr(self, key, "") 32 31 self.connDict = dict.fromkeys(connKeys) 33 32 self._origConnDict = dict.fromkeys(connKeys) … … 51 50 52 51 def createControls(self): 53 self.Caption = "Connection Editor"54 self.Size= (500, 800)55 self.bg = dui.dPanel(self, BackColor="LightSteelBlue")56 57 52 gbsz = dui.dGridSizer(VGap=12, HGap=5, MaxCols=2) 58 53 59 54 # Add the fields 55 self.dataFields = {} 60 56 # Connection Dropdown 61 cap = dui.dLabel(self.bg, Caption="Connection") 62 ctl = dui.dDropdownList(self.bg, Choices=[""], 63 RegID="connectionSelector") 64 ctl.bindEvent(dEvents.Hit, self.onConnectionChange) 65 btn = dui.dButton(self.bg, Caption="Edit Name", RegID="cxnEdit") 57 cap = dui.dLabel(self, Caption="Connection") 58 ctl = dui.dDropdownList(self, Choices=[""], OnHit=self.onConnectionChange) 59 self.dataFields["name"] = ctl 60 self.connectionSelector = ctl 61 ctl.controller = self 62 btn = dui.dButton(self, Caption="Edit Name", OnHit=self.onCxnEdit) 63 self.cxnEdit = btn 64 btn.controller = self 66 65 hsz = dui.dSizer("h") 67 66 hsz.append(ctl) … … 69 68 hsz.append(btn) 70 69 71 btn = dui.dButton(self.bg, Caption="Delete This Connection", RegID="cxnDelete", 72 DynamicEnabled=self.hasMultipleConnections) 70 btn = dui.dButton(self, Caption="Delete This Connection", 71 DynamicEnabled=self.hasMultipleConnections, 72 OnHit = self.onCxnDelete) 73 self.cxnDelete = btn 74 btn.controller = self 73 75 hsz.appendSpacer(10) 74 76 hsz.append(btn) … … 78 80 79 81 # Backend Type 80 cap = dui.dLabel(self.bg, Caption="Database Type") 81 ctl = dui.dDropdownList(self.bg, RegID="DbType", 82 Choices=["MySQL", "Firebird", "PostgreSQL", "MsSQL", "SQLite"], 83 DataSource="form", DataField="dbtype", 82 cap = dui.dLabel(self, Caption="Database Type") 83 ctl = dui.dDropdownList(self, Choices=["MySQL", "Firebird", "PostgreSQL", "MsSQL", "SQLite"], 84 84 OnHit=self.onDbTypeChanged) 85 self.dataFields["dbtype"] = ctl 86 self.DbType = ctl 87 ctl.controller = self 85 88 gbsz.append(cap, halign="right") 86 89 gbsz.append(ctl) … … 88 91 89 92 # Host 90 cap = dui.dLabel(self.bg, Caption="Host") 91 ctl = dui.dTextBox(self.bg, DataSource="form", DataField="host") 93 cap = dui.dLabel(self, Caption="Host") 94 ctl = dui.dTextBox(self) 95 self.dataFields["host"] = ctl 96 ctl.controller = self 92 97 gbsz.append(cap, halign="right") 93 98 gbsz.append(ctl, "expand") … … 95 100 96 101 # Port 97 cap = dui.dLabel(self.bg, Caption="Port") 98 ctl = dui.dTextBox(self.bg, DataSource="form", DataField="port") 102 cap = dui.dLabel(self, Caption="Port") 103 ctl = dui.dTextBox(self) 104 self.dataFields["port"] = ctl 105 ctl.controller = self 99 106 gbsz.append(cap, halign="right") 100 107 gbsz.append(ctl, "expand") … … 102 109 103 110 # Database 104 cap = dui.dLabel(self.bg, Caption="Database") 105 ctl = dui.dTextBox(self.bg, DataSource="form", DataField="database") 111 cap = dui.dLabel(self, Caption="Database") 112 ctl = dui.dTextBox(self) 113 self.dataFields["database"] = ctl 114 self.dbText = ctl 115 ctl.controller = self 106 116 hsz = dui.dSizer("h") 107 self.btnDbSelect = dui.dButton(self .bg, Caption=" ... ", RegID="btnDbSelect",108 Visible=False)117 self.btnDbSelect = dui.dButton(self, Caption=" ... ", Visible=False, OnHit=self.onDbSelect) 118 self.btnDbSelect.controller = self 109 119 hsz.append1x(ctl) 110 120 hsz.appendSpacer(2) … … 112 122 gbsz.append(cap, halign="right") 113 123 gbsz.append(hsz, "expand") 114 self.dbText = ctl115 124 116 125 # Username 117 cap = dui.dLabel(self.bg, Caption="User Name") 118 ctl = dui.dTextBox(self.bg, DataSource="form", DataField="user") 126 cap = dui.dLabel(self, Caption="User Name") 127 ctl = dui.dTextBox(self) 128 self.dataFields["user"] = ctl 129 self.userText = ctl 130 ctl.controller = self 119 131 gbsz.append(cap, halign="right") 120 132 gbsz.append(ctl, "expand") 121 self.userText = ctl122 133 123 134 # Password 124 cap = dui.dLabel(self.bg, Caption="Password") 125 ctl = dui.dTextBox(self.bg, PasswordEntry=True, 126 DataSource="form", DataField="password") 135 cap = dui.dLabel(self, Caption="Password") 136 ctl = dui.dTextBox(self, PasswordEntry=True) 137 self.dataFields["password"] = ctl 138 self.pwText = ctl 139 ctl.controller = self 127 140 gbsz.append(cap, halign="right") 128 141 gbsz.append(ctl, "expand") 129 self.pwText = ctl 130 131 # Open Button 142 132 143 btnSizer1 = dui.dSizer("h") 133 144 btnSizer2 = dui.dSizer("h") 134 btnTest = dui.dButton(self.bg, RegID="btnTest", Caption="Test...") 135 btnSave = dui.dButton(self.bg, RegID="btnSave", Caption="Save") 136 btnNewConn = dui.dButton(self.bg, RegID="btnNewConn", 137 Caption="New Connection") 138 btnNewFile = dui.dButton(self.bg, RegID="btnNewFile", 139 Caption="New File") 140 btnOpen = dui.dButton(self.bg, RegID="btnOpen", 141 Caption="Open File...") 142 btnSizer1.append(btnTest, 0, border=3) 143 btnSizer1.append(btnSave, 0, border=3) 144 btnSizer2.append(btnNewConn, 0, border=3) 145 btnSizer2.append(btnNewFile, 0, border=3) 146 btnSizer2.append(btnOpen, 0, border=3) 145 self.btnTest = dui.dButton(self, Caption="Test...", OnHit=self.onTest) 146 self.btnSave = dui.dButton(self, Caption="Save", OnHit=self.onSave) 147 self.btnNewConn = dui.dButton(self, Caption="New Connection", OnHit=self.onNewConn) 148 self.btnNewFile = dui.dButton(self, Caption="New File", OnHit=self.onNewFile) 149 self.btnOpen = dui.dButton(self, Caption="Open File...", OnHit=self.onOpenFile) 150 self.btnTest.controller = self.btnSave.controller = self.btnNewConn.controller = \ 151 self.btnNewFile.controller = self.btnOpen.controller = self 152 btnSizer1.append(self.btnTest, 0, border=3) 153 btnSizer1.append(self.btnSave, 0, border=3) 154 btnSizer2.append(self.btnNewConn, 0, border=3) 155 btnSizer2.append(self.btnNewFile, 0, border=3) 156 btnSizer2.append(self.btnOpen, 0, border=3) 147 157 148 158 gbsz.setColExpand(True, 1) 149 159 self.gridSizer = gbsz 150 160 151 self.bg.Sizer = dui.dSizer("v") 152 self.bg.Sizer.append(gbsz, 0, "expand", halign="center", border=20) 153 self.bg.Sizer.append(btnSizer1, 0, halign="center") 154 self.bg.Sizer.append(btnSizer2, 0, halign="center") 155 self.Sizer = dui.dSizer("h") 156 self.Sizer.append(self.bg, 1, "expand", halign="center") 157 self.Layout() 161 self.Sizer = dui.dSizer("v") 162 self.Sizer.append(gbsz, 0, "expand", halign="center", border=20) 163 self.Sizer.append(btnSizer1, 0, halign="center") 164 self.Sizer.append(btnSizer2, 0, halign="center") 165 self.layout() 158 166 159 167 … … 162 170 163 171 164 def on Hit_cxnDelete(self, evt):172 def onCxnDelete(self, evt): 165 173 if not dabo.ui.areYouSure(_("Delete this connection?"), 166 174 title=_("Confirm Deletion"), cancelButton=False): … … 178 186 179 187 180 def on Hit_cxnEdit(self, evt):188 def onCxnEdit(self, evt): 181 189 chc = self.connectionSelector.Choices 182 190 idx = self.connectionSelector.PositionValue … … 198 206 199 207 200 def on Hit_btnTest(self, evt):208 def onTest(self, evt): 201 209 self.testConnection() 202 210 203 211 204 def on Hit_btnOpen(self, evt):212 def onOpenFile(self, evt): 205 213 # Update the values 206 214 self.updtFromForm() … … 209 217 210 218 211 def on Hit_btnNewFile(self, evt):219 def onNewFile(self, evt): 212 220 # Update the values 213 221 self.updtFromForm() … … 218 226 219 227 220 def on Hit_btnNewConn(self, evt):228 def onNewConn(self, evt): 221 229 # Update the values 222 230 self.updtFromForm() … … 225 233 226 234 227 def on Hit_btnSave(self, evt):235 def onSave(self, evt): 228 236 self.saveFile() 229 237 … … 255 263 256 264 257 def on Hit_btnDbSelect(self, evt):265 def onDbSelect(self, evt): 258 266 dbFile = dui.getFile() 259 267 if dbFile: … … 262 270 263 271 264 def onHit_connectionSelector(self, evt):265 self.currentConn = self.connectionSelector.StringValue266 self.updtToForm()267 self.enableControls()268 self.update()269 270 271 272 def testConnection(self): 272 273 # Update the values … … 293 294 the connection dictionary with them. 294 295 """ 296 print "UPDT form FORM" 295 297 # Make sure that changes to the current control are used. 296 self. activeControlValid()298 self.Form.activeControlValid() 297 299 if self.currentConn is not None: 298 300 dd = self.connDict[self.currentConn] 299 301 for fld in dd.keys(): 300 val = eval("self.%s" % fld)302 val = self.dataFields[fld].Value 301 303 if fld == "password": 302 304 origVal = self.crypt.decrypt(dd[fld]) … … 315 317 dictionary. 316 318 """ 319 print "UPDT TO FORM" 317 320 if self.currentConn is not None: 318 321 dd = self.connDict[self.currentConn] … … 323 326 else: 324 327 val = dd[fld] 325 if isinstance(val, basestring): 326 val = self.escQuote(val) # Add quotes 327 exec("self.%s = %s" % (fld, val) ) 328 self.dataFields[fld].Value = val 328 329 329 330 … … 339 340 self.connDict = {} 340 341 # Set the form caption 341 self.Caption = "Dabo Connection Editor: %s" %os.path.basename(self.connFile)342 self.Caption = os.path.basename(self.connFile) 342 343 # Add a new blank connection 343 344 self.newConnection() … … 398 399 def populate(self): 399 400 self.updtToForm() 400 self.update()401 # self.update() 401 402 conn = self.currentConn 402 403 self.connectionSelector.Value = conn … … 404 405 405 406 def openFile(self, connFile=None): 406 self. activeControlValid()407 self.Form.activeControlValid() 407 408 # See if the user wants to save changes (if any) 408 409 if not self.confirmChanges(): … … 433 434 self.currentConn = self.connDict.keys()[0] 434 435 # Set the form caption 435 self.Caption = _("Dabo Connection Editor: %s") %os.path.basename(self.connFile)436 self.Caption = os.path.basename(self.connFile) 436 437 # Fill the controls 437 438 self.populate() … … 443 444 444 445 def confirmChanges(self): 445 self. activeControlValid()446 self.Form.activeControlValid() 446 447 self.updtFromForm() 447 448 if self._origConnDict != self.connDict: branches/ed-ide/components/CxnEditor/__init__.py
r4063 r4138 2 2 # -*- coding: utf-8 -*- 3 3 4 from CxnEditor import EditorForm 4 import dabo 5 import dabo.dEvents as dEvents 6 from dabo.dLocalize import _ 7 import CxnEditor 8 from CxnEditor import CxnEditorPage 9 10 11 masterForm = None 12 13 def register(master): 14 global masterForm 15 masterForm = master 16 tb = master.toolbar 17 18 dummyBtn = dabo.ui.dBitmapButton(tb, Picture="open", AutoSize=False, 19 OnMouseLeftDown=onDummy) 20 21 master.setToolBarGroup("CxnEditor", [dummyBtn]) 22 23 24 def onDummy(self, evt): 25 print "DUMMY BUTTON" 26 branches/ed-ide/components/TextEditor/__init__.py
r4081 r4138 15 15 tb = master.toolbar 16 16 17 funcBtn = tb.appendButton(_("Functions"), 18 dabo.ui.bitmapFromData(TextEditor.funcButtonData()), 19 toggle=False, 17 funcBtn = dabo.ui.dBitmapButton(tb, 18 Picture=dabo.ui.bitmapFromData(TextEditor.funcButtonData()), 20 19 OnMouseLeftDown=onFuncButton) 21 bmkBtn = tb.appendButton(_("Bookmarks"), 22 dabo.ui.bitmapFromData(TextEditor.bmkButtonData()), 23 toggle=False, 20 bmkBtn = dabo.ui.dBitmapButton(tb, 21 Picture=dabo.ui.bitmapFromData(TextEditor.bmkButtonData()), 24 22 OnMouseLeftDown=onBmkButton) 25 printBtn = tb.appendButton(_("Print"), 26 "print", 27 toggle=False, 28 OnHit=onPrint) 23 printBtn = dabo.ui.dBitmapButton(tb, Picture="print", OnHit=onPrint) 29 24 lexSelector = dabo.ui.dDropdownList(tb, ValueMode="String", 30 Choices = dabo.ui.dEditor.getAvailableLanguages(), 31 OnHit = onLexSelect) 32 tb.appendControl(lexSelector) 25 Choices=dabo.ui.dEditor.getAvailableLanguages(), OnHit=onLexSelect) 33 26 34 27 master.setToolBarGroup("TextEditor", [funcBtn, bmkBtn, printBtn, lexSelector]) … … 44 37 masterForm.Caption = evt.EventObject.Value 45 38 46 def updateLex(self):47 if not self.lexSelector.Choices:48 self.lexSelector.Choices = self.CurrentEditor.getAvailableLanguages()39 def updateLex(self): 40 if not self.lexSelector.Choices: 41 self.lexSelector.Choices = self.CurrentEditor.getAvailableLanguages()
