Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpguilet2017-08-02 08:37:47 +0000
committerPierre Guilet2017-08-16 08:02:37 +0000
commit082555ec5a2f04d23f392cf367a55d8684f00445 (patch)
treee2cc92d860a5d144d3620be60c834dfc15ec1c57
parent72c73eb4eb50eee3acfb0cc9723da9d085f779f5 (diff)
downloadorg.eclipse.sirius-082555ec5a2f04d23f392cf367a55d8684f00445.tar.gz
org.eclipse.sirius-082555ec5a2f04d23f392cf367a55d8684f00445.tar.xz
org.eclipse.sirius-082555ec5a2f04d23f392cf367a55d8684f00445.zip
[520425] Make straighten to edge actions available in tabbar
Bug: 520425 Change-Id: I73cf3fc5a0a2a8c0227268a935f6e0962fff4ea3 Signed-off-by: pguilet <pierre.guilet@obeo.fr>
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarFillerWithContributions.java4
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/actions/StraightenToMenuManager.java5
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/actions/TabbarStraightenToMenuManager.java111
-rw-r--r--plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/contributions/TabbarContributionFactory.java162
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/TabBarTest.java33
-rw-r--r--plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/TabbarContributorExtensionTest.java13
6 files changed, 204 insertions, 124 deletions
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarFillerWithContributions.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarFillerWithContributions.java
index 950c8b7c63..21bc97f789 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarFillerWithContributions.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/TabbarFillerWithContributions.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2016 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2010, 2017 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
@@ -194,6 +194,7 @@ public class TabbarFillerWithContributions extends AbstractTabbarFiller {
}
private void addDiagramElementContributionItems() {
+ addContributionItem(diagramElementContributionItems, ARRANGE_SELECTION, contributionFactory.createStraightenContribution());
addContributionItem(diagramElementContributionItems, ARRANGE_SELECTION, contributionFactory.createDistributeContribution());
addContributionItem(diagramElementContributionItems, ARRANGE_SELECTION, contributionFactory.createAlignMenuManager());
addContributionItem(diagramElementContributionItems, ARRANGE_SELECTION, contributionFactory.createArrangeMenuManager(part));
@@ -226,6 +227,7 @@ public class TabbarFillerWithContributions extends AbstractTabbarFiller {
addContributionItem(diagramElementContributionItems, SIZE, contributionFactory.createAutoSizeContribution(part));
addContributionItem(diagramElementContributionItems, SIZE, contributionFactory.createSizeBothContribution(part));
+
}
@Override
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/actions/StraightenToMenuManager.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/actions/StraightenToMenuManager.java
index 5c3704cb60..5bcf529bd4 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/actions/StraightenToMenuManager.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/actions/StraightenToMenuManager.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2016, 2017 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
@@ -26,8 +26,7 @@ import org.eclipse.sirius.diagram.ui.tools.api.ui.actions.ActionIds;
public class StraightenToMenuManager extends ActionMenuManager {
/**
- * The straighten menu action containing the UI for the straighten menu
- * manager
+ * The straighten menu action containing the UI for the straighten menu manager
*/
private static class StraightenMenuAction extends Action {
StraightenMenuAction() {
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/actions/TabbarStraightenToMenuManager.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/actions/TabbarStraightenToMenuManager.java
new file mode 100644
index 0000000000..ca15235904
--- /dev/null
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/actions/TabbarStraightenToMenuManager.java
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Copyright (c) 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.diagram.ui.tools.internal.editor.tabbar.actions;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.eclipse.core.runtime.Status;
+import org.eclipse.gmf.runtime.common.ui.action.IDisposableAction;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.sirius.common.ui.tools.api.util.EclipseUIUtil;
+import org.eclipse.sirius.diagram.ui.provider.DiagramUIPlugin;
+import org.eclipse.sirius.diagram.ui.tools.api.ui.actions.ActionIds;
+import org.eclipse.sirius.diagram.ui.tools.internal.actions.straighten.StraightenToAction;
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * A distribute menu manager which handle cleanly {@link IDisposableAction} and set correctly handler for tabbar.
+ *
+ * @author <a href="mailto:pierre.guilet@obeo.fr">Pierre Guilet</a>
+ *
+ */
+public class TabbarStraightenToMenuManager extends DistributeMenuManager {
+
+ @Override
+ public void add(IAction action) {
+ super.add(action);
+ if (action instanceof IDisposableAction) {
+ ((IDisposableAction) action).init();
+ }
+ }
+
+ @Override
+ protected void itemRemoved(IContributionItem item) {
+ if (item instanceof ActionContributionItem) {
+ IAction action = ((ActionContributionItem) item).getAction();
+ if (action instanceof IDisposableAction) {
+ ((IDisposableAction) action).dispose();
+ }
+ }
+ super.itemRemoved(item);
+ }
+
+ @Override
+ public void dispose() {
+ removeAll();
+ super.dispose();
+ }
+
+ /**
+ * Set the default action id for this menu manager.
+ *
+ * @param actionId
+ * the action id to set
+ */
+ public void setDefaultAction(String actionId) {
+ for (final IContributionItem item : getItems()) {
+ if (item instanceof ActionContributionItem) {
+ if (actionId.equals(((ActionContributionItem) item).getAction().getId())) {
+ final IAction defaultAction = ((ActionContributionItem) item).getAction();
+ setHandler(defaultAction);
+ super.setDefaultAction(defaultAction);
+ return;
+ }
+ }
+ }
+ }
+
+ /**
+ * We should use reflection to access the default handler method
+ *
+ * @param defaultAction
+ * the default action to set
+ */
+ private void setHandler(final IAction defaultAction) {
+ Method method;
+ try {
+ method = MenuCreatorAction.class.getDeclaredMethod("setActionHandler", IAction.class); //$NON-NLS-1$
+ method.setAccessible(true);
+ method.invoke(super.action, defaultAction);
+ } catch (SecurityException | NoSuchMethodException | IllegalArgumentException | IllegalAccessException | InvocationTargetException e) {
+ DiagramUIPlugin.getPlugin().getLog().log(new Status(Status.ERROR, DiagramUIPlugin.ID, e.getMessage(), e));
+ }
+ }
+
+ @Override
+ public void setVisible(boolean visible) {
+ super.setVisible(visible);
+ if (isEmpty() && visible) {
+ IWorkbenchPage page = EclipseUIUtil.getActivePage();
+ if (page != null) {
+ add(StraightenToAction.createStraightenToLeftAction(page));
+ add(StraightenToAction.createStraightenToRightAction(page));
+ add(StraightenToAction.createStraightenToTopAction(page));
+ add(StraightenToAction.createStraightenToBottomAction(page));
+ setDefaultAction(ActionIds.STRAIGHTEN_TO_LEFT);
+ }
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/contributions/TabbarContributionFactory.java b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/contributions/TabbarContributionFactory.java
index 144a760dea..50889eff93 100644
--- a/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/contributions/TabbarContributionFactory.java
+++ b/plugins/org.eclipse.sirius.diagram.ui/src-diag/org/eclipse/sirius/diagram/ui/tools/internal/editor/tabbar/contributions/TabbarContributionFactory.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2016 Obeo.
+ * Copyright (c) 2016, 2017 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
@@ -55,6 +55,7 @@ import org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar.actions.Tabbar
import org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar.actions.TabbarPinElementsEclipseAction;
import org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar.actions.TabbarRouterMenuManager;
import org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar.actions.TabbarSelectMenuManager;
+import org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar.actions.TabbarStraightenToMenuManager;
import org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar.actions.TabbarUnpinElementsEclipseAction;
import org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar.actions.TabbarZoomAction;
import org.eclipse.sirius.diagram.ui.tools.internal.editor.tabbar.actions.TabbarZoomInAction;
@@ -76,9 +77,8 @@ public class TabbarContributionFactory {
private static final String HIDE_ELEMENT_ID = "org.eclipse.sirius.diagram.ui.tabbar.hideelement"; //$NON-NLS-1$
/**
- * Creates the Automatic Layout contribution item. Organized in a drop-down
- * menu, this item is used to trigger an automatic layout of the elements on
- * the diagram.
+ * Creates the Automatic Layout contribution item. Organized in a drop-down menu, this item is used to trigger an
+ * automatic layout of the elements on the diagram.
*
* @param part
* the current IDiagramWorkbenchPart.
@@ -91,9 +91,8 @@ public class TabbarContributionFactory {
}
/**
- * Creates the Select menu manager contribution item. Organized in a
- * drop-down menu, can be used to select groups of diagram elements in a
- * single operation.
+ * Creates the Select menu manager contribution item. Organized in a drop-down menu, can be used to select groups of
+ * diagram elements in a single operation.
*
* @return the {@link IContributionItem}.
*/
@@ -104,9 +103,8 @@ public class TabbarContributionFactory {
}
/**
- * Creates the Alignment contribution item. This menu contains several
- * operations which can be used to align several graphical elements in
- * various ways.
+ * Creates the Alignment contribution item. This menu contains several operations which can be used to align several
+ * graphical elements in various ways.
*
* @return the {@link IContributionItem}.
*/
@@ -190,8 +188,7 @@ public class TabbarContributionFactory {
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createSelectHiddenElementsContribution(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -203,8 +200,7 @@ public class TabbarContributionFactory {
}
/**
- * Creates the Hide Element contribution item. This button hides all the
- * selected elements from view.
+ * Creates the Hide Element contribution item. This button hides all the selected elements from view.
*
* @param part
* the current IDiagramWorkbenchPart.
@@ -219,8 +215,7 @@ public class TabbarContributionFactory {
}
/**
- * Creates the Hide Element Label contribution item. This button hides the
- * label of the selected elements.
+ * Creates the Hide Element Label contribution item. This button hides the label of the selected elements.
*
* @param part
* the current IDiagramWorkbenchPart.
@@ -232,9 +227,8 @@ public class TabbarContributionFactory {
}
/**
- * Creates the Delete From Diagram contribution item. This action removes
- * the selected graphical element from the diagram, but does not delete the
- * corresponding semantic elements.
+ * Creates the Delete From Diagram contribution item. This action removes the selected graphical element from the
+ * diagram, but does not delete the corresponding semantic elements.
*
* @param part
* the current IDiagramWorkbenchPart.
@@ -247,13 +241,12 @@ public class TabbarContributionFactory {
}
/**
- * Creates the Delete From Model contribution item. This action removes both
- * the selected graphical element and the corresponding semantic elements.
+ * Creates the Delete From Model contribution item. This action removes both the selected graphical element and the
+ * corresponding semantic elements.
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createDeleteFromModelContribution(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -270,8 +263,7 @@ public class TabbarContributionFactory {
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createSelectPinnedElementsContribution(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -284,8 +276,7 @@ public class TabbarContributionFactory {
}
/**
- * Creates the Pin element contribution item. Mark all the selected elements
- * as pinned.
+ * Creates the Pin element contribution item. Mark all the selected elements as pinned.
*
* @param part
* the current IDiagramWorkbenchPart.
@@ -297,8 +288,7 @@ public class TabbarContributionFactory {
}
/**
- * Creates the Unpin element contribution item. Mark all the selected
- * elements as un-pinned.
+ * Creates the Unpin element contribution item. Mark all the selected elements as un-pinned.
*
* @param part
* the current IDiagramWorkbenchPart.
@@ -324,8 +314,7 @@ public class TabbarContributionFactory {
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createZoomContribution(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -350,8 +339,7 @@ public class TabbarContributionFactory {
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createZoomInContribution(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -369,8 +357,7 @@ public class TabbarContributionFactory {
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createZoomOutContribution(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -388,8 +375,7 @@ public class TabbarContributionFactory {
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createFontColorContribution(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -406,8 +392,7 @@ public class TabbarContributionFactory {
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createBoldFontStyleContribution(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -423,8 +408,7 @@ public class TabbarContributionFactory {
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createItalicFontStyleContribution(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -440,8 +424,7 @@ public class TabbarContributionFactory {
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createFontDialogContribution(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -458,8 +441,7 @@ public class TabbarContributionFactory {
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createFillColorContribution(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -476,8 +458,7 @@ public class TabbarContributionFactory {
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createLineColorPropertyContribution(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -490,14 +471,12 @@ public class TabbarContributionFactory {
}
/**
- * Creates the Cancel Custom Style contribution item. The Cancel Custom
- * Style button resets all the style attributes of an element to its default
- * values and un-marks it as customized.
+ * Creates the Cancel Custom Style contribution item. The Cancel Custom Style button resets all the style attributes
+ * of an element to its default values and un-marks it as customized.
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createResetStylePropertyContribution(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -509,10 +488,8 @@ public class TabbarContributionFactory {
}
/**
- * Creates the set style to workspace image contribution item. The Workspace
- * image button can be used to replace the graphical representation of an
- * element by an image that you can select from anywhere in your Eclipse
- * workspace.
+ * Creates the set style to workspace image contribution item. The Workspace image button can be used to replace the
+ * graphical representation of an element by an image that you can select from anywhere in your Eclipse workspace.
*
* @param part
* the current IDiagramWorkbenchPart.
@@ -523,10 +500,8 @@ public class TabbarContributionFactory {
}
/**
- * Creates the Distribute menu contribution item. This menu contains several
- * actions which can be used to distribute the selected diagram elements
- * horizontally/vertically with a same space between their centers or their
- * bounds.
+ * Creates the Distribute menu contribution item. This menu contains several actions which can be used to distribute
+ * the selected diagram elements horizontally/vertically with a same space between their centers or their bounds.
*
* @return the {@link IContributionItem}.
*/
@@ -536,8 +511,8 @@ public class TabbarContributionFactory {
}
/**
- * Creates the Export As Image contribution item.This button can be used to
- * export the current diagram as an image file stored on disk.
+ * Creates the Export As Image contribution item.This button can be used to export the current diagram as an image
+ * file stored on disk.
*
* @return the {@link IContributionItem}.
*/
@@ -547,15 +522,13 @@ public class TabbarContributionFactory {
}
/**
- * Creates the Layout Mode contribution item. This button enables a special
- * "layout mode", in which some operations are prevented from having an
- * effect on the semantic model.
+ * Creates the Layout Mode contribution item. This button enables a special "layout mode", in which some operations
+ * are prevented from having an effect on the semantic model.
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized or if the diagram doesn't allow the layouting
- * mode.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized or if the diagram
+ * doesn't allow the layouting mode.
*/
public IContributionItem createLayoutingModeContributionItem(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -571,8 +544,8 @@ public class TabbarContributionFactory {
}
/**
- * Creates the Router contribution item. This action allows changing the
- * line style of edges (Rectilinear, Oblique, Tree)
+ * Creates the Router contribution item. This action allows changing the line style of edges (Rectilinear, Oblique,
+ * Tree)
*
* @return the {@link IContributionItem}.
*/
@@ -583,13 +556,12 @@ public class TabbarContributionFactory {
}
/**
- * Creates the Apply Style contribution item. Use this button to reproduce
- * the visual style of an element onto others.
+ * Creates the Apply Style contribution item. Use this button to reproduce the visual style of an element onto
+ * others.
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createCopyAppearancePropertiesContribution(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -601,14 +573,12 @@ public class TabbarContributionFactory {
}
/**
- * Creates the copy format contribution item. This tool can be used to
- * duplicate the format of some diagram elements from this diagram into
- * another.
+ * Creates the copy format contribution item. This tool can be used to duplicate the format of some diagram elements
+ * from this diagram into another.
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createCopyFormatContribution(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -624,8 +594,7 @@ public class TabbarContributionFactory {
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createPasteFormatContribution(IDiagramWorkbenchPart part) {
TabbarPasteFormatMenuManager pasteFormatMenu = new TabbarPasteFormatMenuManager();
@@ -634,9 +603,8 @@ public class TabbarContributionFactory {
}
/**
- * Creates the Refresh action contribution item. This operation, which can
- * also be invoked with the F5 keyboard shortcut, will force an update of
- * the diagram's content according to the latest version of the underlying
+ * Creates the Refresh action contribution item. This operation, which can also be invoked with the F5 keyboard
+ * shortcut, will force an update of the diagram's content according to the latest version of the underlying
* semantic model.
*
* @return the {@link IContributionItem}.
@@ -648,14 +616,12 @@ public class TabbarContributionFactory {
}
/**
- * Creates the Make Same Size contribution item. When multiple elements are
- * selected, clicking on this tool will resize all of them to have the same
- * size (both width and height).
+ * Creates the Make Same Size contribution item. When multiple elements are selected, clicking on this tool will
+ * resize all of them to have the same size (both width and height).
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createSizeBothContribution(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -668,13 +634,11 @@ public class TabbarContributionFactory {
}
/**
- * Creates the Auto-Size contribution item. This button marks the selected
- * elements as auto-sized.
+ * Creates the Auto-Size contribution item. This button marks the selected elements as auto-sized.
*
* @param part
* the current IDiagramWorkbenchPart.
- * @return the {@link IContributionItem} or null if the workbench part is
- * being initialized.
+ * @return the {@link IContributionItem} or null if the workbench part is being initialized.
*/
public IContributionItem createAutoSizeContribution(IDiagramWorkbenchPart part) {
IWorkbenchPartSite site = part.getSite();
@@ -685,4 +649,16 @@ public class TabbarContributionFactory {
return null;
}
+ /**
+ * Creates the straighten to contribution item. This menu contains several operations which can be used to
+ * straighten to different positions edges.
+ *
+ * @return the {@link IContributionItem}.
+ */
+ public IContributionItem createStraightenContribution() {
+ TabbarStraightenToMenuManager straightenToMenuManager = new TabbarStraightenToMenuManager();
+ straightenToMenuManager.setVisible(true);
+ return straightenToMenuManager;
+ }
+
}
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/TabBarTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/TabBarTest.java
index 1fbba74359..f019974db8 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/TabBarTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/TabBarTest.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2010, 2016 THALES GLOBAL SERVICES and others.
+ * Copyright (c) 2010, 2017 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
@@ -95,8 +95,8 @@ public class TabBarTest extends AbstractSiriusSwtBotGefTestCase {
private static final String[] DIAGRAM_TOOLBARTOGGLEBUTTONS_TOOLTIPS = { Messages.LayoutingModeSwitchingAction_activate };
- private static final String[] CONTAINER_TOOLBARDROPDOWNBUTTONS_TOOLTIPS = { "Arrange Selection", "Align Left", DistributeAction.getTooltip(DistributeAction.GAPS_HORIZONTALLY), "Font Color",
- "Fill &Color", "Li&ne Color", "Line Style" };
+ private static final String[] CONTAINER_TOOLBARDROPDOWNBUTTONS_TOOLTIPS = { "Arrange Selection", "Straighten to left", "Align Left",
+ DistributeAction.getTooltip(DistributeAction.GAPS_HORIZONTALLY), "Font Color", "Fill &Color", "Li&ne Color", "Line Style" };
private static final String[] CONTAINER_TOOLBARBUTTONS_TOOLTIPS = { Messages.PinElementsEclipseAction_text, Messages.UnpinElementsEclipseAction_text, Messages.CopyFormatAction_toolTipText,
Messages.SiriusDiagramActionBarContributor_hideElement, Messages.SiriusDiagramActionBarContributor_hideLabel, Messages.SiriusDiagramActionBarContributor_deleteFromDiagram,
@@ -173,9 +173,8 @@ public class TabBarTest extends AbstractSiriusSwtBotGefTestCase {
}
/**
- * When an element is selected on a diagram, setting focus on another view,
- * than the editor, should not reload the tabbar like if there was no
- * selection. (VP-3663)
+ * When an element is selected on a diagram, setting focus on another view, than the editor, should not reload the
+ * tabbar like if there was no selection. (VP-3663)
*
* @throws Exception
* Test error.
@@ -196,9 +195,8 @@ public class TabBarTest extends AbstractSiriusSwtBotGefTestCase {
}
/**
- * When an element is selected on a diagram, setting focus on another editor
- * (with split editor area to display more than one editor), should not
- * reload the tabbar like if there was no selection. (VP-3663)
+ * When an element is selected on a diagram, setting focus on another editor (with split editor area to display more
+ * than one editor), should not reload the tabbar like if there was no selection. (VP-3663)
*
* @throws Exception
* Test error.
@@ -328,12 +326,10 @@ public class TabBarTest extends AbstractSiriusSwtBotGefTestCase {
}
/**
- * Test toggling the old style preference programmatically. Note that this
- * preference does not exist anymore in the UI, but can still be used
- * un-officially in the code to programmatically disable the tabbar. This
- * possibility is used for in some SWTBot tests that rely heavily on
- * hard-coded screen corrdinates which were determined when the tabbar did
- * not exist (in particular for sequence diagrams).
+ * Test toggling the old style preference programmatically. Note that this preference does not exist anymore in the
+ * UI, but can still be used un-officially in the code to programmatically disable the tabbar. This possibility is
+ * used for in some SWTBot tests that rely heavily on hard-coded screen corrdinates which were determined when the
+ * tabbar did not exist (in particular for sequence diagrams).
*
* @throws Exception
* Test error.
@@ -451,11 +447,10 @@ public class TabBarTest extends AbstractSiriusSwtBotGefTestCase {
}
/**
- * Test Pin/Unpin and Show/Hide wizard tabbar buttons are enabled when
- * diagram is selected.
+ * Test Pin/Unpin and Show/Hide wizard tabbar buttons are enabled when diagram is selected.
*
- * See VP-3731 : those buttons were disabled and hidden just after element
- * creation. The diagram selection made them visible but not enabled.
+ * See VP-3731 : those buttons were disabled and hidden just after element creation. The diagram selection made them
+ * visible but not enabled.
*/
public void testTabbarDiagramActionsEnablement() {
if (TestsUtil.shouldSkipUnreliableTests()) {
diff --git a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/TabbarContributorExtensionTest.java b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/TabbarContributorExtensionTest.java
index 3da5f3d3e5..154f42552e 100644
--- a/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/TabbarContributorExtensionTest.java
+++ b/plugins/org.eclipse.sirius.tests.swtbot/src/org/eclipse/sirius/tests/swtbot/tabbar/TabbarContributorExtensionTest.java
@@ -40,8 +40,7 @@ import org.eclipse.swtbot.eclipse.gef.finder.widgets.SWTBotGefEditPart;
import org.eclipse.ui.PlatformUI;
/**
- * Test case to check the tabbar extension point. See
- * https://bugs.eclipse.org/bugs/show_bug.cgi?id=481573
+ * Test case to check the tabbar extension point. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=481573
*
* @author Florian Barbin
*/
@@ -81,15 +80,14 @@ public class TabbarContributorExtensionTest extends AbstractSiriusSwtBotGefTestC
}
/**
- * Test that the default tabbar is properly displayed when no contributor is
- * provided.
+ * Test that the default tabbar is properly displayed when no contributor is provided.
*/
public void testTabbarCountWithoutContributor() {
editor = (SWTBotSiriusDiagramEditor) openRepresentation(localSession.getOpenedSession(), REPRESENTATION_NAME, REPRESENTATION_INSTANCE_NAME, DDiagram.class);
selectDiagramElement();
SWTBotUtils.waitAllUiEvents();
int count = getTabbarItemsCount();
- assertEquals("Unexpected number of tabbar contribution items", 28, count);
+ assertEquals("Unexpected number of tabbar contribution items", 29, count);
selectDiagram();
SWTBotUtils.waitAllUiEvents();
count = getTabbarItemsCount();
@@ -97,12 +95,11 @@ public class TabbarContributorExtensionTest extends AbstractSiriusSwtBotGefTestC
selectEdge();
SWTBotUtils.waitAllUiEvents();
count = getTabbarItemsCount();
- assertEquals("Unexpected number of tabbar contribution items", 28, count);
+ assertEquals("Unexpected number of tabbar contribution items", 29, count);
}
/**
- * Tests that the custom tabbar is properly displayed when it is installed
- * via extension point.
+ * Tests that the custom tabbar is properly displayed when it is installed via extension point.
*/
public void testCustomTabbarContributor() {
registerExtension();

Back to the top