Bug 513548: [Import Rpy] Papyrus Interoperability Common should provide a blackbox to sort UML NamedElement
Change-Id: Ie2e76cb8f835c10d0fa654ed7496992ee18076aa
Signed-off-by: Vincent Lorenzo <vincent.lorenzo@cea.fr>
diff --git a/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/META-INF/MANIFEST.MF b/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/META-INF/MANIFEST.MF
index 0264254..d5c2eb9 100644
--- a/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/META-INF/MANIFEST.MF
+++ b/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/META-INF/MANIFEST.MF
@@ -11,8 +11,8 @@
org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)";resolution:=optional;x-installation:=greedy,
org.eclipse.emf.ecore;bundle-version="[2.13.0,3.0.0)";visibility:=reexport,
org.eclipse.papyrus.infra.core.log;bundle-version="[1.2.0,2.0.0)",
- org.eclipse.papyrus.m2m.qvto;bundle-version="[1.4.0,2.0.0)",
- org.eclipse.m2m.qvt.oml;bundle-version="[3.7.0,4.0.0)"
+ org.eclipse.m2m.qvt.oml;bundle-version="[3.7.0,4.0.0)",
+ org.eclipse.uml2.uml;bundle-version="[5.2.0,6.0.0)"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.papyrus.interoperability.common.blackboxes,
diff --git a/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/plugin.xml b/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/plugin.xml
index c86d61a..f3d0d1d 100644
--- a/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/plugin.xml
+++ b/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/plugin.xml
@@ -30,5 +30,17 @@
</metamodel>
</library>
</unit>
+ <unit
+ description="This Blackbox provides useful uml methods"
+ name="UMLHelper"
+ namespace="org.eclipse.papyrus.interoperability.common.blackboxes.uml">
+ <library
+ class="org.eclipse.papyrus.interoperability.common.blackboxes.uml.UMLHelper"
+ name="UMLHelper">
+ <metamodel
+ nsURI="http://www.eclipse.org/uml2/5.0.0/UML">
+ </metamodel>
+ </library>
+ </unit>
</extension>
</plugin>
diff --git a/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/src/org/eclipse/papyrus/interoperability/common/blackboxes/uml/UMLHelper.java b/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/src/org/eclipse/papyrus/interoperability/common/blackboxes/uml/UMLHelper.java
new file mode 100755
index 0000000..576d2e9
--- /dev/null
+++ b/common/plugins/org.eclipse.papyrus.interoperability.common.blackboxes/src/org/eclipse/papyrus/interoperability/common/blackboxes/uml/UMLHelper.java
@@ -0,0 +1,74 @@
+/*****************************************************************************
+ * Copyright (c) 2017 CEA LIST and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Vincent LORENZO (CEA LIST) vincent.lorenzo@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+
+package org.eclipse.papyrus.interoperability.common.blackboxes.uml;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.m2m.qvt.oml.blackbox.java.Operation;
+import org.eclipse.m2m.qvt.oml.blackbox.java.Operation.Kind;
+import org.eclipse.uml2.uml.NamedElement;
+
+/**
+ *
+ * This class provides useful method for UML
+ *
+ */
+public class UMLHelper {
+
+ /**
+ *
+ * @param listToSort
+ * the list to sort
+ * @return
+ * the sorted list
+ */
+ @Operation(kind = Kind.HELPER)
+ public List<NamedElement> sortNamedElement(final List<NamedElement> listToSort) {
+ final List<NamedElement> sortedList = new ArrayList<NamedElement>(listToSort);
+ Collections.sort(sortedList, new NamedElementComparator());
+ return sortedList;
+ }
+
+ /**
+ *
+ * NamedElement comparator
+ *
+ */
+ private class NamedElementComparator implements Comparator<NamedElement> {
+
+ /**
+ * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
+ *
+ * @param o1
+ * @param o2
+ * @return
+ */
+ @Override
+ public int compare(NamedElement o1, NamedElement o2) {
+ String name1 = o1.getName();
+ if (null == name1) {
+ name1 = ""; //$NON-NLS-1$
+ }
+ String name2 = o2.getName();
+ if (null == name2) {
+ name2 = ""; //$NON-NLS-1$
+ }
+ return name1.compareToIgnoreCase(name2);
+ }
+ }
+
+}
diff --git a/common/plugins/org.eclipse.papyrus.interoperability.common/.settings/org.eclipse.pde.api.tools.prefs b/common/plugins/org.eclipse.papyrus.interoperability.common/.settings/org.eclipse.pde.api.tools.prefs
new file mode 100755
index 0000000..23fb95e
--- /dev/null
+++ b/common/plugins/org.eclipse.papyrus.interoperability.common/.settings/org.eclipse.pde.api.tools.prefs
@@ -0,0 +1,98 @@
+ANNOTATION_ELEMENT_TYPE_ADDED_METHOD_WITHOUT_DEFAULT_VALUE=Error
+ANNOTATION_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
+ANNOTATION_ELEMENT_TYPE_REMOVED_FIELD=Error
+ANNOTATION_ELEMENT_TYPE_REMOVED_METHOD=Error
+ANNOTATION_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
+API_COMPONENT_ELEMENT_TYPE_REMOVED_API_TYPE=Error
+API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_API_TYPE=Error
+API_COMPONENT_ELEMENT_TYPE_REMOVED_REEXPORTED_TYPE=Error
+API_COMPONENT_ELEMENT_TYPE_REMOVED_TYPE=Error
+API_USE_SCAN_FIELD_SEVERITY=Error
+API_USE_SCAN_METHOD_SEVERITY=Error
+API_USE_SCAN_TYPE_SEVERITY=Error
+CLASS_ELEMENT_TYPE_ADDED_METHOD=Error
+CLASS_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error
+CLASS_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
+CLASS_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error
+CLASS_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
+CLASS_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error
+CLASS_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error
+CLASS_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
+CLASS_ELEMENT_TYPE_REMOVED_CONSTRUCTOR=Error
+CLASS_ELEMENT_TYPE_REMOVED_FIELD=Error
+CLASS_ELEMENT_TYPE_REMOVED_METHOD=Error
+CLASS_ELEMENT_TYPE_REMOVED_SUPERCLASS=Error
+CLASS_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
+CLASS_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+CONSTRUCTOR_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
+CONSTRUCTOR_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
+CONSTRUCTOR_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error
+CONSTRUCTOR_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+ENUM_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error
+ENUM_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
+ENUM_ELEMENT_TYPE_REMOVED_ENUM_CONSTANT=Error
+ENUM_ELEMENT_TYPE_REMOVED_FIELD=Error
+ENUM_ELEMENT_TYPE_REMOVED_METHOD=Error
+ENUM_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
+FIELD_ELEMENT_TYPE_ADDED_VALUE=Error
+FIELD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
+FIELD_ELEMENT_TYPE_CHANGED_FINAL_TO_NON_FINAL_STATIC_CONSTANT=Error
+FIELD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error
+FIELD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error
+FIELD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error
+FIELD_ELEMENT_TYPE_CHANGED_TYPE=Error
+FIELD_ELEMENT_TYPE_CHANGED_VALUE=Error
+FIELD_ELEMENT_TYPE_REMOVED_TYPE_ARGUMENT=Error
+FIELD_ELEMENT_TYPE_REMOVED_VALUE=Error
+ILLEGAL_EXTEND=Warning
+ILLEGAL_IMPLEMENT=Warning
+ILLEGAL_INSTANTIATE=Warning
+ILLEGAL_OVERRIDE=Warning
+ILLEGAL_REFERENCE=Warning
+INTERFACE_ELEMENT_TYPE_ADDED_FIELD=Ignore
+INTERFACE_ELEMENT_TYPE_ADDED_METHOD=Error
+INTERFACE_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error
+INTERFACE_ELEMENT_TYPE_ADDED_SUPER_INTERFACE_WITH_METHODS=Error
+INTERFACE_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
+INTERFACE_ELEMENT_TYPE_CHANGED_CONTRACTED_SUPERINTERFACES_SET=Error
+INTERFACE_ELEMENT_TYPE_CHANGED_TYPE_CONVERSION=Error
+INTERFACE_ELEMENT_TYPE_REMOVED_FIELD=Error
+INTERFACE_ELEMENT_TYPE_REMOVED_METHOD=Error
+INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_MEMBER=Error
+INTERFACE_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+INVALID_ANNOTATION=Ignore
+INVALID_JAVADOC_TAG=Ignore
+INVALID_REFERENCE_IN_SYSTEM_LIBRARIES=Ignore
+LEAK_EXTEND=Warning
+LEAK_FIELD_DECL=Warning
+LEAK_IMPLEMENT=Warning
+LEAK_METHOD_PARAM=Warning
+LEAK_METHOD_RETURN_TYPE=Warning
+METHOD_ELEMENT_TYPE_ADDED_RESTRICTIONS=Error
+METHOD_ELEMENT_TYPE_ADDED_TYPE_PARAMETER=Error
+METHOD_ELEMENT_TYPE_CHANGED_DECREASE_ACCESS=Error
+METHOD_ELEMENT_TYPE_CHANGED_NON_ABSTRACT_TO_ABSTRACT=Error
+METHOD_ELEMENT_TYPE_CHANGED_NON_FINAL_TO_FINAL=Error
+METHOD_ELEMENT_TYPE_CHANGED_NON_STATIC_TO_STATIC=Error
+METHOD_ELEMENT_TYPE_CHANGED_STATIC_TO_NON_STATIC=Error
+METHOD_ELEMENT_TYPE_CHANGED_VARARGS_TO_ARRAY=Error
+METHOD_ELEMENT_TYPE_REMOVED_ANNOTATION_DEFAULT_VALUE=Error
+METHOD_ELEMENT_TYPE_REMOVED_TYPE_PARAMETER=Error
+MISSING_EE_DESCRIPTIONS=Error
+TYPE_PARAMETER_ELEMENT_TYPE_ADDED_CLASS_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_ADDED_INTERFACE_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_CLASS_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_CHANGED_INTERFACE_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_CLASS_BOUND=Error
+TYPE_PARAMETER_ELEMENT_TYPE_REMOVED_INTERFACE_BOUND=Error
+UNUSED_PROBLEM_FILTERS=Warning
+automatically_removed_unused_problem_filters=Enabled
+eclipse.preferences.version=1
+incompatible_api_component_version=Error
+incompatible_api_component_version_include_major_without_breaking_change=Disabled
+incompatible_api_component_version_include_minor_without_api_change=Disabled
+invalid_since_tag_version=Error
+malformed_since_tag=Error
+missing_since_tag=Warning
+report_api_breakage_when_major_version_incremented=Disabled
+report_resolution_errors_api_component=Warning