pynsource icon indicating copy to clipboard operation
pynsource copied to clipboard

Refactor gui to use command objects

Open GoogleCodeExporter opened this issue 9 years ago • 19 comments

Tame the large pynsourceGui classes and break them up into smaller pieces of 
functionality.

Original issue reported on code.google.com by [email protected] on 15 Jul 2012 at 2:32

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

Work has begun r418

Original comment by [email protected] on 15 Jul 2012 at 2:32

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

Added a couple of commands.  Not sure about the structure. r421

Original comment by [email protected] on 15 Jul 2012 at 3:32

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

This issue was updated by revision r425.

For more info on using packages see the addendum to my python course notes at 
https://docs.google.com/document/d/1qDkta2lJ8f1v542Lfwtm-zWJDvG5OtOr6Z3hcYgI54s/
edit and possibly the stackoverflow article 
http://stackoverflow.com/questions/448271/what-is-init-py-for 

Original comment by [email protected] on 15 Jul 2012 at 8:54

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

This issue was updated by revision r427.

Created nice UML of current classes to help me think this through.

Original comment by [email protected] on 15 Jul 2012 at 2:35

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

This issue was updated by revision r428.

Introduced beginnings of hexmvc architecture incl. event notification.  App and 
Controller classes created.  Also a Context class created which holds refs to 
all important objects.

Original comment by [email protected] on 16 Jul 2012 at 2:55

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

This issue was updated by revision r429.

Cleaned up Node Shape deletion - made clear the separation between model and 
view a bit more.  Shapes is a view model element and points to a node model 
element via the umlworkspace model mapping dictionary.

Original comment by [email protected] on 16 Jul 2012 at 4:21

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

This issue was updated by revision r430.

CMD_DESELECT_ALL_SHAPES implemented.

Original comment by [email protected] on 16 Jul 2012 at 1:12

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

This issue was updated by revision r432.

Decided to keep local dump diagnostics in the relevant module e.g. umlworkspace 
(which is the model) has a .Dump() methods, as does 
self.context.coordmapper.DumpCalibrationInfo etc.  Only the master 
CmdDumpUmlWorkspace (as called by self.observers.CMD_DUMP_UML_WORKSPACE()) is a 
cmd.

Original comment by [email protected] on 18 Jul 2012 at 12:44

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

This issue was updated by revision r433.

Created model package and moved class UmlWorkspace in there.  As well as 
refactoring to give it the method ConvertParseModelToUmlModel() which should 
always have been in there anyway.

Note: before we start mapping to wx shapes, it seems we have the 
 * 'ParseModel' the parse model (our original model created by the command line tool pynsource)
 * 'UmlModel' the UmlWorkspace  model (more advanced model, subsumes the old model)
the latter contains lots of juicy info e.g. 
 * dict of classname => shape entries  # self.classnametoshape = {}
 * list of (classname, parentclassname) tuples  # self.associations_generalisation = []
 * list of (rhs, lhs) tuples  # self.associations_composition = []
 * UmlGraph()   # self.graph
and the graph is full of GraphNode objects, and associations, which are 
ultimately what we layout.

- arguably the dict of classname => shape entries is a rendering related 
mapping which shouldn't be here?

- I think we need the association mappings because the graph object we use only 
has simple associations not the level of detail we need.  Perhaps re-examing 
this and rely only on a      beefed up graph class instead - in order to 
simplify things?

Original comment by [email protected] on 18 Jul 2012 at 12:50

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

This issue was updated by revision r434.

Converted file management commands into command objects in app/cmds/filemgmt.py
Having the controller.py route all these calls is getting tedious.  And 
creating commands with special initialisers is also a bit tedious.

Original comment by [email protected] on 19 Jul 2012 at 5:43

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

This issue was updated by revision r435.

Refactored from using observer based command invocation to a simpler CmdInvoker 
class, which means no need for Controller to have lots of proxy functions 
fronting for the command classes.

CmdInvoker:
    When you call any method on an instance of this invoker class, the method is
    interpreted as the name of a command class to be instantiated. Parameters in
    the method call are used as paramters to the constructor. After the command
    class is instantiated, a context object is attached, and the command passed
    to a command manager to be run. No extra parameters are injected into the
    constructor or to the execute() call.

Original comment by [email protected] on 21 Jul 2012 at 3:27

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

This issue was updated by revision r436.

Layout commands starting to be moved into command objects.  Interestingly some 
layout functions are being called from other commands - so the issue of 
commands using each other is coming up. Perhaps such commands simply use common 
functionality which doesn't get turned into a command.

Original comment by [email protected] on 21 Jul 2012 at 2:02

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

This issue was updated by revision r437.

Original comment by [email protected] on 21 Jul 2012 at 2:27

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

This issue was updated by revision r439.

Commented how the plethora of redraw functions are used (who is calling each of 
them) and renamed some of them.  Hoping to consolidate them soon.

Original comment by [email protected] on 22 Jul 2012 at 12:23

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

This issue was updated by revision r452.

Created commands out of remaining pynsourcegui methods that call 
redraw_everything().  CmdFileImport, CmdFileImport, CmdRefreshUmlWindow.  Now 
the only things that calls redraw_everything() are commands.  Just trying to 
get organised here and reduce couplings.  Still hope to unify 
redraw_everything() and stateofthenation soon.

Original comment by [email protected] on 28 Jul 2012 at 1:47

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

correction
    # UTILITY - called by CmdFileImport, CmdBootstrap, CmdRefreshUmlWindow
    def redraw_everything(self):

Original comment by [email protected] on 28 Jul 2012 at 4:01

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

This issue was updated by revision r454.

Refactored File Import commands.
Also, redraw_everything() now only called by CmdLayout, CmdRefreshUmlWindow

Original comment by [email protected] on 28 Jul 2012 at 4:18

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

This issue was updated by revision r455.

redraw_everything() removed. :-) The functions that were calling it didn't need 
it, they were already calling stateofthenation etc. Even the scrollbar 
appearance hack doesn't seem necessary anymore. 

Added more accurately placed calls to the coordmapper calibration to the size 
of the physical screen viz. frame_calibration() and this has improved layouts 
on first import - a long standing bug that is diagnosed by seeing the animated 
layout CRUSHED in the top left corner of the screen rather than beautifully 
spread out.

Original comment by [email protected] on 28 Jul 2012 at 5:26

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter

Original comment by [email protected] on 26 Aug 2012 at 1:11

GoogleCodeExporter avatar Mar 15 '15 07:03 GoogleCodeExporter