From: Benjamin B. <bg...@us...> - 2005-05-10 09:12:04
|
Update of /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/plugins/output/funcionality In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12154/Plugin/com/ibm/ecute/plugins/output/funcionality Modified Files: RSAModelCreator.java Log Message: Version 2.1 alpha 6d Edit qualifiers dialog with main functionality added to RSA Index: RSAModelCreator.java =================================================================== RCS file: /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/plugins/output/funcionality/RSAModelCreator.java,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- RSAModelCreator.java 8 Apr 2005 09:11:16 -0000 1.10 +++ RSAModelCreator.java 10 May 2005 09:11:54 -0000 1.11 @@ -17,12 +17,12 @@ import org.eclipse.uml2.Class; import org.eclipse.uml2.Classifier; import org.eclipse.uml2.Comment; -//import org.eclipse.uml2.Constraint; +import org.eclipse.uml2.Constraint; import org.eclipse.uml2.Element; import org.eclipse.uml2.Generalization; import org.eclipse.uml2.Model; import org.eclipse.uml2.MultiplicityElement; -//import org.eclipse.uml2.OpaqueExpression; +import org.eclipse.uml2.OpaqueExpression; import org.eclipse.uml2.Operation; import org.eclipse.uml2.Package; import org.eclipse.uml2.PackageableElement; @@ -122,7 +122,6 @@ public int AddAssociation(String className1, String roleName1, String className2, String roleName2, Object diagram) { //metamorphose lastClass to AssociationClass - //System.out.println("metamorphose: " + lastClass.getName() + " to an AssociationClass"); Element element = lastClass; String s = EObjectUtil.getID(element); Element element1 = (Element) EObjectUtil.metamorphose(element, UML2Package.eINSTANCE.getAssociationClass()); @@ -168,8 +167,6 @@ rootClassName2 = className1; lastAssocPropUpperBound2 = rootAssocPropUpperBound1; lastAssocPropLowerBound2 = rootAssocPropLowerBound1; -// link1Tab = tab + " Role B"; -// link2Tab = tab + " Role A"; } else if (rootAssocPropName1.equalsIgnoreCase(roleName2)) { @@ -183,16 +180,12 @@ lastAssocPropUpperBound1 = rootAssocPropUpperBound2; lastAssocPropLowerBound1 = rootAssocPropLowerBound2; -// link1Tab = tab + " Role B"; -// link2Tab = tab + " Role A"; } else if (rootAssocPropName2.equalsIgnoreCase(roleName2)) { if (rootAssocPropName1.equalsIgnoreCase(roleName1)) { rootClassName1 = className1; lastAssocPropUpperBound1 = rootAssocPropUpperBound1; lastAssocPropLowerBound1 = rootAssocPropLowerBound1; -// link1Tab = tab + " Role B"; -// link2Tab = tab + " Role A"; } rootClassName2 = className2; lastAssocPropUpperBound2 = rootAssocPropUpperBound2; @@ -237,7 +230,6 @@ return NOLINKS; //Create Association - Type type1 = getClass(className1, lastCategory, true); if (type1 == null) return NOLINK1; @@ -314,7 +306,6 @@ } public void AddAttribute(String dataType, String name, String defaultValue){ - //System.out.println("AddAttribute: " + name); if (defaultValue == null) defaultValue = ""; @@ -342,7 +333,6 @@ } public void AddParameter(String dataType, String name, String defaultValue) { - //System.out.println("AddParameter: " + name); org.eclipse.uml2.Parameter parameter; parameter = lastMethod.createOwnedParameter(UML2Package.eINSTANCE.getParameter()); @@ -374,20 +364,14 @@ String dataType = (String) leftDataTypes.get(typedElement); if(!setType(dataType, typedElement, false)){ log.addLine2Log("\nWarning: Datatype \""+dataType+"\" used in "+ typedElement.getQualifiedName() +" can not be found."); - // A dummy class named \""+dataType+"\" was created."); log.updateImage(log.getWarningImage()); -// Class dummy = (Class) typedElement.getNearestPackage().createOwnedMember(UML2Package.eINSTANCE.getClass_()); -// dummy.setName(dataType); -// typedElement.setType(dummy); } } - //System.out.println("Close: "); - //TODO helper.openDiagramEditor(diagram); + //TODO helper.openDiagramEditor(diagram); } public Object CreateCategory(String name, Object rootCategory, Object diagram, String uid) { - //System.out.println("CreateCategory: " + name); org.eclipse.uml2.Package package_; org.eclipse.uml2.Package rootPackage = (org.eclipse.uml2.Package) rootCategory; @@ -433,7 +417,6 @@ public int CreateClass(String name, String rootClass, Object category, boolean replace) { - System.out.println("CreateClass: " + name); org.eclipse.uml2.Package package_ = (org.eclipse.uml2.Package) category; org.eclipse.uml2.Class theRoot = null; int result = OK; @@ -472,7 +455,6 @@ class_ = (org.eclipse.uml2.Class) package_.createOwnedMember(UML2Package.eINSTANCE.getClass_()); class_.setName(name); - System.out.println("CreateClass: " + name + " CREATED"); } lastClassComposition = false; lastCategory = package_; @@ -501,29 +483,14 @@ } public void CreateMethod(String dataType, String name) { - //System.out.println("CreateMethod: " + name); org.eclipse.uml2.Operation method; method = lastClass.createOwnedOperation(UML2Package.eINSTANCE.getOperation()); method.setName(name); -// Type returnType = null; - -// PackageableElement element; -// -// element = uml2Model.getImportedMember(dataType); -// if (element != null) { -// if (element instanceof PrimitiveType) -// returnType = ((PrimitiveType) element); -// } else { -// element = uml2Model.getOwnedMember(dataType); -// if (element instanceof Class) -// returnType = ((Class) element); -// } - //method.setType(returnType); does not work Parameter returnResult = method.createOwnedParameter(UML2Package.eINSTANCE.getParameter()); returnResult.setDirection(ParameterDirectionKind.RETURN_LITERAL); - //returnResult.setType(returnType); + setType(dataType, returnResult, true); returnResult.setName("ReturnType"); @@ -534,7 +501,7 @@ } public void DeleteLastClass() { - //System.out.println("DeleteLastClass: "); + lastClass.destroy(); } @@ -545,7 +512,6 @@ if (package_ == rootCategory) return; - //System.out.println("finishCategory: " + package_.getName()); List list = diagramHelper.getDiagrams(package_, UMLDiagramKind.CLASS_LITERAL); Iterator it = list.iterator(); while (it.hasNext()){ @@ -562,7 +528,6 @@ } public void FinishClass(Object diagram) { - //System.out.println("FinishClass: "); boolean isAssociationClass = false; ArrayList list = new ArrayList(); if (lastClass instanceof AssociationClass) { @@ -573,10 +538,6 @@ diagramHelper.createViews((Diagram) diagram, list); } -// if (lastClass instanceof AssociationClass) { -// isAssociationClass = true; -// } - if (lastRootClass != null) { boolean isRootAssociationClass = false; if (lastRootClass instanceof AssociationClass) { @@ -601,20 +562,10 @@ Generalization generalization = specificClassifier.createGeneralization(generalClassifier); generalization.setIsSubstitutable(true); - //System.out.println("Generalization " + specificClassifier.getQualifiedName() + " ->> " - // + generalClassifier.getQualifiedName() + " created."); -/* - if(!isAssociationClass) { - //add class to the diagram - list.add(lastClass); - diagramHelper.createViews((Diagram) diagram, list); - } -*/ } } public Object GetRootCategory() { - //System.out.println("GetRootCategory: "); lastElement = rootCategory; lastCategory = rootCategory; return rootCategory; @@ -629,18 +580,18 @@ Element theElement = lastElement; Element otherElement = null; Stereotype cimStereotype = theElement.getAppliedStereotype("CIM::Qualifiers"); - + if(type == TCLASS){ if(name.equalsIgnoreCase("Composition")&& !value.equalsIgnoreCase("false")){ lastClassComposition = true; } - /* + // create OCL class constraint if(name.equalsIgnoreCase("OCL")&& !value.equalsIgnoreCase("null")){ Package package_ = lastCategory; Constraint constraint = (Constraint)package_.createOwnedMember(UML2Package.eINSTANCE.getConstraint()); - // constraint.setName(name); + constraint.setName("OCL " + lastClass.getName()); // create specification constraint.createSpecification(UML2Package.eINSTANCE.getOpaqueExpression()); @@ -658,7 +609,7 @@ multiple = true; while (index != -1){ int length = tempBody.length(); - body = body.concat(tempBody.substring(0, index - 2)); + body = body.concat(tempBody.substring(0, index - 1)); body = body.concat("\n"); tempBody = tempBody.substring(index + 2); index = tempBody.indexOf(","); @@ -690,61 +641,23 @@ if (thisDiagram != null){ diagramHelper.createViews(thisDiagram, list); } - }*/ + } } -/* + if(type == TMETHOD){ - - if(name.equalsIgnoreCase("OCL")&& !value.equalsIgnoreCase("null")){ + + // create pre/post conditions of a method + // not implemented yet + if(name.equalsIgnoreCase("OCL")&& !value.equalsIgnoreCase("null")){ System.out.println("class: " + lastClass.getName()); System.out.println("name: " + name + " value: "+ value); - Package package_ = lastCategory; - Constraint constraint = (Constraint)package_.createOwnedMember(UML2Package.eINSTANCE.getConstraint()); - constraint.setName(name); - constraint.createSpecification(UML2Package.eINSTANCE.getOpaqueExpression()); - String tempBody, body = ""; - if(value.startsWith("{")){ - int length = value.length(); - tempBody = value.substring(2, length - 2); - } else { - tempBody = value; - } - int index = tempBody.indexOf(","); - boolean multiple = false; - if (index != -1) - multiple = true; - while (index != -1){ - int length = tempBody.length(); - body = body.concat(tempBody.substring(0, index - 2)); - body = body.concat("\n"); - tempBody = tempBody.substring(index + 2); - index = tempBody.indexOf(","); - } - if (multiple){ - body = body.concat(tempBody.substring(index + 1)); - } - if (!multiple) - body = tempBody; - ((OpaqueExpression)constraint.getSpecification()).setBody(body); - ((OpaqueExpression)constraint.getSpecification()).setLanguage("OCL"); - // TODO add connection line between constraint and class - ArrayList list = new ArrayList(); - list.add(constraint); - List diagrams = diagramHelper.getDiagrams(package_, UMLDiagramKind.CLASS_LITERAL); - Iterator it = diagrams.iterator(); - Diagram thisDiagram = null; - while(it.hasNext()){ - Diagram diagram = (Diagram)it.next(); - if(diagram.getName().equalsIgnoreCase("Main")) - thisDiagram = diagram; - } - if (thisDiagram != null){ - diagramHelper.createViews(thisDiagram, list); - } - } + + // lastMethod.getPreconditions().add(); + // lastMethod.getPostconditions().add(); + } } - */ + // because of the different role order in RSA theElement is // lastAssocProp2 if type TLINK1 if (type == TLINK1) { @@ -973,17 +886,6 @@ return theClass; } - // Class getAssociationClass(String name, Package package_, boolean - // otherPackages) { - // - // AssociationClass assocClass = null; - // PackageableElement element = package_.getOwnedMember(name); - // if(element instanceof AssociationClass) - // assocClass = (AssociationClass) element; - // - // return assocClass; - // } - private boolean setType(String dataType, TypedElement element, boolean retry){ //Search for imported DataTypes. @@ -1009,6 +911,5 @@ return false; } } - } } \ No newline at end of file |