summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJonas Helming2012-11-21 16:57:04 (EST)
committerSopot Cela2012-11-21 16:57:04 (EST)
commitc215c5bbc44faf2aa396a4240b04041d1346f058 (patch)
treeee43d7dc2856b2598442bacefda13930247698ba
parent07b968586e771cb5c9a2a61183a44aea848f1391 (diff)
downloadorg.eclipse.e4.tools-c215c5bbc44faf2aa396a4240b04041d1346f058.zip
org.eclipse.e4.tools-c215c5bbc44faf2aa396a4240b04041d1346f058.tar.gz
org.eclipse.e4.tools-c215c5bbc44faf2aa396a4240b04041d1346f058.tar.bz2
Bug 394347 - Dialog to select parent element for a fragment does not
update correctly
-rw-r--r--bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/TargetElementProviders.java1
-rw-r--r--bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/component/dialogs/FindParentReferenceElementDialog.java44
2 files changed, 31 insertions, 14 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/TargetElementProviders.java b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/TargetElementProviders.java
index 62a37da..66645ee 100644
--- a/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/TargetElementProviders.java
+++ b/bundles/org.eclipse.e4.tools.emf.editor3x/src/org/eclipse/e4/tools/emf/editor3x/TargetElementProviders.java
@@ -118,6 +118,7 @@ public class TargetElementProviders implements IModelElementProvider {
}
public void clearCache() {
+ if (resourceSet==null) return;
for (Resource r : resourceSet.getResources()) {
r.unload();
}
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 9c0df83..04eabeb 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
@@ -35,8 +35,10 @@ import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.jface.viewers.DoubleClickEvent;
import org.eclipse.jface.viewers.IDoubleClickListener;
+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.StyledCellLabelProvider;
import org.eclipse.jface.viewers.StyledString;
import org.eclipse.jface.viewers.TableViewer;
@@ -69,6 +71,10 @@ public class FindParentReferenceElementDialog extends TitleAreaDialog {
private AbstractComponentEditor editor;
private TableViewer viewer;
private Messages Messages;
+ private ModelResultHandlerImpl currentResultHandler;
+ private WritableList list;
+ private ComboViewer eClassViewer;
+ private Text searchText;
public FindParentReferenceElementDialog(Shell parentShell, AbstractComponentEditor editor, MStringModelFragment fragment, Messages Messages) {
super(parentShell);
@@ -101,7 +107,7 @@ public class FindParentReferenceElementDialog extends TitleAreaDialog {
Label l = new Label(container, SWT.NONE);
l.setText(Messages.FindParentReferenceElementDialog_ContainerType);
- final ComboViewer eClassViewer = new ComboViewer(container);
+ eClassViewer = new ComboViewer(container);
eClassViewer.setLabelProvider(new LabelProvider() {
@Override
public String getText(Object element) {
@@ -124,11 +130,18 @@ public class FindParentReferenceElementDialog extends TitleAreaDialog {
eClassViewer.setInput(eClassList);
eClassViewer.getCombo().select(0);
eClassViewer.getControl().setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ eClassViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+
+ public void selectionChanged(SelectionChangedEvent event) {
+ updateSearch();
+
+ }
+ });
l = new Label(container, SWT.NONE);
l.setText(Messages.FindParentReferenceElementDialog_Search);
- final Text searchText = new Text(container, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH);
+ searchText = new Text(container, SWT.BORDER | SWT.SEARCH | SWT.ICON_SEARCH);
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
searchText.setLayoutData(gd);
@@ -166,24 +179,15 @@ public class FindParentReferenceElementDialog extends TitleAreaDialog {
}
});
- final WritableList list = new WritableList();
+ list = new WritableList();
viewer.setInput(list);
final ClassContributionCollector collector = getCollector();
searchText.addModifyListener(new ModifyListener() {
- private ModelResultHandlerImpl currentResultHandler;
public void modifyText(ModifyEvent e) {
- if (currentResultHandler != null) {
- currentResultHandler.cancled = true;
- }
- list.clear();
-
- Filter filter = new Filter((EClass) ((IStructuredSelection) eClassViewer.getSelection()).getFirstElement(), searchText.getText());
-
- currentResultHandler = new ModelResultHandlerImpl(list, filter, editor, ((EObject) fragment).eResource());
- collector.findModelElements(filter, currentResultHandler);
+ updateSearch();
}
});
@@ -196,10 +200,22 @@ public class FindParentReferenceElementDialog extends TitleAreaDialog {
collector.clearModelCache();
}
});
-
return comp;
}
+ protected void updateSearch() {
+ if (currentResultHandler != null) {
+ currentResultHandler.cancled = true;
+ }
+ list.clear();
+
+ Filter filter = new Filter((EClass) ((IStructuredSelection) eClassViewer.getSelection()).getFirstElement(), searchText.getText());
+
+ currentResultHandler = new ModelResultHandlerImpl(list, filter, editor, ((EObject) fragment).eResource());
+ getCollector().findModelElements(filter, currentResultHandler);
+
+ }
+
@Override
protected void okPressed() {
IStructuredSelection s = (IStructuredSelection) viewer.getSelection();