From: <de...@us...> - 2004-01-07 01:48:33
|
Update of /cvsroot/pymerase/smw/smw/scw/UndoRedo In directory sc8-pr-cvs1:/tmp/cvs-serv32238/smw/scw/UndoRedo Added Files: LayerManager.py SfiManager.py __init__.py python.iml Log Message: Imported version of SMW downloaded on 2003 Apr 14 --- NEW FILE: LayerManager.py --- #!/usr/bin/env python2 __layer__ = 'UndoRedo' import unittest from smw.scw.Correctness import LayerManager as CorrectnessLayerManager class LayerManager(CorrectnessLayerManager): pass --- NEW FILE: SfiManager.py --- #!/usr/bin/env python2 __layer__ = 'UndoRedo' """This layer implements undo/redo operation; all modifications of UML model made by LayerManager are expected to follow well-formed rules """ from smw.metamodel.UML14 import * from smw.Project import * from LayerManager import LayerManager from smw.scw.Correctness import SfiManager as CorrectnessSfiManager class SfiManager(CorrectnessSfiManager): def __init__(self,hist=None): """ Constructor for a new SfiManager. """ CorrectnessSfiManager.__init__(self) self.__hist=None self.__called=0 if hist: self.__hist=hist self.__called=1 else: self.__proj = Project() self.__hist=self.__proj.history # self.__proj.setRoot(self.pythonPackage()) def setUp(self): CorrectnessSfiManager.setUp(self) self._layerManager=LayerManager() def project(self): return self.__proj def history(self): return self.__hist def newProject(self, projectName = None): project=CorrectnessSfiManager.newProject(self,projectName) if project and not self.__called: self.__proj.setRoot(project) return project def focusOnProject(self,project): """ Assigns the project given as parameter to current project and returns the current project if the parameter is an existing project. """ rv=CorrectnessSfiManager.focusOnProject(self,project) if (rv) and not self.__called: self.__proj.setRoot(rv) return rv def newLayer(self,anc=None,succ=None,lname=None): inModifyCmd=self.__hist.inModifyCmd if not inModifyCmd: self.__hist.beginStrictTransaction() createdLayer=CorrectnessSfiManager.newLayer(self,anc,succ,lname) #try: if not inModifyCmd: self.__hist.endTransaction() #except WFRException, e: # print 'WFR exception, undo impossible:\n%s' % e return createdLayer def newClass(self, newName=None):#tested - working - adding to current element, if it is a project or package inModifyCmd=self.__hist.inModifyCmd if not inModifyCmd: self.__hist.beginStrictTransaction() createdClass=CorrectnessSfiManager.newClass(self,newName) #try: if not inModifyCmd: self.__hist.endTransaction() #except WFRException, e: # print 'WFR exception, undo impossible:\n%s' % e return createdClass def newInterface(self,newName=None):#tested-working - adding to current element, if it is a project or package inModifyCmd=self.__hist.inModifyCmd if not inModifyCmd: self.__hist.beginStrictTransaction() createdInterface=CorrectnessSfiManager.newInterface(self, newName) #try: if not inModifyCmd: self.__hist.endTransaction() #except WFRException, e: # print 'WFR exception, undo impossible:\n%s' % e return createdInterface def newGeneralization(self,parent,child,newName=None):#tested -working, adding to closest common owner, class or interface inModifyCmd=self.__hist.inModifyCmd if not inModifyCmd: self.__hist.beginStrictTransaction() createdGeneralization=CorrectnessSfiManager.newGeneralization(self,parent,child,newName) #try: if not inModifyCmd: self.__hist.endTransaction() #except WFRException, e: # print 'WFR exception, undo impossible:\n%s' % e return createdGeneralization def newAssociation(self,end1,end2,newName=None):#tested-working - adding to the closest common namespace,project or package. inModifyCmd=self.__hist.inModifyCmd if not inModifyCmd: self.__hist.beginStrictTransaction() createdAssociation=CorrectnessSfiManager.newAssociation(self,end1,end2,newName) #try: if not inModifyCmd: self.__hist.endTransaction() #except WFRException, e: # print 'WFR exception, undo impossible:\n%s' % e return createdAssociation def newDependency(self,supplier,client,newName=None):#tested-working - adding to closest namespace, project or package inModifyCmd=self.__hist.inModifyCmd if not inModifyCmd: self.__hist.beginStrictTransaction() createdDependency=CorrectnessSfiManager.newDependency(self,supplier,client,newName) #try: if not inModifyCmd: self.__hist.endTransaction() #except WFRException, e: # print 'WFR exception, undo impossible:\n%s' % e return createdDependency def newPackage(self,newName=None):#tested-working - adding to current element, if it is project or package inModifyCmd=self.__hist.inModifyCmd if not inModifyCmd: self.__hist.beginStrictTransaction() createdPackage=CorrectnessSfiManager.newPackage(self,newName) #try: if not inModifyCmd: self.__hist.endTransaction() #except WFRException, e: # print 'WFR exception, undo impossible:\n%s' % e return createdPackage def newMethod(self,newName=None,specification=None):#tested-working - adding to currentElement and to the testClass inModifyCmd=self.__hist.inModifyCmd if not inModifyCmd: self.__hist.beginStrictTransaction() createdMethod=CorrectnessSfiManager.newMethod(self,newName,specification) #try: if not inModifyCmd: self.__hist.endTransaction() #except WFRException, e: # print 'WFR exception, undo impossible:\n%s' % e return createdMethod def newOperation(self,newName=None): inModifyCmd=self.__hist.inModifyCmd if not inModifyCmd: self.__hist.beginStrictTransaction() createdOperation=CorrectnessSfiManager.newOperation(self,newName) #try: if not inModifyCmd: self.__hist.endTransaction() #except WFRException, e: # print 'WFR exception, undo impossible:\n%s' % e return createdOperation def newAttribute(self,newName=None):#tested-working - adding to currentElement inModifyCmd=self.__hist.inModifyCmd if not inModifyCmd: self.__hist.beginStrictTransaction() createdAttribute=CorrectnessSfiManager.newAttribute(self,newName) #try: if not inModifyCmd: self.__hist.endTransaction() #except WFRException, e: # print 'WFR exception, undo impossible:\n%s' % e return createdAttribute ## def deleteElement1(self,element=None): #leaves the relationships hanging ## self.__proj.history.beginStrictTransaction() ## deletedElement=CorrectnessSfiManager.deleteElement1(self,element) ## #try: ## self.__proj.history.endTransaction() ## #except WFRException, e: ## # print 'WFR exception, undo impossible:\n%s' % e ## return deletedElement def deleteElement2(self,element=None): #deletes the relationships too inModifyCmd=self.__hist.inModifyCmd if not inModifyCmd: self.__hist.beginStrictTransaction() deletedElement=CorrectnessSfiManager.deleteElement2(self,element) #try: if not inModifyCmd: self.__hist.endTransaction() #except WFRException, e: # print 'WFR exception, undo impossible:\n%s' % e return deletedElement def renameElement(self, element, newName):#tested-working """ Renames the element to 'newName' and returns the new name of the element. Returns none if either one of the parameters is invalid. """ inModifyCmd=self.__hist.inModifyCmd if not inModifyCmd: self.__hist.beginStrictTransaction() # sends the currentElement as parameter so that layerManager knows the current project changedName=CorrectnessSfiManager.renameElement(self,element,newName) #try: if not inModifyCmd: self.__hist.endTransaction() #except WFRException, e: # print 'WFR exception, undo impossible:\n%s' % e return changedName def undo(self): """ Undoes the previous operation done in layermanager. -Current element reference is focused directly to the model. """ self.__hist.undo() self.focusOnElement(self.currentProject()) def redo(self): """ Redoes the previous undone operation. -Current element reference stays in the model regardeless the opertaion redo does. """ self.__hist.redo() --- NEW FILE: __init__.py --- from SfiManager import * from LayerManager import * --- NEW FILE: python.iml --- (ismw.metamodel.UML14 Model p1 (dp2 S'isAbstract' p3 I0 sS'isSpecification' p4 I0 sS'__uniqueID__' p5 S'ib351d2ec95de35465f82789cf7689fa7' p6 sS'isRoot' p7 I0 sS'visibility' p8 [...227897 lines suppressed...] p49406 sg54 S'' sbsg4 I0 sg5 S'iaf81dd77ae2741edd072fd3d40fe0e99' p49407 sg56 I0 sg8 I0 sg10 S'_normpath' p49408 sg17 g48793 sg58 I0 sbasbsbasbsbasbsb. |