Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAxel Richard2013-07-12 07:06:13 +0000
committerGerrit Code Review @ Eclipse.org2013-07-16 13:16:16 +0000
commitee66ae874d12b2f044119b5558070d3a696c8867 (patch)
tree96dab9f0ef306901633984fe7f97b2c185964d85 /plugins/org.eclipse.emf.compare.ide.ui/src
parentcad763d735353874c752548c525dbb375d2e3187 (diff)
downloadorg.eclipse.emf.compare-ee66ae874d12b2f044119b5558070d3a696c8867.tar.gz
org.eclipse.emf.compare-ee66ae874d12b2f044119b5558070d3a696c8867.tar.xz
org.eclipse.emf.compare-ee66ae874d12b2f044119b5558070d3a696c8867.zip
Update merge/navigation actions behavior
-Add compare merge/navigation actions for Juno -Merge actions are now always enabled when a diff is selected -Fix not managed case on Accept and reject actions. Change-Id: Ia3766001e47f324ce56212389e8f1875006a684c
Diffstat (limited to 'plugins/org.eclipse.emf.compare.ide.ui/src')
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareDiffTreeViewer.java78
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/handler/AbstractAcceptRejectChange.java43
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/handler/propertytester/LeftToRightSidePropertyTester.java48
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/handler/propertytester/RightToLeftSidePropertyTester.java48
4 files changed, 96 insertions, 121 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareDiffTreeViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareDiffTreeViewer.java
index fde2f0e1a..08aad6bcd 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareDiffTreeViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareDiffTreeViewer.java
@@ -408,12 +408,7 @@ public class EMFCompareDiffTreeViewer extends DiffTreeViewer {
if (uiWorkbenchBundle != null && uiWorkbenchBundle.getVersion().compareTo(junoStart) >= 0
&& uiWorkbenchBundle.getVersion().compareTo(keplerStart) < 0) {
- IAction action = new CommandAction(PlatformUI.getWorkbench(),
- "org.eclipse.emf.compare.ide.ui.saveComparisonModel"); //$NON-NLS-1$
- action.setToolTipText("Save Comparison model"); //$NON-NLS-1$
- action.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(
- EMFCompareIDEUIPlugin.PLUGIN_ID, "icons/full/toolb16/saveas_edit.gif")); //$NON-NLS-1$
- toolbarManager.add(action);
+ addActionsForJuno(toolbarManager);
}
groupActionMenu = new GroupActionMenu(getStructureMergeViewerGrouper(), getGroupsMenuManager(),
@@ -429,6 +424,77 @@ public class EMFCompareDiffTreeViewer extends DiffTreeViewer {
}
/**
+ * Add the compare merge/navigation actions to the structure merge viewer toolbar.
+ *
+ * @param toolbarManager
+ * the given toolbar.
+ */
+ public void addActionsForJuno(ToolBarManager toolbarManager) {
+ boolean bothSidesEditable = getCompareConfiguration().isLeftEditable()
+ && getCompareConfiguration().isRightEditable();
+ addSMVAction(toolbarManager, "org.eclipse.emf.compare.ide.ui.dropdown", //$NON-NLS-1$
+ "Select the way of merge", "icons/full/toolb16/left_to_right.gif", true); //$NON-NLS-2$
+ toolbarManager.add(new Separator());
+ if (bothSidesEditable) {
+ addSMVAction(toolbarManager, "org.eclipse.emf.compare.ide.ui.mergedToRight", //$NON-NLS-1$
+ "Copy Current Change From Left To Right", "icons/full/toolb16/merge_to_right.gif", true); //$NON-NLS-2$
+ addSMVAction(
+ toolbarManager,
+ "org.eclipse.emf.compare.ide.ui.mergedAllToRight", //$NON-NLS-1$
+ "Copy All Non-Conflicting Changes From Left To Right", "icons/full/toolb16/merge_all_to_right.gif", true); //$NON-NLS-2$
+ toolbarManager.add(new Separator());
+ addSMVAction(toolbarManager, "org.eclipse.emf.compare.ide.ui.mergedToLeft", //$NON-NLS-1$
+ "Copy Current Change From Right To Left", "icons/full/toolb16/merge_to_left.gif", true); //$NON-NLS-2$
+ addSMVAction(
+ toolbarManager,
+ "org.eclipse.emf.compare.ide.ui.mergedAllToLeft", //$NON-NLS-1$
+ "Copy All Non-Conflicting Changes From Right To Left", "icons/full/toolb16/merge_all_to_left.gif", true); //$NON-NLS-2$
+ } else {
+ addSMVAction(toolbarManager, "org.eclipse.emf.compare.ide.ui.acceptChange", //$NON-NLS-1$
+ "Accept Change", "icons/full/toolb16/accept_change.gif", true); //$NON-NLS-2$
+ addSMVAction(toolbarManager, "org.eclipse.emf.compare.ide.ui.acceptAllChanges", //$NON-NLS-1$
+ "Accept All Non-Conflicting Changes", "icons/full/toolb16/accept_all_changes.gif", true); //$NON-NLS-2$
+ toolbarManager.add(new Separator());
+ addSMVAction(toolbarManager, "org.eclipse.emf.compare.ide.ui.rejectChange", //$NON-NLS-1$
+ "Reject Change", "icons/full/toolb16/reject_change.gif", true); //$NON-NLS-2$
+ addSMVAction(toolbarManager, "org.eclipse.emf.compare.ide.ui.rejectAllChanges", //$NON-NLS-1$
+ "Reject All Non-Conflicting Changes", "icons/full/toolb16/reject_all_changes.gif", true); //$NON-NLS-2$
+ }
+ toolbarManager.add(new Separator());
+ addSMVAction(toolbarManager, "org.eclipse.emf.compare.ide.ui.nextDiff", //$NON-NLS-1$
+ "Next Difference", "icons/full/toolb16/next_diff.gif", true); //$NON-NLS-2$
+ addSMVAction(toolbarManager, "org.eclipse.emf.compare.ide.ui.previousDiff", //$NON-NLS-1$
+ "Previous Difference", "icons/full/toolb16/prev_diff.gif", true); //$NON-NLS-2$
+ toolbarManager.add(new Separator());
+ addSMVAction(toolbarManager, "org.eclipse.emf.compare.ide.ui.saveComparisonModel", //$NON-NLS-1$
+ "Save Comparison Model", "icons/full/toolb16/saveas_edit.gif", true); //$NON-NLS-2$
+ }
+
+ /**
+ * Add the given action to the structure merge viewer toolbar.
+ *
+ * @param tb
+ * the given toolbar.
+ * @param actionId
+ * the id of the action to add.
+ * @param tooltip
+ * the tooltip of the action to add.
+ * @param imagePath
+ * the image path of the action to add.
+ * @param activated
+ * the initial state of the action to add.
+ */
+ private void addSMVAction(ToolBarManager tb, String actionId, String tooltip, String imagePath,
+ boolean activated) {
+ IAction action = new CommandAction(PlatformUI.getWorkbench(), actionId);
+ action.setToolTipText(tooltip);
+ action.setImageDescriptor(AbstractUIPlugin.imageDescriptorFromPlugin(EMFCompareIDEUIPlugin.PLUGIN_ID,
+ imagePath));
+ action.setEnabled(activated);
+ tb.add(action);
+ }
+
+ /**
* Returns the viewer filter that is to be applied on the structure viewer.
* <p>
* Note that this will be called from {@link #createToolItems(ToolBarManager)}, which is called from the
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/handler/AbstractAcceptRejectChange.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/handler/AbstractAcceptRejectChange.java
index 317da68e6..4a20f4096 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/handler/AbstractAcceptRejectChange.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/handler/AbstractAcceptRejectChange.java
@@ -27,8 +27,10 @@ import org.eclipse.emf.compare.domain.ICompareEditingDomain;
import org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.handler.util.EMFCompareUIHandlerUtil;
import org.eclipse.emf.compare.internal.utils.DiffUtil;
import org.eclipse.emf.compare.rcp.ui.internal.EMFCompareConstants;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.change.util.ChangeRecorder;
import org.eclipse.emf.edit.command.ChangeCommand;
+import org.eclipse.emf.edit.tree.TreeNode;
import org.eclipse.ui.ISources;
import org.eclipse.ui.handlers.HandlerUtil;
@@ -53,27 +55,30 @@ public abstract class AbstractAcceptRejectChange extends AbstractHandler {
configuration = ((CompareEditorInput)editorInput).getCompareConfiguration();
Object diffNode = ((CompareEditorInput)editorInput).getSelectedEdition();
if (diffNode instanceof Adapter) {
- Notifier diff = ((Adapter)diffNode).getTarget();
- if (diff instanceof Diff) {
- boolean rightEditableOnly = !configuration.isLeftEditable()
- && configuration.isRightEditable();
- boolean leftEditableOnly = configuration.isLeftEditable()
- && !configuration.isRightEditable();
- if (leftEditableOnly) {
- if (isCopyDiffCase((Diff)diff, false)) {
- EMFCompareUIHandlerUtil.copyDiff((Diff)diff, false, configuration);
- } else {
- changeStateFromUnresolvedToMerged((Diff)diff, true);
- }
- } else if (rightEditableOnly) {
- if (isCopyDiffCase((Diff)diff, true)) {
- EMFCompareUIHandlerUtil.copyDiff((Diff)diff, true, configuration);
- } else {
- changeStateFromUnresolvedToMerged((Diff)diff, false);
+ Notifier target = ((Adapter)diffNode).getTarget();
+ if (target instanceof TreeNode) {
+ EObject data = ((TreeNode)target).getData();
+ if (data instanceof Diff) {
+ boolean rightEditableOnly = !configuration.isLeftEditable()
+ && configuration.isRightEditable();
+ boolean leftEditableOnly = configuration.isLeftEditable()
+ && !configuration.isRightEditable();
+ if (leftEditableOnly) {
+ if (isCopyDiffCase((Diff)data, false)) {
+ EMFCompareUIHandlerUtil.copyDiff((Diff)data, false, configuration);
+ } else {
+ changeStateFromUnresolvedToMerged((Diff)data, true);
+ }
+ } else if (rightEditableOnly) {
+ if (isCopyDiffCase((Diff)data, true)) {
+ EMFCompareUIHandlerUtil.copyDiff((Diff)data, true, configuration);
+ } else {
+ changeStateFromUnresolvedToMerged((Diff)data, false);
+ }
}
+ // Select next diff
+ EMFCompareUIHandlerUtil.navigate(true, configuration);
}
- // Select next diff
- EMFCompareUIHandlerUtil.navigate(true, configuration);
}
}
}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/handler/propertytester/LeftToRightSidePropertyTester.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/handler/propertytester/LeftToRightSidePropertyTester.java
deleted file mode 100644
index 780860517..000000000
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/handler/propertytester/LeftToRightSidePropertyTester.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.handler.propertytester;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.CompareEditorInput;
-import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.emf.compare.rcp.ui.internal.EMFCompareConstants;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-
-/**
- * A property tester that check the way of merge.
- *
- * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
- * @since 3.0
- */
-public class LeftToRightSidePropertyTester extends PropertyTester {
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.core.expressions.PropertyTester#test(java.lang.Object, java.lang.String,
- * java.lang.Object[], java.lang.Object)
- */
- public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- if (receiver instanceof IEditorPart) {
- IEditorInput i = ((IEditorPart)receiver).getEditorInput();
- if (i instanceof CompareEditorInput) {
- CompareConfiguration configuration = ((CompareEditorInput)i).getCompareConfiguration();
- Boolean leftToRight = (Boolean)configuration.getProperty(EMFCompareConstants.MERGE_WAY);
- if (leftToRight == null || leftToRight.booleanValue()) {
- return true;
- }
- }
- }
- return false;
- }
-
-}
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/handler/propertytester/RightToLeftSidePropertyTester.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/handler/propertytester/RightToLeftSidePropertyTester.java
deleted file mode 100644
index 92310abc7..000000000
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/handler/propertytester/RightToLeftSidePropertyTester.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2013 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.emf.compare.ide.ui.internal.structuremergeviewer.handler.propertytester;
-
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.CompareEditorInput;
-import org.eclipse.core.expressions.PropertyTester;
-import org.eclipse.emf.compare.rcp.ui.internal.EMFCompareConstants;
-import org.eclipse.ui.IEditorInput;
-import org.eclipse.ui.IEditorPart;
-
-/**
- * A property tester that check the way of merge.
- *
- * @author <a href="mailto:axel.richard@obeo.fr">Axel Richard</a>
- * @since 3.0
- */
-public class RightToLeftSidePropertyTester extends PropertyTester {
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.core.expressions.PropertyTester#test(java.lang.Object, java.lang.String,
- * java.lang.Object[], java.lang.Object)
- */
- public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
- if (receiver instanceof IEditorPart) {
- IEditorInput i = ((IEditorPart)receiver).getEditorInput();
- if (i instanceof CompareEditorInput) {
- CompareConfiguration configuration = ((CompareEditorInput)i).getCompareConfiguration();
- Boolean leftToRight = (Boolean)configuration.getProperty(EMFCompareConstants.MERGE_WAY);
- if (leftToRight != null && !leftToRight.booleanValue()) {
- return true;
- }
- }
- }
- return false;
- }
-
-}

Back to the top