From: Benjamin B. <bg...@us...> - 2005-07-19 16:11:05
|
Update of /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/rsa/core/internal/properties In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9740/Plugin/com/ibm/ecute/rsa/core/internal/properties Modified Files: ValuesTableHelper.java QualifiersPropertySection.java FlavorsHelper.java Added Files: EffectiveInheritedValue.java Log Message: Index: FlavorsHelper.java =================================================================== RCS file: /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/rsa/core/internal/properties/FlavorsHelper.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- FlavorsHelper.java 15 Jul 2005 13:43:39 -0000 1.2 +++ FlavorsHelper.java 19 Jul 2005 16:10:47 -0000 1.3 @@ -8,19 +8,24 @@ import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.emf.common.util.EList; 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.Model; import org.eclipse.uml2.NamedElement; import org.eclipse.uml2.OpaqueExpression; import org.eclipse.uml2.Operation; import org.eclipse.uml2.Package; +import org.eclipse.uml2.Parameter; +import org.eclipse.uml2.ParameterDirectionKind; import org.eclipse.uml2.Property; import org.eclipse.uml2.Stereotype; import org.eclipse.uml2.UML2Package; @@ -28,6 +33,7 @@ import com.ibm.ecute.EcuteEclipsePlugin; import com.ibm.ecute.Qualifiers.QualifiersList; import com.ibm.ecute.utils.License; +import com.ibm.ecute.rsa.core.internal.properties.EffectiveInheritedValue; import com.ibm.xtools.emf.msl.EditingDomain; import com.ibm.xtools.emf.msl.ResourceSetModifyOperation; import com.ibm.xtools.modeler.UMLModeler; @@ -440,7 +446,7 @@ } } - private Class getParentClass(Class class_){ + private static Class getParentClass(Class class_){ List parents = class_.getGenerals(); if(parents.size() > 0){ @@ -472,4 +478,359 @@ return null; } + + public static EffectiveInheritedValue effectiveInheritedValue(NamedElement element, String qualifierName){ + + // ABSTRACT + if(qualifierName.equalsIgnoreCase("Abstract")){ + return null; + //AGGREGATE + } else if(qualifierName.equalsIgnoreCase("Aggregate")){ + if(element instanceof Property && propertyIsOwnedEnd((Property)element) && override(element)){ + Property property = (Property)element; + Class parent = getParentClass((Class)property.getOwner()); + if(parent != null && parent instanceof AssociationClass){ + if(((AssociationClass)parent).getOwnedEnds().size() >= 2){ + Property parentEnd1 = (Property)((AssociationClass)parent).getOwnedEnds().get(0); + Property parentEnd2 = (Property)((AssociationClass)parent).getOwnedEnds().get(1); + Property otherEnd; + if(property.getName().equalsIgnoreCase(parentEnd1.getName())){ + otherEnd = parentEnd2; + } else { + otherEnd = parentEnd1; + } + // check if other end as aggregate qualifier + if(otherEnd.getAggregation().getValue() == AggregationKind.COMPOSITE || otherEnd.getAggregation().getValue() == AggregationKind.SHARED){ + return (new EffectiveInheritedValue("true", parent)); + } + } else { + return null; + } + } else { + return null; + } + } else { + return null; + } + // 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)); + } + } + } else { + return null; + } + + } else { + return null; + } + // 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)); + } + } + } else { + return null; + } + + } else { + return null; + } + // DEPRECATED + } else if(qualifierName.equalsIgnoreCase("Deprecated")){ + return null; + // DESCRIPTION + } else if(qualifierName.equalsIgnoreCase("Description")){ + // getParentClasses + ArrayList parents = getParentClasses(element); + + if(element instanceof Class){ + if(parents.size() > 0){ + 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(); + } + } + if(description != null){ + return(new EffectiveInheritedValue(description, (Class)parents.get(j))); + } + } + return null; + } else { + return null; + } + + } else if (element instanceof Property && override(element)){ + + if(parents.size() > 0){ + 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){ + + 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){ + description = comment.getBody(); + } + } + if(description != null){ + return(new EffectiveInheritedValue(description, (Class)parents.get(j))); + } + } + } + return null; + } else { + return null; + } + } else if (element instanceof Operation && override(element)){ + + if(parents.size() > 0){ + 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){ + + EList list = method.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))); + } + } + } + return null; + } else { + return null; + } + } else if (element instanceof Parameter){ + if(parents.size() > 0){ + 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){ + + EList list = param.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))); + } + } + } + return null; + } else { + return null; + } + } else { + return null; + } + // IN + } else if(qualifierName.equalsIgnoreCase("In") || qualifierName.equalsIgnoreCase("Out")){ + if(element instanceof Parameter){ + ArrayList parents = getParentClasses(element); + if(parents.size() > 0){ + 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){ + + ParameterDirectionKind direction = param.getDirection(); + String direct = null; + if(direction != null){ + direct = direction.getName(); + } + + if(direct != null){ + if(qualifierName.equalsIgnoreCase("In")){ + if(direct.equalsIgnoreCase("in") || direct.equalsIgnoreCase("inout")){ + return(new EffectiveInheritedValue("true", (Class)parents.get(j))); + } + } else { + if(direct.equalsIgnoreCase("out") || direct.equalsIgnoreCase("inout")){ + return(new EffectiveInheritedValue("true", (Class)parents.get(j))); + } + } + } + } + } + return null; + } else { + return null; + } + } else { + return null; + } + + } + return null; + } + + private static boolean propertyIsOwnedEnd(Property prop){ + + boolean isOwnedEnd = false; + if (prop.getOwner() instanceof AssociationClass){ + AssociationClass parentClass = (AssociationClass)prop.getOwner(); + List ends = parentClass.getOwnedEnds(); + if ((Property)ends.get(0) == prop){ + isOwnedEnd = true; + } + if ((Property)ends.get(1) == prop){ + isOwnedEnd = true; + } + return isOwnedEnd; + } else { + return false; + } + } + + private static 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 static ArrayList getParentClasses(NamedElement element){ + + ArrayList parents; + + if(element instanceof Class){ + parents = getParentClasses((Class)element); + } else if (element instanceof Parameter){ + parents = getParentClasses((Class)(((Parameter)element).getOwner().getOwner())); + } else { + parents = getParentClasses((Class)element.getOwner()); + } + + return parents; + } + + private static boolean override(NamedElement namedElement){ + + Stereotype cimStereotype = namedElement.getAppliedStereotype("CIM::Qualifiers"); + List qualifierNames = (List) namedElement.getValue(cimStereotype, "QualifierName"); + List qualifierValues = (List) namedElement.getValue(cimStereotype, "QualifierValue"); + + for(int i = 0; i < qualifierNames.size(); i++){ + String qualifierName = (String)qualifierNames.get(i); + if(qualifierName.equalsIgnoreCase("Override")){ + return true; + } + } + + return false; + } + + } + --- NEW FILE: EffectiveInheritedValue.java --- /* * Created on 19.07.2005 * * TODO To change the template for this generated file go to * Window - Preferences - Java - Code Style - Code Templates */ package com.ibm.ecute.rsa.core.internal.properties; import org.eclipse.uml2.Class; /** * @author Benjamin Bender * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class EffectiveInheritedValue { protected String value; protected Class definedIn; public EffectiveInheritedValue(String value, Class definedIn){ this.value = value; this.definedIn = definedIn; } public String getValue(){ return this.value; } public Class getDefinedIn(){ return this.definedIn; } } Index: ValuesTableHelper.java =================================================================== RCS file: /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/rsa/core/internal/properties/ValuesTableHelper.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ValuesTableHelper.java 15 Jun 2005 09:41:47 -0000 1.1 +++ ValuesTableHelper.java 19 Jul 2005 16:10:47 -0000 1.2 @@ -89,10 +89,10 @@ // } // } - public ArrayList getInheritedQualifers(NamedElement element, ArrayList allAvailableQualifiers){ + 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++){ @@ -102,9 +102,9 @@ applicableQualifiers.add(qualifier); } else if(element instanceof AssociationClass && qualifier.associationScope && !qualifier.RestrictedFlavor){ applicableQualifiers.add(qualifier); - } else if(element instanceof Property && qualifier.propertyScope && !qualifier.RestrictedFlavor){ + } else if(element instanceof Property && !isReference && qualifier.propertyScope && !qualifier.RestrictedFlavor){ applicableQualifiers.add(qualifier); - } else if(element instanceof Property && qualifier.referenceScope && !qualifier.RestrictedFlavor){ + } 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); @@ -114,34 +114,14 @@ } applicableQualifiers.trimToSize(); - if(element instanceof Class && applicableQualifiers.size() > 0){ - Class thisClass = (Class)element; - // get parent classes - ArrayList parents = new ArrayList(); - List generals = thisClass.getGenerals(); - while (generals.size() > 0){ - Class class_ = (Class)generals.get(0); - parents.add(class_); - generals = class_.getGenerals(); - } - - 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; - } - } - } - } - } +// 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 inheritedList; + return getEffectiveInheritedValues(element, applicableQualifiers, allAvailableQualifiers); } public QualifierValueObject checkIfInherited(Qualifier qualifier, Class class_, boolean lastParent){ @@ -230,6 +210,134 @@ 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; @@ -261,6 +369,109 @@ 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; + } + + private ArrayList getEffectiveInheritedValues(NamedElement element, ArrayList applicableQualifiers, ArrayList allAvailableQualifiers){ + ArrayList inheritedList = new ArrayList(); + + for(int i = 0; i < applicableQualifiers.size(); i++){ + EffectiveInheritedValue effectiveInheritedValue = FlavorsHelper.effectiveInheritedValue(element, ((Qualifier)applicableQualifiers.get(i)).name); + if(effectiveInheritedValue != null){ + if(element instanceof Parameter){ + inheritedList.add(new QualifierValueObject(((Qualifier)applicableQualifiers.get(i)).name, + effectiveInheritedValue.getValue(), effectiveInheritedValue.getDefinedIn().getNearestPackage().getName() + "::" + effectiveInheritedValue.getDefinedIn().getName() + + "::" + ((Operation)((Parameter)element).getOwner()).getName() + "::" +element.getName(), -1)); + } else if (element instanceof Class){ + inheritedList.add(new QualifierValueObject(((Qualifier)applicableQualifiers.get(i)).name, + effectiveInheritedValue.getValue(), effectiveInheritedValue.getDefinedIn().getNearestPackage().getName() + "::" + effectiveInheritedValue.getDefinedIn().getName(), -1)); + } else { + inheritedList.add(new QualifierValueObject(((Qualifier)applicableQualifiers.get(i)).name, + effectiveInheritedValue.getValue(), effectiveInheritedValue.getDefinedIn().getNearestPackage().getName() + "::" + effectiveInheritedValue.getDefinedIn().getName() + + "::" + element.getName(), -1)); + } + } + } + + 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; + } + + 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; // private String value; Index: QualifiersPropertySection.java =================================================================== RCS file: /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/rsa/core/internal/properties/QualifiersPropertySection.java,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- QualifiersPropertySection.java 7 Jul 2005 15:42:49 -0000 1.19 +++ QualifiersPropertySection.java 19 Jul 2005 16:10:47 -0000 1.20 @@ -97,12 +97,11 @@ private Table qualifiersTable; private ArrayList defaultValueQualifiers; - private static QualifiersList qualifiersList = null; + private QualifiersList qualifiersList = null; private boolean qualifiersListChanged = false; ArrayList allAvailableQualifers = null; - - + public QualifiersPropertySection() { } @@ -237,7 +236,9 @@ public Object run() { - if(element instanceof Parameter){ + boolean isOwnedEnd = false; + + if(element instanceof Parameter){ //Do not show qualifiers for return parameters if(((Parameter)element).getDirection().getValue() == ParameterDirectionKind.RETURN) return null; @@ -265,11 +266,13 @@ String definedIn = ""; if(element instanceof Class){ - definedIn = element.getName()+" ("+element.getNearestPackage().getName()+")"; + definedIn = element.getName()/*+" ("+element.getNearestPackage().getName()+")"*/; + }else if(element instanceof Parameter){ + definedIn = ((NamedElement)element.getOwner().getOwner()).getName() + "::" + ((NamedElement)element.getOwner()).getName() + "::" + element.getName()/*+" ("+element.getNearestPackage().getName()+")"*/; }else{ Element owner = element.getOwner(); if(owner instanceof NamedElement) - definedIn = ((NamedElement)element.getOwner()).getName()+" ("+owner.getNearestPackage().getName()+")"; + definedIn = ((NamedElement)element.getOwner()).getName() + "::" +element.getName()/*+" ("+owner.getNearestPackage().getName()+")"*/; } //display all qualifiers witch are set in the Qualifiers-Stereotype @@ -434,7 +437,7 @@ Property prop = (Property)element; Property oppositeProp = null; - boolean isOwnedEnd = propertyIsOwnedEnd(prop); + isOwnedEnd = propertyIsOwnedEnd(prop); // get the property of the other association end if (isOwnedEnd /*&& prop.getOwner() instanceof AssociationClass*/){ @@ -558,21 +561,23 @@ } -// //TODO -// ValuesTableHelper tableHelper = new ValuesTableHelper(qualifiersTable); -// ArrayList inheritedQualifiers = tableHelper.getInheritedQualifers(element, allAvailableQualifers); -// for(int k = 0; k < inheritedQualifiers.size(); k++){ -// qualifierName = ((QualifierValueObject)inheritedQualifiers.get(k)).name; -// String qualifierValue = ((QualifierValueObject)inheritedQualifiers.get(k)).value; -// definedIn = ((QualifierValueObject)inheritedQualifiers.get(k)).definedIn; -// Qualifier qualifierObject = qualifiersList.GetElement(qualifierName); -// addQualiferToTable(qualifierName, qualifierValue, definedIn, qualifierObject, -1, false); -// allAvailableQualifers.remove(qualifierObject); -// } + //TODO Inherited qualifiers + // Get all inherited qualifiers which aren't already defined in this element + + ValuesTableHelper tableHelper = new ValuesTableHelper(qualifiersTable); + ArrayList inheritedQualifiers = tableHelper.getInheritedQualifers(element, allAvailableQualifers, isOwnedEnd); + for(int k = 0; k < inheritedQualifiers.size(); k++){ + qualifierName = ((QualifierValueObject)inheritedQualifiers.get(k)).name; + String qualifierValue = ((QualifierValueObject)inheritedQualifiers.get(k)).value; + definedIn = ((QualifierValueObject)inheritedQualifiers.get(k)).definedIn; + Qualifier qualifierObject = qualifiersList.GetElement(qualifierName); + addQualiferToTable(qualifierName, qualifierValue, definedIn, qualifierObject, -1, false); + allAvailableQualifers.remove(qualifierObject); + } //dispaly all qualifiers with default values if(showAllButton.getSelection()){ - definedIn = ""; + definedIn = null; for(Iterator iterator1 = allAvailableQualifers.iterator(); iterator1.hasNext();) { Qualifier qualifier = (Qualifier)iterator1.next(); @@ -786,7 +791,7 @@ String type = ""; if(definedIn==null) - definedIn = ""; + definedIn = "Default value"; //String scope = ""; String inheritance = ""; |