Docview and IDE patch from Morag Hua with fix for bug #1217890
"Closing view crashes Python" plus some new features: New feature added to the IDE is 'Extensions'. Under Tools|Options|Extensions, you can add calls to external programs. For example you can add a "Notepad" extension (under windows) that will exec Notepad on the currently open file. A new "Notepad" menu item will appear under the Tools menu. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34638 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -20,11 +20,23 @@ Fixes for bug #1217872, pydocview.DocService not correctly initialized
|
|||||||
|
|
||||||
Fix for bug #1217874, Error in parameter name in DocManager.CreateView
|
Fix for bug #1217874, Error in parameter name in DocManager.CreateView
|
||||||
|
|
||||||
|
Added wrappers for the wx.RendererNative class.
|
||||||
|
|
||||||
Added the wx.lib.splitter module, which contains the
|
Added the wx.lib.splitter module, which contains the
|
||||||
MultiSplitterWindow class. This class is much like the standard
|
MultiSplitterWindow class. This class is much like the standard
|
||||||
wx.SplitterWindow class, except it allows more than one split, so it
|
wx.SplitterWindow class, except it allows more than one split, so it
|
||||||
can manage more than two child windows.
|
can manage more than two child windows.
|
||||||
|
|
||||||
|
Docview and IDE patch from Morag Hua with fix for bug #1217890
|
||||||
|
"Closing view crashes Python" plus some new features::
|
||||||
|
|
||||||
|
New feature added to the IDE is 'Extensions'. Under
|
||||||
|
Tools|Options|Extensions, you can add calls to external programs.
|
||||||
|
For example you can add a "Notepad" extension (under windows) that
|
||||||
|
will exec Notepad on the currently open file. A new "Notepad"
|
||||||
|
menu item will appear under the Tools menu.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@@ -122,6 +122,7 @@ class TextEditView(wx.lib.docview.View):
|
|||||||
|
|
||||||
|
|
||||||
def OnDraw(self, dc):
|
def OnDraw(self, dc):
|
||||||
|
""" For Print and Print Preview """
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
|
@@ -86,11 +86,15 @@ class CanvasView(wx.lib.docview.View):
|
|||||||
|
|
||||||
|
|
||||||
def OnFocus(self, event):
|
def OnFocus(self, event):
|
||||||
self.SetFocus()
|
|
||||||
self.FocusColorPropertyShape(True)
|
self.FocusColorPropertyShape(True)
|
||||||
event.Skip()
|
event.Skip()
|
||||||
|
|
||||||
|
|
||||||
|
def FocusOnClick(self, event):
|
||||||
|
self.SetFocus()
|
||||||
|
event.Skip()
|
||||||
|
|
||||||
|
|
||||||
def OnKillFocus(self, event):
|
def OnKillFocus(self, event):
|
||||||
self.FocusColorPropertyShape(False)
|
self.FocusColorPropertyShape(False)
|
||||||
event.Skip()
|
event.Skip()
|
||||||
@@ -129,12 +133,12 @@ class CanvasView(wx.lib.docview.View):
|
|||||||
wx.EVT_KEY_DOWN(self._canvas, self.OnKeyPressed)
|
wx.EVT_KEY_DOWN(self._canvas, self.OnKeyPressed)
|
||||||
|
|
||||||
# need this otherwise mouse clicks don't set focus to this view
|
# need this otherwise mouse clicks don't set focus to this view
|
||||||
wx.EVT_LEFT_DOWN(self._canvas, self.OnFocus)
|
wx.EVT_LEFT_DOWN(self._canvas, self.FocusOnClick)
|
||||||
wx.EVT_LEFT_DCLICK(self._canvas, self.OnFocus)
|
wx.EVT_LEFT_DCLICK(self._canvas, self.FocusOnClick)
|
||||||
wx.EVT_RIGHT_DOWN(self._canvas, self.OnFocus)
|
wx.EVT_RIGHT_DOWN(self._canvas, self.FocusOnClick)
|
||||||
wx.EVT_RIGHT_DCLICK(self._canvas, self.OnFocus)
|
wx.EVT_RIGHT_DCLICK(self._canvas, self.FocusOnClick)
|
||||||
wx.EVT_MIDDLE_DOWN(self._canvas, self.OnFocus)
|
wx.EVT_MIDDLE_DOWN(self._canvas, self.FocusOnClick)
|
||||||
wx.EVT_MIDDLE_DCLICK(self._canvas, self.OnFocus)
|
wx.EVT_MIDDLE_DCLICK(self._canvas, self.FocusOnClick)
|
||||||
|
|
||||||
wx.EVT_KILL_FOCUS(self._canvas, self.OnKillFocus)
|
wx.EVT_KILL_FOCUS(self._canvas, self.OnKillFocus)
|
||||||
wx.EVT_SET_FOCUS(self._canvas, self.OnFocus)
|
wx.EVT_SET_FOCUS(self._canvas, self.OnFocus)
|
||||||
@@ -397,7 +401,7 @@ class CanvasView(wx.lib.docview.View):
|
|||||||
shape.SetBrush(brush)
|
shape.SetBrush(brush)
|
||||||
if text:
|
if text:
|
||||||
shape.AddText(text)
|
shape.AddText(text)
|
||||||
shape.SetShadowMode(ogl.SHADOW_RIGHT)
|
shape.SetShadowMode(ogl.SHADOW_NONE)
|
||||||
self._diagram.AddShape(shape)
|
self._diagram.AddShape(shape)
|
||||||
shape.Show(True)
|
shape.Show(True)
|
||||||
if not eventHandler:
|
if not eventHandler:
|
||||||
@@ -417,9 +421,28 @@ class CanvasView(wx.lib.docview.View):
|
|||||||
|
|
||||||
if shape:
|
if shape:
|
||||||
shape.Select(False)
|
shape.Select(False)
|
||||||
self._diagram.RemoveShape(shape)
|
for line in shape.GetLines():
|
||||||
if isinstance(shape, ogl.CompositeShape):
|
shape.RemoveLine(line)
|
||||||
|
self._diagram.RemoveShape(line)
|
||||||
|
for obj in self._diagram.GetShapeList():
|
||||||
|
for line in obj.GetLines():
|
||||||
|
if self.IsShapeContained(shape, line.GetTo()) or self.IsShapeContained(shape, line.GetFrom()):
|
||||||
|
obj.RemoveLine(line)
|
||||||
|
self._diagram.RemoveShape(line)
|
||||||
|
if line == shape:
|
||||||
|
obj.RemoveLine(line)
|
||||||
|
|
||||||
shape.RemoveFromCanvas(self._canvas)
|
shape.RemoveFromCanvas(self._canvas)
|
||||||
|
self._diagram.RemoveShape(shape)
|
||||||
|
|
||||||
|
|
||||||
|
def IsShapeContained(self, parent, shape):
|
||||||
|
if parent == shape:
|
||||||
|
return True
|
||||||
|
elif shape.GetParent():
|
||||||
|
return self.IsShapeContained(parent, shape.GetParent())
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def UpdateShape(self, model):
|
def UpdateShape(self, model):
|
||||||
|
@@ -378,7 +378,8 @@ class DebuggerHarness(object):
|
|||||||
sys.stdout = output
|
sys.stdout = output
|
||||||
sys.stderr = output
|
sys.stderr = output
|
||||||
try:
|
try:
|
||||||
exec command in frame.f_globals, frame.f_locals
|
code = compile(command, '<string>', 'single')
|
||||||
|
exec code in frame.f_globals, frame.f_locals
|
||||||
return output.getvalue()
|
return output.getvalue()
|
||||||
sys.stdout = out
|
sys.stdout = out
|
||||||
sys.stderr = err
|
sys.stderr = err
|
||||||
|
@@ -41,7 +41,7 @@ import pickle
|
|||||||
import DebuggerHarness
|
import DebuggerHarness
|
||||||
import traceback
|
import traceback
|
||||||
import StringIO
|
import StringIO
|
||||||
|
import UICommon
|
||||||
if wx.Platform == '__WXMSW__':
|
if wx.Platform == '__WXMSW__':
|
||||||
try:
|
try:
|
||||||
import win32api
|
import win32api
|
||||||
@@ -132,8 +132,7 @@ import wx.lib.newevent
|
|||||||
class Executor:
|
class Executor:
|
||||||
|
|
||||||
def GetPythonExecutablePath():
|
def GetPythonExecutablePath():
|
||||||
config = wx.ConfigBase_Get()
|
path = UICommon.GetPythonExecPath()
|
||||||
path = config.Read("ActiveGridPythonLocation")
|
|
||||||
if path:
|
if path:
|
||||||
return path
|
return path
|
||||||
wx.MessageBox(_("To proceed I need to know the location of the python.exe you would like to use.\nTo set this, go to Tools-->Options and use the 'Python' tab to enter a value.\n"), _("Python Executable Location Unknown"))
|
wx.MessageBox(_("To proceed I need to know the location of the python.exe you would like to use.\nTo set this, go to Tools-->Options and use the 'Python' tab to enter a value.\n"), _("Python Executable Location Unknown"))
|
||||||
@@ -149,24 +148,29 @@ class Executor:
|
|||||||
path = Executor.GetPythonExecutablePath()
|
path = Executor.GetPythonExecutablePath()
|
||||||
self._cmd = '"' + path + '" -u \"' + fileName + '\"'
|
self._cmd = '"' + path + '" -u \"' + fileName + '\"'
|
||||||
#Better way to do this? Quotes needed for windows file paths.
|
#Better way to do this? Quotes needed for windows file paths.
|
||||||
|
def spaceAndQuote(text):
|
||||||
|
if text.startswith("\"") and text.endswith("\""):
|
||||||
|
return ' ' + text
|
||||||
|
else:
|
||||||
|
return ' \"' + text + '\"'
|
||||||
if(arg1 != None):
|
if(arg1 != None):
|
||||||
self._cmd += ' \"' + arg1 + '\"'
|
self._cmd += spaceAndQuote(arg1)
|
||||||
if(arg2 != None):
|
if(arg2 != None):
|
||||||
self._cmd += ' \"' + arg2 + '\"'
|
self._cmd += spaceAndQuote(arg2)
|
||||||
if(arg3 != None):
|
if(arg3 != None):
|
||||||
self._cmd += ' \"' + arg3 + '\"'
|
self._cmd += spaceAndQuote(arg3)
|
||||||
if(arg4 != None):
|
if(arg4 != None):
|
||||||
self._cmd += ' \"' + arg4 + '\"'
|
self._cmd += spaceAndQuote(arg4)
|
||||||
if(arg5 != None):
|
if(arg5 != None):
|
||||||
self._cmd += ' \"' + arg5 + '\"'
|
self._cmd += spaceAndQuote(arg5)
|
||||||
if(arg6 != None):
|
if(arg6 != None):
|
||||||
self._cmd += ' \"' + arg6 + '\"'
|
self._cmd += spaceAndQuote(arg6)
|
||||||
if(arg7 != None):
|
if(arg7 != None):
|
||||||
self._cmd += ' \"' + arg7 + '\"'
|
self._cmd += spaceAndQuote(arg7)
|
||||||
if(arg8 != None):
|
if(arg8 != None):
|
||||||
self._cmd += ' \"' + arg8 + '\"'
|
self._cmd += spaceAndQuote(arg8)
|
||||||
if(arg9 != None):
|
if(arg9 != None):
|
||||||
self._cmd += ' \"' + arg9 + '\"'
|
self._cmd += spaceAndQuote(arg9)
|
||||||
|
|
||||||
self._stdOutReader = None
|
self._stdOutReader = None
|
||||||
self._stdErrReader = None
|
self._stdErrReader = None
|
||||||
@@ -621,7 +625,7 @@ class DebugCommandUI(wx.Panel):
|
|||||||
self._tb.EnableTool(self.BREAK_INTO_DEBUGGER_ID, False)
|
self._tb.EnableTool(self.BREAK_INTO_DEBUGGER_ID, False)
|
||||||
self._tb.EnableTool(self.KILL_PROCESS_ID, False)
|
self._tb.EnableTool(self.KILL_PROCESS_ID, False)
|
||||||
|
|
||||||
def SynchCurrentLine(self, filename, lineNum):
|
def SynchCurrentLine(self, filename, lineNum, noArrow=False):
|
||||||
# FACTOR THIS INTO DocManager
|
# FACTOR THIS INTO DocManager
|
||||||
self.DeleteCurrentLineMarkers()
|
self.DeleteCurrentLineMarkers()
|
||||||
|
|
||||||
@@ -652,6 +656,7 @@ class DebugCommandUI(wx.Panel):
|
|||||||
foundView.GotoLine(lineNum)
|
foundView.GotoLine(lineNum)
|
||||||
startPos = foundView.PositionFromLine(lineNum)
|
startPos = foundView.PositionFromLine(lineNum)
|
||||||
|
|
||||||
|
if not noArrow:
|
||||||
foundView.GetCtrl().MarkerAdd(lineNum -1, CodeEditor.CodeCtrl.CURRENT_LINE_MARKER_NUM)
|
foundView.GetCtrl().MarkerAdd(lineNum -1, CodeEditor.CodeCtrl.CURRENT_LINE_MARKER_NUM)
|
||||||
|
|
||||||
def DeleteCurrentLineMarkers(self):
|
def DeleteCurrentLineMarkers(self):
|
||||||
@@ -803,7 +808,7 @@ class BreakpointsUI(wx.Panel):
|
|||||||
list = self._bpListCtrl
|
list = self._bpListCtrl
|
||||||
fileName = list.GetItem(self.currentItem, 2).GetText()
|
fileName = list.GetItem(self.currentItem, 2).GetText()
|
||||||
lineNumber = list.GetItem(self.currentItem, 1).GetText()
|
lineNumber = list.GetItem(self.currentItem, 1).GetText()
|
||||||
self._ui.SynchCurrentLine( fileName, int(lineNumber) )
|
self._ui.SynchCurrentLine( fileName, int(lineNumber) , noArrow=True)
|
||||||
|
|
||||||
def ClearBreakPoint(self, event):
|
def ClearBreakPoint(self, event):
|
||||||
if self.currentItem >= 0:
|
if self.currentItem >= 0:
|
||||||
@@ -1810,7 +1815,7 @@ class DebuggerService(Service.Service):
|
|||||||
wsService = wx.GetApp().GetService(WebServerService.WebServerService)
|
wsService = wx.GetApp().GetService(WebServerService.WebServerService)
|
||||||
fileName, args = wsService.StopAndPrepareToDebug()
|
fileName, args = wsService.StopAndPrepareToDebug()
|
||||||
try:
|
try:
|
||||||
page = DebugCommandUI(Service.ServiceView.bottomTab, -1, str(fileName), self)
|
page = DebugCommandUI(Service.ServiceView.bottomTab, -1, fileName, self)
|
||||||
count = Service.ServiceView.bottomTab.GetPageCount()
|
count = Service.ServiceView.bottomTab.GetPageCount()
|
||||||
Service.ServiceView.bottomTab.AddPage(page, _("Debugging: Internal WebServer"))
|
Service.ServiceView.bottomTab.AddPage(page, _("Debugging: Internal WebServer"))
|
||||||
Service.ServiceView.bottomTab.SetSelection(count)
|
Service.ServiceView.bottomTab.SetSelection(count)
|
||||||
@@ -2124,7 +2129,7 @@ class CommandPropertiesDialog(wx.Dialog):
|
|||||||
flexGridSizer.Add(self._pythonPathEntry, 1, wx.EXPAND)
|
flexGridSizer.Add(self._pythonPathEntry, 1, wx.EXPAND)
|
||||||
flexGridSizer.Add(wx.StaticText(parent, -1, ""), 0)
|
flexGridSizer.Add(wx.StaticText(parent, -1, ""), 0)
|
||||||
flexGridSizer.Add(wx.StaticText(parent, -1, ""), 0)
|
flexGridSizer.Add(wx.StaticText(parent, -1, ""), 0)
|
||||||
if debugging:
|
if debugging and _WINDOWS:
|
||||||
self._postpendCheckBox = wx.CheckBox(self, -1, postpendStaticText)
|
self._postpendCheckBox = wx.CheckBox(self, -1, postpendStaticText)
|
||||||
checked = bool(config.ReadInt("PythonPathPostpend", 1))
|
checked = bool(config.ReadInt("PythonPathPostpend", 1))
|
||||||
self._postpendCheckBox.SetValue(checked)
|
self._postpendCheckBox.SetValue(checked)
|
||||||
|
387
wxPython/samples/ide/activegrid/tool/ExtensionService.py
Normal file
387
wxPython/samples/ide/activegrid/tool/ExtensionService.py
Normal file
@@ -0,0 +1,387 @@
|
|||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Name: ExtensionService.py
|
||||||
|
# Purpose: Extension Service for IDE
|
||||||
|
#
|
||||||
|
# Author: Peter Yared
|
||||||
|
#
|
||||||
|
# Created: 5/23/05
|
||||||
|
# CVS-ID: $ID:$
|
||||||
|
# Copyright: (c) 2005 ActiveGrid, Inc.
|
||||||
|
# License: wxWindows License
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
import wx
|
||||||
|
import wx.lib.pydocview
|
||||||
|
import MessageService
|
||||||
|
import os
|
||||||
|
import os.path
|
||||||
|
import pickle
|
||||||
|
|
||||||
|
_ = wx.GetTranslation
|
||||||
|
|
||||||
|
|
||||||
|
SPACE = 10
|
||||||
|
HALF_SPACE = 5
|
||||||
|
|
||||||
|
|
||||||
|
EXTENSIONS_CONFIG_STRING = "Extensions"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
# TODO: Redo extensions menu on OK, or provide alert that it won't happen until restart
|
||||||
|
|
||||||
|
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Classes
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class Extension:
|
||||||
|
|
||||||
|
|
||||||
|
def __init__(self, menuItemName):
|
||||||
|
self.menuItemName = menuItemName
|
||||||
|
self.id = 0
|
||||||
|
self.menuItemDesc = ''
|
||||||
|
self.command = ''
|
||||||
|
self.commandPreArgs = ''
|
||||||
|
self.commandPostArgs = ''
|
||||||
|
self.fileExt = None
|
||||||
|
|
||||||
|
|
||||||
|
class ExtensionService(wx.lib.pydocview.DocService):
|
||||||
|
|
||||||
|
|
||||||
|
def __init__(self):
|
||||||
|
self.LoadExtensions()
|
||||||
|
|
||||||
|
|
||||||
|
def LoadExtensions(self):
|
||||||
|
config = wx.ConfigBase_Get()
|
||||||
|
pickledExtensions = config.Read(EXTENSIONS_CONFIG_STRING)
|
||||||
|
if pickledExtensions:
|
||||||
|
try:
|
||||||
|
self._extensions = pickle.loads(pickledExtensions.encode('ascii'))
|
||||||
|
except:
|
||||||
|
tp, val, tb = sys.exc_info()
|
||||||
|
traceback.print_exception(tp,val,tb)
|
||||||
|
self._extensions = []
|
||||||
|
else:
|
||||||
|
self._extensions = []
|
||||||
|
|
||||||
|
|
||||||
|
def SaveExtensions(self):
|
||||||
|
config = wx.ConfigBase_Get()
|
||||||
|
config.Write(EXTENSIONS_CONFIG_STRING, pickle.dumps(self._extensions))
|
||||||
|
|
||||||
|
|
||||||
|
def GetExtensions(self):
|
||||||
|
return self._extensions
|
||||||
|
|
||||||
|
|
||||||
|
def SetExtensions(self, extensions):
|
||||||
|
self._extensions = extensions
|
||||||
|
|
||||||
|
|
||||||
|
def InstallControls(self, frame, menuBar = None, toolBar = None, statusBar = None, document = None):
|
||||||
|
toolsMenuIndex = menuBar.FindMenu(_("&Tools"))
|
||||||
|
if toolsMenuIndex > -1:
|
||||||
|
toolsMenu = menuBar.GetMenu(toolsMenuIndex)
|
||||||
|
else:
|
||||||
|
toolsMenu = wx.Menu()
|
||||||
|
|
||||||
|
if self._extensions:
|
||||||
|
if toolsMenu.GetMenuItems():
|
||||||
|
toolsMenu.AppendSeparator()
|
||||||
|
for ext in self._extensions:
|
||||||
|
# Append a tool menu item for each extension
|
||||||
|
ext.id = wx.NewId()
|
||||||
|
toolsMenu.Append(ext.id, ext.menuItemName)
|
||||||
|
wx.EVT_MENU(frame, ext.id, frame.ProcessEvent)
|
||||||
|
wx.EVT_UPDATE_UI(frame, ext.id, frame.ProcessUpdateUIEvent)
|
||||||
|
|
||||||
|
if toolsMenuIndex == -1:
|
||||||
|
formatMenuIndex = menuBar.FindMenu(_("&Format"))
|
||||||
|
menuBar.Insert(formatMenuIndex + 1, toolsMenu, _("&Tools"))
|
||||||
|
|
||||||
|
def ProcessEvent(self, event):
|
||||||
|
id = event.GetId()
|
||||||
|
for extension in self._extensions:
|
||||||
|
if id == extension.id:
|
||||||
|
self.OnExecuteExtension(extension)
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def ProcessUpdateUIEvent(self, event):
|
||||||
|
id = event.GetId()
|
||||||
|
for extension in self._extensions:
|
||||||
|
if id == extension.id:
|
||||||
|
if extension.fileExt:
|
||||||
|
doc = wx.GetApp().GetDocumentManager().GetCurrentDocument()
|
||||||
|
if doc and '*' in extension.fileExt:
|
||||||
|
event.Enable(True)
|
||||||
|
return True
|
||||||
|
if doc:
|
||||||
|
for fileExt in extension.fileExt:
|
||||||
|
if fileExt in doc.GetDocumentTemplate().GetFileFilter():
|
||||||
|
event.Enable(True)
|
||||||
|
return True
|
||||||
|
event.Enable(False)
|
||||||
|
return False
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
def OnExecuteExtension(self, extension):
|
||||||
|
if extension.fileExt:
|
||||||
|
doc = wx.GetApp().GetDocumentManager().GetCurrentDocument()
|
||||||
|
if not doc:
|
||||||
|
return
|
||||||
|
filename = doc.GetFilename()
|
||||||
|
ext = os.path.splitext(filename)[1]
|
||||||
|
if not '*' in extension.fileExt:
|
||||||
|
if not ext or ext[1:] not in extension.fileExt:
|
||||||
|
return
|
||||||
|
cmds = [extension.command]
|
||||||
|
if extension.commandPreArgs:
|
||||||
|
cmds.append(extension.commandPreArgs)
|
||||||
|
cmds.append(filename)
|
||||||
|
if extension.commandPostArgs:
|
||||||
|
cmds.append(extension.commandPostArgs)
|
||||||
|
os.spawnv(os.P_NOWAIT, extension.command, cmds)
|
||||||
|
|
||||||
|
else:
|
||||||
|
cmd = extension.command
|
||||||
|
if extension.commandPreArgs:
|
||||||
|
cmd = cmd + ' ' + extension.commandPreArgs
|
||||||
|
if extension.commandPostArgs:
|
||||||
|
cmd = cmd + ' ' + extension.commandPostArgs
|
||||||
|
f = os.popen(cmd)
|
||||||
|
messageService = wx.GetApp().GetService(MessageService.MessageService)
|
||||||
|
messageService.ShowWindow()
|
||||||
|
view = messageService.GetView()
|
||||||
|
for line in f.readlines():
|
||||||
|
view.AddLines(line)
|
||||||
|
view.GetControl().EnsureCaretVisible()
|
||||||
|
f.close()
|
||||||
|
|
||||||
|
|
||||||
|
class ExtensionOptionsPanel(wx.Panel):
|
||||||
|
|
||||||
|
|
||||||
|
def __init__(self, parent, id):
|
||||||
|
wx.Panel.__init__(self, parent, id)
|
||||||
|
|
||||||
|
extOptionsPanelBorderSizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
|
||||||
|
extOptionsPanelSizer = wx.FlexGridSizer(cols=2, hgap=SPACE, vgap=HALF_SPACE)
|
||||||
|
|
||||||
|
extCtrlSizer = wx.BoxSizer(wx.VERTICAL)
|
||||||
|
extCtrlSizer.Add(wx.StaticText(self, -1, _("Extensions:")), 0)
|
||||||
|
self._extListBox = wx.ListBox(self, -1, size=(-1,185), style=wx.LB_SINGLE)
|
||||||
|
self.Bind(wx.EVT_LISTBOX, self.OnListBoxSelect, self._extListBox)
|
||||||
|
extCtrlSizer.Add(self._extListBox, 1, wx.TOP | wx.BOTTOM | wx.EXPAND, SPACE)
|
||||||
|
buttonSizer = wx.GridSizer(rows=1, hgap=10, vgap=5)
|
||||||
|
self._moveUpButton = wx.Button(self, -1, _("Move Up"))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnMoveUp, self._moveUpButton)
|
||||||
|
buttonSizer.Add(self._moveUpButton, 0)
|
||||||
|
self._moveDownButton = wx.Button(self, -1, _("Move Down"))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnMoveDown, self._moveDownButton)
|
||||||
|
buttonSizer.Add(self._moveDownButton, 0)
|
||||||
|
extCtrlSizer.Add(buttonSizer, 0, wx.ALIGN_CENTER | wx.BOTTOM, HALF_SPACE)
|
||||||
|
buttonSizer = wx.GridSizer(rows=1, hgap=10, vgap=5)
|
||||||
|
self._addButton = wx.Button(self, -1, _("Add"))
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnAdd, self._addButton)
|
||||||
|
buttonSizer.Add(self._addButton, 0)
|
||||||
|
self._deleteButton = wx.Button(self, wx.ID_DELETE)
|
||||||
|
self.Bind(wx.EVT_BUTTON, self.OnDelete, self._deleteButton)
|
||||||
|
buttonSizer.Add(self._deleteButton, 0)
|
||||||
|
extCtrlSizer.Add(buttonSizer, 0, wx.ALIGN_CENTER)
|
||||||
|
extOptionsPanelSizer.Add(extCtrlSizer, 0)
|
||||||
|
|
||||||
|
self._extDetailPanel = wx.Panel(self)
|
||||||
|
staticBox = wx.StaticBox(self._extDetailPanel, label=_("Selected Extension"))
|
||||||
|
staticBoxSizer = wx.StaticBoxSizer(staticBox)
|
||||||
|
self._extDetailPanel.SetSizer(staticBoxSizer)
|
||||||
|
extDetailSizer = wx.FlexGridSizer(cols=1, hgap=5, vgap=3)
|
||||||
|
staticBoxSizer.AddSizer(extDetailSizer, 0, wx.ALL, 5)
|
||||||
|
|
||||||
|
extDetailSizer.Add(wx.StaticText(self._extDetailPanel, -1, _("Menu Item Name:")))
|
||||||
|
self._menuItemNameTextCtrl = wx.TextCtrl(self._extDetailPanel, -1, size = (-1, -1))
|
||||||
|
extDetailSizer.Add(self._menuItemNameTextCtrl, 1, wx.EXPAND)
|
||||||
|
self.Bind(wx.EVT_TEXT, self.SaveCurrentItem, self._menuItemNameTextCtrl)
|
||||||
|
|
||||||
|
extDetailSizer.Add(wx.StaticText(self._extDetailPanel, -1, _("Menu Item Description:")))
|
||||||
|
self._menuItemDescTextCtrl = wx.TextCtrl(self._extDetailPanel, -1, size = (-1, -1))
|
||||||
|
extDetailSizer.Add(self._menuItemDescTextCtrl, 1, wx.EXPAND)
|
||||||
|
|
||||||
|
extDetailSizer.Add(wx.StaticText(self._extDetailPanel, -1, _("Command Path:")))
|
||||||
|
self._commandTextCtrl = wx.TextCtrl(self._extDetailPanel, -1, size = (-1, -1))
|
||||||
|
findFileButton = wx.Button(self._extDetailPanel, -1, _("Browse..."))
|
||||||
|
def OnBrowseButton(event):
|
||||||
|
fileDlg = wx.FileDialog(self, _("Choose an Executable:"), style=wx.OPEN | wx.HIDE_READONLY)
|
||||||
|
path = self._commandTextCtrl.GetValue()
|
||||||
|
if path:
|
||||||
|
fileDlg.SetPath(path)
|
||||||
|
if fileDlg.ShowModal() == wx.ID_OK:
|
||||||
|
self._commandTextCtrl.SetValue(fileDlg.GetPath())
|
||||||
|
self._commandTextCtrl.SetInsertionPointEnd()
|
||||||
|
fileDlg.Destroy()
|
||||||
|
wx.EVT_BUTTON(findFileButton, -1, OnBrowseButton)
|
||||||
|
hsizer = wx.BoxSizer(wx.HORIZONTAL)
|
||||||
|
hsizer.Add(self._commandTextCtrl, 1, wx.EXPAND)
|
||||||
|
hsizer.Add(findFileButton, 0, wx.LEFT, HALF_SPACE)
|
||||||
|
extDetailSizer.Add(hsizer, 0)
|
||||||
|
|
||||||
|
extDetailSizer.Add(wx.StaticText(self._extDetailPanel, -1, _("Command Pre Arguments:")))
|
||||||
|
self._commandPreArgsTextCtrl = wx.TextCtrl(self._extDetailPanel, -1, size = (-1, -1))
|
||||||
|
extDetailSizer.Add(self._commandPreArgsTextCtrl, 1, wx.EXPAND)
|
||||||
|
|
||||||
|
extDetailSizer.Add(wx.StaticText(self._extDetailPanel, -1, _("Command Post Arguments:")))
|
||||||
|
self._commandPostArgsTextCtrl = wx.TextCtrl(self._extDetailPanel, -1, size = (-1, -1))
|
||||||
|
extDetailSizer.Add(self._commandPostArgsTextCtrl, 1, wx.EXPAND)
|
||||||
|
|
||||||
|
extDetailSizer.Add(wx.StaticText(self._extDetailPanel, -1, _("File Extensions (Comma Separated):")))
|
||||||
|
self._fileExtTextCtrl = wx.TextCtrl(self._extDetailPanel, -1, size = (-1, -1))
|
||||||
|
self._fileExtTextCtrl.SetToolTipString(_("""For example: "txt, text" or "*" for all files"""))
|
||||||
|
extDetailSizer.Add(self._fileExtTextCtrl, 1, wx.EXPAND)
|
||||||
|
|
||||||
|
extOptionsPanelSizer.Add(self._extDetailPanel, 0)
|
||||||
|
|
||||||
|
extOptionsPanelBorderSizer.Add(extOptionsPanelSizer, 0, wx.ALL | wx.EXPAND, SPACE)
|
||||||
|
self.SetSizer(extOptionsPanelBorderSizer)
|
||||||
|
self.Layout()
|
||||||
|
parent.AddPage(self, _("Extensions"))
|
||||||
|
|
||||||
|
if self.PopulateItems():
|
||||||
|
self._extListBox.SetSelection(0)
|
||||||
|
self.OnListBoxSelect(None)
|
||||||
|
|
||||||
|
|
||||||
|
def OnOK(self, optionsDialog):
|
||||||
|
self.SaveCurrentItem()
|
||||||
|
extensionsService = wx.GetApp().GetService(ExtensionService)
|
||||||
|
oldExtensions = extensionsService.GetExtensions()
|
||||||
|
extensionsService.SetExtensions(self._extensions)
|
||||||
|
extensionsService.SaveExtensions()
|
||||||
|
if oldExtensions.__repr__() != self._extensions.__repr__():
|
||||||
|
msgTitle = wx.GetApp().GetAppName()
|
||||||
|
if not msgTitle:
|
||||||
|
msgTitle = _("Document Options")
|
||||||
|
wx.MessageBox(_("Extension changes will not appear until the application is restarted."),
|
||||||
|
msgTitle,
|
||||||
|
wx.OK | wx.ICON_INFORMATION,
|
||||||
|
self.GetParent())
|
||||||
|
|
||||||
|
|
||||||
|
def PopulateItems(self):
|
||||||
|
extensionsService = wx.GetApp().GetService(ExtensionService)
|
||||||
|
import copy
|
||||||
|
self._extensions = copy.deepcopy(extensionsService.GetExtensions())
|
||||||
|
for extension in self._extensions:
|
||||||
|
self._extListBox.Append(extension.menuItemName, extension)
|
||||||
|
self._currentItem = None
|
||||||
|
self._currentItemIndex = -1
|
||||||
|
return len(self._extensions)
|
||||||
|
|
||||||
|
|
||||||
|
def OnListBoxSelect(self, event):
|
||||||
|
self.SaveCurrentItem()
|
||||||
|
if not self._extListBox.GetSelections():
|
||||||
|
self._currentItemIndex = -1
|
||||||
|
self._currentItem = None
|
||||||
|
self._deleteButton.Enable(False)
|
||||||
|
self._moveUpButton.Enable(False)
|
||||||
|
self._moveDownButton.Enable(False)
|
||||||
|
else:
|
||||||
|
self._currentItemIndex = self._extListBox.GetSelection()
|
||||||
|
self._currentItem = self._extListBox.GetClientData(self._currentItemIndex)
|
||||||
|
self._deleteButton.Enable()
|
||||||
|
self._moveUpButton.Enable(self._extListBox.GetCount() > 1 and self._currentItemIndex > 0)
|
||||||
|
self._moveDownButton.Enable(self._extListBox.GetCount() > 1 and self._currentItemIndex < self._extListBox.GetCount() - 1)
|
||||||
|
self.LoadItem(self._currentItem)
|
||||||
|
|
||||||
|
|
||||||
|
def SaveCurrentItem(self, event=None):
|
||||||
|
extension = self._currentItem
|
||||||
|
if extension:
|
||||||
|
if extension.menuItemName != self._menuItemNameTextCtrl.GetValue():
|
||||||
|
extension.menuItemName = self._menuItemNameTextCtrl.GetValue()
|
||||||
|
self._extListBox.SetString(self._currentItemIndex, extension.menuItemName)
|
||||||
|
extension.menuItemDesc = self._menuItemDescTextCtrl.GetValue()
|
||||||
|
extension.command = self._commandTextCtrl.GetValue()
|
||||||
|
extension.commandPreArgs = self._commandPreArgsTextCtrl.GetValue()
|
||||||
|
extension.commandPostArgs = self._commandPostArgsTextCtrl.GetValue()
|
||||||
|
fileExt = self._fileExtTextCtrl.GetValue().replace(' ','')
|
||||||
|
if not fileExt:
|
||||||
|
extension.fileExt = None
|
||||||
|
else:
|
||||||
|
extension.fileExt = fileExt.split(',')
|
||||||
|
|
||||||
|
|
||||||
|
def LoadItem(self, extension):
|
||||||
|
if extension:
|
||||||
|
self._menuItemDescTextCtrl.SetValue(extension.menuItemDesc or '')
|
||||||
|
self._commandTextCtrl.SetValue(extension.command or '')
|
||||||
|
self._commandPreArgsTextCtrl.SetValue(extension.commandPreArgs or '')
|
||||||
|
self._commandPostArgsTextCtrl.SetValue(extension.commandPostArgs or '')
|
||||||
|
if extension.fileExt:
|
||||||
|
self._fileExtTextCtrl.SetValue(extension.fileExt.__repr__()[1:-1].replace("'","")) # Make the list a string, strip the brakcet on either side
|
||||||
|
else:
|
||||||
|
self._fileExtTextCtrl.SetValue('')
|
||||||
|
self._menuItemNameTextCtrl.SetValue(extension.menuItemName or '') # Do the name last since it triggers the write event that updates the entire item
|
||||||
|
self._extDetailPanel.Enable()
|
||||||
|
else:
|
||||||
|
self._menuItemNameTextCtrl.SetValue('')
|
||||||
|
self._menuItemDescTextCtrl.SetValue('')
|
||||||
|
self._commandTextCtrl.SetValue('')
|
||||||
|
self._commandPreArgsTextCtrl.SetValue('')
|
||||||
|
self._commandPostArgsTextCtrl.SetValue('')
|
||||||
|
self._fileExtTextCtrl.SetValue('')
|
||||||
|
self._extDetailPanel.Enable(False)
|
||||||
|
|
||||||
|
|
||||||
|
def OnAdd(self, event):
|
||||||
|
self.SaveCurrentItem()
|
||||||
|
extensionNames = map(lambda extension: extension.menuItemName, self._extensions)
|
||||||
|
name = _("Untitled")
|
||||||
|
count = 1
|
||||||
|
while name in extensionNames:
|
||||||
|
count = count + 1
|
||||||
|
name = _("Untitled %s") % count
|
||||||
|
extension = Extension(name)
|
||||||
|
self._extensions.append(extension)
|
||||||
|
self._extListBox.Append(extension.menuItemName, extension)
|
||||||
|
self._extListBox.SetSelection(self._extListBox.GetCount() - 1)
|
||||||
|
self.OnListBoxSelect(None)
|
||||||
|
self._menuItemNameTextCtrl.SetFocus()
|
||||||
|
self._menuItemNameTextCtrl.SetSelection(-1, -1)
|
||||||
|
|
||||||
|
|
||||||
|
def OnDelete(self, event):
|
||||||
|
self._extListBox.Delete(self._currentItemIndex)
|
||||||
|
self._extensions.remove(self._currentItem)
|
||||||
|
self._currentItemIndex = min(self._currentItemIndex, self._extListBox.GetCount() - 1)
|
||||||
|
if self._currentItemIndex > -1:
|
||||||
|
self._extListBox.SetSelection(self._currentItemIndex)
|
||||||
|
self._currentItem = None # Don't update it since it no longer exists
|
||||||
|
self.OnListBoxSelect(None)
|
||||||
|
|
||||||
|
|
||||||
|
def OnMoveUp(self, event):
|
||||||
|
itemAboveString = self._extListBox.GetString(self._currentItemIndex - 1)
|
||||||
|
itemAboveData = self._extListBox.GetClientData(self._currentItemIndex - 1)
|
||||||
|
self._extListBox.Delete(self._currentItemIndex - 1)
|
||||||
|
self._extListBox.Insert(itemAboveString, self._currentItemIndex)
|
||||||
|
self._extListBox.SetClientData(self._currentItemIndex, itemAboveData)
|
||||||
|
self._currentItemIndex = self._currentItemIndex - 1
|
||||||
|
self.OnListBoxSelect(None) # Reset buttons
|
||||||
|
|
||||||
|
|
||||||
|
def OnMoveDown(self, event):
|
||||||
|
itemBelowString = self._extListBox.GetString(self._currentItemIndex + 1)
|
||||||
|
itemBelowData = self._extListBox.GetClientData(self._currentItemIndex + 1)
|
||||||
|
self._extListBox.Delete(self._currentItemIndex + 1)
|
||||||
|
self._extListBox.Insert(itemBelowString, self._currentItemIndex)
|
||||||
|
self._extListBox.SetClientData(self._currentItemIndex, itemBelowData)
|
||||||
|
self._currentItemIndex = self._currentItemIndex + 1
|
||||||
|
self.OnListBoxSelect(None) # Reset buttons
|
@@ -81,6 +81,7 @@ class IDEApplication(wx.lib.pydocview.DocApp):
|
|||||||
import DebuggerService
|
import DebuggerService
|
||||||
import AboutDialog
|
import AboutDialog
|
||||||
import SVNService
|
import SVNService
|
||||||
|
import ExtensionService
|
||||||
|
|
||||||
if not ACTIVEGRID_BASE_IDE:
|
if not ACTIVEGRID_BASE_IDE:
|
||||||
import DataModelEditor
|
import DataModelEditor
|
||||||
@@ -304,6 +305,7 @@ class IDEApplication(wx.lib.pydocview.DocApp):
|
|||||||
deploymentService = self.InstallService(DeploymentService.DeploymentService())
|
deploymentService = self.InstallService(DeploymentService.DeploymentService())
|
||||||
dataModelService = self.InstallService(DataModelEditor.DataModelService())
|
dataModelService = self.InstallService(DataModelEditor.DataModelService())
|
||||||
welcomeService = self.InstallService(WelcomeService.WelcomeService())
|
welcomeService = self.InstallService(WelcomeService.WelcomeService())
|
||||||
|
extensionService = self.InstallService(ExtensionService.ExtensionService())
|
||||||
optionsService = self.InstallService(wx.lib.pydocview.DocOptionsService(supportedModes=wx.lib.docview.DOC_MDI))
|
optionsService = self.InstallService(wx.lib.pydocview.DocOptionsService(supportedModes=wx.lib.docview.DOC_MDI))
|
||||||
aboutService = self.InstallService(wx.lib.pydocview.AboutService(AboutDialog.AboutDialog))
|
aboutService = self.InstallService(wx.lib.pydocview.AboutService(AboutDialog.AboutDialog))
|
||||||
svnService = self.InstallService(SVNService.SVNService())
|
svnService = self.InstallService(SVNService.SVNService())
|
||||||
@@ -326,6 +328,7 @@ class IDEApplication(wx.lib.pydocview.DocApp):
|
|||||||
optionsService.AddOptionsPanel(STCTextEditor.TextOptionsPanel)
|
optionsService.AddOptionsPanel(STCTextEditor.TextOptionsPanel)
|
||||||
optionsService.AddOptionsPanel(HtmlEditor.HtmlOptionsPanel)
|
optionsService.AddOptionsPanel(HtmlEditor.HtmlOptionsPanel)
|
||||||
optionsService.AddOptionsPanel(SVNService.SVNOptionsPanel)
|
optionsService.AddOptionsPanel(SVNService.SVNOptionsPanel)
|
||||||
|
optionsService.AddOptionsPanel(ExtensionService.ExtensionOptionsPanel)
|
||||||
|
|
||||||
filePropertiesService.AddCustomEventHandler(projectService)
|
filePropertiesService.AddCustomEventHandler(projectService)
|
||||||
|
|
||||||
@@ -374,7 +377,7 @@ class IDEApplication(wx.lib.pydocview.DocApp):
|
|||||||
if os.path.exists(tips_path):
|
if os.path.exists(tips_path):
|
||||||
wx.CallAfter(self.ShowTip, docManager.FindSuitableParent(), wx.CreateFileTipProvider(tips_path, 0))
|
wx.CallAfter(self.ShowTip, docManager.FindSuitableParent(), wx.CreateFileTipProvider(tips_path, 0))
|
||||||
|
|
||||||
wx.UpdateUIEvent.SetUpdateInterval(200) # Overhead of updating menus was too much. Change to update every 200 milliseconds.
|
wx.UpdateUIEvent.SetUpdateInterval(400) # Overhead of updating menus was too much. Change to update every 400 milliseconds.
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@ from wxPython.lib.rcsizer import RowColSizer
|
|||||||
import time
|
import time
|
||||||
import Service
|
import Service
|
||||||
import sys
|
import sys
|
||||||
import activegrid.util.objutils
|
import activegrid.util.xmlutils
|
||||||
import UICommon
|
import UICommon
|
||||||
import Wizard
|
import Wizard
|
||||||
import SVNService
|
import SVNService
|
||||||
@@ -49,10 +49,10 @@ HALF_SPACE = 5
|
|||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
def load(fileObject):
|
def load(fileObject):
|
||||||
return activegrid.util.objutils.defaultLoad(fileObject)
|
return activegrid.util.xmlutils.defaultLoad(fileObject, knownTypes={"projectmodel" : ProjectModel})
|
||||||
|
|
||||||
def save(fileObject, projectModel):
|
def save(fileObject, projectModel):
|
||||||
activegrid.util.objutils.defaultSave(fileObject, projectModel, prettyPrint=True)
|
activegrid.util.xmlutils.defaultSave(fileObject, projectModel, prettyPrint=True, knownTypes={"projectmodel" : ProjectModel})
|
||||||
|
|
||||||
|
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
@@ -1055,7 +1055,8 @@ class ProjectView(wx.lib.docview.View):
|
|||||||
descr = template.GetDescription() + _(" (") + template.GetFileFilter() + _(")")
|
descr = template.GetDescription() + _(" (") + template.GetFileFilter() + _(")")
|
||||||
choices.append(descr)
|
choices.append(descr)
|
||||||
allfilter = allfilter + template.GetFileFilter()
|
allfilter = allfilter + template.GetFileFilter()
|
||||||
choices.insert(0, _("All (%s)") % allfilter)
|
choices.insert(0, _("All (%s)") % allfilter) # first item
|
||||||
|
choices.append(_("Any (*.*)")) # last item
|
||||||
filterChoice = wx.Choice(frame, -1, size=(250, -1), choices=choices)
|
filterChoice = wx.Choice(frame, -1, size=(250, -1), choices=choices)
|
||||||
filterChoice.SetSelection(0)
|
filterChoice.SetSelection(0)
|
||||||
filterChoice.SetToolTipString(_("Select file type filter."))
|
filterChoice.SetToolTipString(_("Select file type filter."))
|
||||||
@@ -1112,7 +1113,8 @@ class ProjectView(wx.lib.docview.View):
|
|||||||
paths = []
|
paths = []
|
||||||
|
|
||||||
index = filterChoice.GetSelection()
|
index = filterChoice.GetSelection()
|
||||||
if index:
|
lastIndex = filterChoice.GetCount()-1
|
||||||
|
if index and index != lastIndex: # if not All or Any
|
||||||
template = visibleTemplates[index-1]
|
template = visibleTemplates[index-1]
|
||||||
|
|
||||||
# do search in files on disk
|
# do search in files on disk
|
||||||
@@ -1121,7 +1123,7 @@ class ProjectView(wx.lib.docview.View):
|
|||||||
break
|
break
|
||||||
|
|
||||||
for name in files:
|
for name in files:
|
||||||
if index == 0: # all
|
if index == 0: # All
|
||||||
for template in visibleTemplates:
|
for template in visibleTemplates:
|
||||||
if template.FileMatchesTemplate(name):
|
if template.FileMatchesTemplate(name):
|
||||||
filename = os.path.join(root, name)
|
filename = os.path.join(root, name)
|
||||||
@@ -1132,6 +1134,11 @@ class ProjectView(wx.lib.docview.View):
|
|||||||
|
|
||||||
paths.append(filename)
|
paths.append(filename)
|
||||||
break
|
break
|
||||||
|
elif index == lastIndex: # Any
|
||||||
|
filename = os.path.join(root, name)
|
||||||
|
# if already in project, don't add it, otherwise undo will remove it from project even though it was already in it.
|
||||||
|
if not doc.IsFileInProject(filename):
|
||||||
|
paths.append(filename)
|
||||||
else: # use selected filter
|
else: # use selected filter
|
||||||
if template.FileMatchesTemplate(name):
|
if template.FileMatchesTemplate(name):
|
||||||
filename = os.path.join(root, name)
|
filename = os.path.join(root, name)
|
||||||
|
@@ -14,6 +14,7 @@ import os
|
|||||||
import os.path
|
import os.path
|
||||||
import wx
|
import wx
|
||||||
import ProjectEditor
|
import ProjectEditor
|
||||||
|
import activegrid.util as utillib
|
||||||
_ = wx.GetTranslation
|
_ = wx.GetTranslation
|
||||||
|
|
||||||
def CreateDirectoryControl( parent, fileLabel, dirLabel, fileExtension, startingName="", startingDirectory=""):
|
def CreateDirectoryControl( parent, fileLabel, dirLabel, fileExtension, startingName="", startingDirectory=""):
|
||||||
@@ -118,3 +119,10 @@ def PluralName(name):
|
|||||||
else:
|
else:
|
||||||
return name + 's'
|
return name + 's'
|
||||||
|
|
||||||
|
def GetPythonExecPath():
|
||||||
|
pythonExecPath = wx.ConfigBase_Get().Read("ActiveGridPythonLocation")
|
||||||
|
if not pythonExecPath:
|
||||||
|
pythonExecPath = utillib.pythonExecPath
|
||||||
|
return pythonExecPath
|
||||||
|
|
||||||
|
|
||||||
|
@@ -14,8 +14,10 @@ import traceback
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
|
||||||
def _registerMainModuleDir():
|
def isWindows():
|
||||||
global mainModuleDir
|
return os.name == 'nt'
|
||||||
|
|
||||||
|
def _generateMainModuleDir():
|
||||||
if sys.executable.find('python') != -1:
|
if sys.executable.find('python') != -1:
|
||||||
utilModuleDir = os.path.dirname(__file__)
|
utilModuleDir = os.path.dirname(__file__)
|
||||||
if not os.path.isabs(utilModuleDir):
|
if not os.path.isabs(utilModuleDir):
|
||||||
@@ -25,5 +27,22 @@ def _registerMainModuleDir():
|
|||||||
mainModuleDir = os.path.dirname(mainModuleDir) # Get rid of library.zip
|
mainModuleDir = os.path.dirname(mainModuleDir) # Get rid of library.zip
|
||||||
else:
|
else:
|
||||||
mainModuleDir = os.path.dirname(sys.executable)
|
mainModuleDir = os.path.dirname(sys.executable)
|
||||||
|
return mainModuleDir
|
||||||
|
|
||||||
|
mainModuleDir = _generateMainModuleDir()
|
||||||
|
|
||||||
|
|
||||||
|
def _generatePythonExecPath():
|
||||||
|
if sys.executable.find('python') != -1:
|
||||||
|
pythonExecPath = sys.executable
|
||||||
|
else:
|
||||||
|
pythonExecPath = os.path.join(os.path.dirname(sys.executable), '3rdparty\python2.3\python')
|
||||||
|
return pythonExecPath
|
||||||
|
|
||||||
|
pythonExecPath = _generatePythonExecPath()
|
||||||
|
|
||||||
|
def getCommandNameForExecPath(execPath):
|
||||||
|
if isWindows():
|
||||||
|
return '"%s"' % execPath
|
||||||
|
return execPath
|
||||||
|
|
||||||
_registerMainModuleDir()
|
|
||||||
|
103
wxPython/samples/ide/activegrid/util/aglogging.py
Normal file
103
wxPython/samples/ide/activegrid/util/aglogging.py
Normal file
@@ -0,0 +1,103 @@
|
|||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# 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
|
||||||
|
import logging
|
||||||
|
from activegrid.util.lang import *
|
||||||
|
|
||||||
|
LEVEL_FATAL = logging.FATAL
|
||||||
|
LEVEL_ERROR = logging.ERROR
|
||||||
|
LEVEL_WARN = logging.WARN
|
||||||
|
LEVEL_INFO = logging.INFO
|
||||||
|
LEVEL_DEBUG = logging.DEBUG
|
||||||
|
|
||||||
|
TEST_MODE_NONE = 0
|
||||||
|
TEST_MODE_DETERMINISTIC = 1
|
||||||
|
TEST_MODE_NON_DETERMINISTIC = 2
|
||||||
|
|
||||||
|
global agTestMode
|
||||||
|
agTestMode = TEST_MODE_NONE
|
||||||
|
|
||||||
|
def setTestMode(mode):
|
||||||
|
global agTestMode
|
||||||
|
agTestMode = mode
|
||||||
|
|
||||||
|
def getTestMode():
|
||||||
|
global agTestMode
|
||||||
|
return agTestMode
|
||||||
|
|
||||||
|
def testMode(normalObj, testObj=None):
|
||||||
|
if getTestMode() > TEST_MODE_NONE:
|
||||||
|
return testObj
|
||||||
|
return normalObj
|
||||||
|
|
||||||
|
pythonFileRefPattern = asString(r'(?<=File ")[^"]*(#[^#]*")(, line )[0-9]*')
|
||||||
|
phpFileRefPattern = asString(r'( in ).*#([^#]*#[^ ]*)(?= on line )')
|
||||||
|
pathSepPattern = os.sep
|
||||||
|
if (pathSepPattern == "\\"):
|
||||||
|
pathSepPattern = "\\\\"
|
||||||
|
pythonFileRefPattern = pythonFileRefPattern.replace("#", pathSepPattern)
|
||||||
|
pythonFileRefPattern = re.compile(pythonFileRefPattern)
|
||||||
|
phpFileRefPattern = phpFileRefPattern.replace("#", pathSepPattern)
|
||||||
|
phpFileRefPattern = re.compile(phpFileRefPattern)
|
||||||
|
|
||||||
|
def removeFileRefs(str):
|
||||||
|
str = pythonFileRefPattern.sub(_fileNameReplacement, str)
|
||||||
|
str = phpFileRefPattern.sub(_fileNameReplacementPHP, str)
|
||||||
|
return str
|
||||||
|
|
||||||
|
def removePHPFileRefs(str):
|
||||||
|
str = phpFileRefPattern.sub(_fileNameReplacementPHP, str)
|
||||||
|
return str
|
||||||
|
|
||||||
|
def _fileNameReplacement(match):
|
||||||
|
return "...%s" % match.group(1).replace(os.sep, "/")
|
||||||
|
|
||||||
|
def _fileNameReplacementPHP(match):
|
||||||
|
return "%s...%s" % (match.group(1), match.group(2).replace(os.sep, "/"))
|
||||||
|
|
||||||
|
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, exception=None):
|
||||||
|
if (True): # exception == None):
|
||||||
|
extype, val, t = sys.exc_info()
|
||||||
|
else:
|
||||||
|
extype = type(exception)
|
||||||
|
val = exception
|
||||||
|
if (stacktrace):
|
||||||
|
e,v,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
|
||||||
|
|
67
wxPython/samples/ide/activegrid/util/lang.py
Normal file
67
wxPython/samples/ide/activegrid/util/lang.py
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Name: lang.py
|
||||||
|
# Purpose: Active grid language specific utilities -- provides portability
|
||||||
|
# for common idiom's that have language specific implementations
|
||||||
|
#
|
||||||
|
# Author: Jeff Norton
|
||||||
|
#
|
||||||
|
# Created: 04/27/05
|
||||||
|
# CVS-ID: $Id$
|
||||||
|
# Copyright: (c) 2004-2005 ActiveGrid, Inc.
|
||||||
|
# License: wxWindows License
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
def isMain(caller):
|
||||||
|
return caller == '__main__'
|
||||||
|
|
||||||
|
def ag_className(obj):
|
||||||
|
return obj.__class__.__name__
|
||||||
|
|
||||||
|
def asDict(src):
|
||||||
|
return src
|
||||||
|
|
||||||
|
def asList(src):
|
||||||
|
return src
|
||||||
|
|
||||||
|
def asTuple(src):
|
||||||
|
return src
|
||||||
|
|
||||||
|
def asString(src):
|
||||||
|
return src
|
||||||
|
|
||||||
|
def asInt(src):
|
||||||
|
return src
|
||||||
|
|
||||||
|
def asBool(src):
|
||||||
|
return src
|
||||||
|
|
||||||
|
def asObject(src):
|
||||||
|
return src
|
||||||
|
|
||||||
|
def cast(src, type):
|
||||||
|
return src
|
||||||
|
|
||||||
|
def asRef(src):
|
||||||
|
return src
|
||||||
|
|
||||||
|
def asClass(src):
|
||||||
|
return src
|
||||||
|
|
||||||
|
def localize(text):
|
||||||
|
return text
|
||||||
|
|
||||||
|
# Pass in Python code as a string. The cross-compiler will convert to PHP
|
||||||
|
# and in-line the result.
|
||||||
|
def pyToPHP(expr):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Pass in PHP code as a string. The cross-compiler will drop it in-line verbatim.
|
||||||
|
def PHP(expr):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# Bracket Python only code. The Cross-compiler will ignore the bracketed code.
|
||||||
|
def ifDefPy(comment=False):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def endIfDef():
|
||||||
|
pass
|
@@ -14,98 +14,7 @@ import logging
|
|||||||
import traceback
|
import traceback
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
import xmlmarshaller
|
from types import *
|
||||||
|
|
||||||
AG_TYPE_MAPPING = { "ag:append" : "activegrid.model.processmodel.AppendOperation",
|
|
||||||
"ag:body" : "activegrid.model.processmodel.Body",
|
|
||||||
"ag:copy" : "activegrid.model.processmodel.CopyOperation",
|
|
||||||
"ag:cssRule" : "activegrid.model.processmodel.CssRule",
|
|
||||||
"ag:datasource" : "activegrid.data.dataservice.DataSource",
|
|
||||||
"ag:debug" : "activegrid.model.processmodel.DebugOperation",
|
|
||||||
"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:schemaOptions" : "activegrid.model.schema.SchemaOptions",
|
|
||||||
"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:catch" : "activegrid.model.processmodel.BPELCatch",
|
|
||||||
"bpws:faultHandlers" : "activegrid.model.processmodel.BPELFaultHandlers",
|
|
||||||
"bpws:invoke" : "activegrid.model.processmodel.BPELInvoke",
|
|
||||||
"bpws:onMessage" : "activegrid.model.processmodel.BPELOnMessage",
|
|
||||||
"bpws:otherwise" : "activegrid.model.processmodel.BPELOtherwise",
|
|
||||||
"bpws:pick" : "activegrid.model.processmodel.BPELPick",
|
|
||||||
"bpws:process" : "activegrid.model.processmodel.BPELProcess",
|
|
||||||
"bpws:receive" : "activegrid.model.processmodel.BPELReceive",
|
|
||||||
"bpws:reply" : "activegrid.model.processmodel.BPELReply",
|
|
||||||
"bpws:scope" : "activegrid.model.processmodel.BPELScope",
|
|
||||||
"bpws:sequence" : "activegrid.model.processmodel.BPELSequence",
|
|
||||||
"bpws:switch" : "activegrid.model.processmodel.BPELSwitch",
|
|
||||||
"bpws:terminate" : "activegrid.model.processmodel.BPELTerminate",
|
|
||||||
"bpws:variable" : "activegrid.model.processmodel.BPELVariable",
|
|
||||||
"bpws:variables" : "activegrid.model.processmodel.BPELVariables",
|
|
||||||
"bpws:while" : "activegrid.model.processmodel.BPELWhile",
|
|
||||||
"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",
|
|
||||||
"xs:all" : "activegrid.model.schema.XsdSequence",
|
|
||||||
"xs:complexType" : "activegrid.model.schema.XsdComplexType",
|
|
||||||
"xs:element" : "activegrid.model.schema.XsdElement",
|
|
||||||
"xs:field" : "activegrid.model.schema.XsdKeyField",
|
|
||||||
"xs:key" : "activegrid.model.schema.XsdKey",
|
|
||||||
"xs:keyref" : "activegrid.model.schema.XsdKeyRef",
|
|
||||||
"xs:schema" : "activegrid.model.schema.Schema",
|
|
||||||
"xs:selector" : "activegrid.model.schema.XsdKeySelector",
|
|
||||||
"xs:sequence" : "activegrid.model.schema.XsdSequence",
|
|
||||||
"projectmodel" : "activegrid.tool.ProjectEditor.ProjectModel",
|
|
||||||
}
|
|
||||||
|
|
||||||
def defaultLoad(fileObject, knownTypes=None):
|
|
||||||
xml = fileObject.read()
|
|
||||||
loadedObject = defaultUnmarshal(xml, knownTypes=knownTypes)
|
|
||||||
if hasattr(fileObject, 'name'):
|
|
||||||
loadedObject.fileName = os.path.abspath(fileObject.name)
|
|
||||||
loadedObject.initialize()
|
|
||||||
return loadedObject
|
|
||||||
|
|
||||||
def defaultUnmarshal(xml, knownTypes=None):
|
|
||||||
if not knownTypes: knownTypes = AG_TYPE_MAPPING
|
|
||||||
return xmlmarshaller.unmarshal(xml, knownTypes=knownTypes)
|
|
||||||
|
|
||||||
def defaultSave(fileObject, objectToSave, prettyPrint=True, knownTypes=None, withEncoding=1, encoding='utf-8'):
|
|
||||||
xml = defaultMarshal(objectToSave, prettyPrint=prettyPrint, knownTypes=knownTypes, withEncoding=withEncoding, encoding=encoding)
|
|
||||||
fileObject.write(xml)
|
|
||||||
fileObject.flush()
|
|
||||||
|
|
||||||
def defaultMarshal(objectToSave, prettyPrint=True, knownTypes=None, withEncoding=1, encoding='utf-8'):
|
|
||||||
if not knownTypes: knownTypes = AG_TYPE_MAPPING
|
|
||||||
return xmlmarshaller.marshal(objectToSave, prettyPrint=prettyPrint, knownTypes=knownTypes, withEncoding=withEncoding, encoding=encoding)
|
|
||||||
|
|
||||||
def clone(objectToClone, knownTypes=None, encoding='utf-8'):
|
|
||||||
if not knownTypes: knownTypes = AG_TYPE_MAPPING
|
|
||||||
xml = xmlmarshaller.marshal(objectToClone, prettyPrint=True, knownTypes=knownTypes, encoding=encoding)
|
|
||||||
clonedObject = xmlmarshaller.unmarshal(xml, knownTypes=knownTypes)
|
|
||||||
if hasattr(objectToClone, 'fileName'):
|
|
||||||
clonedObject.fileName = objectToClone.fileName
|
|
||||||
try:
|
|
||||||
clonedObject.initialize()
|
|
||||||
except AttributeError:
|
|
||||||
pass
|
|
||||||
return clonedObject
|
|
||||||
|
|
||||||
def classForName(className):
|
def classForName(className):
|
||||||
pathList = className.split('.')
|
pathList = className.split('.')
|
||||||
@@ -115,31 +24,6 @@ def classForName(className):
|
|||||||
code = code.__dict__[name]
|
code = code.__dict__[name]
|
||||||
return code
|
return code
|
||||||
|
|
||||||
def hasattrignorecase(object, name):
|
|
||||||
namelow = name.lower()
|
|
||||||
for attr in dir(object):
|
|
||||||
if attr.lower() == namelow:
|
|
||||||
return True
|
|
||||||
for attr in dir(object):
|
|
||||||
if attr.lower() == '_' + namelow:
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
def setattrignorecase(object, name, value):
|
|
||||||
namelow = name.lower()
|
|
||||||
for attr in object.__dict__:
|
|
||||||
if attr.lower() == namelow:
|
|
||||||
object.__dict__[attr] = value
|
|
||||||
return
|
|
||||||
object.__dict__[name] = value
|
|
||||||
|
|
||||||
def getattrignorecase(object, name):
|
|
||||||
namelow = name.lower()
|
|
||||||
for attr in object.__dict__:
|
|
||||||
if attr.lower() == namelow:
|
|
||||||
return object.__dict__[attr]
|
|
||||||
return object.__dict__[name]
|
|
||||||
|
|
||||||
def hasPropertyValue(obj, attr):
|
def hasPropertyValue(obj, attr):
|
||||||
hasProp = False
|
hasProp = False
|
||||||
try:
|
try:
|
||||||
@@ -159,7 +43,7 @@ def hasPropertyValue(obj, attr):
|
|||||||
return hasProp
|
return hasProp
|
||||||
|
|
||||||
def toDiffableString(value):
|
def toDiffableString(value):
|
||||||
s = repr(value)
|
s = str(value)
|
||||||
ds = ""
|
ds = ""
|
||||||
i = s.find(" at 0x")
|
i = s.find(" at 0x")
|
||||||
start = 0
|
start = 0
|
||||||
@@ -172,18 +56,50 @@ def toDiffableString(value):
|
|||||||
i = s.find(" at 0x", start)
|
i = s.find(" at 0x", start)
|
||||||
return ds + s[start:]
|
return ds + s[start:]
|
||||||
|
|
||||||
|
def toString(value, options=0):
|
||||||
|
if ((options & PRINT_OBJ_DIFFABLE) > 0):
|
||||||
|
return toDiffableString(value)
|
||||||
|
return value
|
||||||
|
|
||||||
|
def toTypeString(obj):
|
||||||
|
if (isinstance(obj, BooleanType)):
|
||||||
|
return "bool"
|
||||||
|
elif (isinstance(obj, UnicodeType)):
|
||||||
|
return "unicode"
|
||||||
|
elif (isinstance(obj, basestring)):
|
||||||
|
return "string"
|
||||||
|
elif (isinstance(obj, IntType)):
|
||||||
|
return "int"
|
||||||
|
elif (isinstance(obj, FloatType)):
|
||||||
|
return "float"
|
||||||
|
elif (type(obj) == ListType):
|
||||||
|
return "list"
|
||||||
|
elif (isinstance(obj, DictType)):
|
||||||
|
return "dict"
|
||||||
|
elif (isinstance(obj, TupleType)):
|
||||||
|
return "tuple"
|
||||||
|
elif (isinstance(obj, InstanceType)):
|
||||||
|
return type(obj)
|
||||||
|
else:
|
||||||
|
return type(obj)
|
||||||
|
|
||||||
PRINT_OBJ_GETATTR = 1
|
PRINT_OBJ_GETATTR = 1
|
||||||
PRINT_OBJ_HIDE_INTERNAL = 2
|
PRINT_OBJ_HIDE_INTERNAL = 2
|
||||||
PRINT_OBJ_COMPACT = 4
|
PRINT_OBJ_COMPACT = 4
|
||||||
PRINT_OBJ_NONONE = 8
|
PRINT_OBJ_NONONE = 8
|
||||||
|
PRINT_OBJ_DIFFABLE = 16
|
||||||
PRINT_OBJ_INTERNAL = 512
|
PRINT_OBJ_INTERNAL = 512
|
||||||
|
|
||||||
def printObject(out, object, name="", indent=0, flags=0, exclude=None, maxIndent=30):
|
def printObject(out, object, name="", indent=0, flags=0, exclude=None, maxIndent=30):
|
||||||
if ((maxIndent != None) and (indent > maxIndent)):
|
if ((maxIndent != None) and (indent > maxIndent)):
|
||||||
print >> out, " "*indent, name, str(object)
|
print >> out, " "*indent, "%s: %s" % (name, toString(str(object), flags)),
|
||||||
|
if ((flags & PRINT_OBJ_INTERNAL) == 0):
|
||||||
|
print >> out
|
||||||
return True
|
return True
|
||||||
finalNewLine = False
|
finalNewLine = False
|
||||||
printed = True
|
printed = True
|
||||||
|
## if (exclude == None):
|
||||||
|
## exclude = []
|
||||||
if ((flags & PRINT_OBJ_COMPACT) > 0):
|
if ((flags & PRINT_OBJ_COMPACT) > 0):
|
||||||
if (exclude and object in exclude):
|
if (exclude and object in exclude):
|
||||||
return
|
return
|
||||||
@@ -191,7 +107,7 @@ def printObject(out, object, name="", indent=0, flags=0, exclude=None, maxIndent
|
|||||||
if ((flags & PRINT_OBJ_INTERNAL) == 0):
|
if ((flags & PRINT_OBJ_INTERNAL) == 0):
|
||||||
finalNewLine = True
|
finalNewLine = True
|
||||||
flags |= PRINT_OBJ_INTERNAL
|
flags |= PRINT_OBJ_INTERNAL
|
||||||
if (object == None):
|
if (object is None):
|
||||||
if (flags & PRINT_OBJ_NONONE) == 0:
|
if (flags & PRINT_OBJ_NONONE) == 0:
|
||||||
print >> out, " "*indent, name, " = None",
|
print >> out, " "*indent, name, " = None",
|
||||||
else:
|
else:
|
||||||
@@ -201,21 +117,21 @@ def printObject(out, object, name="", indent=0, flags=0, exclude=None, maxIndent
|
|||||||
finalNewLine = False
|
finalNewLine = False
|
||||||
printed = False
|
printed = False
|
||||||
elif (isinstance(object, (list, tuple))):
|
elif (isinstance(object, (list, tuple))):
|
||||||
if (exclude and object in exclude):
|
if ((exclude != None) and object in exclude):
|
||||||
print >> out, " "*indent, name, " : ", type(object), " of length = ", len(object), " (already printed)",
|
print >> out, " "*indent, name, " : ", toTypeString(object), " of length = ", len(object), " (already printed)",
|
||||||
elif (exclude and name in exclude):
|
elif ((exclude != None) and name in exclude):
|
||||||
print >> out, " "*indent, name, " : ", type(object), " of length = ", len(object), " (excluded)",
|
print >> out, " "*indent, name, " : ", toTypeString(object), " of length = ", len(object), " (excluded)",
|
||||||
else:
|
else:
|
||||||
if (exclude != None): exclude.append(object)
|
if ((exclude != None) and (len(object) > 0)): exclude.append(object)
|
||||||
print >> out, " "*indent, name, " : ", type(object), " of length = %i" % len(object),
|
print >> out, " "*indent, name, " : ", toTypeString(object), " of length = %d" % len(object),
|
||||||
for i, o in enumerate(object):
|
for i, o in enumerate(object):
|
||||||
print >> out
|
print >> out
|
||||||
printObject(out, o, name="[%i]" % i, indent=indent+2, flags=flags, exclude=exclude, maxIndent=maxIndent)
|
printObject(out, o, name="[%d]" % i, indent=indent+2, flags=flags, exclude=exclude, maxIndent=maxIndent)
|
||||||
elif (isinstance(object, dict)):
|
elif (isinstance(object, dict)):
|
||||||
if (exclude and object in exclude):
|
if ((exclude != None) and object in exclude):
|
||||||
print >> out, " "*indent, name, " : ", type(object), " (already printed)",
|
print >> out, " "*indent, name, " : ", toTypeString(object), " (already printed)",
|
||||||
else:
|
else:
|
||||||
if (exclude != None): exclude.append(object)
|
if ((exclude != None) and (len(object) > 0)): exclude.append(object)
|
||||||
if (len(name) > 0):
|
if (len(name) > 0):
|
||||||
print >> out, " "*indent, name,
|
print >> out, " "*indent, name,
|
||||||
if ((flags & PRINT_OBJ_COMPACT) == 0):
|
if ((flags & PRINT_OBJ_COMPACT) == 0):
|
||||||
@@ -226,25 +142,29 @@ def printObject(out, object, name="", indent=0, flags=0, exclude=None, maxIndent
|
|||||||
print >> out
|
print >> out
|
||||||
keys = object.keys()
|
keys = object.keys()
|
||||||
keys.sort()
|
keys.sort()
|
||||||
for n in keys:
|
for key in keys:
|
||||||
if ((n != None) and (not n.startswith("_") or ((flags & PRINT_OBJ_HIDE_INTERNAL) == 0))):
|
if (key != None):
|
||||||
if printObject(out, object[n], name=n, indent=indent+2, flags=flags, exclude=exclude, maxIndent=maxIndent):
|
n = key
|
||||||
|
if (not (isinstance(n, basestring))):
|
||||||
|
n = str(n)
|
||||||
|
if ((not n.startswith("_") or ((flags & PRINT_OBJ_HIDE_INTERNAL) == 0))):
|
||||||
|
if printObject(out, object[key], name=n, indent=indent+2, flags=(flags | PRINT_OBJ_INTERNAL), exclude=exclude, maxIndent=maxIndent):
|
||||||
if ((flags & PRINT_OBJ_COMPACT) == 0):
|
if ((flags & PRINT_OBJ_COMPACT) == 0):
|
||||||
print >> out
|
print >> out
|
||||||
else:
|
else:
|
||||||
print >> out, ",",
|
print >> out, ",",
|
||||||
print >> out, " "*indent, "}",
|
print >> out, " "*indent, "}",
|
||||||
elif (hasattr(object, "__dict__")):
|
elif (hasattr(object, "__dict__")):
|
||||||
if (exclude and object in exclude):
|
if ((exclude != None) and object in exclude):
|
||||||
print >> out, " "*indent, name, " : ", type(object), " (already printed) = ", toDiffableString(object),
|
print >> out, " "*indent, name, " : ", toTypeString(object), " (already printed) = ", toDiffableString(object),
|
||||||
else:
|
else:
|
||||||
if (exclude != None): exclude.append(object)
|
if (exclude != None): exclude.append(object)
|
||||||
if (name.startswith("_")):
|
if (name.startswith("_")): ## and ((flags & PRINT_OBJ_HIDE_INTERNAL) > 0)):
|
||||||
print >> out, " "*indent, name, " : ", type(object),
|
print >> out, " "*indent, name, " : ", toTypeString(object),
|
||||||
elif (exclude and object.__dict__ in exclude):
|
elif ((exclude != None) and object.__dict__ in exclude):
|
||||||
print >> out, " "*indent, name, " : ", type(object), " (already printed)",
|
print >> out, " "*indent, name, " : ", toTypeString(object), " (already printed)",
|
||||||
else:
|
else:
|
||||||
print >> out, " "*indent, name, " : ", type(object),
|
print >> out, " "*indent, name, " : ", toTypeString(object),
|
||||||
if ((flags & PRINT_OBJ_GETATTR) == 0):
|
if ((flags & PRINT_OBJ_GETATTR) == 0):
|
||||||
if ((flags & PRINT_OBJ_COMPACT) == 0):
|
if ((flags & PRINT_OBJ_COMPACT) == 0):
|
||||||
print >> out
|
print >> out
|
||||||
@@ -259,14 +179,19 @@ def printObject(out, object, name="", indent=0, flags=0, exclude=None, maxIndent
|
|||||||
elif (indent < 0):
|
elif (indent < 0):
|
||||||
print >> out, object,
|
print >> out, object,
|
||||||
elif isinstance(object, basestring):
|
elif isinstance(object, basestring):
|
||||||
if (exclude and name in exclude):
|
if ((exclude != None) and name in exclude):
|
||||||
print >> out, " "*indent, name, " : ", type(object), " of length = ", len(object), " (excluded)",
|
print >> out, " "*indent, name, " : ", toTypeString(object), " of length = ", len(object), " (excluded)",
|
||||||
elif (len(object) > 100):
|
elif (len(object) > 100):
|
||||||
print >> out, " "*indent, name, ":", type(object), "[%i] = %s...%s" % (len(object), object[:50], object[-50:]),
|
print >> out, " "*indent, name, ":", toTypeString(object), "[%d] = %s...%s" % (len(object), object[:50], object[-50:]),
|
||||||
else:
|
else:
|
||||||
print >> out, " "*indent, name, ":", type(object), "=", str(object),
|
print >> out, " "*indent, name, ":", toTypeString(object), "=", str(object),
|
||||||
|
## elif (isinstance(object, float)):
|
||||||
|
## val = str(object)
|
||||||
|
## if (len(val) > 17):
|
||||||
|
## val = val[:17]
|
||||||
|
## print >> out, " "*indent, name, ":", type(object), "=", val,
|
||||||
else:
|
else:
|
||||||
print >> out, " "*indent, name, ":", type(object), "=", str(object),
|
print >> out, " "*indent, name, ":", toTypeString(object), "=", str(object),
|
||||||
if (finalNewLine):
|
if (finalNewLine):
|
||||||
print >> out
|
print >> out
|
||||||
return printed
|
return printed
|
||||||
|
File diff suppressed because it is too large
Load Diff
@@ -10,8 +10,7 @@
|
|||||||
# License: wxWindows License
|
# License: wxWindows License
|
||||||
#----------------------------------------------------------------------------
|
#----------------------------------------------------------------------------
|
||||||
import xml.sax
|
import xml.sax
|
||||||
import xml.sax.handler
|
from activegrid.util.lang import *
|
||||||
|
|
||||||
|
|
||||||
class XMLPrettyPrinter(xml.sax.ContentHandler):
|
class XMLPrettyPrinter(xml.sax.ContentHandler):
|
||||||
def __init__(self, indentationChar=' ', newlineChar='\n'):
|
def __init__(self, indentationChar=' ', newlineChar='\n'):
|
||||||
@@ -24,7 +23,7 @@ class XMLPrettyPrinter(xml.sax.ContentHandler):
|
|||||||
|
|
||||||
## ContentHandler methods
|
## ContentHandler methods
|
||||||
def startElement(self, name, attrs):
|
def startElement(self, name, attrs):
|
||||||
indentation = self.newlineChar + (self.indentationLevel * self.indentationChar)
|
indentation = self.newlineChar + (self.indentationChar * self.indentationLevel)
|
||||||
# build attribute string
|
# build attribute string
|
||||||
attrstring = ''
|
attrstring = ''
|
||||||
for attr in attrs.getNames():
|
for attr in attrs.getNames():
|
||||||
@@ -36,6 +35,7 @@ class XMLPrettyPrinter(xml.sax.ContentHandler):
|
|||||||
self.hitCharData = False
|
self.hitCharData = False
|
||||||
|
|
||||||
def characters(self, content):
|
def characters(self, content):
|
||||||
|
## print "--> characters(%s)" % content
|
||||||
self.xmlOutput += content
|
self.xmlOutput += content
|
||||||
self.hitCharData = True
|
self.hitCharData = True
|
||||||
|
|
||||||
@@ -43,11 +43,12 @@ class XMLPrettyPrinter(xml.sax.ContentHandler):
|
|||||||
self.indentationLevel -= 1
|
self.indentationLevel -= 1
|
||||||
indentation = ''
|
indentation = ''
|
||||||
if not self.hitCharData:
|
if not self.hitCharData:
|
||||||
## indentation += self.newlineChar + (self.indentationLevel * self.indentationChar)
|
indentation += self.newlineChar + (self.indentationChar * self.indentationLevel)
|
||||||
indentation += self.indentationLevel * self.indentationChar
|
## indentation += self.indentationChar * self.indentationLevel
|
||||||
else:
|
else:
|
||||||
self.hitCharData = False
|
self.hitCharData = False
|
||||||
self.xmlOutput += '%s</%s>%s' % (indentation, self.elementStack.pop(), self.newlineChar)
|
## self.xmlOutput += '%s</%s>%s' % (indentation, self.elementStack.pop(), self.newlineChar)
|
||||||
|
self.xmlOutput += '%s</%s>' % (indentation, self.elementStack.pop())
|
||||||
|
|
||||||
def getXMLString(self):
|
def getXMLString(self):
|
||||||
return self.xmlOutput[1:]
|
return self.xmlOutput[1:]
|
||||||
@@ -57,7 +58,7 @@ def xmlprettyprint(xmlstr, spaces=4):
|
|||||||
xml.sax.parseString(xmlstr, xpp)
|
xml.sax.parseString(xmlstr, xpp)
|
||||||
return xpp.getXMLString()
|
return xpp.getXMLString()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if isMain(__name__):
|
||||||
simpleTestString = """<one>some text<two anattr="booga">two's data</two></one>"""
|
simpleTestString = """<one>some text<two anattr="booga">two's data</two></one>"""
|
||||||
print prettyprint(simpleTestString)
|
print xmlprettyprint(simpleTestString)
|
||||||
|
|
||||||
|
128
wxPython/samples/ide/activegrid/util/xmlutils.py
Normal file
128
wxPython/samples/ide/activegrid/util/xmlutils.py
Normal file
@@ -0,0 +1,128 @@
|
|||||||
|
#----------------------------------------------------------------------------
|
||||||
|
# Name: xmlutils.py
|
||||||
|
# Purpose: XML and Marshaller Utilities
|
||||||
|
#
|
||||||
|
# Author: Jeff Norton
|
||||||
|
#
|
||||||
|
# Created: 6/2/05
|
||||||
|
# CVS-ID: $Id$
|
||||||
|
# Copyright: (c) 2004-2005 ActiveGrid, Inc.
|
||||||
|
# License: wxWindows License
|
||||||
|
#----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
import os
|
||||||
|
import activegrid.util.objutils as objutils
|
||||||
|
import activegrid.util.xmlmarshaller as xmlmarshaller
|
||||||
|
|
||||||
|
agKnownTypes = None
|
||||||
|
|
||||||
|
def defaultLoad(fileObject, knownTypes=None):
|
||||||
|
xml = fileObject.read()
|
||||||
|
loadedObject = unmarshal(xml, knownTypes=knownTypes)
|
||||||
|
if hasattr(fileObject, 'name'):
|
||||||
|
loadedObject.fileName = os.path.abspath(fileObject.name)
|
||||||
|
loadedObject.initialize()
|
||||||
|
return loadedObject
|
||||||
|
|
||||||
|
def unmarshal(xml, knownTypes=None):
|
||||||
|
if not knownTypes: knownTypes = getAgKnownTypes()
|
||||||
|
return xmlmarshaller.unmarshal(xml, knownTypes=knownTypes)
|
||||||
|
|
||||||
|
def defaultSave(fileObject, objectToSave, prettyPrint=True, knownTypes=None, encoding='utf-8'):
|
||||||
|
xml = marshal(objectToSave, prettyPrint=prettyPrint, knownTypes=knownTypes, encoding=encoding)
|
||||||
|
fileObject.write(xml)
|
||||||
|
fileObject.flush()
|
||||||
|
|
||||||
|
def marshal(objectToSave, prettyPrint=True, knownTypes=None, encoding='utf-8'):
|
||||||
|
if not knownTypes: knownTypes = getAgKnownTypes()
|
||||||
|
return xmlmarshaller.marshal(objectToSave, prettyPrint=prettyPrint, knownTypes=knownTypes, encoding=encoding)
|
||||||
|
|
||||||
|
def cloneObject(objectToClone, knownTypes=None, encoding='utf-8'):
|
||||||
|
if not knownTypes: knownTypes = getAgKnownTypes()
|
||||||
|
xml = xmlmarshaller.marshal(objectToClone, prettyPrint=True, knownTypes=knownTypes, encoding=encoding)
|
||||||
|
clonedObject = xmlmarshaller.unmarshal(xml, knownTypes=knownTypes)
|
||||||
|
if hasattr(objectToClone, 'fileName'):
|
||||||
|
clonedObject.fileName = objectToClone.fileName
|
||||||
|
try:
|
||||||
|
clonedObject.initialize()
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
|
return clonedObject
|
||||||
|
|
||||||
|
def getAgKnownTypes():
|
||||||
|
import activegrid.model.processmodel
|
||||||
|
import activegrid.model.schema
|
||||||
|
import activegrid.data.dataservice
|
||||||
|
import activegrid.server.deployment
|
||||||
|
global agKnownTypes
|
||||||
|
if agKnownTypes == None:
|
||||||
|
tmpAgKnownTypes = {}
|
||||||
|
AG_TYPE_MAPPING = {
|
||||||
|
"ag:append" : "activegrid.model.processmodel.AppendOperation",
|
||||||
|
"ag:body" : "activegrid.model.processmodel.Body",
|
||||||
|
"ag:cssRule" : "activegrid.model.processmodel.CssRule",
|
||||||
|
"ag:datasource" : "activegrid.data.dataservice.DataSource",
|
||||||
|
"ag:debug" : "activegrid.model.processmodel.DebugOperation",
|
||||||
|
"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:restParameter" : "activegrid.server.deployment.RestParameter",
|
||||||
|
"ag:restService" : "activegrid.server.deployment.RestService",
|
||||||
|
"ag:schemaOptions" : "activegrid.model.schema.SchemaOptions",
|
||||||
|
"ag:schemaref" : "activegrid.server.deployment.SchemaRef",
|
||||||
|
"ag:serviceref" : "activegrid.server.deployment.ServiceRef",
|
||||||
|
"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:catch" : "activegrid.model.processmodel.BPELCatch",
|
||||||
|
"bpws:faultHandlers" : "activegrid.model.processmodel.BPELFaultHandlers",
|
||||||
|
"bpws:invoke" : "activegrid.model.processmodel.BPELInvoke",
|
||||||
|
"bpws:onMessage" : "activegrid.model.processmodel.BPELOnMessage",
|
||||||
|
"bpws:otherwise" : "activegrid.model.processmodel.BPELOtherwise",
|
||||||
|
"bpws:pick" : "activegrid.model.processmodel.BPELPick",
|
||||||
|
"bpws:process" : "activegrid.model.processmodel.BPELProcess",
|
||||||
|
"bpws:receive" : "activegrid.model.processmodel.BPELReceive",
|
||||||
|
"bpws:reply" : "activegrid.model.processmodel.BPELReply",
|
||||||
|
"bpws:scope" : "activegrid.model.processmodel.BPELScope",
|
||||||
|
"bpws:sequence" : "activegrid.model.processmodel.BPELSequence",
|
||||||
|
"bpws:switch" : "activegrid.model.processmodel.BPELSwitch",
|
||||||
|
"bpws:terminate" : "activegrid.model.processmodel.BPELTerminate",
|
||||||
|
"bpws:variable" : "activegrid.model.processmodel.BPELVariable",
|
||||||
|
"bpws:variables" : "activegrid.model.processmodel.BPELVariables",
|
||||||
|
"bpws:while" : "activegrid.model.processmodel.BPELWhile",
|
||||||
|
"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",
|
||||||
|
"xs:all" : "activegrid.model.schema.XsdSequence",
|
||||||
|
"xs:complexType" : "activegrid.model.schema.XsdComplexType",
|
||||||
|
"xs:element" : "activegrid.model.schema.XsdElement",
|
||||||
|
"xs:field" : "activegrid.model.schema.XsdKeyField",
|
||||||
|
"xs:key" : "activegrid.model.schema.XsdKey",
|
||||||
|
"xs:keyref" : "activegrid.model.schema.XsdKeyRef",
|
||||||
|
"xs:schema" : "activegrid.model.schema.Schema",
|
||||||
|
"xs:selector" : "activegrid.model.schema.XsdKeySelector",
|
||||||
|
"xs:sequence" : "activegrid.model.schema.XsdSequence",
|
||||||
|
}
|
||||||
|
|
||||||
|
for keyName, className in AG_TYPE_MAPPING.iteritems():
|
||||||
|
try:
|
||||||
|
tmpAgKnownTypes[keyName] = objutils.classForName(className)
|
||||||
|
except KeyError:
|
||||||
|
print "Error mapping knownType", className
|
||||||
|
pass
|
||||||
|
if len(tmpAgKnownTypes) > 0:
|
||||||
|
agKnownTypes = tmpAgKnownTypes
|
||||||
|
return agKnownTypes
|
@@ -90,6 +90,8 @@ class TextEditorApplication(pydocview.DocApp):
|
|||||||
if os.path.exists("tips.txt"):
|
if os.path.exists("tips.txt"):
|
||||||
wx.CallAfter(self.ShowTip, wx.GetApp().GetTopWindow(), wx.CreateFileTipProvider("tips.txt", 0))
|
wx.CallAfter(self.ShowTip, wx.GetApp().GetTopWindow(), wx.CreateFileTipProvider("tips.txt", 0))
|
||||||
|
|
||||||
|
wx.UpdateUIEvent.SetUpdateInterval(400) # Overhead of updating menus was too much. Change to update every 400 milliseconds.
|
||||||
|
|
||||||
# Tell the framework that everything is great
|
# Tell the framework that everything is great
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import os.path
|
import os.path
|
||||||
|
import shutil
|
||||||
import wx
|
import wx
|
||||||
import sys
|
import sys
|
||||||
_ = wx.GetTranslation
|
_ = wx.GetTranslation
|
||||||
@@ -436,6 +437,7 @@ class Document(wx.EvtHandler):
|
|||||||
|
|
||||||
backupFilename = None
|
backupFilename = None
|
||||||
fileObject = None
|
fileObject = None
|
||||||
|
copied = False
|
||||||
try:
|
try:
|
||||||
# if current file exists, move it to a safe place temporarily
|
# if current file exists, move it to a safe place temporarily
|
||||||
if os.path.exists(filename):
|
if os.path.exists(filename):
|
||||||
@@ -453,7 +455,8 @@ class Document(wx.EvtHandler):
|
|||||||
while os.path.exists(backupFilename):
|
while os.path.exists(backupFilename):
|
||||||
i += 1
|
i += 1
|
||||||
backupFilename = "%s.bak%s" % (filename, i)
|
backupFilename = "%s.bak%s" % (filename, i)
|
||||||
os.rename(filename, backupFilename)
|
shutil.copy(filename, backupFilename)
|
||||||
|
copied = True
|
||||||
|
|
||||||
fileObject = file(filename, 'w')
|
fileObject = file(filename, 'w')
|
||||||
self.SaveObject(fileObject)
|
self.SaveObject(fileObject)
|
||||||
@@ -470,11 +473,9 @@ class Document(wx.EvtHandler):
|
|||||||
if fileObject:
|
if fileObject:
|
||||||
fileObject.close() # file is still open, close it, need to do this before removal
|
fileObject.close() # file is still open, close it, need to do this before removal
|
||||||
|
|
||||||
# save failed, restore old file
|
# save failed, remove copied file
|
||||||
if backupFilename:
|
if backupFilename and copied:
|
||||||
os.remove(filename)
|
os.remove(backupFilename)
|
||||||
os.rename(backupFilename, filename)
|
|
||||||
self.SetDocumentModificationDate()
|
|
||||||
|
|
||||||
wx.MessageBox("Could not save '%s'. %s" % (FileNameFromPath(filename), sys.exc_value),
|
wx.MessageBox("Could not save '%s'. %s" % (FileNameFromPath(filename), sys.exc_value),
|
||||||
msgTitle,
|
msgTitle,
|
||||||
@@ -1247,10 +1248,6 @@ class DocTemplate(wx.Object):
|
|||||||
Returns True if the path's extension matches one of this template's
|
Returns True if the path's extension matches one of this template's
|
||||||
file filter extensions.
|
file filter extensions.
|
||||||
"""
|
"""
|
||||||
## print "*** path", path
|
|
||||||
## if "*.*" in self.GetFileFilter():
|
|
||||||
## return True
|
|
||||||
##
|
|
||||||
ext = FindExtension(path)
|
ext = FindExtension(path)
|
||||||
if not ext: return False
|
if not ext: return False
|
||||||
return ext in self.GetFileFilter()
|
return ext in self.GetFileFilter()
|
||||||
@@ -2793,8 +2790,10 @@ class DocMDIChildFrame(wx.MDIChildFrame):
|
|||||||
self._childView.Activate(False)
|
self._childView.Activate(False)
|
||||||
self._childView.Destroy()
|
self._childView.Destroy()
|
||||||
self._childView = None
|
self._childView = None
|
||||||
if self._childDocument:
|
if self._childDocument: # This isn't in the wxWindows codebase but the document needs to be disposed of somehow
|
||||||
self._childDocument.Destroy() # This isn't in the wxWindows codebase but the document needs to be disposed of somehow
|
self._childDocument.DeleteContents()
|
||||||
|
if self._childDocument.GetDocumentManager():
|
||||||
|
self._childDocument.GetDocumentManager().RemoveDocument(self._childDocument)
|
||||||
self._childDocument = None
|
self._childDocument = None
|
||||||
self.Destroy()
|
self.Destroy()
|
||||||
else:
|
else:
|
||||||
|
@@ -1185,7 +1185,7 @@ class DocService(wx.EvtHandler):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
"""Initializes the DocService."""
|
"""Initializes the DocService."""
|
||||||
wx.EvtHandler.__init__(self)
|
pass
|
||||||
|
|
||||||
|
|
||||||
def GetDocumentManager(self):
|
def GetDocumentManager(self):
|
||||||
@@ -1478,7 +1478,7 @@ class GeneralOptionsPanel(wx.Panel):
|
|||||||
msgTitle = wx.GetApp().GetAppName()
|
msgTitle = wx.GetApp().GetAppName()
|
||||||
if not msgTitle:
|
if not msgTitle:
|
||||||
msgTitle = _("Document Options")
|
msgTitle = _("Document Options")
|
||||||
wx.MessageBox("Document interface changes will not appear until the application is restarted.",
|
wx.MessageBox(_("Document interface changes will not appear until the application is restarted."),
|
||||||
msgTitle,
|
msgTitle,
|
||||||
wx.OK | wx.ICON_INFORMATION,
|
wx.OK | wx.ICON_INFORMATION,
|
||||||
self.GetParent())
|
self.GetParent())
|
||||||
@@ -1995,10 +1995,7 @@ class DocApp(wx.PySimpleApp):
|
|||||||
if isinstance(document, ChildDocument) and document.GetParentDocument() == parentDocument:
|
if isinstance(document, ChildDocument) and document.GetParentDocument() == parentDocument:
|
||||||
if document.GetFirstView().GetFrame():
|
if document.GetFirstView().GetFrame():
|
||||||
document.GetFirstView().GetFrame().SetFocus()
|
document.GetFirstView().GetFrame().SetFocus()
|
||||||
if document.GetFirstView().OnClose(deleteWindow = False):
|
if not document.GetFirstView().OnClose():
|
||||||
if document.GetFirstView().GetFrame():
|
|
||||||
document.GetFirstView().GetFrame().Close() # wxBug: Need to do this for some random reason
|
|
||||||
else:
|
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
@@ -2338,7 +2335,6 @@ class AboutService(DocService):
|
|||||||
"""
|
"""
|
||||||
Initializes the AboutService.
|
Initializes the AboutService.
|
||||||
"""
|
"""
|
||||||
DocService.__init__(self)
|
|
||||||
if aboutDialog:
|
if aboutDialog:
|
||||||
self._dlg = aboutDialog
|
self._dlg = aboutDialog
|
||||||
self._image = None
|
self._image = None
|
||||||
@@ -2406,7 +2402,6 @@ class FilePropertiesService(DocService):
|
|||||||
"""
|
"""
|
||||||
Initializes the PropertyService.
|
Initializes the PropertyService.
|
||||||
"""
|
"""
|
||||||
DocService.__init__(self)
|
|
||||||
self._customEventHandlers = []
|
self._customEventHandlers = []
|
||||||
|
|
||||||
|
|
||||||
@@ -2710,7 +2705,6 @@ class WindowMenuService(DocService):
|
|||||||
"""
|
"""
|
||||||
Initializes the WindowMenu and its globals.
|
Initializes the WindowMenu and its globals.
|
||||||
"""
|
"""
|
||||||
DocService.__init__(self)
|
|
||||||
self.ARRANGE_WINDOWS_ID = wx.NewId()
|
self.ARRANGE_WINDOWS_ID = wx.NewId()
|
||||||
self.SELECT_WINDOW_1_ID = wx.NewId()
|
self.SELECT_WINDOW_1_ID = wx.NewId()
|
||||||
self.SELECT_WINDOW_2_ID = wx.NewId()
|
self.SELECT_WINDOW_2_ID = wx.NewId()
|
||||||
|
Reference in New Issue
Block a user