Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteven Spungin2014-04-02 19:25:59 -0400
committerSteven Spungin2014-04-02 19:28:45 -0400
commita9ea0b0a4112a67df6e4af992b0cd774ad783886 (patch)
tree76a403f967d869aa4cbeef058237391b46d0ba34
parent7937d36a333066d77b95ed30bcf737784c129f76 (diff)
downloadorg.eclipse.e4.tools-a9ea0b0a4112a67df6e4af992b0cd774ad783886.tar.gz
org.eclipse.e4.tools-a9ea0b0a4112a67df6e4af992b0cd774ad783886.tar.xz
org.eclipse.e4.tools-a9ea0b0a4112a67df6e4af992b0cd774ad783886.zip
Bug 431847 - duplicate top level items created in tree when editing xmiI20140403-2200
Change-Id: I504de19c6070dcd576a9b233b4b04b749baad548 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/TreeViewerEx.java13
1 files changed, 9 insertions, 4 deletions
diff --git a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/TreeViewerEx.java b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/TreeViewerEx.java
index d3011212..e05c4acd 100644
--- a/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/TreeViewerEx.java
+++ b/bundles/org.eclipse.e4.tools.emf.ui/src/org/eclipse/e4/tools/emf/ui/internal/common/TreeViewerEx.java
@@ -6,7 +6,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 396902
+ * Steven Spungin <steven@spungin.tv> - initial API and implementation, Bug 396902, Bug 431847
******************************************************************************/
package org.eclipse.e4.tools.emf.ui.internal.common;
@@ -48,12 +48,13 @@ public class TreeViewerEx extends TreeViewer {
E4XMIResource xmiResource = (E4XMIResource) ((EObject) modelProvider.getRoot().get(0)).eResource();
ArrayList<Object> newElements = new ArrayList<Object>();
ObservableListTreeContentProvider provider = (ObservableListTreeContentProvider) getContentProvider();
+ Object[] children = new Object[] { modelProvider.getRoot().get(0) };
for (String id : elementsIds) {
EObject eObject = xmiResource.getEObject(id);
if (eObject != null) {
newElements.add(eObject);
// force tree node creation
- getFirstMatchingItem(eObject, provider, provider.getChildren(getInput()));
+ getFirstMatchingItem(eObject, provider, children);
}
}
ArrayList<Object> newSelected = new ArrayList<Object>();
@@ -62,14 +63,14 @@ public class TreeViewerEx extends TreeViewer {
if (eObject != null) {
newSelected.add(eObject);
// force tree node creation
- getFirstMatchingItem(eObject, provider, provider.getChildren(getInput()));
+ getFirstMatchingItem(eObject, provider, children);
}
}
setExpandedElements(newElements.toArray(new Object[0]));
setSelection(new StructuredSelection(newSelected));
// update our stored id values
- documentAboutToBeChanged(event);
+ reloadIds(modelProvider);
} catch (Exception e) {
e.printStackTrace();
}
@@ -78,6 +79,10 @@ public class TreeViewerEx extends TreeViewer {
@Override
public void documentAboutToBeChanged(DocumentEvent event) {
+ reloadIds(modelProvider);
+ }
+
+ private void reloadIds(final IModelResource modelProvider) {
try {
// Stash XmiIds
Object[] elements = getExpandedElements();

Back to the top