Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Spungin2014-06-15 00:12:58 -0400
committerSteven Spungin2014-06-16 12:06:39 -0400
commite4f2eee5774edc96faa678085dfe6fdfc5699f24 (patch)
tree080db2e53aacf39734e184429fea4ee2bf7a247b
parentb1f10c10ec1346f08f32cb33efdbe106a526d5d1 (diff)
downloadorg.eclipse.e4.tools-e4f2eee5774edc96faa678085dfe6fdfc5699f24.tar.gz
org.eclipse.e4.tools-e4f2eee5774edc96faa678085dfe6fdfc5699f24.tar.xz
org.eclipse.e4.tools-e4f2eee5774edc96faa678085dfe6fdfc5699f24.zip
Bug 437469 - [model editor] add autocomplete combo box to
FindParentReferenceElementDialog Change-Id: If300beb121a667d9b91292c0babb48170aae11d0 Signed-off-by: Steven Spungin <steven@spungin.tv>
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/FindParentReferenceElementDialog.java29
1 files changed, 26 insertions, 3 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/FindParentReferenceElementDialog.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/FindParentReferenceElementDialog.java
index 89ca837b..76c83b91 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/FindParentReferenceElementDialog.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/FindParentReferenceElementDialog.java
@@ -7,10 +7,12 @@
*
* Contributors:
* Tom Schindl <tom.schindl@bestsolution.at> - initial API and implementation
+ * Steven Spungin <steven@spungin.tv> - Bug 437469
******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common.component.dialogs;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.List;
import org.eclipse.core.databinding.observable.list.IObservableList;
import org.eclipse.core.databinding.observable.list.WritableList;
@@ -31,6 +33,8 @@ import org.eclipse.emf.ecore.resource.Resource;
import org.eclipse.emf.edit.command.SetCommand;
import org.eclipse.jface.databinding.viewers.ObservableListContentProvider;
import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.jface.fieldassist.AutoCompleteField;
+import org.eclipse.jface.fieldassist.ComboContentAdapter;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.DoubleClickEvent;
@@ -39,6 +43,7 @@ import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.StyledCellLabelProvider;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.TableViewer;
@@ -56,6 +61,7 @@ import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
@@ -75,6 +81,7 @@ public class FindParentReferenceElementDialog extends TitleAreaDialog {
private WritableList list;
private ComboViewer eClassViewer;
private Text searchText;
+ private AutoCompleteField acText;
public FindParentReferenceElementDialog(Shell parentShell, AbstractComponentEditor editor, MStringModelFragment fragment, Messages Messages) {
super(parentShell);
@@ -113,7 +120,8 @@ public class FindParentReferenceElementDialog extends TitleAreaDialog {
Label l = new Label(container, SWT.NONE);
l.setText(Messages.FindParentReferenceElementDialog_ContainerType);
- eClassViewer = new ComboViewer(container);
+ Combo combo = new Combo(container, SWT.NONE);
+ eClassViewer = new ComboViewer(combo);
eClassViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
@@ -121,7 +129,7 @@ public class FindParentReferenceElementDialog extends TitleAreaDialog {
}
});
eClassViewer.setContentProvider(new ArrayContentProvider());
- List<EClass> eClassList = new ArrayList<EClass>();
+ final List<EClass> eClassList = new ArrayList<EClass>();
for (InternalPackage p : Util.loadPackages()) {
eClassList.addAll(p.getAllClasses());
}
@@ -141,10 +149,25 @@ public class FindParentReferenceElementDialog extends TitleAreaDialog {
@Override
public void selectionChanged(SelectionChangedEvent event) {
updateSearch();
-
}
});
+ ArrayList<String> vals = new ArrayList<String>();
+ for (EClass item : eClassList) {
+ vals.add(item.getName());
+ }
+ final String[] values = vals.toArray(new String[0]);
+ ComboContentAdapter textContentAdapter = new ComboContentAdapter() {
+ @Override
+ public void setControlContents(Control control, String text1, int cursorPosition) {
+ super.setControlContents(control, text1, cursorPosition);
+ int index = Arrays.asList(values).indexOf(text1);
+ EClass eClass = eClassList.get(index);
+ eClassViewer.setSelection(new StructuredSelection(eClass));
+ }
+ };
+ acText = new AutoCompleteField(combo, textContentAdapter, values);
+
l = new Label(container, SWT.NONE);
l.setText(Messages.FindParentReferenceElementDialog_Search);

Back to the top