from ASG_myTest import * from graph_ASG_ERmetaMetaModel import * from Tkinter import * from ATOM3TypeInfo import * from ATOM3String import * from StatusBar import * from ATOM3TypeDialog import * from aTest import * from aRel import * def createNewASGroot(self): return ASG_myTest(self, None) def createModelMenu(self, modelMenu): "Creates a customized Model Menu for the actual formalism" modelMenu = Menu(self.mmtoolMenu, tearoff=0) modelMenu.add_command(label="new aTest", command=lambda x=self: x.newModesaTest(x) ) modelMenu.add_command(label="new aRel", command=lambda x=self: x.newModesaRel(x) ) def setConnectivity(self): self.ConnectivityMap['aRel']={ 'aRel': [( 'aTest', self.createNewaTest)] ,'aTest': [] } self.ConnectivityMap['aTest']={ 'aRel': [] ,'aTest': [( 'aRel', self.createNewaRel)] } self.CardinalityTable['aTest']={ 'aTest': [] ,'aRel': [('0', 'N', 'Source'), ('0', 'N', 'Destination')] } self.CardinalityTable['aRel']={ 'aTest': [('0', 'N', 'Destination'), ('0', 'N', 'Source')] ,'aRel': [] } self.entitiesInMetaModel['myTest']=["aTest", "aRel"] def createNewaTest(self, wherex, wherey, screenCoordinates = 1): self.fromClass = None self.toClass = None # try the global constraints... res = self.ASGroot.preCondition(ASG.CREATE) if res: self.constraintViolation(res) self.mode=self.IDLEMODE return new_semantic_obj = aTest(self) ne = len(self.ASGroot.listNodes["aTest"]) if new_semantic_obj.keyword_: new_semantic_obj.keyword_.setValue(new_semantic_obj.keyword_.toString()+str(ne)) if screenCoordinates: new_obj = graph_aTest(self.UMLmodel.canvasx(wherex), self.UMLmodel.canvasy(wherey), new_semantic_obj) else: # already in canvas coordinates new_obj = graph_aTest(wherex, wherey, new_semantic_obj) new_obj.DrawObject(self.UMLmodel, self.editGGLabel) self.UMLmodel.addtag_withtag("aTest", new_obj.tag) new_semantic_obj.graphObject_ = new_obj self.ASGroot.addNode(new_semantic_obj) res = self.ASGroot.postCondition(ASG.CREATE) if res: self.constraintViolation(res) self.mode=self.IDLEMODE return res = new_semantic_obj.postCondition(ASGNode.CREATE) if res: self.constraintViolation(res) self.mode=self.IDLEMODE return self.mode=self.IDLEMODE if self.editGGLabel : self.statusbar.event(StatusBar.TRANSFORMATION, StatusBar.CREATE) else: self.statusbar.event(StatusBar.MODEL, StatusBar.CREATE) return new_semantic_obj def createNewaRel(self, wherex, wherey, screenCoordinates = 1): self.fromClass = None self.toClass = None # try the global constraints... res = self.ASGroot.preCondition(ASG.CREATE) if res: self.constraintViolation(res) self.mode=self.IDLEMODE return new_semantic_obj = aRel(self) ne = len(self.ASGroot.listNodes["aRel"]) if new_semantic_obj.keyword_: new_semantic_obj.keyword_.setValue(new_semantic_obj.keyword_.toString()+str(ne)) if screenCoordinates: new_obj = graph_aRel(self.UMLmodel.canvasx(wherex), self.UMLmodel.canvasy(wherey), new_semantic_obj) else: # already in canvas coordinates new_obj = graph_aRel(wherex, wherey, new_semantic_obj) new_obj.DrawObject(self.UMLmodel, self.editGGLabel) self.UMLmodel.addtag_withtag("aRel", new_obj.tag) new_semantic_obj.graphObject_ = new_obj self.ASGroot.addNode(new_semantic_obj) res = self.ASGroot.postCondition(ASG.CREATE) if res: self.constraintViolation(res) self.mode=self.IDLEMODE return res = new_semantic_obj.postCondition(ASGNode.CREATE) if res: self.constraintViolation(res) self.mode=self.IDLEMODE return self.mode=self.IDLEMODE if self.editGGLabel : self.statusbar.event(StatusBar.TRANSFORMATION, StatusBar.CREATE) else: self.statusbar.event(StatusBar.MODEL, StatusBar.CREATE) return new_semantic_obj def createNew_Model(self, wherex, wherey, screenCoordinates = 1): self.toClass = None self.fromClass = None new_semantic_obj = ASG_myTest(self) ne = len(self.ASGroot.listNodes["ASG_myTest"]) if new_semantic_obj.keyword_: new_semantic_obj.keyword_.setValue(new_semantic_obj.keyword_.toString()+str(ne)) if screenCoordinates: new_obj = graph_ASG_ERmetaMetaModel(self.UMLmodel.canvasx(wherex), self.UMLmodel.canvasy(wherey), new_semantic_obj) else: # already in canvas coordinates new_obj = graph_ASG_ERmetaMetaModel(wherex, wherey, new_semantic_obj) new_obj.DrawObject(self.UMLmodel, self.editGGLabel) self.UMLmodel.addtag_withtag("ASG_myTest", new_obj.tag) new_semantic_obj.graphObject_ = new_obj self.ASGroot.addNode(new_semantic_obj) self.mode=self.IDLEMODE if self.editGGLabel : self.statusbar.event(StatusBar.TRANSFORMATION, StatusBar.CREATE) else: self.statusbar.event(StatusBar.MODEL, StatusBar.CREATE) return new_semantic_obj def fillTypesInformation(self): objs = [] obj = ATOM3TypeInfo(self) params = [] obj.setValue(("String", "ATOM3String", params, (None, 0) )) objs.append(obj) obj = ATOM3TypeInfo(self) params = [] param = ATOM3String("None") params.append(param) param = ATOM3String("None") params.append(param) param = ATOM3String("1") params.append(param) obj.setValue(("Boolean", "ATOM3Boolean", params, (None, 0) )) objs.append(obj) obj = ATOM3TypeInfo(self) params = [] obj.setValue(("Integer", "ATOM3Integer", params, (None, 0) )) objs.append(obj) obj = ATOM3TypeInfo(self) params = [] obj.setValue(("Float", "ATOM3Float", params, (None, 0) )) objs.append(obj) obj = ATOM3TypeInfo(self) params = [] param = ATOM3String("self.types") params.append(param) obj.setValue(("Attribute", "ATOM3Attribute", params, (None, 0) )) objs.append(obj) obj = ATOM3TypeInfo(self) params = [] param = ATOM3String("[1,1,1,self.types]") params.append(param) param = ATOM3String("ATOM3Attribute") params.append(param) param = ATOM3String("self.types") params.append(param) obj.setValue(("List", "ATOM3List", params, (None, 0) )) objs.append(obj) obj = ATOM3TypeInfo(self) params = [] param = ATOM3String("[]") params.append(param) param = ATOM3String("1") params.append(param) param = ATOM3String("1") params.append(param) obj.setValue(("Enum", "ATOM3Enum", params, (None, 0) )) objs.append(obj) obj = ATOM3TypeInfo(self) params = [] obj.setValue(("Constraint", "ATOM3Constraint", params, (None, 0) )) objs.append(obj) obj = ATOM3TypeInfo(self) params = [] param = ATOM3String("'class0'") params.append(param) param = ATOM3String("None") params.append(param) obj.setValue(("Appearance", "ATOM3Appearance", params, (None, 0) )) objs.append(obj) obj = ATOM3TypeInfo(self) params = [] obj.setValue(("BottomType", "ATOM3BottomType", params, (None, 0) )) objs.append(obj) obj = ATOM3TypeInfo(self) params = [] obj.setValue(("Link", "ATOM3Link", params, (None, 0) )) objs.append(obj) obj = ATOM3TypeInfo(self) params = [] obj.setValue(("Port", "ATOM3Port", params, (None, 0) )) objs.append(obj) self.typeList.setValue(objs)