Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurent Redor2016-04-01 16:15:42 +0000
committerLaurent Redor2016-04-07 09:51:10 +0000
commitdaf401adef38db2873e3f0abb87eff1528f955ec (patch)
tree54d077a489b830cc2485f9b095a305802282b58f
parent4ff45cc279585d1bedd5fd6cfbca74212dfa6001 (diff)
downloadorg.eclipse.sirius-daf401adef38db2873e3f0abb87eff1528f955ec.tar.gz
org.eclipse.sirius-daf401adef38db2873e3f0abb87eff1528f955ec.tar.xz
org.eclipse.sirius-daf401adef38db2873e3f0abb87eff1528f955ec.zip
[481573] Fix pb on some contributions that are not correctly refreshed
They are not correctly refreshed during the tabbar.notify*() calls. This problem is revealed with new tests in LockedTabBarTest that use the custom tabbar. Bug: 481573 Change-Id: If8f3036be8929fcb6c55d656a3ba189a3c71ee59 Signed-off-by: Laurent Redor <laurent.redor@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/editor/tabbar/AbstractTabbarContributor.java10
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/LockedTabBarTest.java104
2 files changed, 103 insertions, 11 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/editor/tabbar/AbstractTabbarContributor.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/editor/tabbar/AbstractTabbarContributor.java
index 9d42f3d03d..1a9d75d1fb 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/editor/tabbar/AbstractTabbarContributor.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/api/editor/tabbar/AbstractTabbarContributor.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2015 Obeo.
+ * Copyright (c) 2015, 2016 Obeo.
* 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
@@ -64,8 +64,8 @@ import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.ui.IWorkbenchPartSite;
/**
- * Abstract implementation of {@link ITabbarContributor}. Inherit from this class
- * allows creating one or several contribution items of the default Sirius
+ * Abstract implementation of {@link ITabbarContributor}. Inherit from this
+ * class allows creating one or several contribution items of the default Sirius
* tabbar.
*
* @author Florian Barbin
@@ -160,7 +160,7 @@ public abstract class AbstractTabbarContributor implements ITabbarContributor {
IWorkbenchPartSite site = part.getSite();
if (site != null) {
SelectHiddenElementsAction selectHiddenElementsAction = new SelectHiddenElementsAction(site.getPage(), part);
- return new ActionContributionItem(selectHiddenElementsAction);
+ return new DiagramActionContributionItem(selectHiddenElementsAction);
}
return null;
}
@@ -239,7 +239,7 @@ public abstract class AbstractTabbarContributor implements ITabbarContributor {
if (site != null) {
SelectPinnedElementsAction pinnedElementsAction = new SelectPinnedElementsAction(site.getPage(), part);
- return new ActionContributionItem(pinnedElementsAction);
+ return new DiagramActionContributionItem(pinnedElementsAction);
}
return null;
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/LockedTabBarTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/LockedTabBarTest.java
index 12f6246307..6e414a7063 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/LockedTabBarTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/LockedTabBarTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2015 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2010, 2016 THALES GLOBAL SERVICES and others.
* 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
@@ -10,12 +10,20 @@
*******************************************************************************/
package org.eclipse.sirius.tests.swtbot.tabbar;
+import java.io.ByteArrayInputStream;
import java.util.Collection;
import java.util.Collections;
+import org.eclipse.core.internal.registry.ExtensionRegistry;
+import org.eclipse.core.runtime.ContributorFactoryOSGi;
+import org.eclipse.core.runtime.IContributor;
+import org.eclipse.core.runtime.IExtension;
+import org.eclipse.core.runtime.IExtensionRegistry;
+import org.eclipse.core.runtime.Platform;
import org.eclipse.sirius.diagram.DDiagram;
import org.eclipse.sirius.diagram.ui.edit.api.part.AbstractDiagramContainerEditPart;
import org.eclipse.sirius.diagram.ui.edit.api.part.IDDiagramEditPart;
+import org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar.ExtensionPointTabbarContributorProvider;
import org.eclipse.sirius.ecore.extender.business.api.accessor.ExtenderConstants;
import org.eclipse.sirius.ecore.extender.business.api.permission.IPermissionProvider;
import org.eclipse.sirius.ecore.extender.business.api.permission.PermissionAuthorityRegistry;
@@ -100,6 +108,10 @@ public class LockedTabBarTest extends AbstractSiriusSwtBotGefTestCase {
private PermissionProviderDescriptor permissionProviderDescriptor;
+ private static final String PLUGIN_XML = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><?eclipse version=\"3.4\"?><plugin><extension id=\"customTabbar\" point=\""
+ + ExtensionPointTabbarContributorProvider.EXTENSION_ID
+ + "\"><tabbarContributor class=\"org.eclipse.sirius.tests.swtbot.tabbar.TabbarContributorSample\"></tabbarContributor></extension></plugin>";
+
@Override
protected void onSetUpBeforeClosingWelcomePage() throws Exception {
copyFileToTestProject(Activator.PLUGIN_ID, DATA_UNIT_DIR, MODEL, SESSION_FILE, VSM_FILE);
@@ -111,9 +123,6 @@ public class LockedTabBarTest extends AbstractSiriusSwtBotGefTestCase {
sessionAirdResource = new UIResource(designerProject, FILE_DIR, SESSION_FILE);
localSession = designerPerspective.openSessionFromFile(sessionAirdResource);
-
- // Open the editor
- editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), "Entities", "aaaa package entities", DDiagram.class);
}
/**
@@ -121,6 +130,56 @@ public class LockedTabBarTest extends AbstractSiriusSwtBotGefTestCase {
* permission authority
*/
public void testTabbarActionsEnablement() {
+ testTabbarActionsEnablement(false);
+ }
+
+ /**
+ * Check that tabbar actions are enabled or disabled depending on the
+ * permission authority
+ */
+ public void testTabbarActionsEnablementWithCustomTabbar() {
+ testTabbarActionsEnablement(true);
+ }
+
+ /**
+ * Check that tabbar actions are enabled or disabled for the diagram
+ * depending on the permission authority
+ */
+ public void testTabbarActionsEnablementForDiagram() {
+ testTabbarActionsEnablementForDiagram(false);
+ }
+
+ /**
+ * Check that tabbar actions are enabled or disabled for the diagram
+ * depending on the permission authority
+ */
+ public void testTabbarActionsEnablementForDiagramWithCustomTabbar() {
+ testTabbarActionsEnablementForDiagram(true);
+ }
+
+ /**
+ * Check that tabbar actions are enabled or disabled for a selection
+ * depending on the permission authority
+ */
+ public void testTabbarActionsEnablementForSelection() {
+ testTabbarActionsEnablementForSelection(false);
+ }
+
+ /**
+ * Check that tabbar actions are enabled or disabled for a selection
+ * depending on the permission authority
+ */
+ public void testTabbarActionsEnablementForSelectionWithCustomTabbar() {
+ testTabbarActionsEnablementForSelection(true);
+ }
+
+ private void testTabbarActionsEnablement(boolean customTabbar) {
+ if (customTabbar) {
+ registerExtension();
+ }
+ // Open the editor
+ editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), "Entities", "aaaa package entities", DDiagram.class);
+
// check that tested buttons are enabled for the diagram
selectDiagram();
checkEnabled(true);
@@ -145,7 +204,14 @@ public class LockedTabBarTest extends AbstractSiriusSwtBotGefTestCase {
* Check that tabbar actions are enabled or disabled for the diagram
* depending on the permission authority
*/
- public void testTabbarActionsEnablementForDiagram() {
+ private void testTabbarActionsEnablementForDiagram(boolean customTabbar) {
+ if (customTabbar) {
+ registerExtension();
+ }
+
+ // Open the editor
+ editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), "Entities", "aaaa package entities", DDiagram.class);
+
selectDiagram();
// check that tested buttons are enabled for the diagram
@@ -162,7 +228,13 @@ public class LockedTabBarTest extends AbstractSiriusSwtBotGefTestCase {
* Check that tabbar actions are enabled or disabled for a selection
* depending on the permission authority
*/
- public void testTabbarActionsEnablementForSelection() {
+ private void testTabbarActionsEnablementForSelection(boolean customTabbar) {
+ if (customTabbar) {
+ registerExtension();
+ }
+ // Open the editor
+ editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), "Entities", "aaaa package entities", DDiagram.class);
+
selectPackageElement();
// check that tested buttons are enabled for the selected package
@@ -287,6 +359,7 @@ public class LockedTabBarTest extends AbstractSiriusSwtBotGefTestCase {
@Override
protected void tearDown() throws Exception {
PermissionService.removeExtension(permissionProviderDescriptor);
+ removeExtension();
permissionProviderDescriptor = null;
editor = null;
localSession = null;
@@ -326,4 +399,23 @@ public class LockedTabBarTest extends AbstractSiriusSwtBotGefTestCase {
}
}
+ /**
+ * Installs dynamically the tabbar extension.
+ */
+ private void registerExtension() {
+ IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+ IContributor contributor = ContributorFactoryOSGi.createContributor(Activator.getDefault().getBundle());
+ extensionRegistry.addContribution(new ByteArrayInputStream(PLUGIN_XML.getBytes()), contributor, false, null, null, ((ExtensionRegistry) extensionRegistry).getTemporaryUserToken());
+ }
+
+ /**
+ * Remove the installed extension (if it exists).
+ */
+ private void removeExtension() {
+ IExtensionRegistry extensionRegistry = Platform.getExtensionRegistry();
+ IExtension extension = extensionRegistry.getExtension(ExtensionPointTabbarContributorProvider.EXTENSION_ID, Activator.PLUGIN_ID + ".customTabbar");
+ if (extension != null) {
+ extensionRegistry.removeExtension(extension, ((ExtensionRegistry) extensionRegistry).getTemporaryUserToken());
+ }
+ }
}

Back to the top