summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGabriel Pascual2014-07-01 09:14:49 (EDT)
committerRemi Schnekenburger2014-07-16 05:45:29 (EDT)
commit81fdf1aa7bf84a8cc4ddfbba0143535ce1cbf075 (patch)
tree1d11313d00796dd757a3f8d96a96f3a6fe83cea5
parenta6e4293cdabaf731647f73f4557d2d32045b48c4 (diff)
downloadorg.eclipse.papyrus-81fdf1aa7bf84a8cc4ddfbba0143535ce1cbf075.zip
org.eclipse.papyrus-81fdf1aa7bf84a8cc4ddfbba0143535ce1cbf075.tar.gz
org.eclipse.papyrus-81fdf1aa7bf84a8cc4ddfbba0143535ce1cbf075.tar.bz2
436926: [Profile Diagram] Profile Import Metaclass not sortedrefs/changes/55/29255/2
https://bugs.eclipse.org/bugs/show_bug.cgi?id=436926 - Add method to sort MetaClasses list Change-Id: Ie9478a40f66328780ac74cf334fb26bb454d9de3 Signed-off-by: Gabriel Pascual <gabriel.pascual@all4tec.net>
-rw-r--r--plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLMetaclassContentProvider.java154
1 files changed, 86 insertions, 68 deletions
diff --git a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLMetaclassContentProvider.java b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLMetaclassContentProvider.java
index d0a6163..7a1deda 100644
--- a/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLMetaclassContentProvider.java
+++ b/plugins/uml/tools/org.eclipse.papyrus.uml.tools/src/org/eclipse/papyrus/uml/tools/providers/UMLMetaclassContentProvider.java
@@ -1,68 +1,86 @@
-/*****************************************************************************
- * Copyright (c) 2013 CEA LIST.
- *
- *
- * 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.uml.tools.providers;
-
-import java.util.List;
-
-import org.eclipse.papyrus.infra.widgets.providers.AbstractFilteredContentProvider;
-import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
-import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
-import org.eclipse.uml2.uml.Class;
-import org.eclipse.uml2.uml.Element;
-
-/**
- * The metaclass content provider
- *
- * @author Vincent Lorenzo
- *
- */
-public class UMLMetaclassContentProvider extends AbstractFilteredContentProvider implements IStaticContentProvider {
-
- /**
- * the list of the avalaible metaclassse
- */
- final private List<Class> possibleMetaclasses;
-
- /**
- *
- * Constructor.
- *
- * @param element
- * the element used to find the available metaclasses
- */
- public UMLMetaclassContentProvider(final Element element) {
- this.possibleMetaclasses = ElementUtil.getPossibleMetaclasses(element);
- }
-
- /**
- *
- * @see org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider#getElements()
- *
- * @return
- */
- public Object[] getElements() {
- return this.possibleMetaclasses.toArray();
- }
-
- /**
- *
- * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
- *
- * @param inputElement
- * @return
- */
- public Object[] getElements(Object inputElement) {
- return getElements();
- }
-}
+/*****************************************************************************
+ * Copyright (c) 2013 CEA LIST.
+ *
+ *
+ * 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.uml.tools.providers;
+
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.papyrus.infra.widgets.providers.AbstractFilteredContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.papyrus.uml.tools.utils.ElementUtil;
+import org.eclipse.uml2.uml.Class;
+import org.eclipse.uml2.uml.Element;
+
+/**
+ * The metaclass content provider
+ *
+ * @author Vincent Lorenzo
+ *
+ */
+public class UMLMetaclassContentProvider extends AbstractFilteredContentProvider implements IStaticContentProvider {
+
+ /**
+ * the list of the avalaible metaclassse
+ */
+ final private List<Class> possibleMetaclasses;
+
+ /**
+ *
+ * Constructor.
+ *
+ * @param element
+ * the element used to find the available metaclasses
+ */
+ public UMLMetaclassContentProvider(final Element element) {
+ this.possibleMetaclasses = ElementUtil.getPossibleMetaclasses(element);
+ sortPossibleMetaClasses();
+ }
+
+ /**
+ * Handle MetaClasses list to sort it.
+ */
+ private void sortPossibleMetaClasses() {
+ Collections.sort(possibleMetaclasses, new Comparator<Class>() {
+
+ public int compare(Class firstClass, Class secondClass) {
+
+ // Use default lexicographically sorter of String based on Class name
+ return firstClass.getName().compareTo(secondClass.getName());
+
+ }
+ });
+ }
+
+ /**
+ *
+ * @see org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider#getElements()
+ *
+ * @return
+ */
+ public Object[] getElements() {
+ return this.possibleMetaclasses.toArray();
+ }
+
+ /**
+ *
+ * @see org.eclipse.jface.viewers.IStructuredContentProvider#getElements(java.lang.Object)
+ *
+ * @param inputElement
+ * @return
+ */
+ public Object[] getElements(Object inputElement) {
+ return getElements();
+ }
+}