From: <sv...@ww...> - 2008-02-17 14:58:16
|
Author: nsmoooose Date: 2008-02-17 06:58:09 -0800 (Sun, 17 Feb 2008) New Revision: 2218 Modified: trunk/csp/tools/layout2/scripts/ui/CommandControlFactory.py trunk/csp/tools/layout2/scripts/ui/commands/Command.py trunk/csp/tools/layout2/scripts/ui/commands/OpenSelectedFileCommand.py Log: All command objects in the layout editor now has a output document set. This means that every command can print output very easily to the output window. Browse at: https://www.zerobar.net/viewcvs/viewcvs.cgi?view=rev&rev=2218 Modified: trunk/csp/tools/layout2/scripts/ui/CommandControlFactory.py =================================================================== --- trunk/csp/tools/layout2/scripts/ui/CommandControlFactory.py 2008-02-17 13:26:20 UTC (rev 2217) +++ trunk/csp/tools/layout2/scripts/ui/CommandControlFactory.py 2008-02-17 14:58:09 UTC (rev 2218) @@ -50,6 +50,18 @@ def Execute(self, event): """Bind this method to a wx event. When the event is fired the command will be executed.""" - print("Executing: " + self.command.__class__.__name__) + + # If possible we will print the command execution to the output document. + # We will also assign the output document to the command so the command can + # be able the print messages to the console. + application = wx.GetApp() + if application is not None: + documents = application.GetDocumentRegistry() + outputDocument = documents.GetByName('output') + if outputDocument is not None: + self.command.SetOutputDocument(outputDocument) + outputDocument.WriteLine("Executing: " + self.command.__class__.__name__) + + # Execute the command. self.command.Execute() event.Skip() \ No newline at end of file Modified: trunk/csp/tools/layout2/scripts/ui/commands/Command.py =================================================================== --- trunk/csp/tools/layout2/scripts/ui/commands/Command.py 2008-02-17 13:26:20 UTC (rev 2217) +++ trunk/csp/tools/layout2/scripts/ui/commands/Command.py 2008-02-17 14:58:09 UTC (rev 2218) @@ -4,6 +4,9 @@ """Base class for all command objects. Implement apropriate methods in your derived class to execute this command.""" + + def __init__(self): + self.outputDocument = None def GetCaption(self): """The name of the command to be displayed in a menu @@ -24,3 +27,8 @@ def Execute(self): pass + def SetOutputDocument(self, outputDocument): + self.outputDocument = outputDocument + + def GetOutputDocument(self): + return self.outputDocument \ No newline at end of file Modified: trunk/csp/tools/layout2/scripts/ui/commands/OpenSelectedFileCommand.py =================================================================== --- trunk/csp/tools/layout2/scripts/ui/commands/OpenSelectedFileCommand.py 2008-02-17 13:26:20 UTC (rev 2217) +++ trunk/csp/tools/layout2/scripts/ui/commands/OpenSelectedFileCommand.py 2008-02-17 14:58:09 UTC (rev 2218) @@ -3,9 +3,10 @@ import wx from csp.tools.layout2.scripts.data import DataTree from csp.tools.layout2.scripts.ui.controls.ProjectTree import ProjectTree +from Command import Command from FileCommandRegistry import FileCommandRegistry -class OpenSelectedFileCommand: +class OpenSelectedFileCommand(Command): """Opens the selected file in the project tree of this application. When this command is executed we are trying to identify the type of file we are loading and then |