Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpguilet2017-09-29 15:43:05 +0000
committerMaxime Porhel2017-10-02 08:20:35 +0000
commit30f16fa6d0a6eea6a05a63e826ebb2ddfa2d2887 (patch)
tree26947d78b5b9cf8b49c871c823151871e90172fa
parentb651feff0401000ecaba5254238250e548f7e21d (diff)
downloadorg.eclipse.sirius-30f16fa6d0a6eea6a05a63e826ebb2ddfa2d2887.tar.gz
org.eclipse.sirius-30f16fa6d0a6eea6a05a63e826ebb2ddfa2d2887.tar.xz
org.eclipse.sirius-30f16fa6d0a6eea6a05a63e826ebb2ddfa2d2887.zip
[522478] fix item mixing with another
Fix model explorer view DRepresentation descriptor items replaced by RepresentationItemImpl when diagram is opened. Selected item when link to editor is activated and a diagram is opened will now always be the representation item under the semantic owner item. Change-Id: Icd3111b7bd11c02a2ccfffd0558baa79ab2a7a63 Signed-off-by: pguilet <pierre.guilet@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/modelexplorer/LinkWithEditorFeatureWithModelExplorerViewTest.java40
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/modelexplorer/ModelExplorerItemComparer.java71
-rw-r--r--plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/modelexplorer/ModelExplorerView.java1
3 files changed, 17 insertions, 95 deletions
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/modelexplorer/LinkWithEditorFeatureWithModelExplorerViewTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/modelexplorer/LinkWithEditorFeatureWithModelExplorerViewTest.java
index 39d5b1c87c..e103a1f041 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/modelexplorer/LinkWithEditorFeatureWithModelExplorerViewTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/modelexplorer/LinkWithEditorFeatureWithModelExplorerViewTest.java
@@ -19,7 +19,6 @@ import org.eclipse.sirius.tests.swtbot.support.api.AbstractSiriusSwtBotGefTestCa
import org.eclipse.sirius.tests.swtbot.support.api.business.UIResource;
import org.eclipse.sirius.tests.swtbot.support.api.editor.SWTBotSiriusDiagramEditor;
import org.eclipse.sirius.tests.swtbot.support.utils.SWTBotUtils;
-import org.eclipse.sirius.tests.unit.diagram.modeler.ecore.EcoreModeler;
import org.eclipse.sirius.tree.DTree;
import org.eclipse.sirius.ui.tools.api.views.modelexplorerview.IModelExplorerView;
import org.eclipse.sirius.ui.tools.internal.views.modelexplorer.ModelExplorerView;
@@ -32,8 +31,7 @@ import org.eclipse.swtbot.swt.finder.widgets.SWTBotTree;
import org.eclipse.swtbot.swt.finder.widgets.SWTBotTreeItem;
/**
- * Test that the "link with editor" feature works correctly in model explorer
- * view.
+ * Test that the "link with editor" feature works correctly in model explorer view.
*
* @author <a href="mailto:belqassim.djafer@obeo.fr">Belqassim Djafer</a>
*/
@@ -84,16 +82,16 @@ public class LinkWithEditorFeatureWithModelExplorerViewTest extends AbstractSiri
}
/**
- * Ensure that the "link with editor" feature works correctly in model
- * explorer view by checking if the opened element is the selected one in
- * model explorer view.
+ * Ensure that the "link with editor" feature works correctly in model explorer view by checking if the
+ * representation item corresponding to the opened diagram and selected in the model explorer view is the one in the
+ * under semantic item owner.
*/
public void testLinkWithEditorFeatureWithModelExplorerView() {
SWTBotTreeItem projectTreeItemBot = modelExplorerViewBot.tree().expandNode(getProjectName(), true);
SWTBotTreeItem representationsResourceTreeItemBot = projectTreeItemBot.getNode(REPRESENTATIONS_RESOURCE_NAME);
- SWTBotTreeItem viewpointTreeItemBot = representationsResourceTreeItemBot.getNode(0).getNode(EcoreModeler.DESIGN_VIEWPOINT_NAME);
- SWTBotTreeItem representationDescriptionTreeItemBot = viewpointTreeItemBot.getNode(0);
- SWTBotTreeItem representationTreeItemBot = representationDescriptionTreeItemBot.getNode(0);
+ SWTBotTreeItem semanticTreeItemBot = representationsResourceTreeItemBot.getNode(1);
+ SWTBotTreeItem rootTreeItemBot = semanticTreeItemBot.getNode("root");
+ SWTBotTreeItem representationTreeItemBot = rootTreeItemBot.getNode(0);
SWTBotView modelExplorerView = bot.viewById(IModelExplorerView.ID);
boolean linkWithEditorInitialStatus = modelExplorerView.toolbarToggleButton("Link with Editor").isChecked();
try {
@@ -112,8 +110,8 @@ public class LinkWithEditorFeatureWithModelExplorerViewTest extends AbstractSiri
}
/**
- * Tests that when selecting an element which are not in the representation,
- * this element is still selected. Deactivated because of unreliable.
+ * Tests that when selecting an element which are not in the representation, this element is still selected.
+ * Deactivated because of unreliable.
*/
public void _testLinkWithEditorWithElementsNotInTheRepresentation() {
final SWTBotView modelExplorerView = bot.viewById(IModelExplorerView.ID);
@@ -143,9 +141,8 @@ public class LinkWithEditorFeatureWithModelExplorerViewTest extends AbstractSiri
}
/**
- * Tests that the link with editor (editor toward model explorer) works
- * properly when selecting a diagram element. Deactivated because of
- * unreliable.
+ * Tests that the link with editor (editor toward model explorer) works properly when selecting a diagram element.
+ * Deactivated because of unreliable.
*/
public void _testLinkWithEditorWithDiagramElementSelection() {
final SWTBotView modelExplorerView = bot.viewById(IModelExplorerView.ID);
@@ -194,9 +191,8 @@ public class LinkWithEditorFeatureWithModelExplorerViewTest extends AbstractSiri
}
/**
- * Tests that the link with editor (editor toward model explorer) is not
- * activated when the action is not checked. Deactivated because of
- * unreliable.
+ * Tests that the link with editor (editor toward model explorer) is not activated when the action is not checked.
+ * Deactivated because of unreliable.
*/
public void _testLinkWithEditorDeactivate() {
final SWTBotView modelExplorerView = bot.viewById(IModelExplorerView.ID);
@@ -220,9 +216,8 @@ public class LinkWithEditorFeatureWithModelExplorerViewTest extends AbstractSiri
}
/**
- * Tests that the link with editor (editor toward model explorer) works
- * properly when selecting a table element. Deactivated because of
- * unreliable.
+ * Tests that the link with editor (editor toward model explorer) works properly when selecting a table element.
+ * Deactivated because of unreliable.
*/
public void _testLinkWithEditorWithTableElementSelection() {
final SWTBotView modelExplorerView = bot.viewById(IModelExplorerView.ID);
@@ -270,9 +265,8 @@ public class LinkWithEditorFeatureWithModelExplorerViewTest extends AbstractSiri
}
/**
- * Tests that the link with editor (editor toward model explorer) works
- * properly when selecting a tree element. Deactivated because of
- * unreliable.
+ * Tests that the link with editor (editor toward model explorer) works properly when selecting a tree element.
+ * Deactivated because of unreliable.
*/
public void _testLinkWithEditorWithTreeElementSelection() {
final SWTBotView modelExplorerView = bot.viewById(IModelExplorerView.ID);
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/modelexplorer/ModelExplorerItemComparer.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/modelexplorer/ModelExplorerItemComparer.java
deleted file mode 100644
index 8faf06302a..0000000000
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/modelexplorer/ModelExplorerItemComparer.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013, 2017 THALES GLOBAL SERVICES.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.sirius.ui.tools.internal.views.modelexplorer;
-
-import org.eclipse.jface.viewers.IElementComparer;
-import org.eclipse.sirius.ui.tools.api.views.common.item.ItemWrapper;
-import org.eclipse.sirius.ui.tools.internal.views.common.item.RepresentationItemImpl;
-import org.eclipse.sirius.viewpoint.DRepresentationDescriptor;
-
-/**
- * A {@link IElementComparer} to have {@link ItemWrapper} considered equals to {@link ItemWrapper#getWrappedObject()}.
- * This comparer is created to allow link to editor functionality to select {@link RepresentationItemImpl} corresponding
- * to opened {@link DRepresentationDescriptor} of an opened diagram.
- *
- * @author <a href="mailto:esteban.dugueperoux@obeo.fr">Esteban Dugueperoux</a>
- */
-public class ModelExplorerItemComparer implements IElementComparer {
-
- /**
- * {@inheritDoc}
- */
- @Override
- public boolean equals(Object a, Object b) {
- boolean equals = false;
- // We compare wrapped object of RepresentationItemImpl only when other object is a DRepresentationDescriptor. In
- // every other cases we use standard equality. It allows to link with editor RepresentationItemImpl in
- // ModelExplorerView with DRepresentationDescriptor of the opened diagram.
- if ((a instanceof DRepresentationDescriptor && b instanceof RepresentationItemImpl) || (b instanceof DRepresentationDescriptor && a instanceof RepresentationItemImpl)) {
- Object realAObject = a;
- if (realAObject instanceof ItemWrapper) {
- ItemWrapper itemWrapper = (ItemWrapper) realAObject;
- realAObject = itemWrapper.getWrappedObject();
- }
- Object realBObject = b;
- if (realBObject instanceof ItemWrapper) {
- ItemWrapper itemWrapper = (ItemWrapper) realBObject;
- realBObject = itemWrapper.getWrappedObject();
- }
- equals = realAObject != null && realAObject.equals(realBObject);
- } else {
- equals = a.equals(b);
- }
- return equals;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public int hashCode(Object element) {
- int hashCode = 0;
- Object realElementObject = element;
- if (realElementObject instanceof ItemWrapper) {
- ItemWrapper itemWrapper = (ItemWrapper) realElementObject;
- realElementObject = itemWrapper.getWrappedObject();
- }
- if (realElementObject != null) {
- hashCode = realElementObject.hashCode();
- }
- return hashCode;
- }
-
-}
diff --git a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/modelexplorer/ModelExplorerView.java b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/modelexplorer/ModelExplorerView.java
index 4d9c229b2c..a5a98eb029 100644
--- a/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/modelexplorer/ModelExplorerView.java
+++ b/plugins/org.eclipse.sirius.ui/src/org/eclipse/sirius/ui/tools/internal/views/modelexplorer/ModelExplorerView.java
@@ -143,7 +143,6 @@ public class ModelExplorerView extends CommonNavigator implements IModelExplorer
createTabs(tabDescriptors);
}
- getCommonViewer().setComparer(new ModelExplorerItemComparer());
}
/**

Back to the top