Updates to doc/view modules and sample apps from ActiveGrid.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@33904 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robin Dunn 2005-04-28 00:00:50 +00:00
parent 73ed39b580
commit bbf7159c82
28 changed files with 603 additions and 1183 deletions

View File

@ -7,7 +7,7 @@
# Created: 8/1/03
# CVS-ID: $Id$
# Copyright: (c) 2003-2005 ActiveGrid, Inc. (Port of wxWindows classes by Julian Smart et al)
# License: wxWindows license
# License: wxWindows License
#----------------------------------------------------------------------------

View File

@ -324,7 +324,7 @@ class CodeView(STCTextEditor.TextView):
self.GetCtrl().SetSelection(pos, pos)
self._GetParentFrame().SetStatusText(_("Syntax Error: %s") % message)
except:
self._GetParentFrame().SetStatusText(sys.exc_info()[0])
self._GetParentFrame().SetStatusText("%s: %s" % (sys.exc_info()[0], sys.exc_info()[1]))
def OnAutoComplete(self):

View File

@ -1418,6 +1418,7 @@ class DebuggerService(Service.Service):
CLEAR_ALL_BREAKPOINTS = wx.NewId()
RUN_ID = wx.NewId()
DEBUG_ID = wx.NewId()
DEBUG_WEBSERVER_ID = wx.NewId()
def ComparePaths(first, second):
one = DebuggerService.ExpandPath(first)
@ -1493,6 +1494,12 @@ class DebuggerService(Service.Service):
wx.EVT_MENU(frame, DebuggerService.DEBUG_ID, frame.ProcessEvent)
wx.EVT_UPDATE_UI(frame, DebuggerService.DEBUG_ID, frame.ProcessUpdateUIEvent)
if not ACTIVEGRID_BASE_IDE:
debuggerMenu.AppendSeparator()
debuggerMenu.Append(DebuggerService.DEBUG_WEBSERVER_ID, _("Debug Internal Web Server"), _("Debugs the internal webservier"))
wx.EVT_MENU(frame, DebuggerService.DEBUG_WEBSERVER_ID, frame.ProcessEvent)
wx.EVT_UPDATE_UI(frame, DebuggerService.DEBUG_WEBSERVER_ID, frame.ProcessUpdateUIEvent)
debuggerMenu.AppendSeparator()
debuggerMenu.Append(DebuggerService.TOGGLE_BREAKPOINT_ID, _("&Toggle Breakpoint...\tCtrl+B"), _("Toggle a breakpoint"))
@ -1536,6 +1543,9 @@ class DebuggerService(Service.Service):
elif an_id == DebuggerService.DEBUG_ID:
self.OnDebugProject(event)
return True
elif an_id == DebuggerService.DEBUG_WEBSERVER_ID:
self.OnDebugWebServer(event)
return True
return False
def ProcessUpdateUIEvent(self, event):
@ -1572,7 +1582,10 @@ class DebuggerService(Service.Service):
self.ShowWindow(True)
projectService = wx.GetApp().GetService(ProjectEditor.ProjectService)
project = projectService.GetView().GetDocument()
dlg = CommandPropertiesDialog(self.GetView().GetFrame(), 'Debug Python File', projectService, None, pythonOnly=True, okButtonName="Debug", debugging=True)
try:
dlg = CommandPropertiesDialog(self.GetView().GetFrame(), 'Debug Python File', projectService, None, pythonOnly=True, okButtonName="Debug", debugging=True)
except:
return
if dlg.ShowModal() == wx.ID_OK:
fileToDebug, initialArgs, startIn, isPython, environment = dlg.GetSettings()
dlg.Destroy()
@ -1586,12 +1599,26 @@ class DebuggerService(Service.Service):
try:
page = DebugCommandUI(Service.ServiceView.bottomTab, -1, str(fileToDebug), self)
count = Service.ServiceView.bottomTab.GetPageCount()
Service.ServiceView.bottomTab.AddPage(page, "Debugging: " + shortFile)
Service.ServiceView.bottomTab.AddPage(page, _("Debugging: ") + shortFile)
Service.ServiceView.bottomTab.SetSelection(count)
page.Execute(initialArgs, startIn, environment)
except:
pass
def OnDebugWebServer(self, event):
import WebServerService
wsService = wx.GetApp().GetService(WebServerService.WebServerService)
fileName, args = wsService.StopAndPrepareToDebug()
try:
page = DebugCommandUI(Service.ServiceView.bottomTab, -1, str(fileName), self)
count = Service.ServiceView.bottomTab.GetPageCount()
Service.ServiceView.bottomTab.AddPage(page, _("Debugging: Internal WebServer"))
Service.ServiceView.bottomTab.SetSelection(count)
page.Execute(args, startIn=os.getcwd(), environment=os.environ)
except:
pass
def HasAnyFiles(self):
docs = wx.GetApp().GetDocumentManager().GetDocuments()
return len(docs) > 0
@ -1630,7 +1657,10 @@ class DebuggerService(Service.Service):
return
projectService = wx.GetApp().GetService(ProjectEditor.ProjectService)
project = projectService.GetView().GetDocument()
dlg = CommandPropertiesDialog(self.GetView().GetFrame(), 'Run', projectService, None)
try:
dlg = CommandPropertiesDialog(self.GetView().GetFrame(), 'Run', projectService, None)
except:
return
if dlg.ShowModal() == wx.ID_OK:
fileToRun, initialArgs, startIn, isPython, environment = dlg.GetSettings()
@ -1817,10 +1847,6 @@ class DebuggerOptionsPanel(wx.Panel):
class CommandPropertiesDialog(wx.Dialog):
def __init__(self, parent, title, projectService, currentProjectDocument, pythonOnly=False, okButtonName="Run", debugging=False):
if _WINDOWS:
wx.Dialog.__init__(self, parent, -1, title)
else:
wx.Dialog.__init__(self, parent, -1, title, size=(390,270))
self._projService = projectService
self._pmext = None
self._pyext = None
@ -1830,8 +1856,16 @@ class CommandPropertiesDialog(wx.Dialog):
if template.GetDocumentType() == PythonEditor.PythonDocument:
self._pyext = template.GetDefaultExtension()
self._pythonOnly = pythonOnly
self._currentProj = currentProjectDocument
self._projectNameList, self._projectDocumentList, selectedIndex = self.GetProjectList()
if not self._projectNameList:
wx.MessageBox(_("To run or debug you must have an open runnable file or project containing runnable files. Use File->Open to open the file you wish to run or debug."), _("Nothing to Run"))
raise BadBadBad
if _WINDOWS:
wx.Dialog.__init__(self, parent, -1, title)
else:
wx.Dialog.__init__(self, parent, -1, title, size=(390,270))
projStaticText = wx.StaticText(self, -1, _("Project:"))
fileStaticText = wx.StaticText(self, -1, _("File:"))
argsStaticText = wx.StaticText(self, -1, _("Arguments:"))
@ -1839,7 +1873,6 @@ class CommandPropertiesDialog(wx.Dialog):
pythonPathStaticText = wx.StaticText(self, -1, _("PYTHONPATH:"))
postpendStaticText = _("Postpend win32api path")
cpPanelBorderSizer = wx.BoxSizer(wx.VERTICAL)
self._projectNameList, self._projectDocumentList, selectedIndex = self.GetProjectList()
self._projList = wx.Choice(self, -1, (200,-1), choices=self._projectNameList)
self.Bind(wx.EVT_CHOICE, self.EvtListBox, self._projList)
HALF_SPACE = 5
@ -2049,11 +2082,36 @@ class CommandPropertiesDialog(wx.Dialog):
found = True
index = count
count += 1
#Check for open files not in any of these projects and add them to a default project
def AlreadyInProject(fileName):
for projectDocument in docList:
if projectDocument.IsFileInProject(fileName):
return True
return False
unprojectedFiles = []
for document in self._projService.GetDocumentManager().GetDocuments():
if not ACTIVEGRID_BASE_IDE and type(document) == ProcessModelEditor.ProcessModelDocument:
if not AlreadyInProject(document.GetFilename()):
unprojectedFiles.append(document.GetFilename())
if type(document) == PythonEditor.PythonDocument:
if not AlreadyInProject(document.GetFilename()):
unprojectedFiles.append(document.GetFilename())
if unprojectedFiles:
unprojProj = ProjectEditor.ProjectDocument()
unprojProj.SetFilename(_("Not in any Project"))
unprojProj.AddFiles(unprojectedFiles)
docList.append(unprojProj)
nameList.append(_("Not in any Project"))
return nameList, docList, index
#----------------------------------------------------------------------
from wx import ImageFromStream, BitmapFromImage
from wx import EmptyIcon
import cStringIO
#----------------------------------------------------------------------
def getBreakData():
return \
@ -2075,9 +2133,7 @@ def getBreakImage():
return ImageFromStream(stream)
def getBreakIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getBreakBitmap())
return icon
return wx.IconFromBitmap(getBreakBitmap())
#----------------------------------------------------------------------
def getClearOutputData():
@ -2102,9 +2158,7 @@ def getClearOutputImage():
return ImageFromStream(stream)
def getClearOutputIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getClearOutputBitmap())
return icon
return wx.IconFromBitmap(getClearOutputBitmap())
#----------------------------------------------------------------------
def getCloseData():
@ -2126,9 +2180,7 @@ def getCloseImage():
return ImageFromStream(stream)
def getCloseIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getCloseBitmap())
return icon
return wx.IconFromBitmap(getCloseBitmap())
#----------------------------------------------------------------------
def getContinueData():
@ -2151,9 +2203,7 @@ def getContinueImage():
return ImageFromStream(stream)
def getContinueIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getContinueBitmap())
return icon
return wx.IconFromBitmap(getContinueBitmap())
#----------------------------------------------------------------------
def getNextData():
@ -2176,9 +2226,7 @@ def getNextImage():
return ImageFromStream(stream)
def getNextIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getNextBitmap())
return icon
return wx.IconFromBitmap(getNextBitmap())
#----------------------------------------------------------------------
def getStepInData():
@ -2200,9 +2248,7 @@ def getStepInImage():
return ImageFromStream(stream)
def getStepInIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getStepInBitmap())
return icon
return wx.IconFromBitmap(getStepInBitmap())
#----------------------------------------------------------------------
def getStopData():
@ -2222,9 +2268,7 @@ def getStopImage():
return ImageFromStream(stream)
def getStopIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getStopBitmap())
return icon
return wx.IconFromBitmap(getStopBitmap())
#----------------------------------------------------------------------
def getStepReturnData():
@ -2247,10 +2291,9 @@ def getStepReturnImage():
return ImageFromStream(stream)
def getStepReturnIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getStepReturnBitmap())
return icon
return wx.IconFromBitmap(getStepReturnBitmap())
#----------------------------------------------------------------------
def getAddWatchData():
return \
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
@ -2270,6 +2313,4 @@ def getAddWatchImage():
return ImageFromStream(stream)
def getAddWatchIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getAddWatchBitmap())
return icon
return wx.IconFromBitmap(getAddWatchBitmap())

View File

@ -58,10 +58,18 @@ class FindInDirService(FindService.FindService):
def ProcessEvent(self, event):
id = event.GetId()
if id == FindInDirService.FINDALL_ID:
self.ShowFindAllDialog()
view = wx.GetApp().GetDocumentManager().GetCurrentView()
if hasattr(view, "GetCtrl") and view.GetCtrl() and hasattr(view.GetCtrl(), "GetSelectedText"):
self.ShowFindAllDialog(view.GetCtrl().GetSelectedText())
else:
self.ShowFindAllDialog()
return True
elif id == FindInDirService.FINDDIR_ID:
self.ShowFindDirDialog()
view = wx.GetApp().GetDocumentManager().GetCurrentView()
if hasattr(view, "GetCtrl") and view.GetCtrl() and hasattr(view.GetCtrl(), "GetSelectedText"):
self.ShowFindDirDialog(view.GetCtrl().GetSelectedText())
else:
self.ShowFindDirDialog()
return True
else:
return FindService.FindService.ProcessEvent(self, event)
@ -83,7 +91,7 @@ class FindInDirService(FindService.FindService):
return FindService.FindService.ProcessUpdateUIEvent(self, event)
def ShowFindDirDialog(self):
def ShowFindDirDialog(self, findString=None):
config = wx.ConfigBase_Get()
frame = wx.Dialog(None, -1, _("Find in Directory"), size= (320,200))
@ -122,7 +130,11 @@ class FindInDirService(FindService.FindService):
lineSizer = wx.BoxSizer(wx.HORIZONTAL)
lineSizer.Add(wx.StaticText(frame, -1, _("Find what:")), 0, wx.ALIGN_CENTER | wx.RIGHT, HALF_SPACE)
findCtrl = wx.TextCtrl(frame, -1, config.Read(FindService.FIND_MATCHPATTERN, ""), size=(200,-1))
if not findString:
findString = config.Read(FindService.FIND_MATCHPATTERN, "")
findCtrl = wx.TextCtrl(frame, -1, findString, size=(200,-1))
findCtrl.SetFocus()
findCtrl.SetSelection(0,-1)
lineSizer.Add(findCtrl, 0, wx.LEFT, HALF_SPACE)
contentSizer.Add(lineSizer, 0, wx.BOTTOM, SPACE)
wholeWordCtrl = wx.CheckBox(frame, -1, _("Match whole word only"))
@ -270,7 +282,7 @@ class FindInDirService(FindService.FindService):
config.WriteInt(FIND_MATCHDIRSUBFOLDERS, searchSubfolders)
def ShowFindAllDialog(self):
def ShowFindAllDialog(self, findString=None):
config = wx.ConfigBase_Get()
frame = wx.Dialog(None, -1, _("Find in Project"), size= (320,200))
@ -279,7 +291,9 @@ class FindInDirService(FindService.FindService):
contentSizer = wx.BoxSizer(wx.VERTICAL)
lineSizer = wx.BoxSizer(wx.HORIZONTAL)
lineSizer.Add(wx.StaticText(frame, -1, _("Find what:")), 0, wx.ALIGN_CENTER | wx.RIGHT, HALF_SPACE)
findCtrl = wx.TextCtrl(frame, -1, config.Read(FindService.FIND_MATCHPATTERN, ""), size=(200,-1))
if not findString:
findString = config.Read(FindService.FIND_MATCHPATTERN, "")
findCtrl = wx.TextCtrl(frame, -1, findString, size=(200,-1))
lineSizer.Add(findCtrl, 0, wx.LEFT, HALF_SPACE)
contentSizer.Add(lineSizer, 0, wx.BOTTOM, SPACE)
wholeWordCtrl = wx.CheckBox(frame, -1, _("Match whole word only"))

View File

@ -190,7 +190,6 @@ HTMLKEYWORDS = [
# Icon Bitmaps - generated by encode_bitmaps.py
#----------------------------------------------------------------------------
from wx import ImageFromStream, BitmapFromImage
from wx import EmptyIcon
import cStringIO
@ -198,15 +197,16 @@ def getHTMLData():
return \
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
\x00\x00\xcdIDAT8\x8dcd`f\xf8\xcf@\x01`\xfc\x7f\xa3\x87"\x03X\xfe}\xbeI\x89~\
\x06&\x8at\x0f\n\x03\x18\xe4\x954\xff\xc3\x00\x8c-\xaf\xa4\xf9_\xc7\xc0\xfc\
\xbf\x93\xab\xf7\xff\xff\xff\xff\xff70\xb6\xfe\x7f\xed\xce\x93\xff\xd7\xee<\
\xf9\xafc`\x0eW\xf3\xf5\xd7\xff\xff,\x0f\x1f^gPP\xd6B1\xf4\xc1\xddk\x0c\xf6\
\xb6\x16\x0c{wma````x\xf7\xfc\x06\xc3\xea\xa5\xb3\x198\xd8X\x18\xbe~|\x06W\
\xc7\xc5\xca\xc0\xc0\xc2\xc0\xc0\xc0P\\\x9c\xcf\xf0\xf4\xc5\x1b\x86\x15K\x97\
\xc2%Y\xd9y\xe0lF\x0e1\x86C\x87\x8e0\x88\x88\x8a3\xfccD\x88\xe3\xf4\x026\xf6\
\xa9c{\xfe_<s\x18\xc5\x9b\xf2J\x9a\xff\x19\xff\x9eN\xa5(!\r|4\x0e\x03\x03\
\x00R\xe4{\xe74\x9e\xbb\xd1\x00\x00\x00\x00IEND\xaeB`\x82'
\x00\x00\xd3IDAT8\x8dcddbf\xa0\x040\xfe\xbf\xd1\xf3\x9f\x12\x03X\xfe}\xbeI\
\x91\x0b\x98(\xd2=(\x0c`\x90W\xd2\xfc\x0f\x030\xb6\xbc\x92\xe6\x7f\x1d\x03\
\xf3\xffN\xae\xde\xff\xff\xff\xff\xff\xdf\xc0\xd8\xfa\xff\xb5;O\xfe_\xbb\xf3\
\xe4\xbf\x8e\x819\\\xcd\xd7_\xff\xff\xb3<|x\x9dAAY\x0b\xc5\xd0\x07w\xaf1\xd8\
\xdbZ0\xec\xdd\xb5\x85\x81\x81\x81\x81\xe1\xdd\xf3\x1b\x0c\xab\x97\xcef\xe0`\
ca\xf8\xfa\xf1\x19\\\x1d\x17+\x03\x03\x0b\x03\x03\x03Cqq>\xc3\xd3\x17o\x18V,\
]\n\x97de\xe7\x81\xb3\x199\xc4\x18\x0e\x1d:\xc2 "*\xce\xf0\x8f\x11!\x8e\xd3\
\x0b\xd8\xd8\xa7\x8e\xed\xf9\x7f\xf1\xcca\x14o\xca+i\xfeg\xfc{:\x95\xa2\x844\
\xf0\xd1H\xb1\x01\x8c\x94\xe6F\x8a]\x00\x00YXz\xf0\x97\x87\'\x1a\x00\x00\x00\
\x00IEND\xaeB`\x82'
def getHTMLBitmap():
@ -217,6 +217,4 @@ def getHTMLImage():
return ImageFromStream(stream)
def getHTMLIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getHTMLBitmap())
return icon
return wx.IconFromBitmap(getHTMLBitmap())

View File

@ -15,6 +15,7 @@ import wx.lib.docview
import wx.lib.pydocview
import sys
import wx.grid
import os.path
_ = wx.GetTranslation
ACTIVEGRID_BASE_IDE = False
@ -318,6 +319,10 @@ class IDEApplication(wx.lib.pydocview.DocApp):
outlineService.StartBackgroundTimer()
if not ACTIVEGRID_BASE_IDE:
propertyService.AddTemplateForBackgroundHandler(dataModelTemplate)
propertyService.AddTemplateForBackgroundHandler(processModelTemplate)
propertyService.AddTemplateForBackgroundHandler(viewTemplate)
propertyService.AddTemplateForBackgroundHandler(dataModelChildTemplate)
propertyService.StartBackgroundTimer()
self.SetDefaultIcon(getActiveGridIcon())
@ -341,7 +346,8 @@ class IDEApplication(wx.lib.pydocview.DocApp):
if not ACTIVEGRID_BASE_IDE:
if not welcomeService.RunWelcomeIfFirstTime():
wx.CallAfter(self.ShowTip, docManager.FindSuitableParent(), wx.CreateFileTipProvider("activegrid/tool/data/tips.txt", 0))
if os.path.exists("activegrid/tool/data/tips.txt"):
wx.CallAfter(self.ShowTip, docManager.FindSuitableParent(), wx.CreateFileTipProvider("activegrid/tool/data/tips.txt", 0))
return True
@ -368,7 +374,6 @@ class IDEMDIParentFrame(wx.lib.pydocview.DocMDIParentFrame):
# Icon Bitmaps - generated by encode_bitmaps.py
#----------------------------------------------------------------------------
from wx import ImageFromStream, BitmapFromImage
from wx import EmptyIcon
import cStringIO
def getSplashData():
@ -1963,63 +1968,28 @@ def getSplashImage():
#----------------------------------------------------------------------
def getActiveGridData():
return \
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\
\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x05cID\
ATX\x85\xed\x97\xcbo\x1b\xd7\x15\xc6\x7fw^\x1c\x92C\x8a\xa4DQ\xa2)\xd9\xb2%?\
\xe0\xa7\x82\xc0\x85\x83"\xa8\x1b\x17AwYtQtU\xb4\x8b\xa2\x7fH\xfe\x8c\xee\
\x8b\xac\x124\xab\x02E\n\x17h\x01\x17\x86Q7\xaac7~I\xb2hZ\xe2sH\xce\x83s\xef\
\xedB\xa6dI~))\x90E\xf2\x01\x17\x98\xb9s\xe7\x9c\xef\x9c\xf9\xce\xb9w\x840L\
\xbeK\x18\xdf\xa9\xf7\x1f\x08\x00\xa2\xd5ji!\x04\xe3\xf1ma\x9a\x02!\x0c\xe0\
\xa0-\xa55O\xb6\x06t\xfb\x11\xa0\x98\xca\x99\x880\x0c5\xf0R\xe7B\x08\xb4\xde\
\xbd6\xc4\xd8\xee\x0bk\xb5\xde3\'\x84f\x10J\x06aB4R\xd8\x96\xc1\x97\x8f{\xfc\
\xfbq\x97-?\xa2\xe49\x9c\x9d\xf38u\xc4\xa3\x945\xb0\xc6\x8e\r!`\x1f\t!\xd8C\
\x004\x89\xd4\x04\xb1$\x88%#\xa9(f,\xd6\xdb!\xab\x9b\x01\x9b\xbd\x98 \x96\
\xb4z\x11\xa6\x80\xea\x94K\x9ch\xfe\xf5\xa0\xcb\xfa\xd6\x90\xea\xa4\xcb\x99Z\
\x8e\xead\x96\xa2\x97\xc2\x14\t\xd6s\xf3h\x04JC"\xf5\xf3\xa1\x00M.c\xd1\xe9\
\'\xf4\x82\x11\xc3H\xd2\x0f\x13\xda~L\xcb\x8fI\x12\xc9\x953\x93\\\xff\xaa\
\xc9\x17\xb7\xb7\xf8j\xdd\xa7\x13J\x82aB\xad\x94\xe2\x83\xe5)\xba\xc3\x84\
\xde a\xa6\x98\xe2\xc3wf\xb8\xbcX\xa2\xe89(\xa5\x08\x82\xd1\x98\x00\x04qB/\
\x1c\xd1\xf6Gl\xf6"\x9euc\x84\xd0\xfc\xf4\\\x99Oo\xd4\xf9\xe2\xf6\x16w\x9f\
\x0chG\t\xbe\x1f\x13\xf9#\xa63\x16\x1f\xff\xee\x027\xefw\xb9\xf5\xb0K\xc7\
\x8f\x11\xa6`a\xc6\xe5\xdc\xbc\xc7\xfcT\x06/msa~\x82\xa5\xd9\x1c\x8em`\x08\
\xd0Z\xa1\x94\x02\xc0\xb2,\x8b\x8d\xe6\x90\xcfnl\xf0\xf9\xcd\x06\xf1H\x13E\
\x92h0\xa2\x906\xe9\x0eF\xf4#I<\x88\xb9w\xa7I\x9cs\xc8\xa5-\xcae\x97\xa3\x93\
i\xdc\x94\xa0\xe4\xd9\x143\x16\xfd~\xc4\xf4D\x8ak\x17\xa6\xb9z\xae\xcc\xd1r\
\x06\xc76)dm\xb2)\x03\xa5\xf7jLk\xb0\xc6\x9f~\xbd\x19r}\xa5\xc9\xb0\x9fl?\
\x1d)&2\x16n\xe9\x19?_.sf>\xcf\xbd\xc7>x6\xaeka\n0S&~\x980\x88\x12l[\xb08\
\x9b\xe1\xda\xa5\nW\xcfW8;\x9f\'\xefZ;\x02\xd5Z\xa3\xb5~\xae\xa5\xdd\xaa\xb3\
\x94R\x94<\x87\xc5\xaa\xc7\xe9#9V\xee\xb61\x1d\x13\xc7\xb3I\xa7L\xfe[\x1f\
\xf0\xd1\xe5\x19\x96O\x97\x08\x84\xa6\xd1\x0c\xe9\r\x136\xfd\x98F7f\xbd\x19Q\
\xefD\xa4]\x93\xf7O\x95\xf9\xed\xb5\x05\xa6\x0bi\xd0\xa0\xb5\x06\xa5w\x8a\
\xe6\xc5J\x13B`Y\x16\x96\x94\n\xc76\xf9\xd9\xc5il\x03>\x1e\xc6\x94\x8b.\xc7g\
2\xcc\x16]\xc2(a\xbd\x19\xa2\xd0,U\xb2\xfc\xf1\xcf\xab\xb4\xba#\xd2\x9eM\xed\
H\x96 N\xa8\xe4m~\xb4X\xe47W\x8f\x92\xcf\xd8\xe8\xfd\xb9~\x05l\xdb\xde\x16\
\xa1R\x8a\xa9\xbc\xc3\xd5\xf3\x15\x8a\x9e\xc3\xadG\x1dV\xd6|\xfe\xfa\xe5\x16\
\x83@"\xa4f\xf9D\x9eKKE\xe6k9\xaa\x15I\xca1\xc9y\x16\xbd0ay\xa1\xc0\xf2B\x91\
B\xd6\xd9\x8ez\x7f-\xbf\x04\xe3lX\xdb\xcdF\xe3\x98\x06\xd5\x92Kmj\x96l\xc6\
\xa4\xd1\x89\xf8\xc7\x9d6O\x9e\x05\xa8 \xc1\x16P\x9b\xcd\xf2\xd1{U\xfe\xb3\
\xda\xe5\xd1\xd3!A?\xa1\x92Oq\xf1X\x81\x93\xd5\xdc[E\xbd\x1f;e8f\xae\xb5\xe0\
lm\x82\xa7\xa7c\xd67CB\x7fD\xa4!\x1a):\xc3\x84_\xfd\xf8\x08\x1b\xad!\x8f\x1a\
CD\xa4x\xf7x\x81\xc5\x19\x8fl\xcaDJu\xe8v.\xe28\xd6cu\x8e\xb3\xa1\x81`\xa4y\
\xd8\x18\xf0\xc9\xdf\xd6ht\x02\x0c\xd3`\xc2\xb3\t\xa5\xa2\xde\x8eX\xdb\n0\
\x81?\xfc\xfe"\x8b3y,\xcb\xf8F\x04,8\xb8\x0f\x18B\xe0\xa5\x04K\xb3Y~\xf9\xfe\
\x1c\xc3(\xe1\xc6\xd7m>\xffg\x9d\x87\xf7{,\x1d\xcfsr6K\xde5\x01\x81T\x1a\xeb\
%v\xde\x9a\xc0\x9e\x94<7\xa2\xb5&e\x19\x9c\x9d\xcbo\xef\th\xee\xac\xf6xp\xb7\
\x8b\x1f\x8c\xa8\x98i\xe6\xa6\\6\xfd\x98\xf2\xc4\xb6(w\xeb\xfc[\x10x\x81\xca\
\x9e\xe6qy\xb1Dm2\x83e\x18\xdcZ\xed\xd2\xe8\x84,L\xbb\xdc\xaf\x0f\xa8\x163L\
\xe6R\x87\x0b}\xec%\x8e\xe3\x9d\xba\xd9\xcf~,\xcc\xf1\xbc\xd2\xb0\xd9\r\xb8\
\xf9\xa0\xc3\xdf\xef5Yy\xd2\xe7|-\xc7/\xae\xd4\xb8t\xac\x88\x94\xf2\xff\x99\
\x81\x83\x84L\x01\xd5R\x1a\xcb2\t\x13\xcd\xd7\x8d!\xd7\xef\xb4x\xf7D\x89ss\
\x13\x98\xc6\xee\xf9\xe1M\xd0Z\x93$\xc9\xe1\x8edZk\x94\x86r>\xc5\x85\xa3\x05\
\xde;9\x89\xd2\xb0\xb2\xd6\xe3\xee\x86\x8fa\x18\xe3\x85oM\xe0\xb5\x198\x00!P\
J\x03\x9a\xc5J\x86_\xff\xe4\x18\x00\xb7\x1ev\xf8\xd3\xcd\xa7,\xcd\xe6\xb0\
\x0e\x11\x92R\xea\xf5\x1ax\x15\xf3\x9dk\xa0\xd9O\xf8\xcb\xed\x06\x1b\xed\x80\
\x13\x95,\x1f\x9c\x9f\xc6s\xdf\x1c\xd7\xf6\x81$\xc08\xd0\xbb\xdf\x80=;\x1a0\
\x9dw\xb8rj\x92w\x16\nH\xa9h\xf9\x11\xe1H\x1e \xfb*[\x96\x94r\xe7\xe6\xb0\n\
\xd6Z\xa3\x94b\xae\x94"\x97\x12<\xde2\x08\xa2\x98 2\xb0\r\xe7\xb5}AJ\xb9]5\
\xf5z]\x03\xbb\x02\xfa\x06\x10\x80m\x1b\x18\xa6\xc9\xda3\x1f\xd71\xc9\xb9\
\xf6k\xdf\x91R\x12E\x11\xe2\x87\x7f\xc3\xef=\x81\xff\x01\x1d\xae\x83\xc3q\
\xb9\xc6\x9f\x00\x00\x00\x00IEND\xaeB`\x82'
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
\x00\x01\xe9IDAT8\x8d\xc5\x93\xbfkSq\x14\xc5?\xf7\xfb}\xf1\xe5%1\xadVm1\xa5Z\
\x7f\x81%\xa8\x88\xc5\x0e\xba\x89?\xb6n\x82[\x07\'E\x07\xb1\xff\x808(\xe8\
\xea`\x11ADpPp\x10\xa5(\x08..b\xb0C\xd5\x8a6\xadF\xb4\xe5\xd54\xef%/y\xef}\
\x1dl,-\xa9\x0e\x1d<\xeb\xbd\xe7\xdc\xc3\xbd\xe7\x8a(\xcdj\xa0V\xc5\x06\xc4\
\xf7}\xa3\xf5\xbf]X\x96"6B\x14C\xd0\x88\x98\xf8:GWVai\xad\x11\x11\x94j\x9a1\
\x08B%hPr\x03\x9c\x84\xe2\xc1\xab\x12\x9f\xbey\xf4v\xa5\xf8X\xaa\x90\xb65CGz\
\xc9$\x05KD(\xfe\xf0\x19\x9b\x9eg|\xb2\xcc\xf1\x03\x9d\x9c\xb9Q\xa0\xf0\xa5B\
\xe8\x06\\?\xbf\x8f\xab\x0f?\x90\xeb\xb0\xc9o\xc9p\xfa\xe86\xf2=Y\xe2\xd8\
\xe0y\x1e\x96\xd6\x8a\x9b\xcf\x8a\\\xb9;\x0e\xc0\xcb\t\x97\x83;\xdaI\xa7,f\
\xe6\xeb\x94\xfd\x90\xdd\xb9\x14\xd7\x86\xf6\x90\xefi\x03 \x8ebXpm\x85a\xc4\
\xf0\xe0N\xdeM\x97\xd9\xd8f\xd3hD\xec\xda\x9ae\xe4\xe9g6mHQk\x84\xdc:\xd7O\
\xf7\xfa$\xc647\'\x008\x8e\x83\x12\x112\xb6\xe2\xfe\xc5\x01\x1c[s\xfbq\x91{\
\xcf\x8b\x8c\\\xd8O\xbd\xd6\xe0\xd8\xdeN6\xb7\'\x89cC+H\xbd^7"\x821\x06\xad5\
w^L26\xf5\x93\xd7\xef\xe7\x88-x4<@\xca\xb6\x16\xa7/\xc3\x9f\x1c\x88\x08Q\x14\
q\xeaP7gOl\xa7Z\r\xe9\xcb\xa5y[,\xafH^"\xd0\x14\x11\x11r\xeb\x1cF/\x1fF)\x8b\
\xd1\xc2\xf7\xdf\xc7m\xa1\x12E\xd1\xcaI\\\xa3\x15\x97N\xf615[er\xb6\xda\xb2\
\xa7V\xab!A\x10\x98\xc5\x10-\x87\xc1\xf5B\x9e\xbc)1\xd8\x9f#\x99P\xc8\xc2\
\x05\x00|\xdfG\\\xd7\xfd\x8b\x00\x08\x90\xb0-J3\x1e\x1dk\xed%5\xdf\xf7\x91\
\xff\xfe\x8d\xbf\x00\xff\xd5\xb5\xd8\x1d!\x93\x80\x00\x00\x00\x00IEND\xaeB`\
\x82'
def getActiveGridBitmap():
return BitmapFromImage(getActiveGridImage())
@ -2029,9 +1999,7 @@ def getActiveGridImage():
return ImageFromStream(stream)
def getActiveGridIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getActiveGridBitmap())
return icon
return wx.IconFromBitmap(getActiveGridBitmap())
#----------------------------------------------------------------------
def getDPLData():
@ -2051,6 +2019,4 @@ def getDPLImage():
return ImageFromStream(stream)
def getDPLIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getDPLBitmap())
return icon
return wx.IconFromBitmap(getDPLBitmap())

View File

@ -1,445 +0,0 @@
#----------------------------------------------------------------------------
# Name: IDEFindService.py
# Purpose: Find Service for pydocview
#
# Author: Morgan Hua
#
# Created: 8/15/03
# CVS-ID: $Id$
# Copyright: (c) 2004-2005 ActiveGrid, Inc.
# License: wxWindows License
#----------------------------------------------------------------------------
import wx
import wx.lib.docview
import os
from os.path import join
import re
import ProjectEditor
import MessageService
import FindService
import OutlineService
_ = wx.GetTranslation
#----------------------------------------------------------------------------
# Constants
#----------------------------------------------------------------------------
FILENAME_MARKER = _("Found in file: ")
PROJECT_MARKER = _("Searching project: ")
FIND_MATCHDIR = "FindMatchDir"
FIND_MATCHDIRSUBFOLDERS = "FindMatchDirSubfolders"
SPACE = 10
HALF_SPACE = 5
class IDEFindService(FindService.FindService):
#----------------------------------------------------------------------------
# Constants
#----------------------------------------------------------------------------
FINDALL_ID = wx.NewId() # for bringing up Find All dialog box
FINDDIR_ID = wx.NewId() # for bringing up Find Dir dialog box
def InstallControls(self, frame, menuBar = None, toolBar = None, statusBar = None, document = None):
FindService.FindService.InstallControls(self, frame, menuBar, toolBar, statusBar, document)
editMenu = menuBar.GetMenu(menuBar.FindMenu(_("&Edit")))
wx.EVT_MENU(frame, IDEFindService.FINDALL_ID, self.ProcessEvent)
wx.EVT_UPDATE_UI(frame, IDEFindService.FINDALL_ID, self.ProcessUpdateUIEvent)
editMenu.Append(IDEFindService.FINDALL_ID, _("Find in Project...\tCtrl+Shift+F"), _("Searches for the specified text in all the files in the project"))
wx.EVT_MENU(frame, IDEFindService.FINDDIR_ID, self.ProcessEvent)
wx.EVT_UPDATE_UI(frame, IDEFindService.FINDDIR_ID, self.ProcessUpdateUIEvent)
editMenu.Append(IDEFindService.FINDDIR_ID, _("Find in Directory..."), _("Searches for the specified text in all the files in the directory"))
def ProcessEvent(self, event):
id = event.GetId()
if id == IDEFindService.FINDALL_ID:
self.ShowFindAllDialog()
return True
elif id == IDEFindService.FINDDIR_ID:
self.ShowFindDirDialog()
return True
else:
return FindService.FindService.ProcessEvent(self, event)
def ProcessUpdateUIEvent(self, event):
id = event.GetId()
if id == IDEFindService.FINDALL_ID:
projectService = wx.GetApp().GetService(ProjectEditor.ProjectService)
view = projectService.GetView()
if view and view.GetDocument() and view.GetDocument().GetFiles():
event.Enable(True)
else:
event.Enable(False)
return True
elif id == IDEFindService.FINDDIR_ID:
event.Enable(True)
else:
return FindService.FindService.ProcessUpdateUIEvent(self, event)
def ShowFindDirDialog(self):
config = wx.ConfigBase_Get()
frame = wx.Dialog(None, -1, _("Find in Directory"), size= (320,200))
borderSizer = wx.BoxSizer(wx.HORIZONTAL)
contentSizer = wx.BoxSizer(wx.VERTICAL)
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, config.Read(FIND_MATCHDIR, ""), size=(200,-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)
def OnBrowseButton(event):
dlg = wx.DirDialog(frame, _("Choose a directory:"), style=wx.DD_DEFAULT_STYLE)
dir = dirCtrl.GetValue()
if len(dir):
dlg.SetPath(dir)
if dlg.ShowModal() == wx.ID_OK:
dirCtrl.SetValue(dlg.GetPath())
dirCtrl.SetToolTipString(dirCtrl.GetValue())
dirCtrl.SetInsertionPointEnd()
dlg.Destroy()
wx.EVT_BUTTON(findDirButton, -1, OnBrowseButton)
subfolderCtrl = wx.CheckBox(frame, -1, _("Search in subfolders"))
subfolderCtrl.SetValue(config.ReadInt(FIND_MATCHDIRSUBFOLDERS, True))
contentSizer.Add(subfolderCtrl, 0, wx.BOTTOM, SPACE)
lineSizer = wx.BoxSizer(wx.VERTICAL) # let the line expand horizontally without vertical expansion
lineSizer.Add(wx.StaticLine(frame, -1, size = (10,-1)), 0, flag=wx.EXPAND)
contentSizer.Add(lineSizer, flag=wx.EXPAND|wx.ALIGN_CENTER_VERTICAL|wx.BOTTOM, border=HALF_SPACE)
lineSizer = wx.BoxSizer(wx.HORIZONTAL)
lineSizer.Add(wx.StaticText(frame, -1, _("Find what:")), 0, wx.ALIGN_CENTER | wx.RIGHT, HALF_SPACE)
findCtrl = wx.TextCtrl(frame, -1, config.Read(FindService.FIND_MATCHPATTERN, ""), size=(200,-1))
lineSizer.Add(findCtrl, 0, wx.LEFT, HALF_SPACE)
contentSizer.Add(lineSizer, 0, wx.BOTTOM, SPACE)
wholeWordCtrl = wx.CheckBox(frame, -1, _("Match whole word only"))
wholeWordCtrl.SetValue(config.ReadInt(FindService.FIND_MATCHWHOLEWORD, False))
matchCaseCtrl = wx.CheckBox(frame, -1, _("Match case"))
matchCaseCtrl.SetValue(config.ReadInt(FindService.FIND_MATCHCASE, False))
regExprCtrl = wx.CheckBox(frame, -1, _("Regular expression"))
regExprCtrl.SetValue(config.ReadInt(FindService.FIND_MATCHREGEXPR, False))
contentSizer.Add(wholeWordCtrl, 0, wx.BOTTOM, SPACE)
contentSizer.Add(matchCaseCtrl, 0, wx.BOTTOM, SPACE)
contentSizer.Add(regExprCtrl, 0, wx.BOTTOM, SPACE)
borderSizer.Add(contentSizer, 0, wx.TOP | wx.BOTTOM | wx.LEFT, SPACE)
buttonSizer = wx.BoxSizer(wx.VERTICAL)
findBtn = wx.Button(frame, wx.ID_OK, _("Find"))
findBtn.SetDefault()
buttonSizer.Add(findBtn, 0, wx.BOTTOM, HALF_SPACE)
buttonSizer.Add(wx.Button(frame, wx.ID_CANCEL, _("Cancel")), 0)
borderSizer.Add(buttonSizer, 0, wx.ALL, SPACE)
frame.SetSizer(borderSizer)
frame.Fit()
status = frame.ShowModal()
# save user choice state for this and other Find Dialog Boxes
dirString = dirCtrl.GetValue()
searchSubfolders = subfolderCtrl.IsChecked()
self.SaveFindDirConfig(dirString, searchSubfolders)
findString = findCtrl.GetValue()
matchCase = matchCaseCtrl.IsChecked()
wholeWord = wholeWordCtrl.IsChecked()
regExpr = regExprCtrl.IsChecked()
self.SaveFindConfig(findString, wholeWord, matchCase, regExpr)
while not os.path.exists(dirString):
dlg = wx.MessageDialog(frame,
_("'%s' does not exist.") % dirString,
_("Find in Directory"),
wx.OK | wx.ICON_EXCLAMATION
)
dlg.ShowModal()
dlg.Destroy()
status = frame.ShowModal()
# save user choice state for this and other Find Dialog Boxes
dirString = dirCtrl.GetValue()
searchSubfolders = subfolderCtrl.IsChecked()
self.SaveFindDirConfig(dirString, searchSubfolders)
findString = findCtrl.GetValue()
matchCase = matchCaseCtrl.IsChecked()
wholeWord = wholeWordCtrl.IsChecked()
regExpr = regExprCtrl.IsChecked()
self.SaveFindConfig(findString, wholeWord, matchCase, regExpr)
if status == wx.ID_CANCEL:
break
if status == wx.ID_OK:
frame.Destroy()
messageService = wx.GetApp().GetService(MessageService.MessageService)
messageService.ShowWindow()
view = messageService.GetView()
if view:
wx.GetApp().GetTopWindow().SetCursor(wx.StockCursor(wx.CURSOR_WAIT))
view.ClearLines()
view.SetCallback(self.OnJumpToFoundLine)
view.AddLines(_("Searching for '%s' in '%s'\n\n") % (findString, dirString))
if os.path.isfile(dirString):
try:
docFile = file(dirString, 'r')
lineNum = 1
needToDisplayFilename = True
line = docFile.readline()
while line:
count, foundStart, foundEnd, newText = self.DoFind(findString, None, line, 0, 0, True, matchCase, wholeWord, regExpr)
if count != -1:
if needToDisplayFilename:
view.AddLines(FILENAME_MARKER + dirString + "\n")
needToDisplayFilename = False
line = repr(lineNum).zfill(4) + ":" + line
view.AddLines(line)
line = docFile.readline()
lineNum += 1
if not needToDisplayFilename:
view.AddLines("\n")
except IOError, (code, message):
print _("Warning, unable to read file: '%s'. %s") % (dirString, message)
else:
# do search in files on disk
for root, dirs, files in os.walk(dirString):
if not searchSubfolders and root != dirString:
break
for name in files:
filename = os.path.join(root, name)
try:
docFile = file(filename, 'r')
except IOError, (code, message):
print _("Warning, unable to read file: '%s'. %s") % (filename, message)
continue
lineNum = 1
needToDisplayFilename = True
line = docFile.readline()
while line:
count, foundStart, foundEnd, newText = self.DoFind(findString, None, line, 0, 0, True, matchCase, wholeWord, regExpr)
if count != -1:
if needToDisplayFilename:
view.AddLines(FILENAME_MARKER + filename + "\n")
needToDisplayFilename = False
line = repr(lineNum).zfill(4) + ":" + line
view.AddLines(line)
line = docFile.readline()
lineNum += 1
if not needToDisplayFilename:
view.AddLines("\n")
view.AddLines(_("Search completed."))
wx.GetApp().GetTopWindow().SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))
return True
else:
frame.Destroy()
return False
def SaveFindDirConfig(self, dirString, searchSubfolders):
""" Save search dir patterns and flags to registry.
dirString = search directory
searchSubfolders = Search subfolders
"""
config = wx.ConfigBase_Get()
config.Write(FIND_MATCHDIR, dirString)
config.WriteInt(FIND_MATCHDIRSUBFOLDERS, searchSubfolders)
def ShowFindAllDialog(self):
config = wx.ConfigBase_Get()
frame = wx.Dialog(None, -1, _("Find in Project"), size= (320,200))
borderSizer = wx.BoxSizer(wx.HORIZONTAL)
contentSizer = wx.BoxSizer(wx.VERTICAL)
lineSizer = wx.BoxSizer(wx.HORIZONTAL)
lineSizer.Add(wx.StaticText(frame, -1, _("Find what:")), 0, wx.ALIGN_CENTER | wx.RIGHT, HALF_SPACE)
findCtrl = wx.TextCtrl(frame, -1, config.Read(FindService.FIND_MATCHPATTERN, ""), size=(200,-1))
lineSizer.Add(findCtrl, 0, wx.LEFT, HALF_SPACE)
contentSizer.Add(lineSizer, 0, wx.BOTTOM, SPACE)
wholeWordCtrl = wx.CheckBox(frame, -1, _("Match whole word only"))
wholeWordCtrl.SetValue(config.ReadInt(FindService.FIND_MATCHWHOLEWORD, False))
matchCaseCtrl = wx.CheckBox(frame, -1, _("Match case"))
matchCaseCtrl.SetValue(config.ReadInt(FindService.FIND_MATCHCASE, False))
regExprCtrl = wx.CheckBox(frame, -1, _("Regular expression"))
regExprCtrl.SetValue(config.ReadInt(FindService.FIND_MATCHREGEXPR, False))
contentSizer.Add(wholeWordCtrl, 0, wx.BOTTOM, SPACE)
contentSizer.Add(matchCaseCtrl, 0, wx.BOTTOM, SPACE)
contentSizer.Add(regExprCtrl, 0, wx.BOTTOM, SPACE)
borderSizer.Add(contentSizer, 0, wx.TOP | wx.BOTTOM | wx.LEFT, SPACE)
buttonSizer = wx.BoxSizer(wx.VERTICAL)
findBtn = wx.Button(frame, wx.ID_OK, _("Find"))
findBtn.SetDefault()
buttonSizer.Add(findBtn, 0, wx.BOTTOM, HALF_SPACE)
buttonSizer.Add(wx.Button(frame, wx.ID_CANCEL, _("Cancel")), 0)
borderSizer.Add(buttonSizer, 0, wx.ALL, SPACE)
frame.SetSizer(borderSizer)
frame.Fit()
status = frame.ShowModal()
# save user choice state for this and other Find Dialog Boxes
findString = findCtrl.GetValue()
matchCase = matchCaseCtrl.IsChecked()
wholeWord = wholeWordCtrl.IsChecked()
regExpr = regExprCtrl.IsChecked()
self.SaveFindConfig(findString, wholeWord, matchCase, regExpr)
if status == wx.ID_OK:
frame.Destroy()
messageService = wx.GetApp().GetService(MessageService.MessageService)
messageService.ShowWindow()
view = messageService.GetView()
if view:
view.ClearLines()
view.SetCallback(self.OnJumpToFoundLine)
projectService = wx.GetApp().GetService(ProjectEditor.ProjectService)
projectFilenames = projectService.GetFilesFromCurrentProject()
projView = projectService.GetView()
if projView:
projName = wx.lib.docview.FileNameFromPath(projView.GetDocument().GetFilename())
view.AddLines(PROJECT_MARKER + projName + "\n\n")
# do search in open files first, open files may have been modified and different from disk because it hasn't been saved
openDocs = wx.GetApp().GetDocumentManager().GetDocuments()
openDocsInProject = filter(lambda openDoc: openDoc.GetFilename() in projectFilenames, openDocs)
for openDoc in openDocsInProject:
if isinstance(openDoc, ProjectEditor.ProjectDocument): # don't search project model
continue
openDocView = openDoc.GetFirstView()
# some views don't have a in memory text object to search through such as the PM and the DM
# even if they do have a non-text searchable object, how do we display it in the message window?
if not hasattr(openDocView, "GetValue"):
continue
text = openDocView.GetValue()
lineNum = 1
needToDisplayFilename = True
start = 0
end = 0
count = 0
while count != -1:
count, foundStart, foundEnd, newText = self.DoFind(findString, None, text, start, end, True, matchCase, wholeWord, regExpr)
if count != -1:
if needToDisplayFilename:
view.AddLines(FILENAME_MARKER + openDoc.GetFilename() + "\n")
needToDisplayFilename = False
lineNum = openDocView.LineFromPosition(foundStart)
line = repr(lineNum).zfill(4) + ":" + openDocView.GetLine(lineNum)
view.AddLines(line)
start = text.find("\n", foundStart)
if start == -1:
break
end = start
if not needToDisplayFilename:
view.AddLines("\n")
openDocNames = map(lambda openDoc: openDoc.GetFilename(), openDocs)
# do search in closed files, skipping the open ones we already searched
filenames = filter(lambda filename: filename not in openDocNames, projectFilenames)
for filename in filenames:
try:
docFile = file(filename, 'r')
except IOError, (code, message):
print _("Warning, unable to read file: '%s'. %s") % (filename, message)
continue
lineNum = 1
needToDisplayFilename = True
line = docFile.readline()
while line:
count, foundStart, foundEnd, newText = self.DoFind(findString, None, line, 0, 0, True, matchCase, wholeWord, regExpr)
if count != -1:
if needToDisplayFilename:
view.AddLines(FILENAME_MARKER + filename + "\n")
needToDisplayFilename = False
line = repr(lineNum).zfill(4) + ":" + line
view.AddLines(line)
line = docFile.readline()
lineNum += 1
if not needToDisplayFilename:
view.AddLines("\n")
view.AddLines(_("Search for '%s' completed.") % findString)
return True
else:
frame.Destroy()
return False
def OnJumpToFoundLine(self, event):
messageService = wx.GetApp().GetService(MessageService.MessageService)
lineText, pos = messageService.GetView().GetCurrLine()
if lineText == "\n" or lineText.find(FILENAME_MARKER) != -1 or lineText.find(PROJECT_MARKER) != -1:
return
lineEnd = lineText.find(":")
if lineEnd == -1:
return
else:
lineNum = int(lineText[0:lineEnd])
text = messageService.GetView().GetText()
curPos = messageService.GetView().GetCurrentPos()
startPos = text.rfind(FILENAME_MARKER, 0, curPos)
endPos = text.find("\n", startPos)
filename = text[startPos + len(FILENAME_MARKER):endPos]
foundView = None
openDocs = wx.GetApp().GetDocumentManager().GetDocuments()
for openDoc in openDocs:
if openDoc.GetFilename() == filename:
foundView = openDoc.GetFirstView()
break
if not foundView:
doc = wx.GetApp().GetDocumentManager().CreateDocument(filename, wx.lib.docview.DOC_SILENT)
foundView = doc.GetFirstView()
if foundView:
foundView.GetFrame().SetFocus()
foundView.Activate()
if hasattr(foundView, "GotoLine"):
foundView.GotoLine(lineNum)
startPos = foundView.PositionFromLine(lineNum)
# wxBug: Need to select in reverse order, (end, start) to put cursor at head of line so positioning is correct
# Also, if we use the correct positioning order (start, end), somehow, when we open a edit window for the first
# time, we don't see the selection, it is scrolled off screen
foundView.SetSelection(startPos - 1 + len(lineText[lineEnd:].rstrip("\n")), startPos)
wx.GetApp().GetService(OutlineService.OutlineService).LoadOutline(foundView, position=startPos)

View File

@ -62,21 +62,20 @@ class ImageView(wx.lib.docview.View):
# Icon Bitmaps - generated by encode_bitmaps.py
#----------------------------------------------------------------------------
from wx import ImageFromStream, BitmapFromImage
from wx import EmptyIcon
import cStringIO
def getImageData():
return \
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x0f\x00\x00\x00\x0e\x08\x06\
\x00\x00\x00\xf0\x8aF\xef\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
\x00\x00\x97IDAT(\x91\x9d\x93Q\n\xc4 \x0cD\'\xda\xd3\xa9\xe9ac\xdb\x8bx\xa0\
\xf4C"\xd6mAw@\x0c1/\t\x03\x123+\x16\x95s\x06\x00l\x00p\x9c\x17\xad\xc0\xe4<\
R\x0c\xeaf\x81\x14\x83\xa6\x18\x1e[N\xc1)\x06\x15\x01Dj\xbc\x04\x7fi\x9b):\
\xce\x8b\xf6\xbdN\xec\xfd\x99\x82G\xc8\xf4\xba\xf6\x9b9o\xfa\x81\xab9\x02\
\x11i\xe6|6cf%\xe7A\xce\x83\x99\xd5\xc4\xccZJ\xd11\xd7\xd76\xd8\x8aJ)\xed\
\xb6c\x8d,~\xc0\xe3\xe3L\xdc\xe0~\xcaJ\x03\xfa\xe7c\x98n\x01\x88\xc6k\xb1\
\x83\x04\x87\x00\x00\x00\x00IEND\xaeB`\x82'
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x02\
\x00\x00\x00\x90\x91h6\x00\x00\x00\x03sBIT\x08\x08\x08\xdb\xe1O\xe0\x00\x00\
\x00\x9aIDAT(\x91\x95\x92\xc1\r\xc50\x08C\xdd\xaa\xeb\xc12\xec\x90\x9b\x97!\
\x0b\xb0\x03\x19\xe8\x1fR\xa9U\xf2\xd5\xb4>DH\xf8\t\x13\xb1E\x04\xbe\xe8\x00\
@\xf2\x8d\xb5\xd6z\x02\x00\xccl\t\x98\x19\xc9}\xe9#y\x8f\xb0\x00H\xba\xc3\
\xfd\x8a\xbd\x9e0\xe8xn\x9b\x99*q[r\x01`\xfa\x8f?\x91\x86-\x07\x8d\x00Iww\
\xf7\xce\xcc\xf0>\xbb\x01\xa8j)e\x80G\xa0\xb7[k\x00J)\xfdU\xd5\xd6Z\x87O_D\
\x88\x88\x88dff>\x17"r\x02y\xd33\xb3E\xc4\xcb\xe3\xeb\xda\xbe\x9e\xf7\x0f\
\xa0B\x86\xd5X\x16\xcc\xea\x00\x00\x00\x00IEND\xaeB`\x82'
def getImageBitmap():
@ -87,7 +86,5 @@ def getImageImage():
return ImageFromStream(stream)
def getImageIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getImageBitmap())
return icon
return wx.IconFromBitmap(getImageBitmap())

View File

@ -442,12 +442,13 @@ class OutlineService(Service.Service):
if not self.GetView():
return
self.SaveExpansionState()
if view.DoLoadOutlineCallback(force=force):
self.GetView().OnSort(wx.ConfigBase_Get().ReadInt("OutlineSort", SORT_NONE))
self.LoadExpansionState()
if position >= 0:
self.SyncToPosition(position)
if hasattr(view, "DoLoadOutlineCallback"):
self.SaveExpansionState()
if view.DoLoadOutlineCallback(force=force):
self.GetView().OnSort(wx.ConfigBase_Get().ReadInt("OutlineSort", SORT_NONE))
self.LoadExpansionState()
if position >= 0:
self.SyncToPosition(position)
def SyncToPosition(self, position):
@ -501,8 +502,8 @@ class OutlineService(Service.Service):
foundRegisteredView = True
break
if not foundRegisteredView:
self.GetView().ClearTreeCtrl()
if not foundRegisteredView:
self.GetView().ClearTreeCtrl()
self._timer.Start(1000) # 1 second interval

View File

@ -269,7 +269,6 @@ PHPKEYWORDS = [
# Icon Bitmaps - generated by encode_bitmaps.py
#----------------------------------------------------------------------------
from wx import ImageFromStream, BitmapFromImage
from wx import EmptyIcon
import cStringIO
@ -292,6 +291,4 @@ def getPHPImage():
return ImageFromStream(stream)
def getPHPIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getPHPBitmap())
return icon
return wx.IconFromBitmap(getPHPBitmap())

View File

@ -387,29 +387,29 @@ PERLKEYWORDS = [
# Icon Bitmaps - generated by encode_bitmaps.py
#----------------------------------------------------------------------------
from wx import ImageFromStream, BitmapFromImage
from wx import EmptyIcon
import cStringIO
def getPerlData():
return \
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x0e\x00\x00\x00\x10\x08\x06\
\x00\x00\x00&\x94N:\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\
\x01mIDAT(\x91\x9d\x93/\x8e\xf30\x10\xc5\x7f[\xed\x05\xca\x82,Ef\xc6e\x01Vx{\
\x89\x04\x16\x94\x97\x045\xa8\xa0\xa44G\x08\xc9\x01\xa2\x80\x1e $ld\xc9\xa8w\
\x08\xf0\xa2x\x93~\x1f\xda\x91F\xb2\xfd\xe6=\xcd?\x7f\xcd\xf3\x1c\xf8\x83}/\
\x87i\x9a\x000\xc6D\xb0\xeb:\x86a MS\xce\xe7\xf3\x968M\x13}\xdf\xe3\x9cCD\
\xb8\xddn\x18c\xe8\xba\x8e\xb2,\xc9\xb2\x0c\x11\x01\xd8\x90w\xc6\x18\x94R\
\xf1\xa1\xef{\xba\xae\xa3i\x1a\xb4\xd6h\xad)\x8a\x02\xe7\\\xccj\x93\xea\xa2\
\nP\xd75\xd7\xeb\x15\x00\xef\xfdFt)e\xb7\x80\x8b\xbas\x8e$I\xe2}\xc1\x8b\xa2\
\xd8\xf4b\x07\xa0\x94\xe2\xf5za\xad\xc5Z\xcb\xfb\xfdFD\xe8\xfb\x9e\x05\x17\
\x11\x9cs4M\xf3K<\x9dNdY\xc60\x0cx\xef\x11\x11\xea\xbaF)\x85s\x8e\xba\xae)\
\xcb\x12\x11!M\xd3_"\xc0\xfd~\xc7Z\x8bs\x0e\x80$I\xa2:@UU1u\x00\xe6y\x0ek\
\x1f\xc71\x1c\x0e\x87\xd0\xb6m\xd8\xef\xf7\xe1\xf1x\x84\xcb\xe5\x12\xe6y\x0e\
\xc7\xe31\xc6\xed\xf80\x11!\xcb2\xbc\xf7TUE\x9e\xe71=\xadul\xce\xf7\'Qk\x8d\
\xf7\x9e<\xcf\x81\xed&Yk\xb7\xe3\xf84\xa5\x14\xc6\x18D\x84\xe7\xf3\x19\x83\
\xd75\xfe\x97\xb8\x0eXo\xcc2\x9e\x7f\x9a3\x8ech\xdb6|6l\xf15\xf6\xf5\xd7o\
\xf5\x03\xaf\x9f\xfa@\x02\xe4\xdc\xf9\x00\x00\x00\x00IEND\xaeB`\x82'
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
\x00\x01\x81IDAT8\x8d\xa5S1n\xe30\x10\x1cJ\xf9\x80;U\x04\x04~\xc06\xdc\xa9\
\x10\xd4\xb3K\xf2\x01\xf9\x01F\x92\xce\x8d:vI\x84\xdc\xd5\xaa\xdc%\xd1\x17\
\x0c\x17ns\xa7\x07,\x16\xe0G6E@B\x91\x9c*\x0b\x10 \xb9\xe4\xecpg\xa8T\x92\
\xe27q5^\xbc\xbf\xbd\n\x00\\\xdf\xdc\xaa\xb0\xf7\xfc\xf4(\xcc\x8c<\xcfqw\xff\
\xa0\xa6\x00PI\x8aa\x18\xa4m[\xd9\xedvb\xad\x95a\x18D%)\xfa\xbe\x97\xc5b!\
\xd6Z\xb1\xd6J\xdb\xb6\xa2\x92\x14\xe3\x91\x00\xc0r\xb5VZ\xeb\x08z<\x1e\xf1\
\xfe\xf6*]\xd7\xc1\x18\x03c\x0c\xea\xba\x063\xe3\xff\xbf\x0f\xf9\xf1\tD\x14\
\xe7\xce9\xec\xf7{\x00\x80\xf7\xfe\x1b\xf88\x920\xf1\xde\xc7j\xcc\x8c,\xcb\
\xe2:\xe4\xeb\xba\x06\x80o,"\x03\xad5\x0e\x87C\xacz>\x9fAD\xb1\xba\xd6\x1aD\
\x04f\x063\xcf\x19\\\xdf\xdc\xaa\xa2(p:\x9d\xe0\xbd\x07\x11\xc19\x07\xad5\
\x98\x19\xce9l\xb7[\x10\x11\xf2<\x9f\x03\x00\xc0\xcb\x9f\xbf\xaa,\xcbX!\xcb2\
t]\x17\xf3M\xd3\xc4\'\xc5\x98\xca\x12d\xddl6\x12d\x0c\x12\xab$\x85\xb5Vf2N\
\x83\x88P\x14\x05\xbc\xf7h\x9a\x06UUE\xda\xc6\x98\xcbM\x1c\x871\x06\xde{TU\
\x05\xe0\xcb\'\xe1RY\x96X\xae\xd6\xd1\x91\x17\x19\x00_]_\xae\xd6\x8a\x88\xf0\
\xfc\xf4(\xe1\xd2\xb4\x07?\x02\x8c\x0f\x8e\x1d85\xd2\xc5\x06\xf6}?\xf3|\x18\
\xb3\xdco\xbf\xf3\'`\xa6\xbc1\xa7\xd6\xcb\xbf\x00\x00\x00\x00IEND\xaeB`\x82'\
def getPerlBitmap():
@ -420,6 +420,4 @@ def getPerlImage():
return ImageFromStream(stream)
def getPerlIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getPerlBitmap())
return icon
return wx.IconFromBitmap(getPerlBitmap())

View File

@ -39,15 +39,16 @@ else:
#----------------------------------------------------------------------------
# XML Marshalling Methods
#----------------------------------------------------------------------------
LOCAL_TYPE_MAPPING = { "projectmodel" : "activegrid.tool.ProjectEditor.ProjectModel", }
def load(fileObject):
xml = fileObject.read()
projectModel = activegrid.util.xmlmarshaller.unmarshal(xml)
projectModel = activegrid.util.xmlmarshaller.unmarshal(xml, knownTypes=LOCAL_TYPE_MAPPING)
return projectModel
def save(fileObject, projectModel):
xml = activegrid.util.xmlmarshaller.marshal(projectModel, prettyPrint=True)
xml = activegrid.util.xmlmarshaller.marshal(projectModel, prettyPrint=True, knownTypes=LOCAL_TYPE_MAPPING)
fileObject.write(xml)
@ -69,7 +70,7 @@ class ProjectDocument(wx.lib.docview.Document):
def __init__(self):
wx.lib.docview.Document.__init__(self)
self._projectModel = ProjectModel()
def GetModel(self):
return self._projectModel
@ -174,6 +175,7 @@ class ProjectDocument(wx.lib.docview.Document):
self.SetFilename(filename, True)
view.AddProjectToView(self)
self.SetDocumentModificationDate()
self.UpdateAllViews()
self._savedYet = True
view.Activate(True)
@ -780,25 +782,21 @@ class ProjectView(wx.lib.docview.View):
for i, item in enumerate(self._GetChildItems(self._treeCtrl.GetRootItem())):
if i == 0:
firstItem = item
if expandedProjects[i]:
self._treeCtrl.Expand(item)
else:
self._treeCtrl.Collapse(item)
# wxBug: This causes a crash, tried using ScrollTo which crashed as well. Then tried calling it with wx.CallAfter and that crashed as well, with both EnsureVisible and ScrollTo
# self._treeCtrl.EnsureVisible(self._treeCtrl.GetRootItem())
# So doing the following massive hack which forces the treectrl to scroll up to the top item
if firstItem:
if expandedProjects[i]:
self._treeCtrl.Collapse(firstItem)
self._treeCtrl.Expand(firstItem)
else:
self._treeCtrl.Expand(firstItem)
self._treeCtrl.Collapse(firstItem)
self._treeCtrl.EnsureVisible(firstItem)
def GetSelectedFile(self):
for item in self._treeCtrl.GetSelections():
return self._GetItemFile(item)
def AddProjectToView(self, document):
rootItem = self._treeCtrl.GetRootItem()
projectItem = self._treeCtrl.AppendItem(rootItem, self._MakeProjectName(document))
@ -814,17 +812,6 @@ class ProjectView(wx.lib.docview.View):
if self._embeddedWindow:
document.GetCommandProcessor().SetEditMenu(wx.GetApp().GetEditMenu(self._GetParentFrame()))
#----------------------------------------------------------------------------
# Methods for OutlineService
#----------------------------------------------------------------------------
def DoLoadOutlineCallback(self, force=False):
""" Project Editor is a special case for the Outline Service.
You need to be able to be active in the Project Manager without clearing
the Outline View. So we make the Project Editor a client of the Outline
Service, but we don't load anything in the Outline View, leaving the
contents of the Outline View alone (e.g. last document's outline view).
"""
pass
#----------------------------------------------------------------------------
# Control events
@ -1375,9 +1362,10 @@ class ProjectOptionsPanel(wx.Panel):
projectBorderSizer = wx.BoxSizer(wx.VERTICAL)
projectSizer = wx.BoxSizer(wx.VERTICAL)
projectSizer.Add(self._projSaveDocsCheckBox, 0, wx.ALL, HALF_SPACE)
self._projShowWelcomeCheckBox = wx.CheckBox(self, -1, _("Show Welcome Dialog"))
self._projShowWelcomeCheckBox.SetValue(config.ReadInt("RunWelcomeDialog", True))
projectSizer.Add(self._projShowWelcomeCheckBox, 0, wx.ALL, HALF_SPACE)
if not ACTIVEGRID_BASE_IDE:
self._projShowWelcomeCheckBox = wx.CheckBox(self, -1, _("Show Welcome Dialog"))
self._projShowWelcomeCheckBox.SetValue(config.ReadInt("RunWelcomeDialog", True))
projectSizer.Add(self._projShowWelcomeCheckBox, 0, wx.ALL, HALF_SPACE)
projectBorderSizer.Add(projectSizer, 0, wx.ALL, SPACE)
self.SetSizer(projectBorderSizer)
self.Layout()
@ -1398,7 +1386,8 @@ class ProjectOptionsPanel(wx.Panel):
def OnOK(self, optionsDialog):
config = wx.ConfigBase_Get()
config.WriteInt("ProjectSaveDocs", self._projSaveDocsCheckBox.GetValue())
config.WriteInt("RunWelcomeDialog", self._projShowWelcomeCheckBox.GetValue())
if not ACTIVEGRID_BASE_IDE:
config.WriteInt("RunWelcomeDialog", self._projShowWelcomeCheckBox.GetValue())
class ProjectService(Service.Service):
@ -1793,7 +1782,6 @@ class ProjectService(Service.Service):
# Icon Bitmaps - generated by encode_bitmaps.py
#----------------------------------------------------------------------------
from wx import ImageFromStream, BitmapFromImage
from wx import EmptyIcon
import cStringIO
@ -1814,23 +1802,20 @@ def getProjectImage():
return ImageFromStream(stream)
def getProjectIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getProjectBitmap())
return icon
return wx.IconFromBitmap(getProjectBitmap())
#----------------------------------------------------------------------------
def getBlankData():
return \
"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\
\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x00\
\x85IDATX\x85\xed\x97\xc9\n\xc0 \x0cD3\xda\xff\xffcMo\x96Z\xc4\xa5\x91\x14:9\
\x8a\xe8\xcb\xd3\xb8\x00!\x8ag\x04\xd7\xd9E\xe4\xa8\x1b4'}3 B\xc4L\x7fs\x03\
\xb3\t<\x0c\x94\x81tN\x04p%\xae9\xe9\xa8\x89m{`\xd4\x84\xfd\x12\xa8\x16{#\
\x10\xdb\xab\xa0\x07a\x0e\x00\xe0\xb6\x1fz\x10\xdf;\x07V\xa3U5\xb5\x8d:\xdc\
\r\x10\x80\x00\x04 \x00\x01\x08@\x80\xe6{\xa0w\x8f[\x85\xbb\x01\xfc\xfeoH\
\x80\x13>\xf9(3zH\x1e\xfb\x00\x00\x00\x00IEND\xaeB`\x82"
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
\x00\x00]IDAT8\x8d\xed\x931\x0e\xc00\x08\x03m\x92\xff\xff8q\x87\xb6C\x11\x89\
\xa8X:\xd4\x13\x03:\x1b\x01\xa45T\xd4\xefBsh\xd7Hk\xdc\x02\x00@\x8a\x19$\xa1\
9\x14A,\x95\xf3\x82G)\xd3\x00\xf24\xf7\x90\x1ev\x07\xee\x1e\xf4:\xc1J?\xe0\
\x0b\x80\xc7\x1d\xf8\x1dg\xc4\xea7\x96G8\x00\xa8\x91\x19(\x85#P\x7f\x00\x00\
\x00\x00IEND\xaeB`\x82'
def getBlankBitmap():
@ -1841,7 +1826,5 @@ def getBlankImage():
return ImageFromStream(stream)
def getBlankIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getBlankBitmap())
return icon
return wx.IconFromBitmap(getBlankBitmap())

View File

@ -581,7 +581,6 @@ class PythonOptionsPanel(wx.Panel):
# Icon Bitmaps - generated by encode_bitmaps.py
#----------------------------------------------------------------------------
from wx import ImageFromStream, BitmapFromImage
from wx import EmptyIcon
import cStringIO
@ -609,6 +608,4 @@ def getPythonImage():
return ImageFromStream(stream)
def getPythonIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getPythonBitmap())
return icon
return wx.IconFromBitmap(getPythonBitmap())

View File

@ -53,6 +53,7 @@ class TextDocument(wx.lib.docview.Document):
docFile.write(view.GetValue())
docFile.close()
self.Modify(False)
self.SetDocumentModificationDate()
self.SetDocumentSaved(True)
return True
@ -64,6 +65,7 @@ class TextDocument(wx.lib.docview.Document):
view.SetValue(data)
self.SetFilename(filename, True)
self.Modify(False)
self.SetDocumentModificationDate()
self.UpdateAllViews()
self._savedYet = True
return True
@ -979,8 +981,7 @@ class TextCtrl(wx.stc.StyledTextCtrl):
self._font = None
self._fontColor = None
self.SetVisiblePolicy(wx.stc.STC_VISIBLE_STRICT,0)
self.SetYCaretPolicy(0, 0)
self.SetVisiblePolicy(wx.stc.STC_VISIBLE_STRICT,1)
self.CmdKeyClear(wx.stc.STC_KEY_ADD, wx.stc.STC_SCMOD_CTRL)
self.CmdKeyClear(wx.stc.STC_KEY_SUBTRACT, wx.stc.STC_SCMOD_CTRL)
@ -1220,7 +1221,6 @@ class TextCtrl(wx.stc.StyledTextCtrl):
# Icon Bitmaps - generated by encode_bitmaps.py
#----------------------------------------------------------------------------
from wx import ImageFromStream, BitmapFromImage
from wx import EmptyIcon
import cStringIO
@ -1243,9 +1243,7 @@ def getTextImage():
return ImageFromStream(stream)
def getTextIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getTextBitmap())
return icon
return wx.IconFromBitmap(getTextBitmap())
#----------------------------------------------------------------------------

View File

@ -192,10 +192,11 @@ class ServiceView(wx.EvtHandler):
def Show(self, show = True):
self.GetFrame().Show(show)
if self._embeddedWindow:
mdiParentFrame = wx.GetApp().GetTopWindow()
mdiParentFrame.ShowEmbeddedWindow(self.GetFrame(), show)
if self.GetFrame():
self.GetFrame().Show(show)
if self._embeddedWindow:
mdiParentFrame = wx.GetApp().GetTopWindow()
mdiParentFrame.ShowEmbeddedWindow(self.GetFrame(), show)
class Service(wx.lib.pydocview.DocService):

View File

@ -112,4 +112,4 @@ def PluralName(name):
return name[0:-1] + 'ies'
else:
return name + 's'

View File

@ -129,7 +129,6 @@ XMLKEYWORDS = [
# Icon Bitmaps - generated by encode_bitmaps.py
#----------------------------------------------------------------------------
from wx import ImageFromStream, BitmapFromImage
from wx import EmptyIcon
import cStringIO
@ -137,18 +136,18 @@ def getXMLData():
return \
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
\x00\x01\x18IDAT8\x8d\xed\x92=N\xc3P\x0c\xc7\x7f~\xc9K\xd2\xa0\x16\xa9\xdc\
\x84+\xf4\x06\x1c\xa1\x12\x133\xa7`\xea\x05\xba\xc0\xc0\xd0\x93\x80*uc``e\t\
\x82\xb6J\xf3Q?3D\x04\x81`\xea\xc2\x80\x17K\xb6\xfc\xff\xb0-ff\x1c\x10\xee\
\x90\xe1\xbf\x01\x10s}\x0em\tu\t\xfb\x06\xcbFP\xad\x11\x17\x81\x196\x18!\xdb\
\x02\xd2#hk\xc8\x8f\t\xc1p\x89g\xb9\\\x11\xdb\xfd-\xbcn\x91\xa8C\x94,\x81\
\xaa\xe9\x19\xe4\x1b\xa3}R\xf3\xf0\x08\x0e\x9f\x81\xef\x9c\x94s\x83\xaa\xe92\
P\xcf\nv\xa7g\xd4\xb3\xa2\xef\xaf\xc5#i\x04\x89#\x8a\x05\'m\r)\x84\r\xe4S\
\xa1\x9c\x1b\xf9\xb4\xe3\xd5\xe1\x18?\xb9@\x87\xe3^\x81\xbe\xb5H\xab`\x013\
\xc3\xa9\xf3h\x15pC\xfa\xe1\x0f\x05\x00\xf1\xd5\xe4\x8b\x85la\x10@[0q\x88]\
\x9e\x18/\x05\xe8/k\xde\x01\x83\x1f\xea\x19,\x9e\x1c\xf1\xcdj\xc3\xae\x01jP\
\x05\x9fv\x07q1\x88\x83(\x8f\xd0\x8d"1h\x05\xba\x077\x80$\x87\xbb\xe7\x80\
\xfc\xbf\xf2\xe1\x00\xef\x8c\xb8x\x06\x07\xd1$\xff\x00\x00\x00\x00IEND\xaeB`\
\x00\x01\x1aIDAT8\x8d\xed\x92?N\xc3P\x0c\xc6\x7fv\xf2\x924\xa8E*7\xe1\n\xbd\
\x01G\xa8\xd8\x989\x05S/\xd0\x0110\xf4$\xa0J\xdd\x18\x18XY\x82\xa0\xad\xd2\
\xfc\xe9{f\x08-\x02\xc1\xd4\x85\x01/\xb6l\xd9\xdf\xf7\xd9\x16\xd1\x88CL\x0f\
\xea\xfe\x13\x03\xc4\xae\xcf\x8d\xb6\x84\xba\x84m\x83e\x03\xa8\x96\x88F`\x86\
\xf5\x06\xc8\xba\x80\xf4\x08\xda\x1a\xf2cB04q\xcc\xe7\x0bb\xbb\xbf\x85\xd75\
\xf2\xb1K\xc9\x12\xa8\x9aO\x84o\x88\xb6\x0bbxx\x04\xc5e\xe0:%\xe5\xd4\xa0j:\
\x0f\xd4\x93\x82\xcd\xe9\x19\xf5\xa4\xd8\xd7\x97\xe2\x904\x82D\x89bA\xa5\xad\
!\x85\xb0\x82|,\x94S#\x1fw\xb8\xbe?\xc4\x8d.\xf0\xfd\xe1\x9e\x81\x7fk\x91\
\xd6\x83\x05\xcc\x0c\xf5\xea\xf0U@\xfb\xec\x9bw\x0c\x00\xe2\xab\xd1\x17\t\
\xd9\xcc \x80o\xc1D\x11\xbb<1^\n\xf0\xbf\xacy\x03\xf4~\xc8g0{R\xe2\x9b\xc5\
\x8aM\x03\xd4\xe0=\xb8\xb4;\x88\xc6 \nQ\x1e\xe1W\x1e\x89\xc1W\xe0\xb7\xa0=Hr\
\xb8{\x0e\xc8\xff+\x1f>\xe0\x1d~\xafr\x13\x04HY"\x00\x00\x00\x00IEND\xaeB`\
\x82'
@ -160,6 +159,4 @@ def getXMLImage():
return ImageFromStream(stream)
def getXMLIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getXMLBitmap())
return icon
return wx.IconFromBitmap(getXMLBitmap())

View File

@ -594,7 +594,8 @@ class Module :
warnings.append(w)
return 0
except:
w = Warning(self.moduleName, 1, sys.exc_info()[0] + " NOT PROCESSED UNABLE TO IMPORT")
exc_type, exc_value, exc_tb = sys.exc_info()
w = Warning(self.moduleName, 1, "%s: %s.\nUnable to import module %s." % (exc_type, exc_value, self.moduleName))
warnings.append(w)
importError(self.moduleName)
return 0

View File

@ -1,84 +0,0 @@
#----------------------------------------------------------------------------
# Name: aglogging.py
# Purpose: Utilities to help with logging
#
# Author: Jeff Norton
#
# Created: 01/04/05
# CVS-ID: $Id$
# Copyright: (c) 2005 ActiveGrid, Inc.
# License: wxWindows License
#----------------------------------------------------------------------------
import sys
import os
import re
import traceback
global agTestMode
agTestMode = False
def setTestMode(mode):
global agTestMode
if (mode):
agTestMode = True
else:
agTestMode = False
def getTestMode():
global agTestMode
return agTestMode
def testMode(normalObj, testObj=None):
if getTestMode():
return testObj
return normalObj
def toDiffableString(value):
s = repr(value)
ds = ""
i = s.find(" at 0x")
start = 0
while (i >= 0):
j = s.find(">", i)
if (j < i):
break
ds += s[start:i]
start = j
i = s.find(" at 0x", start)
return ds + s[start:]
def removeFileRefs(str):
str = re.sub(r'(?<=File ")[^"]*(\\[^\\]*")(, line )[0-9]*', _fileNameReplacement, str)
return str
def _fileNameReplacement(match):
return "...%s" % match.group(1)
def getTraceback():
extype, val, tb = sys.exc_info()
tbs = "\n"
for s in traceback.format_tb(tb):
tbs += s
return tbs
def reportException(out=None, stacktrace=False, diffable=False):
extype, val, t = sys.exc_info()
if (diffable):
exstr = removeFileRefs(str(val))
else:
exstr = str(val)
if (out == None):
print "Got Exception = %s: %s" % (extype, exstr)
else:
print >> out, "Got Exception = %s: %s" % (extype, exstr)
if (stacktrace):
fmt = traceback.format_exception(extype, val, t)
for s in fmt:
if (diffable):
s = removeFileRefs(s)
if (out == None):
print s
else:
print >> out, s

View File

@ -1,87 +0,0 @@
#----------------------------------------------------------------------------
# Name: cachedloader.py
# Purpose:
#
# Author: Joel Hare
#
# Created: 8/31/04
# CVS-ID: $Id$
# Copyright: (c) 2004-2005 ActiveGrid, Inc.
# License: wxWindows License
#----------------------------------------------------------------------------
import copy
import os.path
import string
import cStringIO
import time
# TODO: Instantiate the database and create a pool
class CachedLoader(object):
def __init__(self):
self.cache = {}
self.baseLoadDir = None
def fullPath(self, fileName):
if os.path.isabs(fileName):
absPath = fileName
elif self.baseLoadDir:
absPath = os.path.join(self.baseLoadDir, fileName)
else:
absPath = os.path.abspath(fileName)
return absPath
def setPrototype(self, fileName, loadedFile):
absPath = self.fullPath(fileName)
mtime = time.time() + 31536000.0 # Make sure prototypes aren't replaced by files on disk
self.cache[absPath] = (mtime, loadedFile)
def update(self, loader):
self.cache.update(loader.cache)
def clear(self):
self.cache.clear()
def delete(self, fileName):
absPath = self.fullPath(fileName)
del self.cache[absPath]
def needsLoad(self, fileName):
absPath = self.fullPath(fileName)
try:
cached = self.cache[absPath]
cachedTime = cached[0]
if cachedTime >= os.path.getmtime(absPath):
return False
except KeyError:
pass
return True
def load(self, fileName, loader):
absPath = self.fullPath(fileName)
loadedFile = None
try:
cached = self.cache[absPath]
except KeyError:
cached = None
if cached:
cachedTime = cached[0]
# ToDO We might need smarter logic for checking if a file needs to be reloaded
# ToDo We need a way to disable checking if this is a production server
if cachedTime >= os.path.getmtime(absPath):
loadedFile = cached[1]
if not loadedFile:
targetFile = file(absPath)
try:
mtime = os.path.getmtime(absPath)
loadedFile = loader(targetFile)
self.cache[absPath] = (mtime, loadedFile)
finally:
targetFile.close()
return loadedFile

View File

@ -1,145 +0,0 @@
#----------------------------------------------------------------------------
# Name: dependencymgr.py
# Purpose: Dependency Manager
#
# Author: Jeff Norton
#
# Created: 01/28/05
# CVS-ID: $Id$
# Copyright: (c) 2004-2005 ActiveGrid, Inc.
#----------------------------------------------------------------------------
DM_NO_ID = 0
DM_ID_ATTR = "_DependencyMgr__ID"
##class ManageableObject(object):
##
## def __init__(self):
## self.__id = DM_NO_ID
##
## def __repr__(self):
## return "<ManageableObject id = %s>" % self.__id
##
## def __getID(self):
## return self.__id
##
## def __setID(self, value):
## if (self.__id != DM_NO_ID):
## raise DependencyMgrException("Cannot set the dependency ID on object %s to \"%s\" because it already has one (\"%s\")." % (repr(self), value, self.__id))
## self.__id = value
##
## _DependencyMgr__ID = property(__getID, __setID)
class DependencyMgr(object):
def __init__(self):
self.clear()
def clear(self):
self.__dependencies = {}
self.__lastID = DM_NO_ID
def addDependency(self, parent, child):
pid = self._initObjectID(parent)
try:
parentCollection = self.__dependencies[pid]
except KeyError:
parentCollection = self._newDependencyCollection()
self.__dependencies[pid] = parentCollection
if (child not in parentCollection):
parentCollection.append(child)
def removeDependency(self, parent, child):
pid = self._getObjectID(parent)
if (pid != DM_NO_ID):
try:
parentCollection = self.__dependencies[pid]
parentCollection.remove(child)
if (len(parentCollection) == 0):
del self.__dependencies[pid]
except KeyError, ValueError:
pass
def clearDependencies(self, parent):
"Returns a list of objects or an empty list if no dependencies exist as for getDependencies, and then removes the dependency list."
pid = self._getObjectID(parent)
try:
deps = self.__dependencies[pid]
del self.__dependencies[pid]
return deps
except KeyError:
return []
def hasDependency(self, parent):
"Returns a boolean"
return (self._getObjectID(parent) in self.__dependencies)
def getDependencies(self, parent):
"Returns a list of objects or an empty list if no dependencies exist."
try:
return self.__dependencies[self._getObjectID(parent)]
except KeyError:
return []
def dumpState(self, out):
"Writes the state of the dependency manager (as reported by getState) to out"
for line in self.getState():
print >> out, line
def getState(self):
"Returns the state of the dependency manager including all managed objects as a list of strings"
out = []
out.append("DependencyMgr %s has %i parent objects, last id assigned is %i" % (repr(self), len(self.__dependencies), self.__lastID))
for key, val in self.__dependencies.iteritems():
out.append("Object %s has dependents: %s " % (repr(key), ", ".join([repr(d) for d in val])))
return out
def _initObjectID(self, obj):
try:
id = getattr(obj, DM_ID_ATTR)
except AttributeError:
id = DM_NO_ID
if (id == DM_NO_ID):
id = self._newID()
setattr(obj, DM_ID_ATTR, id)
return id
def _getObjectID(self, obj):
try:
id = getattr(obj, DM_ID_ATTR)
except AttributeError:
id = DM_NO_ID
return id
def _newID(self):
self.__lastID += 1
return self.__lastID
def _newDependencyCollection(self):
return []
globalDM = DependencyMgr()
def addDependency(parent, child):
getGlobalDM().addDependency(parent, child)
def removeDependency(parent, child):
getGlobalDM().removeDependency(parent, child)
def clearDependencies(parent):
return getGlobalDM().clearDependencies(parent)
def hasDependency(parent):
return getGlobalDM().hasDependency(parent)
def getDependencies(parent):
return getGlobalDM().getDependencies(parent)
def getState():
return getGlobalDM().getState()
def dumpState(out):
getGlobalDM().dumpState(out)
def getGlobalDM():
return globalDM

View File

@ -1,39 +0,0 @@
#----------------------------------------------------------------------------
# Name: fileutils.py
# Purpose: Active grid miscellaneous utilities
#
# Author: Jeff Norton
#
# Created: 12/10/04
# CVS-ID: $Id$
# Copyright: (c) 2004-2005 ActiveGrid, Inc.
# License: wxWindows License
#----------------------------------------------------------------------------
import os
def createFile(filename, mode='w'):
f = None
try:
f = file(filename, mode)
except:
os.makedirs(filename[:filename.rindex(os.sep)])
f = file(filename, mode)
return f
def compareFiles(file1, file2):
file1.seek(0)
file2.seek(0)
while True:
line1 = file1.readline()
line2 = file2.readline()
if (len(line1) == 0):
if (len(line2) == 0):
return 0
else:
return -1
elif (len(line2) == 0):
return -1
elif (line1 != line2):
return -1

View File

@ -1,36 +0,0 @@
#----------------------------------------------------------------------------
# Name: gettersetter.py
# Purpose:
#
# Author: Peter Yared
#
# Created: 7/28/04
# CVS-ID: $Id$
# Copyright: (c) 2004-2005 ActiveGrid, Inc.
# License: wxWindows License
#----------------------------------------------------------------------------
def gettersetter(list):
for attr in list:
lowercase = attr[0].lower() + attr[1:]
uppercase = attr[0].upper() + attr[1:]
print " def get%s(self):" % uppercase
print " return self._%s" % lowercase
print
print " def set%s(self, %s):" % (uppercase, lowercase)
print " self._%s = %s" % (lowercase, lowercase)
print
def listgettersetter(list):
for attr in list:
lowercase = attr[0].lower() + attr[1:]
uppercase = attr[0].upper() + attr[1:]
print " def get%s(self):" % uppercase
print " return self._%s" % lowercase
print
print " def add%s(self, %s):" % (uppercase[:-1], lowercase[:-1])
print " self._%s.append(%s)" % (lowercase, lowercase[:-1])
print
print " def remove%s(self, %s):" % (uppercase[:-1], lowercase[:-1])
print " self._%s.remove(%s)" % (lowercase, lowercase[:-1])
print

View File

@ -86,6 +86,13 @@ a list of the Python attribute names. e.g.:
__xmlattrnamespaces__ = { "ag":["firstName", "lastName", "addressLine1", "city"] }
name: __xmlattrgroups__
type: dict
description: a dict specifying groups of attributes to be wrapped in an enclosing tag.
The key is the name of the enclosing tag; the value is a list of attributes to include
within it. e.g.
__xmlattrgroups__ = {"name": ["firstName", "lastName"], "address": ["addressLine1", "city", "state", "zip"]}
"""
@ -132,22 +139,58 @@ XMLNS_PREFIX = XMLNS + ':'
XMLNS_PREFIX_LENGTH = len(XMLNS_PREFIX)
BASETYPE_ELEMENT_NAME = 'item'
# This list doesn't seem to be used.
# Internal documentation or useless? You make the call!
MEMBERS_TO_SKIP = ('__module__', '__doc__', '__xmlname__', '__xmlattributes__',
'__xmlexclude__', '__xmlflattensequence__', '__xmlnamespaces__',
'__xmldefaultnamespace__', '__xmlattrnamespaces__')
'__xmldefaultnamespace__', '__xmlattrnamespaces__',
'__xmlattrgroups__')
WELL_KNOWN_OBJECTS = { "xs:element" : "activegrid.model.schema.XsdElement",
"xs:complexType" : "activegrid.model.schema.XsdComplexType",
"xs:complexType" : "activegrid.model.schema.XsdComplexType",
"xs:element" : "activegrid.model.schema.XsdElement",
"xs:key" : "activegrid.model.schema.XsdKey",
"xs:field" : "activegrid.model.schema.XsdKeyField",
"xs:keyref" : "activegrid.model.schema.XsdKeyRef",
"xs:selector" : "activegrid.model.schema.XsdKeySelector",
"xs:schema" : "activegrid.model.schema.Schema",
"ag:schemaOptions":"activegrid.model.schema.SchemaOptions",
"ag:debug" : "activegrid.model.processmodel.DebugOperation",
}
#WELL_KNOWN_OBJECTS = { #"xs:element" : "activegrid.model.schema.XsdElement",
#"xs:complexType" : "activegrid.model.schema.XsdComplexType",
#"xs:sequence" : "activegrid.model.schema.XsdSequence",
#"xs:element" : "activegrid.model.schema.XsdElement",
#"xs:key" : "activegrid.model.schema.XsdKey",
#"xs:field" : "activegrid.model.schema.XsdKeyField",
#"xs:keyref" : "activegrid.model.schema.XsdKeyRef",
#"xs:selector" : "activegrid.model.schema.XsdKeySelector",
#"xs:schema" : "activegrid.model.schema.Schema",
#"ag:schemaOptions":"activegrid.model.schema.SchemaOptions",
#"ag:debug" : "activegrid.model.processmodel.DebugOperation",
#"ag:body" : "activegrid.model.processmodel.Body", # alan (start)
#"ag:cssRule" : "activegrid.model.processmodel.CssRule",
#"ag:datasource" : "activegrid.data.dataservice.DataSource",
#"ag:deployment" : "activegrid.server.deployment.Deployment",
#"ag:glue" : "activegrid.model.processmodel.Glue",
#"ag:hr" : "activegrid.model.processmodel.HorizontalRow",
#"ag:image" : "activegrid.model.processmodel.Image",
#"ag:inputs" : "activegrid.model.processmodel.Inputs",
#"ag:label" : "activegrid.model.processmodel.Label",
#"ag:processmodel" : "activegrid.model.processmodel.ProcessModel",
#"ag:processmodelref" : "activegrid.server.deployment.ProcessModelRef",
#"ag:query" : "activegrid.model.processmodel.Query",
#"ag:schemaref" : "activegrid.server.deployment.SchemaRef",
#"ag:set" : "activegrid.model.processmodel.SetOperation",
#"ag:text" : "activegrid.model.processmodel.Text",
#"ag:title" : "activegrid.model.processmodel.Title",
#"ag:view" : "activegrid.model.processmodel.View",
#"bpws:case" : "activegrid.model.processmodel.BPELCase",
#"bpws:invoke" : "activegrid.model.processmodel.BPELInvoke",
#"bpws:otherwise" : "activegrid.model.processmodel.BPELOtherwise",
#"bpws:process" : "activegrid.model.processmodel.BPELProcess",
#"bpws:reply" : "activegrid.model.processmodel.BPELReply",
#"bpws:switch" : "activegrid.model.processmodel.BPELSwitch",
#"bpws:variable" : "activegrid.model.processmodel.BPELVariable",
#"projectmodel" : "activegrid.tool.ProjectEditor.ProjectModel",
#"wsdl:message" : "activegrid.model.processmodel.WSDLMessage",
#"wsdl:part" : "activegrid.model.processmodel.WSDLPart",
#"xforms:group" : "activegrid.model.processmodel.XFormsGroup",
#"xforms:input" : "activegrid.model.processmodel.XFormsInput",
#"xforms:label" : "activegrid.model.processmodel.XFormsLabel",
#"xforms:output" : "activegrid.model.processmodel.XFormsOutput",
#"xforms:secret" : "activegrid.model.processmodel.XFormsSecret",
#"xforms:submit" : "activegrid.model.processmodel.XFormsSubmit"} # alan(end)
################################################################################
@ -161,7 +204,6 @@ def _objectfactory(objname, objargs=None, xsname=None):
'''dynamically create an object based on the objname and return
it. look it up in the BASETYPE_ELEMENT_MAP first.
'''
## print "_objectfactory creating an object of type %s and value %s, xsname=%s" % (objname, objargs, xsname)
# split the objname into the typename and module path,
# importing the module if need be.
if not isinstance(objargs, list):
@ -169,10 +211,11 @@ def _objectfactory(objname, objargs=None, xsname=None):
if (xsname):
try:
objname = WELL_KNOWN_OBJECTS[xsname]
objname = knownGlobalTypes[xsname]
except KeyError:
pass
## print "[objectfactory] creating an object of type %s and value %s, xsname=%s" % (objname, objargs, xsname)
objtype = objname.split('.')[-1]
pathlist = objname.split('.')
modulename = '.'.join(pathlist[0:-1])
@ -223,6 +266,13 @@ class Element:
return self.attrs.getValue('objtype')
else:
return 'str'
def toString(self):
print " name = ", self.name, "; attrs = ", self.attrs, "number of children = ", len(self.children)
i = -1
for child in self.children:
i = i + 1
childClass = child.__class__.__name__
print " Child ", i, " class: ",childClass
class XMLObjectFactory(xml.sax.ContentHandler):
@ -231,8 +281,23 @@ class XMLObjectFactory(xml.sax.ContentHandler):
self.elementstack = []
xml.sax.handler.ContentHandler.__init__(self)
def toString(self):
print "-----XMLObjectFactory Dump-------------------------------"
if (self.rootelement == None):
print "rootelement is None"
else:
print "rootelement is an object"
i = -1
print "length of elementstack is: ", len(self.elementstack)
for e in self.elementstack:
i = i + 1
print "elementstack[", i, "]: "
e.toString()
print "-----end XMLObjectFactory--------------------------------"
## ContentHandler methods
def startElement(self, name, attrs):
## print "startElement for name: ", name
if name.find(':') > -1: # Strip namespace prefixes for now until actually looking them up in xsd
name = name[name.index(':') + 1:]
## for attrname in attrs.getNames():
@ -251,22 +316,43 @@ class XMLObjectFactory(xml.sax.ContentHandler):
xsname = name
if name.find(':') > -1: # Strip namespace prefixes for now until actually looking them up in xsd
name = name[name.index(':') + 1:]
oldChildren = self.elementstack[-1].children
element = self.elementstack.pop()
if ((len(self.elementstack) > 1) and (self.elementstack[-1].getobjtype() == "None")):
parentElement = self.elementstack[-2]
## print "[endElement] %s: found parent with objtype==None: using its grandparent" % name
elif (len(self.elementstack) > 0):
parentElement = self.elementstack[-1]
objtype = element.getobjtype()
## print "element objtype is: ", objtype
if (objtype == "None"):
## print "[endElement] %s: skipping a (objtype==None) end tag" % name
return
constructorarglist = []
if element.content:
strippedElementContent = element.content.strip()
if strippedElementContent:
constructorarglist.append(element.content)
## print "[endElement] calling objectfactory"
obj = _objectfactory(objtype, constructorarglist, xsname)
complexType = None
if hasattr(obj, '__xsdcomplextype__'):
complexType = getattr(obj, '__xsdcomplextype__')
if (hasattr(obj, '__xmlname__') and getattr(obj, '__xmlname__') == "sequence"):
## print "[endElement] sequence found"
## self.toString()
self.elementstack[-1].children = oldChildren
## self.toString()
## print "done moving sequence stuff; returning"
return
if len(self.elementstack) > 0:
self.elementstack[-1].children.append((name, obj))
## print "[endElement] appending child with name: ", name, "; objtype: ", objtype
parentElement.children.append((name, obj))
## print "parentElement now has ", len(parentElement.children), " children"
else:
self.rootelement = obj
if element.attrs and not isinstance(obj, list):
## print "[endElement] %s: element has attrs and the obj is not a list" % name
for attrname, attr in element.attrs.items():
if attrname == XMLNS or attrname.startswith(XMLNS_PREFIX):
if attrname.startswith(XMLNS_PREFIX):
@ -298,28 +384,44 @@ class XMLObjectFactory(xml.sax.ContentHandler):
# stuff any child attributes meant to be in a sequence via the __xmlflattensequence__
flattenDict = {}
if hasattr(obj, '__xmlflattensequence__'):
for sequencename, xmlnametuple in obj.__xmlflattensequence__.items():
for xmlname in xmlnametuple:
flattenDict[xmlname] = sequencename
## print "[endElement] %s: obj has __xmlflattensequence__" % name
if (isinstance(obj.__xmlflattensequence__,dict)):
## print "[endElement] dict with obj.__xmlflattensequence__.items: ", obj.__xmlflattensequence__.items()
for sequencename, xmlnametuple in obj.__xmlflattensequence__.items():
for xmlname in xmlnametuple:
## print "[endElement]: adding flattenDict[%s] = %s" % (xmlname, sequencename)
flattenDict[xmlname] = sequencename
# handle __xmlflattensequence__ list/tuple (i.e. no element rename)
elif (isinstance(obj.__xmlflattensequence__,list) or isinstance(obj.__xmlflattensequence__,tuple)):
for sequencename in obj.__xmlflattensequence__:
flattenDict[sequencename] = sequencename
else:
raise "Invalid type for __xmlflattensequence___ : it must be a dict, list, or tuple"
# reattach an object's attributes to it
for childname, child in element.children:
## print "[endElement] childname is: ", childname, "; child is: ", child
if flattenDict.has_key(childname):
sequencename = _toAttrName(obj, flattenDict[childname])
## print "[endElement] sequencename is: ", sequencename
try:
## print "[endElement] obj.__dict__ is: ", obj.__dict__
sequencevalue = obj.__dict__[sequencename]
except AttributeError:
sequencevalue = None
except KeyError:
sequencevalue = None
if sequencevalue == None:
sequencevalue = []
obj.__dict__[sequencename] = sequencevalue
sequencevalue.append(child)
elif isinstance(obj, list):
## print "appended childname = ", childname
obj.append(child)
else:
## print "childname = %s, obj = %s, child = %s" % (childname, repr(obj), repr(child))
util.setattrignorecase(obj, _toAttrName(obj, childname), child)
## obj.__dict__[_toAttrName(obj, childname)] = child
obj.__dict__[_toAttrName(obj, childname)] = child
if complexType:
for element in complexType.elements:
@ -356,6 +458,11 @@ __typeMappingXsdToPython = {
"bool": "bool",
"str": "str",
"unicode": "unicode",
"short": "int",
"duration": "str", # see above (date)
"datetime": "str", # see above (date)
"time": "str", # see above (date)
"double": "float",
}
def xsdToPythonType(xsdType):
@ -370,13 +477,18 @@ def _getXmlValue(pythonValue):
else:
return str(pythonValue)
def unmarshal(xmlstr):
def unmarshal(xmlstr, knownTypes=None):
global knownGlobalTypes
if (knownTypes == None):
knownGlobalTypes = {}
else:
knownGlobalTypes = knownTypes
objectfactory = XMLObjectFactory()
xml.sax.parseString(xmlstr, objectfactory)
return objectfactory.getRootObject()
def marshal(obj, elementName=None, nameSpacePrefix='', nameSpaces=None, prettyPrint=False, indent=0):
def marshal(obj, elementName=None, nameSpacePrefix='', nameSpaces=None, prettyPrint=False, indent=0, knownTypes=None):
if prettyPrint or indent:
prefix = ' '*indent
newline = '\n'
@ -391,6 +503,8 @@ def marshal(obj, elementName=None, nameSpacePrefix='', nameSpaces=None, prettyPr
## attribute, else use the default generic BASETYPE_ELEMENT_NAME.
if not nameSpaces: nameSpaces = {} # Need to do this since if the {} is a default parameter it gets shared by all calls into the function
nameSpaceAttrs = ''
if knownTypes == None:
knownTypes = {}
if hasattr(obj, '__xmlnamespaces__'):
for nameSpaceKey, nameSpaceUrl in getattr(obj, '__xmlnamespaces__').items():
if nameSpaceUrl in nameSpaces:
@ -409,7 +523,7 @@ def marshal(obj, elementName=None, nameSpacePrefix='', nameSpaces=None, prettyPr
nameSpaceAttrs += ' xmlns:%s="%s" ' % (nameSpaceKey, nameSpaceUrl)
nameSpaceAttrs = nameSpaceAttrs.rstrip()
if hasattr(obj, '__xmldefaultnamespace__'):
nameSpacePrefix = getattr(obj, '__xmldefaultnamespace__') + ':'
nameSpacePrefix = getattr(obj, '__xmldefaultnamespace__') + ':'
if not elementName:
if hasattr(obj, '__xmlname__'):
elementName = nameSpacePrefix + obj.__xmlname__
@ -417,17 +531,24 @@ def marshal(obj, elementName=None, nameSpacePrefix='', nameSpaces=None, prettyPr
elementName = nameSpacePrefix + BASETYPE_ELEMENT_NAME
else:
elementName = nameSpacePrefix + elementName
if hasattr(obj, '__xmlsequencer__'):
elementAdd = obj.__xmlsequencer__
else:
elementAdd = None
## print "marshal: entered with elementName: ", elementName
members_to_skip = []
## Add more members_to_skip based on ones the user has selected
## via the __xmlexclude__ attribute.
if hasattr(obj, '__xmlexclude__'):
## print "marshal: found __xmlexclude__"
members_to_skip += list(obj.__xmlexclude__)
# Marshal the attributes that are selected to be XML attributes.
objattrs = ''
className = obj.__class__.__name__
classNamePrefix = "_" + className
if hasattr(obj, '__xmlattributes__'):
## print "marshal: found __xmlattributes__"
xmlattributes = obj.__xmlattributes__
members_to_skip += xmlattributes
for attr in xmlattributes:
@ -436,6 +557,7 @@ def marshal(obj, elementName=None, nameSpacePrefix='', nameSpaces=None, prettyPr
internalAttrName = classNamePrefix + attr
# Fail silently if a python attribute is specified to be
# an XML attribute but is missing.
## print "marshal: processing attribute ", internalAttrName
try:
value = obj.__dict__[internalAttrName]
except KeyError:
@ -447,6 +569,7 @@ def marshal(obj, elementName=None, nameSpacePrefix='', nameSpaces=None, prettyPr
## continue
xsdElement = None
if hasattr(obj, '__xsdcomplextype__'):
## print "marshal: found __xsdcomplextype__"
complexType = getattr(obj, '__xsdcomplextype__')
xsdElement = complexType.findElement(attr)
if xsdElement:
@ -468,6 +591,7 @@ def marshal(obj, elementName=None, nameSpacePrefix='', nameSpaces=None, prettyPr
attrNameSpacePrefix = ''
if hasattr(obj, '__xmlattrnamespaces__'):
## print "marshal: found __xmlattrnamespaces__"
for nameSpaceKey, nameSpaceAttributes in getattr(obj, '__xmlattrnamespaces__').items():
if nameSpaceKey == nameSpacePrefix[:-1]: # Don't need to specify attribute namespace if it is the same as it selement
continue
@ -477,41 +601,58 @@ def marshal(obj, elementName=None, nameSpacePrefix='', nameSpaces=None, prettyPr
## if attr.startswith('_'):
## attr = attr[1:]
if (hasattr(obj, "__xmlrename__") and attr in obj.__xmlrename__):
## print "marshal: found __xmlrename__ (and its attribute)"
attr = obj.__xmlrename__[attr]
objattrs += ' %s%s="%s"' % (attrNameSpacePrefix, attr, value)
## print "marshal: new objattrs is: ", objattrs
objtype = type(obj)
if isinstance(obj, NoneType):
#print "marshal: skipping an element with no type"
return ''
# return '%s<%s objtype="None"/>%s' % (prefix, elementName, newline)
elif isinstance(obj, bool):
return '%s<%s objtype="bool">%s</%s>%s' % (prefix, elementName, obj, elementName, newline)
xmlString = '%s<%s objtype="bool">%s</%s>%s' % (prefix, elementName, obj, elementName, newline)
#print "marshal: returning a bool element: \n", xmlString
return xmlString
elif isinstance(obj, int):
return '''%s<%s objtype="int">%s</%s>%s''' % (prefix, elementName, str(obj), elementName, newline)
xmlString = '''%s<%s objtype="int">%s</%s>%s''' % (prefix, elementName, str(obj), elementName, newline)
#print "marshal: returning a int element: \n", xmlString
return xmlString
elif isinstance(obj, long):
return '%s<%s objtype="long">%s</%s>%s' % (prefix, elementName, str(obj), elementName, newline)
xmlString = '%s<%s objtype="long">%s</%s>%s' % (prefix, elementName, str(obj), elementName, newline)
#print "marshal: returning a long element: \n", xmlString
return xmlString
elif isinstance(obj, float):
return '%s<%s objtype="float">%s</%s>%s' % (prefix, elementName, str(obj), elementName, newline)
xmlString = '%s<%s objtype="float">%s</%s>%s' % (prefix, elementName, str(obj), elementName, newline)
#print "marshal: returning a float element: \n", xmlString
return xmlString
elif isinstance(obj, basestring):
return '''%s<%s>%s</%s>%s''' % (prefix, elementName, saxutils.escape(obj), elementName, newline)
xmlString = '''%s<%s>%s</%s>%s''' % (prefix, elementName, saxutils.escape(obj), elementName, newline)
#print "marshal: returning a str element: \n", xmlString
return xmlString
## elif isinstance(obj, unicode):
## return '''%s<%s>%s</%s>%s''' % (prefix, elementName, obj, elementName, newline)
elif isinstance(obj, list):
if len(obj) < 1:
#print "marshal: skipping an empty list"
return ''
xmlString = '%s<%s objtype="list">%s' % (prefix, elementName, newline)
for item in obj:
xmlString += marshal(item, nameSpaces=nameSpaces, indent=indent+increment)
xmlString += marshal(item, nameSpaces=nameSpaces, indent=indent+increment, knownTypes=knownTypes)
xmlString += '%s</%s>%s' % (prefix, elementName, newline)
#print "marshal: returning a list element: \n", xmlString
return xmlString
elif isinstance(obj, tuple):
if len(obj) < 1:
#print "marshal: skipping an empty tuple"
return ''
xmlString = '%s<%s objtype="list" mutable="false">%s' % (prefix, elementName, newline)
for item in obj:
xmlString += marshal(item, nameSpaces=nameSpaces, indent=indent+increment)
xmlString += marshal(item, nameSpaces=nameSpaces, indent=indent+increment, knownTypes=knownTypes)
xmlString += '%s</%s>%s' % (prefix, elementName, newline)
#print "marshal: returning a tuple element: \n", xmlString
return xmlString
elif isinstance(obj, dict):
xmlString = '%s<%s objtype="dict">%s' % (prefix, elementName, newline)
@ -519,17 +660,33 @@ def marshal(obj, elementName=None, nameSpacePrefix='', nameSpaces=None, prettyPr
subindent = indent + 2*increment
for key, val in obj.iteritems():
xmlString += "%s<key>%s%s%s</key>%s%s<value>%s%s%s</value>%s" \
% (subprefix, newline, marshal(key, indent=subindent), subprefix, newline, subprefix, newline, marshal(val, nameSpaces=nameSpaces, indent=subindent), subprefix, newline)
% (subprefix, newline, marshal(key, indent=subindent, knownTypes=knownTypes), subprefix, newline, subprefix, newline, marshal(val, nameSpaces=nameSpaces, indent=subindent, knownTypes=knownTypes), subprefix, newline)
xmlString += '%s</%s>%s' % (prefix, elementName, newline)
#print "marshal: returning a dict element: \n", xmlString
return xmlString
else:
moduleName = obj.__class__.__module__
if (moduleName == "activegrid.model.schema"):
## print "marshal: found an activegrid.model.schema class element"
xmlString = '%s<%s%s%s' % (prefix, elementName, nameSpaceAttrs, objattrs)
else:
xmlString = '%s<%s%s%s objtype="%s.%s"' % (prefix, elementName, nameSpaceAttrs, objattrs, moduleName, className)
## print "marshal: found a ", moduleName, " class element"
# Only add the objtype if the element tag is unknown to us.
try:
objname = knownTypes[elementName]
## print "successfully mapped ", elementName, " to known-objtype ", objname
xmlString = '%s<%s%s%s' % (prefix, elementName, nameSpaceAttrs, objattrs)
except KeyError:
## print "failed to map elementName: ", elementName, "; knownTypes: ", knownTypes
xmlString = '%s<%s%s%s objtype="%s.%s"' % (prefix, elementName, nameSpaceAttrs, objattrs, moduleName, className)
## print "UnknownTypeException: Unknown type (%s.%s) passed to marshaller" % (moduleName, className)
# get the member, value pairs for the object, filtering out
# the types we don't support.
## print "marshal: elementString: \n", xmlString
if (elementAdd != None):
prefix += increment*' '
indent += increment
xmlMemberString = ''
if hasattr(obj, '__xmlbody__'):
xmlMemberString = getattr(obj, obj.__xmlbody__)
@ -542,50 +699,82 @@ def marshal(obj, elementName=None, nameSpacePrefix='', nameSpaces=None, prettyPr
## value = getattr(obj, key)
## entryList.append((key, value))
entryList.sort()
for name, value in entryList:
## # special name handling for private "__*" attributes:
## # remove the _<class-name> added by Python
## if name.startswith(classNamePrefix): name = name[len(classNamePrefix):]
if name in members_to_skip: continue
if name.startswith('__') and name.endswith('__'): continue
## idx = name.find('__')
## if idx > 0:
## newName = name[idx+2:]
## if newName:
## name = newName
subElementNameSpacePrefix = nameSpacePrefix
if hasattr(obj, '__xmlattrnamespaces__'):
for nameSpaceKey, nameSpaceValues in getattr(obj, '__xmlattrnamespaces__').items():
if name in nameSpaceValues:
subElementNameSpacePrefix = nameSpaceKey + ':'
break
# handle sequences listed in __xmlflattensequence__
# specially: instead of listing the contained items inside
# of a separate list, as god intended, list them inside
# the object containing the sequence.
if hasattr(obj, '__xmlflattensequence__') and name in obj.__xmlflattensequence__ and value:
try:
xmlnametuple = obj.__xmlflattensequence__[name]
xmlname = None
if len(xmlnametuple) == 1:
xmlname = xmlnametuple[0]
except:
xmlname = name
## xmlname = name.lower()
for seqitem in value:
xmlMemberString += marshal(seqitem, xmlname, subElementNameSpacePrefix, nameSpaces=nameSpaces, indent=indent+increment)
else:
if (hasattr(obj, "__xmlrename__") and name in obj.__xmlrename__):
xmlname = obj.__xmlrename__[name]
if hasattr(obj, '__xmlattrgroups__'):
attrGroups = obj.__xmlattrgroups__
if (not isinstance(attrGroups,dict)):
raise "__xmlattrgroups__ is not a dict, but must be"
for n in attrGroups:
v = attrGroups[n]
members_to_skip += v
else:
attrGroups = {}
# add the list of all attributes to attrGroups
eList = []
for x, z in entryList:
eList.append(x)
attrGroups['__nogroup__'] = eList
for eName in attrGroups:
eList = attrGroups[eName]
if (eName != '__nogroup__'):
prefix += increment*' '
indent += increment
xmlMemberString += '%s<%s objtype="None">%s' % (prefix, eName, newline)
for name in eList:
value = obj.__dict__[name]
## print " ", name, " = ", value
## # special name handling for private "__*" attributes:
## # remove the _<class-name> added by Python
## if name.startswith(classNamePrefix): name = name[len(classNamePrefix):]
if eName == '__nogroup__' and name in members_to_skip: continue
if name.startswith('__') and name.endswith('__'): continue
## idx = name.find('__')
## if idx > 0:
## newName = name[idx+2:]
## if newName:
## name = newName
## print "marshal: processing subElement ", name
subElementNameSpacePrefix = nameSpacePrefix
if hasattr(obj, '__xmlattrnamespaces__'):
for nameSpaceKey, nameSpaceValues in getattr(obj, '__xmlattrnamespaces__').items():
if name in nameSpaceValues:
subElementNameSpacePrefix = nameSpaceKey + ':'
break
# handle sequences listed in __xmlflattensequence__
# specially: instead of listing the contained items inside
# of a separate list, as god intended, list them inside
# the object containing the sequence.
if hasattr(obj, '__xmlflattensequence__') and name in obj.__xmlflattensequence__ and value:
try:
xmlnametuple = obj.__xmlflattensequence__[name]
xmlname = None
if len(xmlnametuple) == 1:
xmlname = xmlnametuple[0]
except:
xmlname = name
## xmlname = name.lower()
for seqitem in value:
xmlMemberString += marshal(seqitem, xmlname, subElementNameSpacePrefix, nameSpaces=nameSpaces, indent=indent+increment, knownTypes=knownTypes)
else:
xmlname = name
## xmlname = name.lower()
## # skip
## if xmlname.startswith('_') and not xmlname.startswith('__'):
## xmlname = xmlname[1:]
## if (indent > 30):
## print "getting pretty deep, xmlname = ", xmlname
xmlMemberString += marshal(value, xmlname, subElementNameSpacePrefix, nameSpaces=nameSpaces, indent=indent+increment)
if (hasattr(obj, "__xmlrename__") and name in obj.__xmlrename__):
xmlname = obj.__xmlrename__[name]
else:
xmlname = name
## xmlname = name.lower()
## # skip
## if xmlname.startswith('_') and not xmlname.startswith('__'):
## xmlname = xmlname[1:]
## if (indent > 30):
## print "getting pretty deep, xmlname = ", xmlname
## print "marshal: marshalling ", xmlname
xmlMemberString += marshal(value, xmlname, subElementNameSpacePrefix, nameSpaces=nameSpaces, indent=indent+increment, knownTypes=knownTypes)
## print "marshal: back with new xmlMemberString: \n", xmlMemberString
if (eName != '__nogroup__'):
## print "marshal: Completing attrGroup ", eName
xmlMemberString += '%s</%s>%s' % (prefix, eName, newline)
prefix = prefix[:-increment]
indent -= increment
# if we have nested elements, add them here, otherwise close the element tag immediately.
if xmlMemberString:
xmlString += '>'
@ -594,7 +783,13 @@ def marshal(obj, elementName=None, nameSpacePrefix='', nameSpaces=None, prettyPr
xmlString += '</%s>%s' % (elementName, newline)
else:
xmlString += newline
if (elementAdd != None):
xmlString += '%s<%s>%s' % (prefix, elementAdd, newline)
xmlString += xmlMemberString
if (elementAdd != None):
xmlString += '%s</%s>%s' % (prefix, elementAdd, newline)
prefix = prefix[:-increment]
indent -= increment
xmlString += '%s</%s>%s' % (prefix, elementName, newline)
else:
xmlString = xmlString + '/>%s' % newline

View File

@ -7,7 +7,7 @@
# Created: 8/15/03
# CVS-ID: $Id$
# Copyright: (c) 2003-2005 ActiveGrid, Inc.
# License: ASL 2.0 http://apache.org/licenses/LICENSE-2.0
# License: wxWindows License
#----------------------------------------------------------------------------
import wx

View File

@ -7,7 +7,7 @@
# Created: 5/15/03
# CVS-ID: $Id$
# Copyright: (c) 2003-2005 ActiveGrid, Inc.
# License: ASL 2.0 http://apache.org/licenses/LICENSE-2.0
# License: wxWindows License
#----------------------------------------------------------------------------
@ -17,6 +17,7 @@ import wx.lib.docview as docview
import wx.lib.pydocview as pydocview
import TextEditor
import FindService
import os.path
_ = wx.GetTranslation
@ -32,7 +33,8 @@ class TextEditorApplication(pydocview.DocApp):
pydocview.DocApp.OnInit(self)
# Show the splash dialog while everything is loading up
self.ShowSplash("splash.jpg")
if os.path.exists("splash.jpg"):
self.ShowSplash("splash.jpg")
# Set the name and the icon
self.SetAppName(_("wxPython PyDocView Demo"))
@ -61,8 +63,11 @@ class TextEditorApplication(pydocview.DocApp):
optionsService = self.InstallService(pydocview.DocOptionsService())
windowMenuService = self.InstallService(pydocview.WindowMenuService())
filePropertiesService = self.InstallService(pydocview.FilePropertiesService())
aboutService = self.InstallService(pydocview.AboutService(image=wx.Image("splash.jpg")))
if os.path.exists("splash.jpg"):
aboutService = self.InstallService(pydocview.AboutService(image=wx.Image("splash.jpg")))
else:
aboutService = self.InstallService(pydocview.AboutService())
# Install the TextEditor's option panel into the OptionsService
optionsService.AddOptionsPanel(TextEditor.TextOptionsPanel)
@ -77,10 +82,12 @@ class TextEditorApplication(pydocview.DocApp):
textTemplate.CreateDocument('', docview.DOC_NEW).OnNewDocument()
# Close the splash dialog
self.CloseSplash()
if os.path.exists("splash.jpg"):
self.CloseSplash()
# Show the tips dialog
wx.CallAfter(self.ShowTip, wx.GetApp().GetTopWindow(), wx.CreateFileTipProvider("tips.txt", 0))
if os.path.exists("tips.txt"):
wx.CallAfter(self.ShowTip, wx.GetApp().GetTopWindow(), wx.CreateFileTipProvider("tips.txt", 0))
# Tell the framework that everything is great
return True

View File

@ -76,6 +76,10 @@ class Document(wx.EvtHandler):
The document class can be used to model an application's file-based data. It
is part of the document/view framework supported by wxWindows, and cooperates
with the wxView, wxDocTemplate and wxDocManager classes.
Note this wxPython version also keeps track of the modification date of the
document and if it changes on disk outside of the application, we will warn the
user before saving to avoid clobbering the file.
"""
@ -86,7 +90,6 @@ class Document(wx.EvtHandler):
"""
wx.EvtHandler.__init__(self)
self._documentModified = False
self._documentParent = parent
self._documentTemplate = None
self._commandProcessor = None
@ -97,6 +100,7 @@ class Document(wx.EvtHandler):
self._documentFile = None
self._documentTypeName = None
self._documentModified = False
self._documentModificationDate = None
self._documentViews = []
@ -211,6 +215,27 @@ class Document(wx.EvtHandler):
self._documentModified = modify
def SetDocumentModificationDate(self, filename=None):
"""
Saves the file's last modification date.
This is used to check if the file has been modified outside of the application.
This method has been added to wxPython and is not in wxWindows.
"""
if not filename:
filename = self.GetFilename()
self._documentModificationDate = os.path.getmtime(filename)
print "debug print, file: %s set modification date to %s" % (filename, self._documentModificationDate)
def GetDocumentModificationDate(self):
"""
Returns the file's modification date when it was loaded from disk.
This is used to check if the file has been modified outside of the application.
This method has been added to wxPython and is not in wxWindows.
"""
return self._documentModificationDate
def GetViews(self):
"""
Returns the list whose elements are the views on the document.
@ -338,6 +363,24 @@ class Document(wx.EvtHandler):
if not self.IsModified(): # and self._savedYet: This was here, but if it is not modified who cares if it hasn't been saved yet?
return True
""" check for file modification outside of application """
if os.path.exists(self.GetFilename()) and os.path.getmtime(self.GetFilename()) != self.GetDocumentModificationDate():
print "debug print, File %s: new mod date %s, original mod date %s" % (self.GetFilename(), os.path.getmtime(self.GetFilename()), self.GetDocumentModificationDate())
msgTitle = wx.GetApp().GetAppName()
if not msgTitle:
msgTitle = _("Application")
res = wx.MessageBox(_("'%s' has been modified outside of %s. Overwrite '%s' with current changes?") % (self.GetPrintableName(), msgTitle, self.GetPrintableName()),
msgTitle,
wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION,
self.GetDocumentWindow())
if res == wx.NO:
return True
elif res == wx.YES:
pass
else: # elif res == wx.CANCEL:
return False
if not self._documentFile or not self._savedYet:
return self.SaveAs()
return self.OnSaveDocument(self._documentFile)
@ -434,6 +477,7 @@ class Document(wx.EvtHandler):
self.SetFilename(filename, True)
self.Modify(False)
self.SetDocumentModificationDate()
self.SetDocumentSaved(True)
#if wx.Platform == '__WXMAC__': # Not yet implemented in wxPython
# wx.FileName(file).MacSetDefaultTypeAndCreator()
@ -468,6 +512,7 @@ class Document(wx.EvtHandler):
self.SetFilename(filename, True)
self.Modify(False)
self.SetDocumentModificationDate()
self.SetDocumentSaved(True)
self.UpdateAllViews()
return True
@ -549,6 +594,25 @@ class Document(wx.EvtHandler):
if not self.IsModified():
return True
""" check for file modification outside of application """
if os.path.exists(self.GetFilename()) and os.path.getmtime(self.GetFilename()) != self.GetDocumentModificationDate():
print "debug print, File %s: new mod date %s, original mod date %s" % (self.GetFilename(), os.path.getmtime(self.GetFilename()), self.GetDocumentModificationDate())
msgTitle = wx.GetApp().GetAppName()
if not msgTitle:
msgTitle = _("Warning")
res = wx.MessageBox(_("'%s' has been modified outside of %s. Overwrite '%s' with current changes?") % (self.GetPrintableName(), msgTitle, self.GetPrintableName()),
msgTitle,
wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION,
self.GetDocumentWindow())
if res == wx.NO:
self.Modify(False)
return True
elif res == wx.YES:
return wx.lib.docview.Document.Save(self)
else: # elif res == wx.CANCEL:
return False
msgTitle = wx.GetApp().GetAppName()
if not msgTitle:
msgTitle = _("Warning")

View File

@ -121,7 +121,7 @@ class DocFrameMixIn:
editMenu.Append(wx.ID_PASTE, _("&Paste\tCtrl+V"), _("Inserts Clipboard contents"))
wx.EVT_MENU(self, wx.ID_PASTE, self.ProcessEvent)
wx.EVT_UPDATE_UI(self, wx.ID_PASTE, self.ProcessUpdateUIEvent)
editMenu.Append(wx.ID_CLEAR, _("Cle&ar"), _("Erases the selection"))
editMenu.Append(wx.ID_CLEAR, _("&Delete"), _("Erases the selection"))
wx.EVT_MENU(self, wx.ID_CLEAR, self.ProcessEvent)
wx.EVT_UPDATE_UI(self, wx.ID_CLEAR, self.ProcessUpdateUIEvent)
editMenu.AppendSeparator()
@ -144,9 +144,9 @@ class DocFrameMixIn:
helpMenu = wx.Menu()
helpMenu.Append(wx.ID_ABOUT, _("&About" + " " + wx.GetApp().GetAppName()), _("Displays program information, version number, and copyright"))
wx.EVT_MENU(self, wx.ID_ABOUT, self.OnAbout)
menuBar.Append(helpMenu, _("&Help"))
wx.EVT_MENU(self, wx.ID_ABOUT, self.OnAbout)
wx.EVT_UPDATE_UI(self, wx.ID_ABOUT, self.ProcessUpdateUIEvent) # Using ID_ABOUT to update the window menu, the window menu items are not triggering
if sdi: # TODO: Is this really needed?
@ -301,13 +301,17 @@ class DocMDIParentFrameMixIn:
self.CreateEmbeddedWindows(embeddedWindows)
self._LayoutFrame()
if wx.Platform == '__WXMAC__':
self.SetMenuBar(menuBar) # wxBug: Have to set the menubar at the very end or the automatic MDI "window" menu doesn't get put in the right place when the services add new menus to the menubar
wx.GetApp().SetTopWindow(self) # Need to do this here in case the services are looking for wx.GetApp().GetTopWindow()
for service in wx.GetApp().GetServices():
service.InstallControls(self, menuBar = menuBar, toolBar = toolBar, statusBar = statusBar)
if hasattr(service, "ShowWindow"):
service.ShowWindow() # instantiate service windows for correct positioning, we'll hide/show them later based on user preference
self.SetMenuBar(menuBar) # wxBug: Have to set the menubar at the very end or the automatic MDI "window" menu doesn't get put in the right place when the services add new menus to the menubar
if wx.Platform != '__WXMAC__':
self.SetMenuBar(menuBar) # wxBug: Have to set the menubar at the very end or the automatic MDI "window" menu doesn't get put in the right place when the services add new menus to the menubar
def ProcessEvent(self, event):
@ -1359,7 +1363,7 @@ class OptionsDialog(wx.Dialog):
Initializes the options dialog with a notebook page that contains new
instances of the passed optionsPanelClasses.
"""
wx.Dialog.__init__(self, parent, -1, _("Options"), size = (310, 400))
wx.Dialog.__init__(self, parent, -1, _("Options"), size = (570, 365))
self._optionsPanels = []
self._docManager = docManager
@ -1369,7 +1373,7 @@ class OptionsDialog(wx.Dialog):
sizer = wx.BoxSizer(wx.VERTICAL)
optionsNotebook = wx.Notebook(self, -1, size = (310, 375))
optionsNotebook = wx.Notebook(self, -1, size = (560, 325))
sizer.Add(optionsNotebook, 0, wx.ALL | wx.EXPAND, SPACE)
for optionsPanelClass in optionsPanelClasses:
optionsPanel = optionsPanelClass(optionsNotebook, -1)
@ -1377,7 +1381,8 @@ class OptionsDialog(wx.Dialog):
sizer.Add(self.CreateButtonSizer(wx.OK | wx.CANCEL), 0, wx.ALIGN_RIGHT | wx.RIGHT | wx.BOTTOM, HALF_SPACE)
self.SetSizer(sizer)
self.Layout()
self.Fit()
if wx.Platform != '__WXMAC__' or len(optionsPanelClasses) < 6: # wxBug: Notebook tabs are truncated and user can't get to them on the Mac
self.Fit()
wx.CallAfter(self.DoRefresh)
@ -2885,7 +2890,6 @@ class WindowMenuService(DocService):
# File generated by encode_bitmaps.py
#----------------------------------------------------------------------------
from wx import ImageFromStream, BitmapFromImage
from wx import EmptyIcon
import cStringIO
#----------------------------------------------------------------------
@ -3110,14 +3114,13 @@ def getRedoImage():
def getBlankData():
return \
"\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00 \x00\x00\x00 \x08\x06\x00\
\x00\x00szz\xf4\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\x00\x00\
\x85IDATX\x85\xed\x97\xc9\n\xc0 \x0cD3\xda\xff\xffcMo\x96Z\xc4\xa5\x91\x14:9\
\x8a\xe8\xcb\xd3\xb8\x00!\x8ag\x04\xd7\xd9E\xe4\xa8\x1b4'}3 B\xc4L\x7fs\x03\
\xb3\t<\x0c\x94\x81tN\x04p%\xae9\xe9\xa8\x89m{`\xd4\x84\xfd\x12\xa8\x16{#\
\x10\xdb\xab\xa0\x07a\x0e\x00\xe0\xb6\x1fz\x10\xdf;\x07V\xa3U5\xb5\x8d:\xdc\
\r\x10\x80\x00\x04 \x00\x01\x08@\x80\xe6{\xa0w\x8f[\x85\xbb\x01\xfc\xfeoH\
\x80\x13>\xf9(3zH\x1e\xfb\x00\x00\x00\x00IEND\xaeB`\x82"
'\x89PNG\r\n\x1a\n\x00\x00\x00\rIHDR\x00\x00\x00\x10\x00\x00\x00\x10\x08\x06\
\x00\x00\x00\x1f\xf3\xffa\x00\x00\x00\x04sBIT\x08\x08\x08\x08|\x08d\x88\x00\
\x00\x00]IDAT8\x8d\xed\x931\x0e\xc00\x08\x03m\x92\xff\xff8q\x87\xb6C\x11\x89\
\xa8X:\xd4\x13\x03:\x1b\x01\xa45T\xd4\xefBsh\xd7Hk\xdc\x02\x00@\x8a\x19$\xa1\
9\x14A,\x95\xf3\x82G)\xd3\x00\xf24\xf7\x90\x1ev\x07\xee\x1e\xf4:\xc1J?\xe0\
\x0b\x80\xc7\x1d\xf8\x1dg\xc4\xea7\x96G8\x00\xa8\x91\x19(\x85#P\x7f\x00\x00\
\x00\x00IEND\xaeB`\x82'
def getBlankBitmap():
@ -3128,8 +3131,6 @@ def getBlankImage():
return ImageFromStream(stream)
def getBlankIcon():
icon = EmptyIcon()
icon.CopyFromBitmap(getBlankBitmap())
return icon
return wx.IconFromBitmap(getBlankBitmap())