dabo Commit
Revision 4138
Date: 2008-06-15 11:43:22 -0700 (Sun, 15 Jun 2008)
Author: Ed
Trac: http://svn.dabodev.com/trac/dabo/changeset/4138
Changed:
U branches/ed-ide/Studio.py
U branches/ed-ide/components/CxnEditor/CxnEditor.py
U branches/ed-ide/components/CxnEditor/__init__.py
U branches/ed-ide/components/TextEditor/__init__.py
Log:
Improved some of the basic functionality. Added support for editing .cnxml
files.
Diff:
Modified: branches/ed-ide/Studio.py
===================================================================
--- branches/ed-ide/Studio.py 2008-06-14 20:10:03 UTC (rev 4137)
+++ branches/ed-ide/Studio.py 2008-06-15 18:43:22 UTC (rev 4138)
@@ -10,11 +10,13 @@
import dabo.dEvents as dEvents
import components
from components.ClassDesigner import ClassDesigner
-from components.CxnEditor import CxnEditor
+from components.CxnEditor import CxnEditorPage
from components.MenuDesigner import MenuDesigner
from components.ReportDesigner import ReportDesigner
from components.TextEditor import TextEditorPage
+
+
class ProjectTree(dabo.ui.dTreeView):
def beforeInit(self):
self.controller = None
@@ -42,10 +44,9 @@
return
nd = self._context["node"]
pth = self._context["filepath"]
- if pth.endswith(".py"):
- self.controller.editFile(pth)
+ self.controller.editFile(pth)
+
-
class StudioToolBar(dabo.ui.dToolBar):
"""Overrides the _appendInsertButton() method, so that we get actual
Dabo
dBitmapButton or dToggleButton controls instead of the default
wx.ToolBarItem
@@ -66,6 +67,7 @@
return self.insertControl(pos, ctl, bindfunc=bindfunc)
+
class StudioForm(dabo.ui.dDockForm):
def initProperties(self):
self.Caption = _("Dabo Developer Studio")
@@ -85,24 +87,38 @@
self.toolbar = self.addPanel(Toolbar=True, Docked=True,
DockSide="Top",
ShowCaption=False, ShowGripper=True,
BottomDockable=False,
LeftDockable=False, RightDockable=False)
- self.toolbar.Sizer = dabo.ui.dSizer("h")
+ self.toolbar.Sizer = dabo.ui.dSizer("h", DefaultSpacing=10)
+ # Automatically add child controls to the toolbar sizer
+ self.toolbar.bindEvent(dEvents.ChildBorn,
self.onToolbarItemAdded)
cp = self.CenterPanel
csz = cp.Sizer = dabo.ui.dSizer("v")
# self.toolbar = self.ToolBar = StudioToolBar(self)
# csz.append(self.toolbar)
self._toolSets = {None: []}
self._currentToolBar = None
- self.pgfEditors = dabo.ui.dPageFrame(self.CenterPanel,
PageCount=0)
+ dabo.ui.setAfter(self, "CurrentToolBar", None)
+ self.pgfEditors = dabo.ui.dDockTabs(self.CenterPanel,
PageCount=0)
csz.append1x(self.pgfEditors)
# Enable the various parts of the IDE.
self.registerComponents()
self.registerPlugins()
+
+ self._currentProject = None
+ # See if there is a saved project
+ proj = self.PreferenceManager.lastOpenedProject
+ print "LAST", proj
+ if isinstance(proj, basestring) and os.path.exists(proj):
+ self.openProject(proj)
# Make sure that all components are visible
dabo.ui.callAfter(self._showAllPanels)
+ def onToolbarItemAdded(self, evt):
+ self.toolbar.Sizer.append(evt.child)
+
+
def _showAllPanels(self):
self.toolbar.Visible = self.projectTreePanel.Visible = True
self.toolbar.Show()
@@ -115,7 +131,8 @@
for comp in comps:
try:
comp.register(self)
- except AttributeError:
+ except AttributeError, e:
+ print "ERR", e
dabo.errorLog.write(_("Component '%s' lacks a
'register()' method.") % comp)
@@ -128,23 +145,30 @@
def editFile(self, pth):
- pg = self.pgfEditors.appendPage(TextEditorPage)
- pg.openFile(pth)
- self.pgfEditors.SelectedPage = pg
- self.CurrentToolBar = "TextEditor"
+ if pth.endswith(".py"):
+ pg = self.pgfEditors.appendPage(TextEditorPage)
+ pg.openFile(pth)
+ self.pgfEditors.SelectedPage = pg
+ self.CurrentToolBar = "TextEditor"
+ elif pth.endswith(".cnxml"):
+ pg = self.pgfEditors.appendPage(CxnEditorPage)
+ pg.openFile(pth)
+ self.pgfEditors.SelectedPage = pg
+ self.CurrentToolBar = "CxnEditor"
def onOpenProject(self, evt):
- self.openProject()
-
-
- def openProject(self):
pjd = dabo.ui.getDirectory(_("Select Project Base"))
if pjd:
- self.tree.makeDirTree(pjd, ignored=["*pyc", "*~"],
expand=False)
- self.tree.getRootNode().Expanded = True
+ self.openProject(pjd)
+ def openProject(self, proj):
+ self.Application._currentProject = proj
+ self.tree.makeDirTree(proj, ignored=["*pyc", "*~"],
expand=False)
+ self.tree.getRootNode().Expanded = True
+
+
def _getCurrentToolBar(self):
return self._currentToolBar
@@ -154,20 +178,14 @@
return
if val not in self._toolSets:
dabo.errorLog.write(_("Invalid toolbar
specified: '%s'") % val)
-
print self._toolSets.keys()
return
- # Hide all visible buttons
- for btn in self.toolbar.Children[::-1]:
- self.toolbar.remove(btn, False)
self._currentToolBar = val
- # Show the new button set
- for btn in self._toolSets[self._currentToolBar]:
- try:
- self.toolbar.appendItem(btn)
- except AttributeError:
- # A control, not a tool item
- btn.Visible = True
+ sz = self.toolbar.Sizer
+ curr = self._toolSets[self._currentToolBar]
+ for itm in self.toolbar.Children:
+ itm.Visible = (itm in curr)
+ self.toolbar.layout()
else:
self._properties["CurrentToolBar"] = val
@@ -177,8 +195,19 @@
+class StudioApp(dabo.dApp):
+ def afterFinish(self):
+ # Save the current project being edited.
+ pm = self.PreferenceManager
+ print "CURR", self._currentProject
+ if self._currentProject is None:
+ pm.removePref(lastOpenedProject)
+ else:
+ pm.lastOpenedProject = self._currentProject
+
+
def main():
- app = dabo.dApp()
+ app = StudioApp()
app.BasePrefKey = "DeveloperStudio"
app.MainFormClass = StudioForm
app.start()
Modified: branches/ed-ide/components/CxnEditor/CxnEditor.py
===================================================================
--- branches/ed-ide/components/CxnEditor/CxnEditor.py 2008-06-14 20:10:03 UTC
(rev 4137)
+++ branches/ed-ide/components/CxnEditor/CxnEditor.py 2008-06-15 18:43:22 UTC
(rev 4138)
@@ -15,11 +15,7 @@
-class EditorForm(dui.dForm):
- def afterSetMenuBar(self):
- self.createMenu()
-
-
+class CxnEditorPage(dui.dPage):
def afterInit(self):
self.newFileName = "Untitled"
self.fileExtension = "cnxml"
@@ -29,6 +25,9 @@
"MsSQL" : 1433,
"SQLite" : None }
connKeys = ["host", "dbtype", "port", "database", "user",
"password"]
+ # Create the attributes
+ for key in connKeys:
+ setattr(self, key, "")
self.connDict = dict.fromkeys(connKeys)
self._origConnDict = dict.fromkeys(connKeys)
self.currentConn = None
@@ -50,26 +49,29 @@
def createControls(self):
- self.Caption = "Connection Editor"
- self.Size= (500, 800)
- self.bg = dui.dPanel(self, BackColor="LightSteelBlue")
-
gbsz = dui.dGridSizer(VGap=12, HGap=5, MaxCols=2)
# Add the fields
+ self.dataFields = {}
# Connection Dropdown
- cap = dui.dLabel(self.bg, Caption="Connection")
- ctl = dui.dDropdownList(self.bg, Choices=[""],
- RegID="connectionSelector")
- ctl.bindEvent(dEvents.Hit, self.onConnectionChange)
- btn = dui.dButton(self.bg, Caption="Edit Name", RegID="cxnEdit")
+ cap = dui.dLabel(self, Caption="Connection")
+ ctl = dui.dDropdownList(self, Choices=[""],
OnHit=self.onConnectionChange)
+ self.dataFields["name"] = ctl
+ self.connectionSelector = ctl
+ ctl.controller = self
+ btn = dui.dButton(self, Caption="Edit Name",
OnHit=self.onCxnEdit)
+ self.cxnEdit = btn
+ btn.controller = self
hsz = dui.dSizer("h")
hsz.append(ctl)
hsz.appendSpacer(10)
hsz.append(btn)
- btn = dui.dButton(self.bg, Caption="Delete This Connection",
RegID="cxnDelete",
- DynamicEnabled=self.hasMultipleConnections)
+ btn = dui.dButton(self, Caption="Delete This Connection",
+ DynamicEnabled=self.hasMultipleConnections,
+ OnHit = self.onCxnDelete)
+ self.cxnDelete = btn
+ btn.controller = self
hsz.appendSpacer(10)
hsz.append(btn)
@@ -77,91 +79,97 @@
gbsz.append(hsz, valign="middle")
# Backend Type
- cap = dui.dLabel(self.bg, Caption="Database Type")
- ctl = dui.dDropdownList(self.bg, RegID="DbType",
- Choices=["MySQL", "Firebird", "PostgreSQL",
"MsSQL", "SQLite"],
- DataSource="form", DataField="dbtype",
+ cap = dui.dLabel(self, Caption="Database Type")
+ ctl = dui.dDropdownList(self, Choices=["MySQL", "Firebird",
"PostgreSQL", "MsSQL", "SQLite"],
OnHit=self.onDbTypeChanged)
+ self.dataFields["dbtype"] = ctl
+ self.DbType = ctl
+ ctl.controller = self
gbsz.append(cap, halign="right")
gbsz.append(ctl)
self.dbTypeSelector = ctl
# Host
- cap = dui.dLabel(self.bg, Caption="Host")
- ctl = dui.dTextBox(self.bg, DataSource="form", DataField="host")
+ cap = dui.dLabel(self, Caption="Host")
+ ctl = dui.dTextBox(self)
+ self.dataFields["host"] = ctl
+ ctl.controller = self
gbsz.append(cap, halign="right")
gbsz.append(ctl, "expand")
self.hostText = ctl
# Port
- cap = dui.dLabel(self.bg, Caption="Port")
- ctl = dui.dTextBox(self.bg, DataSource="form", DataField="port")
+ cap = dui.dLabel(self, Caption="Port")
+ ctl = dui.dTextBox(self)
+ self.dataFields["port"] = ctl
+ ctl.controller = self
gbsz.append(cap, halign="right")
gbsz.append(ctl, "expand")
self.portText = ctl
# Database
- cap = dui.dLabel(self.bg, Caption="Database")
- ctl = dui.dTextBox(self.bg, DataSource="form",
DataField="database")
+ cap = dui.dLabel(self, Caption="Database")
+ ctl = dui.dTextBox(self)
+ self.dataFields["database"] = ctl
+ self.dbText = ctl
+ ctl.controller = self
hsz = dui.dSizer("h")
- self.btnDbSelect = dui.dButton(self.bg, Caption=" ... ",
RegID="btnDbSelect",
- Visible=False)
+ self.btnDbSelect = dui.dButton(self, Caption=" ... ",
Visible=False, OnHit=self.onDbSelect)
+ self.btnDbSelect.controller = self
hsz.append1x(ctl)
hsz.appendSpacer(2)
hsz.append(self.btnDbSelect, 0, "x")
gbsz.append(cap, halign="right")
gbsz.append(hsz, "expand")
- self.dbText = ctl
# Username
- cap = dui.dLabel(self.bg, Caption="User Name")
- ctl = dui.dTextBox(self.bg, DataSource="form", DataField="user")
+ cap = dui.dLabel(self, Caption="User Name")
+ ctl = dui.dTextBox(self)
+ self.dataFields["user"] = ctl
+ self.userText = ctl
+ ctl.controller = self
gbsz.append(cap, halign="right")
gbsz.append(ctl, "expand")
- self.userText = ctl
# Password
- cap = dui.dLabel(self.bg, Caption="Password")
- ctl = dui.dTextBox(self.bg, PasswordEntry=True,
- DataSource="form", DataField="password")
+ cap = dui.dLabel(self, Caption="Password")
+ ctl = dui.dTextBox(self, PasswordEntry=True)
+ self.dataFields["password"] = ctl
+ self.pwText = ctl
+ ctl.controller = self
gbsz.append(cap, halign="right")
gbsz.append(ctl, "expand")
- self.pwText = ctl
- # Open Button
btnSizer1 = dui.dSizer("h")
btnSizer2 = dui.dSizer("h")
- btnTest = dui.dButton(self.bg, RegID="btnTest",
Caption="Test...")
- btnSave = dui.dButton(self.bg, RegID="btnSave", Caption="Save")
- btnNewConn = dui.dButton(self.bg, RegID="btnNewConn",
- Caption="New Connection")
- btnNewFile = dui.dButton(self.bg, RegID="btnNewFile",
- Caption="New File")
- btnOpen = dui.dButton(self.bg, RegID="btnOpen",
- Caption="Open File...")
- btnSizer1.append(btnTest, 0, border=3)
- btnSizer1.append(btnSave, 0, border=3)
- btnSizer2.append(btnNewConn, 0, border=3)
- btnSizer2.append(btnNewFile, 0, border=3)
- btnSizer2.append(btnOpen, 0, border=3)
+ self.btnTest = dui.dButton(self, Caption="Test...",
OnHit=self.onTest)
+ self.btnSave = dui.dButton(self, Caption="Save",
OnHit=self.onSave)
+ self.btnNewConn = dui.dButton(self, Caption="New Connection",
OnHit=self.onNewConn)
+ self.btnNewFile = dui.dButton(self, Caption="New File",
OnHit=self.onNewFile)
+ self.btnOpen = dui.dButton(self, Caption="Open File...",
OnHit=self.onOpenFile)
+ self.btnTest.controller = self.btnSave.controller =
self.btnNewConn.controller = \
+ self.btnNewFile.controller =
self.btnOpen.controller = self
+ btnSizer1.append(self.btnTest, 0, border=3)
+ btnSizer1.append(self.btnSave, 0, border=3)
+ btnSizer2.append(self.btnNewConn, 0, border=3)
+ btnSizer2.append(self.btnNewFile, 0, border=3)
+ btnSizer2.append(self.btnOpen, 0, border=3)
gbsz.setColExpand(True, 1)
self.gridSizer = gbsz
- self.bg.Sizer = dui.dSizer("v")
- self.bg.Sizer.append(gbsz, 0, "expand", halign="center",
border=20)
- self.bg.Sizer.append(btnSizer1, 0, halign="center")
- self.bg.Sizer.append(btnSizer2, 0, halign="center")
- self.Sizer = dui.dSizer("h")
- self.Sizer.append(self.bg, 1, "expand", halign="center")
- self.Layout()
+ self.Sizer = dui.dSizer("v")
+ self.Sizer.append(gbsz, 0, "expand", halign="center", border=20)
+ self.Sizer.append(btnSizer1, 0, halign="center")
+ self.Sizer.append(btnSizer2, 0, halign="center")
+ self.layout()
def hasMultipleConnections(self):
return len(self.connDict.keys()) > 1
- def onHit_cxnDelete(self, evt):
+ def onCxnDelete(self, evt):
if not dabo.ui.areYouSure(_("Delete this connection?"),
title=_("Confirm Deletion"),
cancelButton=False):
return
@@ -177,7 +185,7 @@
self.update()
- def onHit_cxnEdit(self, evt):
+ def onCxnEdit(self, evt):
chc = self.connectionSelector.Choices
idx = self.connectionSelector.PositionValue
orig = chc[idx]
@@ -197,18 +205,18 @@
self.connectionSelector.PositionValue = idx
- def onHit_btnTest(self, evt):
+ def onTest(self, evt):
self.testConnection()
- def onHit_btnOpen(self, evt):
+ def onOpenFile(self, evt):
# Update the values
self.updtFromForm()
# Now open the file
self.openFile()
- def onHit_btnNewFile(self, evt):
+ def onNewFile(self, evt):
# Update the values
self.updtFromForm()
# See if the user wants to save changes (if any)
@@ -217,14 +225,14 @@
self.newFile()
- def onHit_btnNewConn(self, evt):
+ def onNewConn(self, evt):
# Update the values
self.updtFromForm()
# Create the new connection
self.newConnection()
- def onHit_btnSave(self, evt):
+ def onSave(self, evt):
self.saveFile()
@@ -254,20 +262,13 @@
self.layout()
- def onHit_btnDbSelect(self, evt):
+ def onDbSelect(self, evt):
dbFile = dui.getFile()
if dbFile:
self.database = dbFile
self.update()
- def onHit_connectionSelector(self, evt):
- self.currentConn = self.connectionSelector.StringValue
- self.updtToForm()
- self.enableControls()
- self.update()
-
-
def testConnection(self):
# Update the values
self.updtFromForm()
@@ -292,12 +293,13 @@
""" Grab the current values from the form, and update
the connection dictionary with them.
"""
+ print "UPDT form FORM"
# Make sure that changes to the current control are used.
- self.activeControlValid()
+ self.Form.activeControlValid()
if self.currentConn is not None:
dd = self.connDict[self.currentConn]
for fld in dd.keys():
- val = eval("self.%s" % fld)
+ val = self.dataFields[fld].Value
if fld == "password":
origVal = self.crypt.decrypt(dd[fld])
else:
@@ -314,6 +316,7 @@
""" Populate the current values from the connection
dictionary.
"""
+ print "UPDT TO FORM"
if self.currentConn is not None:
dd = self.connDict[self.currentConn]
for fld in dd.keys():
@@ -322,9 +325,7 @@
val = self.crypt.decrypt(dd[fld])
else:
val = dd[fld]
- if isinstance(val, basestring):
- val = self.escQuote(val)
# Add quotes
- exec("self.%s = %s" % (fld, val) )
+ self.dataFields[fld].Value = val
def escQuote(self, val):
@@ -338,7 +339,7 @@
self.connFile = self.newFileName
self.connDict = {}
# Set the form caption
- self.Caption = "Dabo Connection Editor: %s" %
os.path.basename(self.connFile)
+ self.Caption = os.path.basename(self.connFile)
# Add a new blank connection
self.newConnection()
self._origConnDict = copy.deepcopy(self.connDict)
@@ -397,13 +398,13 @@
def populate(self):
self.updtToForm()
- self.update()
+# self.update()
conn = self.currentConn
self.connectionSelector.Value = conn
def openFile(self, connFile=None):
- self.activeControlValid()
+ self.Form.activeControlValid()
# See if the user wants to save changes (if any)
if not self.confirmChanges():
return
@@ -432,7 +433,7 @@
# Set the current connection
self.currentConn = self.connDict.keys()[0]
# Set the form caption
- self.Caption = _("Dabo Connection Editor: %s") %
os.path.basename(self.connFile)
+ self.Caption = os.path.basename(self.connFile)
# Fill the controls
self.populate()
self.layout()
@@ -442,7 +443,7 @@
def confirmChanges(self):
- self.activeControlValid()
+ self.Form.activeControlValid()
self.updtFromForm()
if self._origConnDict != self.connDict:
response = dui.areYouSure(_("Do you wish to save your
changes?"),
Modified: branches/ed-ide/components/CxnEditor/__init__.py
===================================================================
--- branches/ed-ide/components/CxnEditor/__init__.py 2008-06-14 20:10:03 UTC
(rev 4137)
+++ branches/ed-ide/components/CxnEditor/__init__.py 2008-06-15 18:43:22 UTC
(rev 4138)
@@ -1,4 +1,26 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
-from CxnEditor import EditorForm
+import dabo
+import dabo.dEvents as dEvents
+from dabo.dLocalize import _
+import CxnEditor
+from CxnEditor import CxnEditorPage
+
+
+masterForm = None
+
+def register(master):
+ global masterForm
+ masterForm = master
+ tb = master.toolbar
+
+ dummyBtn = dabo.ui.dBitmapButton(tb, Picture="open", AutoSize=False,
+ OnMouseLeftDown=onDummy)
+
+ master.setToolBarGroup("CxnEditor", [dummyBtn])
+
+
+def onDummy(self, evt):
+ print "DUMMY BUTTON"
+
Modified: branches/ed-ide/components/TextEditor/__init__.py
===================================================================
--- branches/ed-ide/components/TextEditor/__init__.py 2008-06-14 20:10:03 UTC
(rev 4137)
+++ branches/ed-ide/components/TextEditor/__init__.py 2008-06-15 18:43:22 UTC
(rev 4138)
@@ -14,22 +14,15 @@
masterForm = master
tb = master.toolbar
- funcBtn = tb.appendButton(_("Functions"),
- dabo.ui.bitmapFromData(TextEditor.funcButtonData()),
- toggle=False,
+ funcBtn = dabo.ui.dBitmapButton(tb,
+
Picture=dabo.ui.bitmapFromData(TextEditor.funcButtonData()),
OnMouseLeftDown=onFuncButton)
- bmkBtn = tb.appendButton(_("Bookmarks"),
- dabo.ui.bitmapFromData(TextEditor.bmkButtonData()),
- toggle=False,
+ bmkBtn = dabo.ui.dBitmapButton(tb,
+
Picture=dabo.ui.bitmapFromData(TextEditor.bmkButtonData()),
OnMouseLeftDown=onBmkButton)
- printBtn = tb.appendButton(_("Print"),
- "print",
- toggle=False,
- OnHit=onPrint)
+ printBtn = dabo.ui.dBitmapButton(tb, Picture="print", OnHit=onPrint)
lexSelector = dabo.ui.dDropdownList(tb, ValueMode="String",
- Choices = dabo.ui.dEditor.getAvailableLanguages(),
- OnHit = onLexSelect)
- tb.appendControl(lexSelector)
+ Choices=dabo.ui.dEditor.getAvailableLanguages(),
OnHit=onLexSelect)
master.setToolBarGroup("TextEditor", [funcBtn, bmkBtn, printBtn,
lexSelector])
@@ -43,6 +36,6 @@
def onLexSelect(evt):
masterForm.Caption = evt.EventObject.Value
- def updateLex(self):
- if not self.lexSelector.Choices:
- self.lexSelector.Choices =
self.CurrentEditor.getAvailableLanguages()
+def updateLex(self):
+ if not self.lexSelector.Choices:
+ self.lexSelector.Choices =
self.CurrentEditor.getAvailableLanguages()
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: http://leafe.com/archives/byMID/[EMAIL PROTECTED]