Update of /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/rsa/core/internal/properties In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16123/Plugin/com/ibm/ecute/rsa/core/internal/properties Modified Files: QualifiersPropertySection.java Added Files: ValuesTableHelper.java QualifierValueObject.java QualifierDefinitionObject.java Log Message: Version 2.1 beta 1d: Various changes in the edit qualifiers dialog (BB) --- NEW FILE: QualifierDefinitionObject.java --- /* * Created on 15.06.2005 * */ package com.ibm.ecute.rsa.core.internal.properties; /** * @author Benjamin Bender * */ public class QualifierDefinitionObject { public String name; public String type; public String defaultValue; public boolean classScope; public boolean associationScope; public boolean indicationScope; public boolean propertyScope; public boolean methodScope; public boolean parameterScope; public boolean referenceScope; public String inheritanceBehaviour; public boolean translatableFlavor; public QualifierDefinitionObject(){ this.name = null; this.type = null; this.defaultValue = null; this.classScope = false; this.associationScope = false; this.indicationScope = false; this.propertyScope = false; this.methodScope = false; this.parameterScope = false; this.referenceScope = false; this.inheritanceBehaviour = null; this.translatableFlavor = false; } public QualifierDefinitionObject(String name, String type, String defaultValue, boolean classScope, boolean associationScope, boolean indicationScope, boolean propertyScope, boolean methodScope, boolean parameterScope, boolean referenceScope, String inheritanceBehaviour, boolean translatableFlavor){ this.name = name; this.type = type; this.defaultValue = defaultValue; this.classScope = classScope; this.associationScope = associationScope; this.indicationScope = indicationScope; this.propertyScope = propertyScope; this.methodScope = methodScope; this.parameterScope = parameterScope; this.referenceScope = referenceScope; this.inheritanceBehaviour = inheritanceBehaviour; this.translatableFlavor = translatableFlavor; } public boolean equals(QualifierDefinitionObject object){ if( this.name.equalsIgnoreCase(object.name) && this.type.equalsIgnoreCase(object.type) && this.defaultValue.equalsIgnoreCase(object.defaultValue) && this.classScope == object.classScope && this.associationScope == object.associationScope && this.indicationScope == object.indicationScope && this.propertyScope == object.propertyScope && this.methodScope == object.methodScope && this.parameterScope == object.parameterScope && this.referenceScope == object.referenceScope && this.inheritanceBehaviour.equalsIgnoreCase(object.inheritanceBehaviour) && this.translatableFlavor == object.translatableFlavor) { return true; } else { return false; } } public boolean scopeChanged(QualifierDefinitionObject object){ if( this.classScope == false && object.classScope == true || this.associationScope == false && object.associationScope == true || this.indicationScope == false && object.indicationScope == true || this.propertyScope == false && object.propertyScope == true || this.methodScope == false && object.methodScope == true || this.parameterScope == false && object.parameterScope == true || this.referenceScope == false && object.referenceScope) { return true; } else { return false; } } public int type2int() { final int BOOLEAN=0; final int STRING=1; final int UNINT8=2; final int SINT8=3; final int UNINT16=4; final int SINT16=5; final int UNINT32=6; final int SINT32=7; final int UNINT64=8; final int SINT64=9; if(type.equalsIgnoreCase("Boolean")) return BOOLEAN; if(type.equalsIgnoreCase("String")) return STRING; if(type.equalsIgnoreCase("uint8")) return UNINT8; if(type.equalsIgnoreCase("sint8")) return SINT8; if(type.equalsIgnoreCase("uint16")) return UNINT16; if(type.equalsIgnoreCase("sint16")) return SINT16; if(type.equalsIgnoreCase("uint32")) return UNINT32; if(type.equalsIgnoreCase("sint32")) return SINT32; if(type.equalsIgnoreCase("uint64")) return UNINT64; if(type.equalsIgnoreCase("sint64")) return SINT64; return -1; } } --- NEW FILE: QualifierValueObject.java --- /* * Created on 15.06.2005 * */ package com.ibm.ecute.rsa.core.internal.properties; /** * @author Benjamin Bender * */ public class QualifierValueObject { public String name; public String value; public String datatype; public String definedIn; public String inheritance; public String translatable; public String defaultValue; public int index; public QualifierValueObject(String name, String value, String definedIn, int index){ this.name = name; this.value = value; this.definedIn = definedIn; this.index = index; } public QualifierValueObject(String name, String value, String datatype, String definedIn, String inheritance, String translatable, String defaultValue, int index){ this.name = name; this.value = value; this.datatype = datatype; this.definedIn = definedIn; this.inheritance = inheritance; this.translatable = translatable; this.defaultValue = defaultValue; this.index = index; } public boolean equals(QualifierValueObject object){ if( this.name.equalsIgnoreCase(object.name) && this.value.equalsIgnoreCase(object.value) && this.datatype.equalsIgnoreCase(object.datatype) && this.definedIn.equalsIgnoreCase(object.definedIn) && this.inheritance.equalsIgnoreCase(object.inheritance) && this.translatable.equalsIgnoreCase(object.translatable) && this.defaultValue.equalsIgnoreCase(object.defaultValue) && this.index == object.index ) { return true; } else { return false; } } public boolean isDirectMapped(){ if( this.name.equalsIgnoreCase("Association")|| this.name.equalsIgnoreCase("Aggregation")|| this.name.equalsIgnoreCase("Composition")|| this.name.equalsIgnoreCase("Aggregate")|| this.name.equalsIgnoreCase("In")|| this.name.equalsIgnoreCase("Out")|| this.name.equalsIgnoreCase("Inout")|| this.name.equalsIgnoreCase("Min")|| this.name.equalsIgnoreCase("Max")|| this.name.equalsIgnoreCase("Octetstring")|| this.name.equalsIgnoreCase("Static")|| this.name.equalsIgnoreCase("Write")|| this.name.equalsIgnoreCase("Description")|| this.name.equalsIgnoreCase("Abstract")|| this.name.equalsIgnoreCase("Deprecated")|| this.name.equalsIgnoreCase("Key")|| this.name.equalsIgnoreCase("ArrayType")|| this.name.equalsIgnoreCase("OCL") ){ return true; } else { return false; } } } --- NEW FILE: ValuesTableHelper.java --- /* * Created on 07.06.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 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; import org.eclipse.uml2.Operation; 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; /** * @author Benjamin Bender * * TODO To change the template for this generated type comment go to * Window - Preferences - Java - Code Style - Code Templates */ public class ValuesTableHelper { Table table; public ValuesTableHelper(Table table){ 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){ //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 && qualifier.propertyScope && !qualifier.RestrictedFlavor){ applicableQualifiers.add(qualifier); } else if(element instanceof Property && 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 && 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; } } } } } return inheritedList; } 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 String existsOCL(Class class_ ){ String value = null; Package thisPackage = class_.getNearestPackage(); EList ownedMembersList = thisPackage.getOwnedMembers(); for(int i = 0; i < ownedMembersList.size(); i++){ if(ownedMembersList.get(i) instanceof Constraint){ Constraint thisConstraint = (Constraint)ownedMembersList.get(i); EList constrainedElements = thisConstraint.getConstrainedElements(); for(int j = 0; j < constrainedElements.size(); j++){ if(constrainedElements.get(j) instanceof Class){ Class thisClass = (Class)constrainedElements.get(j); if(thisClass.equals(class_)){ value = "{"+((OpaqueExpression)thisConstraint.getSpecification()).getBody()+"}"; i = ownedMembersList.size(); break; } } } } } // return the cantent of the constraint return value; } // public class QualifierValueObject{ // private String name; // private String value; // private String datatype; // private String definedIn; // private String inheritance; // private String translatable; // private String defaultValue; // private int index; // // public QualifierValueObject(String name, String value, String definedIn, int index){ // this.name = name; // this.value = value; // this.definedIn = definedIn; // this.index = index; // } // // public QualifierValueObject(String name, String value, String datatype, String definedIn, // String inheritance, String translatable, String defaultValue, int index){ // this.name = name; // this.value = value; // this.datatype = datatype; // this.definedIn = definedIn; // this.inheritance = inheritance; // this.translatable = translatable; // this.defaultValue = defaultValue; // this.index = index; // } // // public boolean equals(QualifierValueObject object){ // // if( // this.name.equalsIgnoreCase(object.name) && // this.value.equalsIgnoreCase(object.value) && // this.datatype.equalsIgnoreCase(object.datatype) && // this.definedIn.equalsIgnoreCase(object.definedIn) && // this.inheritance.equalsIgnoreCase(object.inheritance) && // this.translatable.equalsIgnoreCase(object.translatable) && // this.defaultValue.equalsIgnoreCase(object.defaultValue) && // this.index == object.index // ) // { // return true; // } else { // return false; // } // } // // public boolean isDirectMapped(){ // // if( this.name.equalsIgnoreCase("Association")|| // this.name.equalsIgnoreCase("Aggregation")|| // this.name.equalsIgnoreCase("Composition")|| // this.name.equalsIgnoreCase("Aggregate")|| // this.name.equalsIgnoreCase("In")|| // this.name.equalsIgnoreCase("Out")|| // this.name.equalsIgnoreCase("Inout")|| // this.name.equalsIgnoreCase("Min")|| // this.name.equalsIgnoreCase("Max")|| // this.name.equalsIgnoreCase("Octetstring")|| // this.name.equalsIgnoreCase("Static")|| // this.name.equalsIgnoreCase("Write")|| // this.name.equalsIgnoreCase("Description")|| // this.name.equalsIgnoreCase("Abstract")|| // this.name.equalsIgnoreCase("Deprecated")|| // this.name.equalsIgnoreCase("Key")|| // this.name.equalsIgnoreCase("ArrayType")|| // this.name.equalsIgnoreCase("OCL") // ){ // return true; // } else { // return false; // } // } // } } Index: QualifiersPropertySection.java =================================================================== RCS file: /cvsroot/sblim/ecute/Plugin/com/ibm/ecute/rsa/core/internal/properties/QualifiersPropertySection.java,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- QualifiersPropertySection.java 6 Jun 2005 14:17:44 -0000 1.17 +++ QualifiersPropertySection.java 15 Jun 2005 09:41:47 -0000 1.18 @@ -7,9 +7,11 @@ import java.io.FileInputStream; import java.io.IOException; import java.lang.reflect.InvocationTargetException; +import java.text.Collator; import java.util.ArrayList; import java.util.Iterator; import java.util.List; +import java.util.Locale; import java.util.Vector; import org.eclipse.core.runtime.IProgressMonitor; @@ -26,6 +28,8 @@ import org.eclipse.swt.layout.FormData; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Listener; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; @@ -95,6 +99,8 @@ private static QualifiersList qualifiersList = null; private boolean qualifiersListChanged = false; + + ArrayList allAvailableQualifers = null; public QualifiersPropertySection() @@ -146,16 +152,46 @@ qualifiersTable.setLinesVisible(true); nameColumn = new TableColumn(qualifiersTable, 0); nameColumn.setText("Name"); + nameColumn.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + sortValuesTableBy(0); + } + }); valueColumn = new TableColumn(qualifiersTable, 0); valueColumn.setText("Value"); + valueColumn.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + sortValuesTableBy(1); + } + }); typeColumn = new TableColumn(qualifiersTable, 0); typeColumn.setText("Type"); + typeColumn.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + sortValuesTableBy(2); + } + }); definedInColumn = new TableColumn(qualifiersTable, 0); definedInColumn.setText("Defined in"); + definedInColumn.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + sortValuesTableBy(3); + } + }); inheritanceColumn = new TableColumn(qualifiersTable, 0); inheritanceColumn.setText("Inheritance Behavior"); + inheritanceColumn.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + sortValuesTableBy(4); + } + }); translatableColumn = new TableColumn(qualifiersTable, SWT.CENTER); translatableColumn.setText("Translatable"); + translatableColumn.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event e) { + sortValuesTableBy(5); + } + }); qualifiersTable.addMouseListener(new MouseAdapter() { public void mouseDoubleClick(MouseEvent e){ @@ -207,66 +243,6 @@ return null; } - // tried to change the OCL qualifier of a class automatically - // when a class constraint body is changed --> failed -/* - if(element instanceof Class){ - List elementList = ((Class)element).getPackage().getOwnedElements(); - ArrayList constraintList = new ArrayList(); - for (int i = 0; i < elementList.size(); i++){ - if (elementList.get(i) instanceof Constraint) - constraintList.add(elementList.get(i)); - } - if (constraintList != null){ - for(int j = 0; j < constraintList.size(); j++){ - Constraint constraint = (Constraint)constraintList.get(j); - List constrainedElements = constraint.getConstrainedElements(); - for(int k = 0; k < constrainedElements.size(); k++){ - if(constrainedElements.get(k) instanceof Class){ - if(((Class)constrainedElements.get(k)).getName().equalsIgnoreCase(((Class)element).getName())){ - String body = ((OpaqueExpression)constraint.getSpecification()).getBody(); - int index = body.indexOf("\n"); - String qualifierValue = "{\""; - if (index != -1){ - qualifierValue = qualifierValue.concat(body.substring(0, index)); - } else { - qualifierValue = qualifierValue.concat(body.substring(0)); - } - qualifierValue = qualifierValue.concat("\""); - body = body.substring(index +1); - index = body.indexOf("\n"); - while (index != -1){ - qualifierValue = qualifierValue.concat(",\""); - qualifierValue = qualifierValue.concat(body.substring(0, index)); - qualifierValue = qualifierValue.concat("\""); - body = body.substring(index +1); - index = body.indexOf("\n"); - if(index == -1){ - qualifierValue = qualifierValue.concat(",\""); - qualifierValue = qualifierValue.concat(body.substring(0)); - qualifierValue = qualifierValue.concat("\""); - } - } - qualifierValue = qualifierValue.concat("}"); - System.out.println("OCL qualifier: " + qualifierValue); - Class thisClass = (Class)constrainedElements.get(k); - - Stereotype cimStereotype = thisClass.getAppliedStereotype("CIM::Qualifiers"); - List qualifierNameList = (List) thisClass.getValue(cimStereotype, "QualifierName"); - int stereotypeOCLIndex = -1; - for(int i = 0; i < qualifierNameList.size(); i++){ - if(qualifierNameList.get(i).toString().equalsIgnoreCase("OCL")){ - stereotypeOCLIndex = i; - } - } - thisClass.setValue(cimStereotype, "QualifierValue["+stereotypeOCLIndex+"]", qualifierValue); - } - } - } - } - } - } -*/ if (qualifiersList == null || qualifiersListChanged == true){ try { qualifiersListChanged = false; @@ -281,10 +257,11 @@ } Vector vector = qualifiersList.GetElements(); //make a copy of the qualifiers list to remove the qualifiers already displayed - ArrayList allAvailableQualifers = new ArrayList(); + allAvailableQualifers = new ArrayList(); for(int i=0; i < vector.size(); i++){ allAvailableQualifers.add(vector.get(i)); } + allAvailableQualifers.trimToSize(); String definedIn = ""; if(element instanceof Class){ @@ -581,8 +558,17 @@ } - //TODO - ArrayList inheritedQualifiers = getInheritedQualifers(element); +// //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); +// } //dispaly all qualifiers with default values if(showAllButton.getSelection()){ @@ -652,6 +638,53 @@ refresh(); } + private void sortValuesTableBy(int columnNumber){ + + Collator collator = Collator.getInstance(Locale.getDefault()); + + boolean decreasing = false; + TableItem[] column = qualifiersTable.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 = qualifiersTable.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(qualifiersTable, SWT.NONE, j); + item.setText(values); + item.setData(data1); + items = qualifiersTable.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(qualifiersTable, SWT.NONE, j); + item.setText(values); + item.setData(data1); + items = qualifiersTable.getItems(); + break; + } + } + } + } + } + private boolean propertyIsOwnedEnd(Property prop){ boolean isOwnedEnd = false; @@ -776,7 +809,8 @@ String as[] = {name, qualifierValue, type, definedIn, inheritance, translatable}; tableitem.setText(as); - tableitem.setData(new QualifierValueObject(name, qualifierValue, defaultValue, index)); + tableitem.setData(new QualifierValueObject(name, qualifierValue, + type, definedIn, inheritance, translatable, defaultValue, index)); return i; } @@ -823,11 +857,146 @@ return true; } - private ArrayList getInheritedQualifers(NamedElement element){ - //TODO - ArrayList list = new ArrayList(); - return list; - } +// private ArrayList getInheritedQualifers(NamedElement element, ArrayList allAvailableQualifiers){ +// //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 && qualifier.propertyScope && !qualifier.RestrictedFlavor){ +// applicableQualifiers.add(qualifier); +// } else if(element instanceof Property && 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 && 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; +// } +// } +// } +// } +// } +// +// return inheritedList; +// } +// +// private 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; +// } private void packColumns() { @@ -1257,19 +1426,4 @@ } } } - - private class QualifierValueObject{ - private String name; - private String value; - private String defaultValue; - private int index; - - public QualifierValueObject(String name, String value, String defaultValue, int index){ - this.name = name; - this.value = value; - this.defaultValue = defaultValue; - this.index = index; - } - } - } |