[581401] Sort Combo input in Object Creation Page
The Combo box used in EEFExtEObjectCreationPage to choose the type of
the object to create is sorted alphabetically.
Bug: 581401
Change-Id: I971d182e2635703362ccbad69ae00f0ac1a363ff
Signed-off-by: Glenn Plouhinec <glenn.plouhinec@obeo.fr>
diff --git a/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/EEFExtEObjectCreationPage.java b/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/EEFExtEObjectCreationPage.java
index 080fffd..f2833c1 100644
--- a/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/EEFExtEObjectCreationPage.java
+++ b/plugins/org.eclipse.eef.ide.ui.ext.widgets.reference/src/org/eclipse/eef/ide/ui/ext/widgets/reference/internal/EEFExtEObjectCreationPage.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016, 2022 Obeo.
+ * Copyright (c) 2016, 2023 Obeo.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v2.0
* which accompanies this distribution, and is available at
@@ -14,6 +14,7 @@
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Comparator;
import java.util.List;
import org.eclipse.core.runtime.IProgressMonitor;
@@ -179,7 +180,7 @@
* The containment EReference to consider
*/
protected void initializeContainmentInput(EObject eObject, EReference eContainementReference) {
- List<Object> values = new ArrayList<>();
+ List<EObject> values = new ArrayList<>();
Adapter adapter = this.composedAdapterFactory.adapt(eObject, IEditingDomainItemProvider.class);
if (adapter instanceof IEditingDomainItemProvider) {
IEditingDomainItemProvider itemProviderAdapter = (IEditingDomainItemProvider) adapter;
@@ -191,12 +192,12 @@
Object value = commandParameter.getValue();
if (commandParameter.getEReference().equals(eContainementReference) && value instanceof EObject
&& this.eReference.getEReferenceType().isSuperTypeOf(((EObject) value).eClass())) {
- values.add(commandParameter.getValue());
+ values.add((EObject) value);
}
}
}
}
-
+ values.sort(Comparator.comparing(eObj -> eObj.eClass().getName()));
this.eClassInstanceComboViewer.setInput(values);
if (values.size() > 0) {
this.eClassInstanceComboViewer.setSelection(new StructuredSelection(values.get(0)));