From: Benjamin B. <bg...@us...> - 2005-07-20 15:22:11
|
Update of /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/rsa/core/internal/properties In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21123/Plugin/com/ibm/ecute/rsa/core/internal/properties Modified Files: ValuesTableHelper.java QualifiersPropertySection.java EffectiveInheritedValue.java FlavorsHelper.java Log Message: flavors presentation rule implemented for values table in properties section and effectiveInheritedQualifier method implemented Index: FlavorsHelper.java =================================================================== RCS file: /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/rsa/core/internal/properties/FlavorsHelper.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- FlavorsHelper.java 19 Jul 2005 16:10:47 -0000 1.3 +++ FlavorsHelper.java 20 Jul 2005 15:21:46 -0000 1.4 @@ -28,6 +28,7 @@ import org.eclipse.uml2.ParameterDirectionKind; import org.eclipse.uml2.Property; import org.eclipse.uml2.Stereotype; +import org.eclipse.uml2.Type; import org.eclipse.uml2.UML2Package; import com.ibm.ecute.EcuteEclipsePlugin; @@ -39,7 +40,7 @@ import com.ibm.xtools.modeler.UMLModeler; /** - * Copyright (c) 2003, International Business Machines + * Copyright (c) 2005, International Business Machines * * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES @@ -49,7 +50,9 @@ * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html * * @author Benjamin Bender <be...@de...> + * */ + public class FlavorsHelper { // Copyright private static final String COPYRIGHT = License.COPYRIGHT; @@ -484,7 +487,7 @@ // ABSTRACT if(qualifierName.equalsIgnoreCase("Abstract")){ return null; - //AGGREGATE + //AGGREGATE } else if(qualifierName.equalsIgnoreCase("Aggregate")){ if(element instanceof Property && propertyIsOwnedEnd((Property)element) && override(element)){ Property property = (Property)element; @@ -512,21 +515,21 @@ } else { return null; } - // AGGREGATION + // AGGREGATION } else if(qualifierName.equalsIgnoreCase("Aggregation")){ if(element instanceof AssociationClass){ Class parent = getParentClass((AssociationClass)element); if(parent != null && parent instanceof AssociationClass){ - AssociationClass aClass = (AssociationClass)parent; - EList ends = aClass.getOwnedEnds(); - Iterator iter = ends.iterator(); - while(iter.hasNext()){ - Property prop = (Property)iter.next(); - if(prop.getAggregation().getValue()== AggregationKind.SHARED || - prop.getAggregation().getValue()== AggregationKind.COMPOSITE){ - return (new EffectiveInheritedValue("true", parent)); - } - } + AssociationClass aClass = (AssociationClass)parent; + EList ends = aClass.getOwnedEnds(); + Iterator iter = ends.iterator(); + while(iter.hasNext()){ + Property prop = (Property)iter.next(); + if(prop.getAggregation().getValue()== AggregationKind.SHARED || + prop.getAggregation().getValue()== AggregationKind.COMPOSITE){ + return (new EffectiveInheritedValue("true", parent)); + } + } } else { return null; } @@ -534,20 +537,20 @@ } else { return null; } - // COMPOSITION + // COMPOSITION } else if(qualifierName.equalsIgnoreCase("Composition")){ if(element instanceof AssociationClass){ Class parent = getParentClass((AssociationClass)element); if(parent != null && parent instanceof AssociationClass){ - AssociationClass aClass = (AssociationClass)parent; - EList ends = aClass.getOwnedEnds(); - Iterator iter = ends.iterator(); - while(iter.hasNext()){ - Property prop = (Property)iter.next(); - if(prop.getAggregation().getValue()== AggregationKind.COMPOSITE){ - return (new EffectiveInheritedValue("true", parent)); - } - } + AssociationClass aClass = (AssociationClass)parent; + EList ends = aClass.getOwnedEnds(); + Iterator iter = ends.iterator(); + while(iter.hasNext()){ + Property prop = (Property)iter.next(); + if(prop.getAggregation().getValue()== AggregationKind.COMPOSITE){ + return (new EffectiveInheritedValue("true", parent)); + } + } } else { return null; } @@ -555,10 +558,10 @@ } else { return null; } - // DEPRECATED + // DEPRECATED } else if(qualifierName.equalsIgnoreCase("Deprecated")){ - return null; - // DESCRIPTION + return null; + // DESCRIPTION } else if(qualifierName.equalsIgnoreCase("Description")){ // getParentClasses ArrayList parents = getParentClasses(element); @@ -568,15 +571,15 @@ for(int j = 0; j < parents.size(); j++){ String description = null; - EList list = ((Class)parents.get(j)).getOwnedComments(); - Iterator it = list.iterator(); - while (it.hasNext()){ - Comment comment = (Comment)it.next(); - Stereotype stereo = comment.getApplicableStereotype("Default::Documentation"); - if(stereo != null){ - description = comment.getBody(); - } - } + EList list = ((Class)parents.get(j)).getOwnedComments(); + Iterator it = list.iterator(); + while (it.hasNext()){ + Comment comment = (Comment)it.next(); + Stereotype stereo = comment.getApplicableStereotype("Default::Documentation"); + if(stereo != null){ + description = comment.getBody(); + } + } if(description != null){ return(new EffectiveInheritedValue(description, (Class)parents.get(j))); } @@ -643,8 +646,8 @@ method = (Operation)operationsList.get(i); } } - - if(method != null){ + + if(method != null && equalMethods(operation, method)){ EList list = method.getOwnedComments(); Iterator it = list.iterator(); @@ -674,6 +677,7 @@ for(int j = 0; j < parents.size(); j++){ String description = null; Parameter param = null; + Operation method = null; List operationsList = ((Class)parents.get(j)).getOwnedOperations(); for(int i = 0; i < operationsList.size(); i++){ @@ -681,13 +685,14 @@ List parameterList = ((Operation)operationsList.get(i)).getOwnedParameters(); for(int k = 0; k < parameterList.size(); k++){ if(((Parameter)parameterList.get(k)).getName().equalsIgnoreCase(parameter.getName())){ - param = (Parameter)parameterList.get(k); + param = (Parameter)parameterList.get(k); + method = (Operation)operationsList.get(i); } } } } - - if(param != null){ + + if(param != null && equalMethods(operation, method)){ EList list = param.getOwnedComments(); Iterator it = list.iterator(); @@ -710,7 +715,7 @@ } else { return null; } - // IN + // IN, OUT } else if(qualifierName.equalsIgnoreCase("In") || qualifierName.equalsIgnoreCase("Out")){ if(element instanceof Parameter){ ArrayList parents = getParentClasses(element); @@ -721,8 +726,9 @@ return null; } for(int j = 0; j < parents.size(); j++){ - String description = null; + //String description = null; Parameter param = null; + Operation method = null; List operationsList = ((Class)parents.get(j)).getOwnedOperations(); for(int i = 0; i < operationsList.size(); i++){ @@ -730,13 +736,14 @@ List parameterList = ((Operation)operationsList.get(i)).getOwnedParameters(); for(int k = 0; k < parameterList.size(); k++){ if(((Parameter)parameterList.get(k)).getName().equalsIgnoreCase(parameter.getName())){ - param = (Parameter)parameterList.get(k); + param = (Parameter)parameterList.get(k); + method = (Operation)operationsList.get(i); } } } } - - if(param != null){ + + if(param != null && equalMethods(operation, method)){ ParameterDirectionKind direction = param.getDirection(); String direct = null; @@ -765,6 +772,369 @@ return null; } + } else if (qualifierName.equalsIgnoreCase("Key")){ + + if(element instanceof Property && override(element)){ + ArrayList parents = getParentClasses(element); + if(parents.size() > 0){ + Property property = (Property)element; + + for(int j = 0; j < parents.size(); j++){ + Property attribute = null; + + List attributeList = ((Class)parents.get(j)).getAttributes(); + for(int i = 0; i < attributeList.size(); i++){ + if(((Property)attributeList.get(i)).getName().equalsIgnoreCase(property.getName())){ + attribute = (Property)attributeList.get(i); + } + } + + if(propertyIsOwnedEnd(property)){ + List endList = ((AssociationClass)parents.get(j)).getOwnedEnds(); + for(int i = 0; i < endList.size(); i++){ + if(((Property)endList.get(i)).getName().equalsIgnoreCase(property.getName())){ + attribute = (Property)endList.get(i); + } + } + } + + if(attribute != null){ + Stereotype stereo = attribute.getAppliedStereotype("CIM::Key"); + if(stereo != null){ + return(new EffectiveInheritedValue("true", (Class)parents.get(j))); + } + } + } + } else { + return null; + } + } else { + return null; + } + } else if (qualifierName.equalsIgnoreCase("Min") || qualifierName.equalsIgnoreCase("Max")){ + + if(element instanceof Property && propertyIsOwnedEnd((Property)element) && override(element)){ + ArrayList parents = getParentClasses(element); + if(parents.size() > 0){ + Property property = (Property)element; + + for(int j = 0; j < parents.size(); j++){ + Property attribute = null; + + List endList = ((AssociationClass)parents.get(j)).getOwnedEnds(); + for(int i = 0; i < endList.size(); i++){ + if(((Property)endList.get(i)).getName().equalsIgnoreCase(property.getName())){ + attribute = (Property)endList.get(i); + } + } + + if(attribute != null){ + String value = null; + if (qualifierName.equalsIgnoreCase("Min")){ + value = (new Integer(attribute.getLower())).toString(); + } else { + value = (new Integer(attribute.getUpper())).toString(); + } + return(new EffectiveInheritedValue(value, (Class)parents.get(j))); + } + } + } else { + return null; + } + } else { + return null; + } + // OCTETSTRING + } else if (qualifierName.equalsIgnoreCase("Octetstring")){ + if((element instanceof Property && override(element)) + || (element instanceof Operation && override(element)) + || element instanceof Parameter){ + + ArrayList parents = getParentClasses(element); + if(parents.size() > 0){ + // Property + if(element instanceof Property){ + Property property = (Property)element; + if(property.getType() != null && property.getType().getName().equalsIgnoreCase("String")){ + + for(int j = 0; j < parents.size(); j++){ + Property attribute = null; + List attributeList = ((Class)parents.get(j)).getAttributes(); + for(int i = 0; i < attributeList.size(); i++){ + if(((Property)attributeList.get(i)).getName().equalsIgnoreCase(property.getName())){ + attribute = (Property)attributeList.get(i); + } + } + + if(attribute != null){ + Type datatype = property.getType(); + if(datatype != null){ + if(datatype.getName().equalsIgnoreCase("Octetstring")){ + return(new EffectiveInheritedValue("true", (Class)parents.get(j))); + } + } + } + } + } else { + return null; + } + // Operation + } else if(element instanceof Operation){ + Operation operation = (Operation)element; + if(operation.getType() != null && operation.getType().getName().equalsIgnoreCase("String")){ + for(int j = 0; j < parents.size(); j++){ + Operation method = null; + + List operationsList = ((Class)parents.get(j)).getOwnedOperations(); + for(int i = 0; i < operationsList.size(); i++){ + if(((Operation)operationsList.get(i)).getName().equalsIgnoreCase(operation.getName())){ + method = (Operation)operationsList.get(i); + } + } + + if(method != null && equalMethods(operation, method)){ + + Type datatype = method.getType(); + if(datatype != null){ + if(datatype.getName().equalsIgnoreCase("Octetstring")){ + return(new EffectiveInheritedValue("true", (Class)parents.get(j))); + } + } + } + } + } else { + return null; + } + // Parameter + } else if(element instanceof Parameter){ + + Parameter parameter = (Parameter)element; + if(parameter.getType() != null && parameter.getType().getName().equalsIgnoreCase("String")){ + Operation operation = (Operation)parameter.getOwner(); + if(!override(operation)){ + return null; + } + for(int j = 0; j < parents.size(); j++){ + //String description = null; + Parameter param = null; + Operation method = null; + + List operationsList = ((Class)parents.get(j)).getOwnedOperations(); + for(int i = 0; i < operationsList.size(); i++){ + if(((Operation)operationsList.get(i)).getName().equalsIgnoreCase(operation.getName())){ + List parameterList = ((Operation)operationsList.get(i)).getOwnedParameters(); + for(int k = 0; k < parameterList.size(); k++){ + if(((Parameter)parameterList.get(k)).getName().equalsIgnoreCase(parameter.getName())){ + param = (Parameter)parameterList.get(k); + method = (Operation)operationsList.get(i); + } + } + } + } + + if(param != null && equalMethods(operation, method)){ + + Type datatype = param.getType(); + if(datatype != null){ + if(datatype.getName().equalsIgnoreCase("Octetstring")){ + return(new EffectiveInheritedValue("true", (Class)parents.get(j))); + } + } + } + } + return null; + } else { + return null; + } + } else { + return null; + } + } else { + return null; + } + } else { + return null; + } + // STATIC + } else if (qualifierName.equalsIgnoreCase("Static")){ + if((element instanceof Property || element instanceof Operation) && override(element)){ + ArrayList parents = getParentClasses(element); + if(parents.size() > 0){ + if(element instanceof Property){ + Property property = (Property)element; + + for(int j = 0; j < parents.size(); j++){ + Property attribute = null; + + List attributeList = ((Class)parents.get(j)).getAttributes(); + for(int i = 0; i < attributeList.size(); i++){ + if(((Property)attributeList.get(i)).getName().equalsIgnoreCase(property.getName())){ + attribute = (Property)attributeList.get(i); + } + } + + if(attribute != null && attribute.isStatic()){ + return(new EffectiveInheritedValue("true", (Class)parents.get(j))); + } + } + + } else if(element instanceof Operation){ + Operation operation = (Operation)element; + + for(int j = 0; j < parents.size(); j++){ + Operation method = null; + + List operationsList = ((Class)parents.get(j)).getOwnedOperations(); + for(int i = 0; i < operationsList.size(); i++){ + if(((Operation)operationsList.get(i)).getName().equalsIgnoreCase(operation.getName())){ + method = (Operation)operationsList.get(i); + } + } + + if(method != null && equalMethods(operation, method) && method.isStatic()){ + return(new EffectiveInheritedValue("true", (Class)parents.get(j))); + } + } + } + } else { + return null; + } + } else { + return null; + } + // WRITE + } else if (qualifierName.equalsIgnoreCase("Write")){ + if(element instanceof Property && override(element)){ + ArrayList parents = getParentClasses(element); + if(parents.size() > 0){ + Property property = (Property)element; + + for(int j = 0; j < parents.size(); j++){ + Property attribute = null; + + List attributeList = ((Class)parents.get(j)).getAttributes(); + for(int i = 0; i < attributeList.size(); i++){ + if(((Property)attributeList.get(i)).getName().equalsIgnoreCase(property.getName())){ + attribute = (Property)attributeList.get(i); + } + } + + if(attribute != null && !attribute.isReadOnly()){ + return(new EffectiveInheritedValue("true", (Class)parents.get(j))); + } + } + } else { + return null; + } + } else { + return null; + } + // Qualifiers in the qualifiers stereotype + } else { + // getParentClasses + ArrayList parents = getParentClasses(element); + if(parents.size() > 0 && !qualifierName.equalsIgnoreCase("ArrayType") + && !qualifierName.equalsIgnoreCase("Association")){ + + if(element instanceof Class){ + for(int j = 0; j < parents.size(); j++){ + String qualValue = getQualifiersStereotypeQualifer((Class)parents.get(j), qualifierName); + if(qualValue != null){ + return(new EffectiveInheritedValue(qualValue, (Class)parents.get(j))); + } + } + return null; + } else if (element instanceof Property && override(element)){ + Property property = (Property)element; + for(int j = 0; j < parents.size(); j++){ + String description = null; + Property attribute = null; + + List attributeList = ((Class)parents.get(j)).getAttributes(); + for(int i = 0; i < attributeList.size(); i++){ + if(((Property)attributeList.get(i)).getName().equalsIgnoreCase(property.getName())){ + attribute = (Property)attributeList.get(i); + } + } + if(propertyIsOwnedEnd(property)){ + List endList = ((AssociationClass)parents.get(j)).getOwnedEnds(); + for(int i = 0; i < endList.size(); i++){ + if(((Property)endList.get(i)).getName().equalsIgnoreCase(property.getName())){ + attribute = (Property)endList.get(i); + } + } + } + + if(attribute != null){ + + String qualValue = getQualifiersStereotypeQualifer(attribute, qualifierName); + if(qualValue != null){ + return(new EffectiveInheritedValue(qualValue, (Class)parents.get(j))); + } + } + } + return null; + + } else if (element instanceof Operation && override(element)){ + Operation operation = (Operation)element; + for(int j = 0; j < parents.size(); j++){ + String description = null; + Operation method = null; + + List operationsList = ((Class)parents.get(j)).getOwnedOperations(); + for(int i = 0; i < operationsList.size(); i++){ + if(((Operation)operationsList.get(i)).getName().equalsIgnoreCase(operation.getName())){ + method = (Operation)operationsList.get(i); + } + } + + if(method != null){ + + String qualValue = getQualifiersStereotypeQualifer(method, qualifierName); + if(qualValue != null){ + return(new EffectiveInheritedValue(qualValue, (Class)parents.get(j))); + } + } + } + return null; + + } else if (element instanceof Parameter){ + Parameter parameter = (Parameter)element; + Operation operation = (Operation)parameter.getOwner(); + if(!override(operation)){ + return null; + } + for(int j = 0; j < parents.size(); j++){ + String description = null; + Parameter param = null; + + List operationsList = ((Class)parents.get(j)).getOwnedOperations(); + for(int i = 0; i < operationsList.size(); i++){ + if(((Operation)operationsList.get(i)).getName().equalsIgnoreCase(operation.getName())){ + List parameterList = ((Operation)operationsList.get(i)).getOwnedParameters(); + for(int k = 0; k < parameterList.size(); k++){ + if(((Parameter)parameterList.get(k)).getName().equalsIgnoreCase(parameter.getName())){ + param = (Parameter)parameterList.get(k); + } + } + } + } + + if(param != null){ + + String qualValue = getQualifiersStereotypeQualifer(param, qualifierName); + if(qualValue != null){ + return(new EffectiveInheritedValue(qualValue, (Class)parents.get(j))); + } + } + } + return null; + } else { + return null; + } + } else { + return null; + } } return null; } @@ -815,6 +1185,24 @@ return parents; } + private static String getQualifiersStereotypeQualifer(NamedElement element, String qualifierName){ + String qualifierValue = null; + + Stereotype cimStereotype = element.getAppliedStereotype("CIM::Qualifiers"); + List qualifierNames = (List)element.getValue(cimStereotype, "QualifierName"); + List qualifierValues = (List)element.getValue(cimStereotype, "QualifierValue"); + + for(int i = 0; i < qualifierNames.size(); i++){ + String qualName = (String)qualifierNames.get(i); + String qualValue = (String)qualifierValues.get(i); + + if(qualName.equalsIgnoreCase(qualifierName)){ + qualifierValue = qualValue; + } + } + return qualifierValue; + } + private static boolean override(NamedElement namedElement){ Stereotype cimStereotype = namedElement.getAppliedStereotype("CIM::Qualifiers"); @@ -831,6 +1219,38 @@ return false; } + private static boolean equalMethods(Operation method1, Operation method2){ + + if(method1 == null || method2 == null){ + return false; + } + + List methodParameters1 = method1.getOwnedParameters(); + List methodParameters2 = method2.getOwnedParameters(); + + if(methodParameters1.size() != methodParameters2.size()){ + return false; + } + + for (int i = 0; i < methodParameters1.size(); i++){ + Parameter parameter1 = (Parameter)methodParameters1.get(i); + Parameter parameter2 = (Parameter)methodParameters2.get(i); + + if(!parameter1.getName().equalsIgnoreCase(parameter2.getName())){ + return false; + } + if(!(parameter1.getType()).getName().equalsIgnoreCase((parameter2.getType()).getName())){ + if(((parameter1.getType()).getName().equalsIgnoreCase("String") || (parameter1.getType()).getName().equalsIgnoreCase("Octetstring")) && + ((parameter2.getType()).getName().equalsIgnoreCase("String") || (parameter2.getType()).getName().equalsIgnoreCase("Octetstring"))){ + continue; + } else { + return false; + } + } + } + return true; + } + } Index: EffectiveInheritedValue.java =================================================================== RCS file: /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/rsa/core/internal/properties/EffectiveInheritedValue.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- EffectiveInheritedValue.java 19 Jul 2005 16:10:47 -0000 1.1 +++ EffectiveInheritedValue.java 20 Jul 2005 15:21:46 -0000 1.2 @@ -8,14 +8,26 @@ import org.eclipse.uml2.Class; +import com.ibm.ecute.utils.License; + /** - * @author Benjamin Bender - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates + * Copyright (c) 2005, International Business Machines + * + * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE + * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES + * RECIPIENTS ACCEPTANCE OF THE AGREEMENT. + * + * You can obtain a current copy of the Common Public License from + * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html + * + * @author Benjamin Bender <be...@de...> */ + public class EffectiveInheritedValue { + // Copyright + private static final String COPYRIGHT = License.COPYRIGHT; + protected String value; protected Class definedIn; @@ -31,4 +43,14 @@ public Class getDefinedIn(){ return this.definedIn; } + + public int getIntValue(){ + int value; + try { + value = (new Integer(this.value)).intValue(); + } catch (NumberFormatException e) { + return -1; + } + return value; + } } Index: ValuesTableHelper.java =================================================================== RCS file: /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/rsa/core/internal/properties/ValuesTableHelper.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ValuesTableHelper.java 19 Jul 2005 16:10:47 -0000 1.2 +++ ValuesTableHelper.java 20 Jul 2005 15:21:46 -0000 1.3 @@ -7,15 +7,11 @@ package com.ibm.ecute.rsa.core.internal.properties; import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; import org.eclipse.emf.common.util.EList; import org.eclipse.swt.widgets.Table; -import org.eclipse.uml2.AggregationKind; import org.eclipse.uml2.AssociationClass; import org.eclipse.uml2.Class; -import org.eclipse.uml2.Comment; import org.eclipse.uml2.Constraint; import org.eclipse.uml2.NamedElement; import org.eclipse.uml2.OpaqueExpression; @@ -23,18 +19,27 @@ import org.eclipse.uml2.Package; import org.eclipse.uml2.Parameter; import org.eclipse.uml2.Property; -import org.eclipse.uml2.Stereotype; import com.ibm.ecute.Qualifiers.Qualifier; - +import com.ibm.ecute.utils.License; /** - * @author Benjamin Bender - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates + * Copyright (c) 2005, International Business Machines + * + * THIS FILE IS PROVIDED UNDER THE TERMS OF THE COMMON PUBLIC LICENSE + * ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES + * RECIPIENTS ACCEPTANCE OF THE AGREEMENT. + * + * You can obtain a current copy of the Common Public License from + * http://oss.software.ibm.com/developerworks/opensource/license-cpl.html + * + * @author Benjamin Bender <be...@de...> */ + public class ValuesTableHelper { + + // Copyright + private static final String COPYRIGHT = License.COPYRIGHT; Table table; @@ -42,302 +47,6 @@ this.table = table; } -// public void sortValuesTableBy(int columnNumber){ -// -// Collator collator = Collator.getInstance(Locale.getDefault()); -// -// boolean decreasing = false; -// TableItem[] column = table.getItems(); -// for (int h = 0; h < column.length-1; h++) { -// String value1 = column[h].getText(columnNumber); -// String value2 = column[h+1].getText(columnNumber); -// if (collator.compare(value1, value2) > 0) { -// decreasing = true; -// } -// } -// -// TableItem[] items = table.getItems(); -// for (int i = 1; i < items.length; i++) { -// String value1 = items[i].getText(columnNumber); -// QualifierValueObject data1 = (QualifierValueObject)items[i].getData(); -// for (int j = 0; j < i; j++){ -// String value2 = items[j].getText(columnNumber); -// if(decreasing){ -// if (collator.compare(value1, value2) < 0) { -// String[] values = {items[i].getText(0), items[i].getText(1), items[i].getText(2), -// items[i].getText(3), items[i].getText(4), items[i].getText(5)}; -// items[i].dispose(); -// TableItem item = new TableItem(table, SWT.NONE, j); -// item.setText(values); -// item.setData(data1); -// items = table.getItems(); -// break; -// } -// } else { -// if (collator.compare(value1, value2) > 0) { -// String[] values = {items[i].getText(0), items[i].getText(1), items[i].getText(2), -// items[i].getText(3), items[i].getText(4), items[i].getText(5)}; -// items[i].dispose(); -// TableItem item = new TableItem(table, SWT.NONE, j); -// item.setText(values); -// item.setData(data1); -// items = table.getItems(); -// break; -// } -// } -// } -// } -// } - - public ArrayList getInheritedQualifers(NamedElement element, ArrayList allAvailableQualifiers, boolean isReference){ - //TODO BB - ArrayList inheritedList = new ArrayList(); - - // get applicable qualifiers for the element - ArrayList applicableQualifiers = new ArrayList(); - for(int i = 0; i < allAvailableQualifiers.size(); i++){ - - Qualifier qualifier = (Qualifier)allAvailableQualifiers.get(i); - if(element instanceof Class && qualifier.classScope && !qualifier.RestrictedFlavor){ - applicableQualifiers.add(qualifier); - } else if(element instanceof AssociationClass && qualifier.associationScope && !qualifier.RestrictedFlavor){ - applicableQualifiers.add(qualifier); - } else if(element instanceof Property && !isReference && qualifier.propertyScope && !qualifier.RestrictedFlavor){ - applicableQualifiers.add(qualifier); - } else if(element instanceof Property && isReference && qualifier.referenceScope && !qualifier.RestrictedFlavor){ - applicableQualifiers.add(qualifier); - } else if(element instanceof Operation && qualifier.methodScope && !qualifier.RestrictedFlavor){ - applicableQualifiers.add(qualifier); - } else if(element instanceof Parameter && qualifier.parameterScope && !qualifier.RestrictedFlavor){ - applicableQualifiers.add(qualifier); - } - } - applicableQualifiers.trimToSize(); - -// if((element instanceof Class || element instanceof AssociationClass) && applicableQualifiers.size() > 0){ -// inheritedList = getInheritedClassQualifiers(element, applicableQualifiers, allAvailableQualifiers); -// } else if(element instanceof Property && isReference && applicableQualifiers.size() > 0){ -// inheritedList = getInheritedReferenceQualifiers(element, applicableQualifiers, allAvailableQualifiers, isReference); -// } -// return inheritedList; - - return getEffectiveInheritedValues(element, applicableQualifiers, allAvailableQualifiers); - } - - public QualifierValueObject checkIfInherited(Qualifier qualifier, Class class_, boolean lastParent){ - QualifierValueObject returnQualifierObject = null; - String classQualifierValue = null; - - if(qualifier.name.equalsIgnoreCase("Abstract")){ - if(class_.isAbstract()){ - classQualifierValue = "true"; - } else { - classQualifierValue = "false"; - } - } else if (qualifier.name.equalsIgnoreCase("Description")){ - EList list = class_.getOwnedComments(); - Iterator it = list.iterator(); - while (it.hasNext()){ - Comment comment = (Comment)it.next(); - Stereotype stereo = comment.getApplicableStereotype("Default::Documentation"); - if(stereo != null){ - classQualifierValue = comment.getBody(); - } - } - } else if (qualifier.name.equalsIgnoreCase("Deprecated")){ - Stereotype stereo = class_.getAppliedStereotype("CIM::Deprecated"); - if(stereo != null){ - classQualifierValue = (String)class_.getValue(stereo, "Value"); - } - } else if (!(class_ instanceof AssociationClass) && qualifier.name.equalsIgnoreCase("OCL")){ - String oclValue = existsOCL(class_); - if(oclValue != null) - classQualifierValue = oclValue; - } else if (class_ instanceof AssociationClass && qualifier.name.equalsIgnoreCase("Aggregation")){ - AssociationClass aClass = (AssociationClass)class_; - EList ends = aClass.getOwnedEnds(); - Iterator iter = ends.iterator(); - while(iter.hasNext()){ - Property prop = (Property)iter.next(); - if(prop.getAggregation().getValue()== AggregationKind.SHARED || - prop.getAggregation().getValue()== AggregationKind.COMPOSITE){ - classQualifierValue = "true"; - break; - } - } - - } else if (class_ instanceof AssociationClass && qualifier.name.equalsIgnoreCase("Composition")){ - AssociationClass aClass = (AssociationClass)class_; - EList ends = aClass.getOwnedEnds(); - Iterator iter = ends.iterator(); - while(iter.hasNext()){ - Property prop = (Property)iter.next(); - if(prop.getAggregation().getValue()== AggregationKind.COMPOSITE){ - classQualifierValue = "true"; - break; - } - } - } else { - - //get all qualifiers witch are set in the Qualifiers-Stereotype - Stereotype cimStereotype = class_.getAppliedStereotype("CIM::Qualifiers"); - List qualifierNames = (List) class_.getValue(cimStereotype, "QualifierName"); - List qualifierValues = (List) class_.getValue(cimStereotype, "QualifierValue"); - - for(int i=0; i<qualifierNames.size(); i++){ - String qualifierName = (String)qualifierNames.get(i); - String qualifierValue = (String)qualifierValues.get(i); - - if(qualifierName.equalsIgnoreCase(qualifier.name)){ - classQualifierValue = qualifierValue; - break; - } - } - - } - - if(classQualifierValue != null && !classQualifierValue.equalsIgnoreCase(qualifier.defaultValue)){ - returnQualifierObject = new QualifierValueObject(qualifier.name, - classQualifierValue, class_.getName() + " (" + - class_.getNearestPackage().getName() + ")" , -1); - } -// if (classQualifierValue == null && lastParent){ -// // set default value and definedIn emptyString -// returnQualifierObject = new QualifierValueObject(qualifier.name, -// qualifier.defaultValue, "", -1); -// } - - return returnQualifierObject; - } - - public QualifierValueObject checkIfInherited(Qualifier qualifier, Property property, boolean isReference, Class class_, boolean lastParent){ - QualifierValueObject returnQualifierObject = null; - - if(isReference && class_ instanceof AssociationClass){ - // property is a reference - AssociationClass thisClass = (AssociationClass)class_; - String propertyQualifierValue = null; - - if(qualifier.name.equalsIgnoreCase("Aggregate")){ - // check if parent association aggregates - Property otherEnd; - // get other association end - List associationEnds = thisClass.getOwnedEnds(); - if(associationEnds.size() >= 2){ - Property end1 = (Property)associationEnds.get(0); - Property end2 = (Property)associationEnds.get(1); - if(end1.getName().equalsIgnoreCase(property.getName())){ - otherEnd = end2; - } else { - otherEnd = end1; - } - } else { - return null; - } - // check if other end as aggregate qualifier - if(otherEnd.getAggregation().getValue() == AggregationKind.COMPOSITE || otherEnd.getAggregation().getValue() == AggregationKind.SHARED){ - propertyQualifierValue = "true"; - } else { - propertyQualifierValue = "false"; - } - - } else if(qualifier.name.equalsIgnoreCase("Min") || qualifier.name.equalsIgnoreCase("Max")){ - Property thisEnd; - // get this association end - List associationEnds = thisClass.getOwnedEnds(); - if(associationEnds.size() >= 2){ - Property end1 = (Property)associationEnds.get(0); - Property end2 = (Property)associationEnds.get(1); - if(end1.getName().equalsIgnoreCase(property.getName())){ - thisEnd = end1; - } else { - thisEnd = end2; - } - } else { - return null; - } - // get qualifier value - if(qualifier.name.equalsIgnoreCase("Min")){ - propertyQualifierValue = new Integer(thisEnd.getLower()).toString(); - } else { - propertyQualifierValue = new Integer(thisEnd.getUpper()).toString(); - } - } else if(!isReference){ - - } - - Property attribute = null; - - List attributeList = class_.getAttributes(); - for(int i = 0; i < attributeList.size(); i++){ - if(((Property)attributeList.get(i)).getName().equalsIgnoreCase(property.getName())){ - attribute = (Property)attributeList.get(i); - } - } - if(isReference){ - List endList = ((AssociationClass)class_).getOwnedEnds(); - for(int i = 0; i < endList.size(); i++){ - if(((Property)endList.get(i)).getName().equalsIgnoreCase(property.getName())){ - attribute = (Property)endList.get(i); - } - } - } - - - if(attribute != null){ - if (qualifier.name.equalsIgnoreCase("Description")){ - - EList list = attribute.getOwnedComments(); - Iterator it = list.iterator(); - while (it.hasNext()){ - Comment comment = (Comment)it.next(); - Stereotype stereo = comment.getApplicableStereotype("Default::Documentation"); - if(stereo != null){ - propertyQualifierValue = comment.getBody(); - } - } - - } else if (qualifier.name.equalsIgnoreCase("Deprecated")){ - Stereotype stereo = attribute.getAppliedStereotype("CIM::Deprecated"); - if(stereo != null){ - propertyQualifierValue = (String)attribute.getValue(stereo, "Value"); - } - - } else if (qualifier.name.equalsIgnoreCase("Key")){ - Stereotype stereo = attribute.getAppliedStereotype("CIM::Key"); - if(stereo != null){ - propertyQualifierValue = "true"; - } - - } else { - - //get all qualifiers witch are set in the Qualifiers-Stereotype - Stereotype cimStereotype = attribute.getAppliedStereotype("CIM::Qualifiers"); - List qualifierNames = (List) attribute.getValue(cimStereotype, "QualifierName"); - List qualifierValues = (List) attribute.getValue(cimStereotype, "QualifierValue"); - - for(int i=0; i < qualifierNames.size(); i++){ - String qualifierName = (String)qualifierNames.get(i); - String qualifierValue = (String)qualifierValues.get(i); - - if(qualifierName.equalsIgnoreCase(qualifier.name)){ - propertyQualifierValue = qualifierValue; - break; - } - } - } - } - - if(propertyQualifierValue != null && !propertyQualifierValue.equalsIgnoreCase(qualifier.defaultValue)){ - returnQualifierObject = new QualifierValueObject(qualifier.name, - propertyQualifierValue, class_.getName() + " (" + - class_.getNearestPackage().getName() + ")" , -1); - } - } - - return returnQualifierObject; - } - public String existsOCL(Class class_ ){ String value = null; @@ -365,61 +74,35 @@ } } - // return the cantent of the constraint + // return the content of the constraint return value; } - private ArrayList getInheritedClassQualifiers(NamedElement element, ArrayList applicableQualifiers, ArrayList allAvailableQualifiers){ - ArrayList inheritedList = new ArrayList(); - Class thisClass = (Class)element; - // get parent classes - ArrayList parents = getParentClasses(thisClass); - parents.trimToSize(); - - if(parents.size() > 0){ - for(int i = 0; i < applicableQualifiers.size(); i++){ - boolean lastParent = false; - for(int j = 0; j < parents.size(); j++){ - if(j == parents.size()-1) lastParent = true; - QualifierValueObject isInherited = checkIfInherited((Qualifier)applicableQualifiers.get(i), (Class)parents.get(j), lastParent); - if(isInherited != null){ - inheritedList.add(isInherited); - allAvailableQualifiers.remove((Qualifier)applicableQualifiers.get(i)); - break; - } - } - } - } - - return inheritedList; - } - private ArrayList getInheritedReferenceQualifiers(NamedElement element, ArrayList applicableQualifiers, ArrayList allAvailableQualifiers, boolean isReference){ - ArrayList inheritedList = new ArrayList(); - Property property = (Property)element; - if(overrides(element)){ - // get parent classes - ArrayList parents = getParentClasses((Class)property.getOwner()); - parents.trimToSize(); - - if(parents.size() > 0){ - for(int i = 0; i < applicableQualifiers.size(); i++){ - boolean lastParent = false; - for(int j = 0; j < parents.size(); j++){ - if(j == parents.size()-1) lastParent = true; - QualifierValueObject isInherited = checkIfInherited((Qualifier)applicableQualifiers.get(i), property, isReference, (Class)parents.get(j), lastParent); - if(isInherited != null){ - inheritedList.add(isInherited); - allAvailableQualifiers.remove((Qualifier)applicableQualifiers.get(i)); - break; - } - } - } - } - } - - return inheritedList; - } + public ArrayList getInheritedQualifers(NamedElement element, ArrayList allAvailableQualifiers, boolean isReference){ + + // get applicable qualifiers for the element + ArrayList applicableQualifiers = new ArrayList(); + for(int i = 0; i < allAvailableQualifiers.size(); i++){ + + Qualifier qualifier = (Qualifier)allAvailableQualifiers.get(i); + if(element instanceof Class && qualifier.classScope && !qualifier.RestrictedFlavor){ + applicableQualifiers.add(qualifier); + } else if(element instanceof AssociationClass && qualifier.associationScope && !qualifier.RestrictedFlavor){ + applicableQualifiers.add(qualifier); + } else if(element instanceof Property && !isReference && qualifier.propertyScope && !qualifier.RestrictedFlavor){ + applicableQualifiers.add(qualifier); + } else if(element instanceof Property && isReference && qualifier.referenceScope && !qualifier.RestrictedFlavor){ + applicableQualifiers.add(qualifier); + } else if(element instanceof Operation && qualifier.methodScope && !qualifier.RestrictedFlavor){ + applicableQualifiers.add(qualifier); + } else if(element instanceof Parameter && qualifier.parameterScope && !qualifier.RestrictedFlavor){ + applicableQualifiers.add(qualifier); + } + } + applicableQualifiers.trimToSize(); + return getEffectiveInheritedValues(element, applicableQualifiers, allAvailableQualifiers); + } private ArrayList getEffectiveInheritedValues(NamedElement element, ArrayList applicableQualifiers, ArrayList allAvailableQualifiers){ ArrayList inheritedList = new ArrayList(); @@ -444,33 +127,297 @@ return inheritedList; } +} - private ArrayList getParentClasses(Class thisClass){ - ArrayList parents = new ArrayList(); - List generals = thisClass.getGenerals(); - while (generals.size() > 0){ - Class class_ = (Class)generals.get(0); - parents.add(class_); - generals = class_.getGenerals(); - } - parents.remove(thisClass); - - return parents; - } +// public void sortValuesTableBy(int columnNumber){ +// +// Collator collator = Collator.getInstance(Locale.getDefault()); +// +// boolean decreasing = false; +// TableItem[] column = table.getItems(); +// for (int h = 0; h < column.length-1; h++) { +// String value1 = column[h].getText(columnNumber); +// String value2 = column[h+1].getText(columnNumber); +// if (collator.compare(value1, value2) > 0) { +// decreasing = true; +// } +// } +// +// TableItem[] items = table.getItems(); +// for (int i = 1; i < items.length; i++) { +// String value1 = items[i].getText(columnNumber); +// QualifierValueObject data1 = (QualifierValueObject)items[i].getData(); +// for (int j = 0; j < i; j++){ +// String value2 = items[j].getText(columnNumber); +// if(decreasing){ +// if (collator.compare(value1, value2) < 0) { +// String[] values = {items[i].getText(0), items[i].getText(1), items[i].getText(2), +// items[i].getText(3), items[i].getText(4), items[i].getText(5)}; +// items[i].dispose(); +// TableItem item = new TableItem(table, SWT.NONE, j); +// item.setText(values); +// item.setData(data1); +// items = table.getItems(); +// break; +// } +// } else { +// if (collator.compare(value1, value2) > 0) { +// String[] values = {items[i].getText(0), items[i].getText(1), items[i].getText(2), +// items[i].getText(3), items[i].getText(4), items[i].getText(5)}; +// items[i].dispose(); +// TableItem item = new TableItem(table, SWT.NONE, j); +// item.setText(values); +// item.setData(data1); +// items = table.getItems(); +// break; +// } +// } +// } +// } +//} + + + +//public QualifierValueObject checkIfInherited(Qualifier qualifier, Class class_, boolean lastParent){ +// QualifierValueObject returnQualifierObject = null; +// String classQualifierValue = null; +// +// if(qualifier.name.equalsIgnoreCase("Abstract")){ +// if(class_.isAbstract()){ +// classQualifierValue = "true"; +// } else { +// classQualifierValue = "false"; +// } +// } else if (qualifier.name.equalsIgnoreCase("Description")){ +// EList list = class_.getOwnedComments(); +// Iterator it = list.iterator(); +// while (it.hasNext()){ +// Comment comment = (Comment)it.next(); +// Stereotype stereo = comment.getApplicableStereotype("Default::Documentation"); +// if(stereo != null){ +// classQualifierValue = comment.getBody(); +// } +// } +// } else if (qualifier.name.equalsIgnoreCase("Deprecated")){ +// Stereotype stereo = class_.getAppliedStereotype("CIM::Deprecated"); +// if(stereo != null){ +// classQualifierValue = (String)class_.getValue(stereo, "Value"); +// } +// } else if (!(class_ instanceof AssociationClass) && qualifier.name.equalsIgnoreCase("OCL")){ +// String oclValue = existsOCL(class_); +// if(oclValue != null) +// classQualifierValue = oclValue; +// } else if (class_ instanceof AssociationClass && qualifier.name.equalsIgnoreCase("Aggregation")){ +// AssociationClass aClass = (AssociationClass)class_; +// EList ends = aClass.getOwnedEnds(); +// Iterator iter = ends.iterator(); +// while(iter.hasNext()){ +// Property prop = (Property)iter.next(); +// if(prop.getAggregation().getValue()== AggregationKind.SHARED || +// prop.getAggregation().getValue()== AggregationKind.COMPOSITE){ +// classQualifierValue = "true"; +// break; +// } +// } +// +// } else if (class_ instanceof AssociationClass && qualifier.name.equalsIgnoreCase("Composition")){ +// AssociationClass aClass = (AssociationClass)class_; +// EList ends = aClass.getOwnedEnds(); +// Iterator iter = ends.iterator(); +// while(iter.hasNext()){ +// Property prop = (Property)iter.next(); +// if(prop.getAggregation().getValue()== AggregationKind.COMPOSITE){ +// classQualifierValue = "true"; +// break; +// } +// } +// } else { +// +// //get all qualifiers witch are set in the Qualifiers-Stereotype +// Stereotype cimStereotype = class_.getAppliedStereotype("CIM::Qualifiers"); +// List qualifierNames = (List) class_.getValue(cimStereotype, "QualifierName"); +// List qualifierValues = (List) class_.getValue(cimStereotype, "QualifierValue"); +// +// for(int i=0; i<qualifierNames.size(); i++){ +// String qualifierName = (String)qualifierNames.get(i); +// String qualifierValue = (String)qualifierValues.get(i); +// +// if(qualifierName.equalsIgnoreCase(qualifier.name)){ +// classQualifierValue = qualifierValue; +// break; +// } +// } +// +// } +// +// if(classQualifierValue != null && !classQualifierValue.equalsIgnoreCase(qualifier.defaultValue)){ +// returnQualifierObject = new QualifierValueObject(qualifier.name, +// classQualifierValue, class_.getName() + " (" + +// class_.getNearestPackage().getName() + ")" , -1); +// } +//// if (classQualifierValue == null && lastParent){ +//// // set default value and definedIn emptyString +//// returnQualifierObject = new QualifierValueObject(qualifier.name, +//// qualifier.defaultValue, "", -1); +//// } +// +// return returnQualifierObject; +//} +// +//public QualifierValueObject checkIfInherited(Qualifier qualifier, Property property, boolean isReference, Class class_, boolean lastParent){ +// QualifierValueObject returnQualifierObject = null; +// +// if(isReference && class_ instanceof AssociationClass){ +// // property is a reference +// AssociationClass thisClass = (AssociationClass)class_; +// String propertyQualifierValue = null; +// +// if(qualifier.name.equalsIgnoreCase("Aggregate")){ +// // check if parent association aggregates +// Property otherEnd; +// // get other association end +// List associationEnds = thisClass.getOwnedEnds(); +// if(associationEnds.size() >= 2){ +// Property end1 = (Property)associationEnds.get(0); +// Property end2 = (Property)associationEnds.get(1); +// if(end1.getName().equalsIgnoreCase(property.getName())){ +// otherEnd = end2; +// } else { +// otherEnd = end1; +// } +// } else { +// return null; +// } +// // check if other end as aggregate qualifier +// if(otherEnd.getAggregation().getValue() == AggregationKind.COMPOSITE || otherEnd.getAggregation().getValue() == AggregationKind.SHARED){ +// propertyQualifierValue = "true"; +// } else { +// propertyQualifierValue = "false"; +// } +// +// } else if(qualifier.name.equalsIgnoreCase("Min") || qualifier.name.equalsIgnoreCase("Max")){ +// Property thisEnd; +// // get this association end +// List associationEnds = thisClass.getOwnedEnds(); +// if(associationEnds.size() >= 2){ +// Property end1 = (Property)associationEnds.get(0); +// Property end2 = (Property)associationEnds.get(1); +// if(end1.getName().equalsIgnoreCase(property.getName())){ +// thisEnd = end1; +// } else { +// thisEnd = end2; +// } +// } else { +// return null; +// } +// // get qualifier value +// if(qualifier.name.equalsIgnoreCase("Min")){ +// propertyQualifierValue = new Integer(thisEnd.getLower()).toString(); +// } else { +// propertyQualifierValue = new Integer(thisEnd.getUpper()).toString(); +// } +// } else if(!isReference){ +// +// } +// +// Property attribute = null; +// +// List attributeList = class_.getAttributes(); +// for(int i = 0; i < attributeList.size(); i++){ +// if(((Property)attributeList.get(i)).getName().equalsIgnoreCase(property.getName())){ +// attribute = (Property)attributeList.get(i); +// } +// } +// if(isReference){ +// List endList = ((AssociationClass)class_).getOwnedEnds(); +// for(int i = 0; i < endList.size(); i++){ +// if(((Property)endList.get(i)).getName().equalsIgnoreCase(property.getName())){ +// attribute = (Property)endList.get(i); +// } +// } +// } +// +// +// if(attribute != null){ +// if (qualifier.name.equalsIgnoreCase("Description")){ +// +// EList list = attribute.getOwnedComments(); +// Iterator it = list.iterator(); +// while (it.hasNext()){ +// Comment comment = (Comment)it.next(); +// Stereotype stereo = comment.getApplicableStereotype("Default::Documentation"); +// if(stereo != null){ +// propertyQualifierValue = comment.getBody(); +// } +// } +// +// } else if (qualifier.name.equalsIgnoreCase("Deprecated")){ +// Stereotype stereo = attribute.getAppliedStereotype("CIM::Deprecated"); +// if(stereo != null){ +// propertyQualifierValue = (String)attribute.getValue(stereo, "Value"); +// } +// +// } else if (qualifier.name.equalsIgnoreCase("Key")){ +// Stereotype stereo = attribute.getAppliedStereotype("CIM::Key"); +// if(stereo != null){ +// propertyQualifierValue = "true"; +// } +// +// } else { +// +// //get all qualifiers witch are set in the Qualifiers-Stereotype +// Stereotype cimStereotype = attribute.getAppliedStereotype("CIM::Qualifiers"); +// List qualifierNames = (List) attribute.getValue(cimStereotype, "QualifierName"); +// List qualifierValues = (List) attribute.getValue(cimStereotype, "QualifierValue"); +// +// for(int i=0; i < qualifierNames.size(); i++){ +// String qualifierName = (String)qualifierNames.get(i); +// String qualifierValue = (String)qualifierValues.get(i); +// +// if(qualifierName.equalsIgnoreCase(qualifier.name)){ +// propertyQualifierValue = qualifierValue; +// break; +// } +// } +// } +// } +// +// if(propertyQualifierValue != null && !propertyQualifierValue.equalsIgnoreCase(qualifier.defaultValue)){ +// returnQualifierObject = new QualifierValueObject(qualifier.name, +// propertyQualifierValue, class_.getName() + " (" + +// class_.getNearestPackage().getName() + ")" , -1); +// } +// } +// +// return returnQualifierObject; +//} - private boolean overrides(NamedElement element){ - - Stereotype cimStereotype = element.getAppliedStereotype("CIM::Qualifiers"); - List qualifierNames = (List) element.getValue(cimStereotype, "QualifierName"); - //List qualifierValues = (List) element.getValue(cimStereotype, "QualifierValue"); - - for(int i = 0; i < qualifierNames.size(); i++){ - if(((String)(qualifierNames.get(i))).equalsIgnoreCase("Override")){ - return true; - } - } - return false; - } +// private ArrayList getParentClasses(Class thisClass){ +// ArrayList parents = new ArrayList(); +// List generals = thisClass.getGenerals(); +// while (generals.size() > 0){ +// Class class_ = (Class)generals.get(0); +// parents.add(class_); +// generals = class_.getGenerals(); +// } +// parents.remove(thisClass); +// +// return parents; +// } + +// private boolean overrides(NamedElement element){ +// +// Stereotype cimStereotype = element.getAppliedStereotype("CIM::Qualifiers"); +// List qualifierNames = (List) element.getValue(cimStereotype, "QualifierName"); +// //List qualifierValues = (List) element.getValue(cimStereotype, "QualifierValue"); +// +// for(int i = 0; i < qualifierNames.size(); i++){ +// if(((String)(qualifierNames.get(i))).equalsIgnoreCase("Override")){ +// return true; +// } +// } +// return false; +// } // public class QualifierValueObject{ // private String name; @@ -547,4 +494,56 @@ // } // } // } -} + +// private ArrayList getInheritedClassQualifiers(NamedElement element, ArrayList applicableQualifiers, ArrayList allAvailableQualifiers){ +// ArrayList inheritedList = new ArrayList(); +// Class thisClass = (Class)element; +// // get parent classes +// ArrayList parents = getParentClasses(thisClass); +// parents.trimToSize(); +// +// if(parents.size() > 0){ +// for(int i = 0; i < applicableQualifiers.size(); i++){ +// boolean lastParent = false; +// for(int j = 0; j < parents.size(); j++){ +// if(j == parents.size()-1) lastParent = true; +// QualifierValueObject isInherited = checkIfInherited((Qualifier)applicableQualifiers.get(i), (Class)parents.get(j), lastParent); +// if(isInherited != null){ +// inheritedList.add(isInherited); +// allAvailableQualifiers.remove((Qualifier)applicableQualifiers.get(i)); +// break; +// } +// } +// } +// } +// +// return inheritedList; +//} +// +//private ArrayList getInheritedReferenceQualifiers(NamedElement element, ArrayList applicableQualifiers, ArrayList allAvailableQualifiers, boolean isReference){ +// ArrayList inheritedList = new ArrayList(); +// Property property = (Property)element; +// if(overrides(element)){ +// // get parent classes +// ArrayList parents = getParentClasses((Class)property.getOwner()); +// parents.trimToSize(); +// +// if(parents.size() > 0){ +// for(int i = 0; i < applicableQualifiers.size(); i++){ +// boolean lastParent = false; +// for(int j = 0; j < parents.size(); j++){ +// if(j == parents.size()-1) lastParent = true; +// QualifierValueObject isInherited = checkIfInherited((Qualifier)applicableQualifiers.get(i), property, isReference, (Class)parents.get(j), lastParent); +// if(isInherited != null){ +// inheritedList.add(isInherited); +// allAvailableQualifiers.remove((Qualifier)applicableQualifiers.get(i)); +// break; +// } +// } +// } +// } +// } +// +// return inheritedList; +//} + Index: QualifiersPropertySection.java =================================================================== RCS file: /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/rsa/core/internal/properties/QualifiersPropertySection.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- QualifiersPropertySection.java 19 Jul 2005 16:10:47 -0000 1.20 +++ QualifiersPropertySection.java 20 Jul 2005 15:21:46 -0000 1.21 @@ -80,6 +80,7 @@ * @author Susanne Katz <ka...@de...> * Benjamin Bender <be...@de...> */ + public class QualifiersPropertySection extends AbstractModelerPropertySection{ // Copyright private static final String COPYRIGHT = License.COPYRIGHT; @@ -275,7 +276,7 @@ definedIn = ((NamedElement)element.getOwner()).getName() + "::" +element.getName()/*+" ("+owner.getNearestPackage().getName()+")"*/; } - //display all qualifiers witch are set in the Qualifiers-Stereotype + //display all qualifiers which are set in the Qualifiers-Stereotype Stereotype cimStereotype = element.getAppliedStereotype("CIM::Qualifiers"); List qualifierNames = (List) element.getValue(cimStereotype, "QualifierName"); List qualifierValues = (List) element.getValue(cimStereotype, "QualifierValue"); @@ -469,14 +470,15 @@ addQualiferToTable(qualifierName, "true", definedIn, qualifierObject, -1, false); } allAvailableQualifers.remove(qualifierObject); - } else { - Qualifier qualifierObject = qualifiersList.GetElement(qualifierName); - exists = existsQualifierInTable(qualifierName); - if (!exists){ - addQualiferToTable(qualifierName, "false", definedIn, qualifierObject, -1, false); - } - allAvailableQualifers.remove(qualifierObject); - } + } +// else { +// Qualifier qualifierObject = qualifiersList.GetElement(qualifierName); +// exists = existsQualifierInTable(qualifierName); +// if (!exists){ +// addQualiferToTable(qualifierName, "false", definedIn, qualifierObject, -1, false); +// } +// allAvailableQualifers.remove(qualifierObject); +// } } //Qualifier: Key qualifierName = "Key"; @@ -489,16 +491,25 @@ //Qualifier: Max, Min if(isOwnedEnd /*&& prop.getOwner() instanceof AssociationCla... [truncated message content] |