Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2011-09-15 12:03:27 +0000
committercletavernie2011-09-15 12:03:27 +0000
commitaf20991c96459d65d9a7d7c030395bcce7a057d5 (patch)
tree403fb2df846fd1078caf85b825fcccff6f13cdc9
parent523407954873f7c757fff5bd416354b57d061084 (diff)
downloadorg.eclipse.papyrus-af20991c96459d65d9a7d7c030395bcce7a057d5.tar.gz
org.eclipse.papyrus-af20991c96459d65d9a7d7c030395bcce7a057d5.tar.xz
org.eclipse.papyrus-af20991c96459d65d9a7d7c030395bcce7a057d5.zip
Sandbox commit :
- Sort "new child" elements by name - Change the action names
-rw-r--r--sandbox/org.eclipse.papyrus.newchild/src/org/eclipse/papyrus/newchild/action/CreateChildAction.java7
-rw-r--r--sandbox/org.eclipse.papyrus.newchild/src/org/eclipse/papyrus/newchild/menu/FillNewChild.java46
2 files changed, 47 insertions, 6 deletions
diff --git a/sandbox/org.eclipse.papyrus.newchild/src/org/eclipse/papyrus/newchild/action/CreateChildAction.java b/sandbox/org.eclipse.papyrus.newchild/src/org/eclipse/papyrus/newchild/action/CreateChildAction.java
index aa5d0870b03..2dc2f1ccd6e 100644
--- a/sandbox/org.eclipse.papyrus.newchild/src/org/eclipse/papyrus/newchild/action/CreateChildAction.java
+++ b/sandbox/org.eclipse.papyrus.newchild/src/org/eclipse/papyrus/newchild/action/CreateChildAction.java
@@ -52,7 +52,7 @@ public class CreateChildAction extends StaticSelectionCommandAction {
Command createInFeature = CreateChildCommand.create(domain, parent, creationParameter, collection);
- super.setText(createInFeature.getLabel());
+ // super.setText(createInFeature.getLabel());
super.setDescription(createInFeature.getDescription());
if(createInFeature instanceof CommandActionDelegate) {
@@ -65,4 +65,9 @@ public class CreateChildAction extends StaticSelectionCommandAction {
return createInFeature;
}
+
+ @Override
+ public String getText() {
+ return createAs.getName();
+ }
}
diff --git a/sandbox/org.eclipse.papyrus.newchild/src/org/eclipse/papyrus/newchild/menu/FillNewChild.java b/sandbox/org.eclipse.papyrus.newchild/src/org/eclipse/papyrus/newchild/menu/FillNewChild.java
index 38553681be1..5d06d16296a 100644
--- a/sandbox/org.eclipse.papyrus.newchild/src/org/eclipse/papyrus/newchild/menu/FillNewChild.java
+++ b/sandbox/org.eclipse.papyrus.newchild/src/org/eclipse/papyrus/newchild/menu/FillNewChild.java
@@ -12,7 +12,11 @@
package org.eclipse.papyrus.newchild.menu;
import java.io.IOException;
-import java.util.HashMap;
+import java.text.Collator;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.LinkedHashMap;
+import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -65,7 +69,7 @@ public class FillNewChild extends FillMenu implements FillElement {
//TODO : Extract that to a static instance, and load with extension point
policyManager = new PolicyManager();
try {
- NewchildConfiguration configuration = (NewchildConfiguration)EMFHelper.loadEMFModel(null, URI.createPlatformResourceURI("org.eclipse.papyrus.newchild/Model/NewchildConfiguration.xmi", true));
+ NewchildConfiguration configuration = (NewchildConfiguration)EMFHelper.loadEMFModel(null, URI.createPlatformPluginURI("org.eclipse.papyrus.newchild/Model/NewchildConfiguration.xmi", true));
policyManager.addConfiguration(configuration);
} catch (IOException ex) {
Activator.log.error(ex);
@@ -94,12 +98,44 @@ public class FillNewChild extends FillMenu implements FillElement {
IMenuManager createChildMenu = getSubMenu(menuManager);
- Map<EStructuralFeature, List<EClass>> instantiableClasses = new HashMap<EStructuralFeature, List<EClass>>();
+ Map<EStructuralFeature, List<EClass>> instantiableClasses = new LinkedHashMap<EStructuralFeature, List<EClass>>();
- for(EStructuralFeature feature : parentEObject.eClass().getEAllStructuralFeatures()) {
+ List<EStructuralFeature> features = new LinkedList<EStructuralFeature>(parentEObject.eClass().getEAllStructuralFeatures());
+ Collections.sort(features, new Comparator<EStructuralFeature>() {
+
+ public int compare(EStructuralFeature feature1, EStructuralFeature feature2) {
+ if(feature1 == null) {
+ if(feature2 == null) {
+ return 0;
+ }
+ return -1;
+ }
+
+ return Collator.getInstance().compare(feature1.getName(), feature2.getName());
+ }
+
+ });
+
+ for(EStructuralFeature feature : features) {
if(feature instanceof EReference && ((EReference)feature).isContainment()) {
EClass type = (EClass)feature.getEType();
- instantiableClasses.put(feature, EMFHelper.getSubclassesOf(type, true));
+ List<EClass> eClasses = EMFHelper.getSubclassesOf(type, true);
+ Collections.sort(eClasses, new Comparator<EClass>() {
+
+ public int compare(EClass class1, EClass class2) {
+ if(class1 == null) {
+ if(class2 == null) {
+ return 0;
+ }
+ return -1;
+ }
+
+ return Collator.getInstance().compare(class1.getName(), class2.getName());
+ }
+
+ });
+
+ instantiableClasses.put(feature, eClasses);
}
}

Back to the top