Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Piers2019-07-04 04:45:50 -0400
committerLaurent Goubet2019-07-04 09:15:38 -0400
commitdf841999a6012a78cfcf85b3646ecdfe8949aec5 (patch)
tree2579a3b32922c201d72d2a28c2cfe88080af10ae
parent08799582e7174a33f8e58d07e48649f5b388af90 (diff)
downloadorg.eclipse.emf.compare-df841999a6012a78cfcf85b3646ecdfe8949aec5.tar.gz
org.eclipse.emf.compare-df841999a6012a78cfcf85b3646ecdfe8949aec5.tar.xz
org.eclipse.emf.compare-df841999a6012a78cfcf85b3646ecdfe8949aec5.zip
Enabled "accept change" action on multiple diff selection
Change-Id: I46c603dcac9fde2c336b21f696c9bc1ca80af338 Signed-off-by: William Piers <william.piers@obeo.fr>
-rw-r--r--plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java37
1 files changed, 28 insertions, 9 deletions
diff --git a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
index 79adb63f6..6ab7cd760 100644
--- a/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
+++ b/plugins/org.eclipse.emf.compare.ide.ui/src/org/eclipse/emf/compare/ide/ui/internal/structuremergeviewer/EMFCompareStructureMergeViewer.java
@@ -564,7 +564,7 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
* the context menu to fill.
*/
private void fillContextMenu(IMenuManager manager) {
- if (!isOneMergeableItemSelected()) {
+ if (!isMergeableItemSelected()) {
return;
}
boolean leftEditable = getCompareConfiguration().isLeftEditable();
@@ -576,10 +576,9 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
modes = EnumSet.of(MergeMode.ACCEPT, MergeMode.REJECT);
}
- boolean singleDiffSelected = isOneDiffSelected();
if (rightEditable || leftEditable) {
IMerger.Registry mergerRegistry = EMFCompareRCPPlugin.getDefault().getMergerRegistry();
- if (singleDiffSelected) {
+ if (isDiffSelected()) {
addSingleDiffMergeActions(manager, modes, mergerRegistry);
} else if (isOneMatchOrResourceMatchSelected() || isOneGroupSelected()) {
addMergeNonConflictingActions(manager, modes, mergerRegistry);
@@ -592,7 +591,7 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
}
}
}
- if (singleDiffSelected && getCompareConfiguration().getComparison().isThreeWay()) {
+ if (isOneDiffSelected() && getCompareConfiguration().getComparison().isThreeWay()) {
final ISelection selection = getSelection();
if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) {
Object element = ((IStructuredSelection)selection).getFirstElement();
@@ -710,15 +709,15 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
*
* @return true if the item selected is mergeable, false otherwise.
*/
- private boolean isOneMergeableItemSelected() {
- return isOneDiffSelected() || isOneMatchOrResourceMatchSelected() || isOneGroupSelected();
+ private boolean isMergeableItemSelected() {
+ return isDiffSelected() || isOneMatchOrResourceMatchSelected() || isOneGroupSelected();
}
/**
- * Specifies whether the a {@link Match} or a {@link MatchResource} is currently selected in this viewer.
+ * Specifies whether a single {@link Diff} is currently selected in this viewer.
*
- * @return <code>true</code> if an instance of a {@link Match} or a {@link MatchResource} is selected,
- * <code>false</code> otherwise.
+ * @return <code>true</code> if a single instance of a {@link Diff} is selected, <code>false</code>
+ * otherwise.
*/
private boolean isOneDiffSelected() {
final ISelection selection = getSelection();
@@ -732,6 +731,23 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
}
/**
+ * Specifies whether anything but {@link Diff} are currently selected in this viewer.
+ *
+ * @return <code>true</code> if only instances of {@link Diff} are selected, <code>false</code> otherwise.
+ */
+ private boolean isDiffSelected() {
+ final ISelection selection = getSelection();
+ if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() > 1) {
+ for (Object element : ((IStructuredSelection)selection).toList()) {
+ if (!(getDataOfTreeNodeOfAdapter(element) instanceof Diff)) {
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+ /**
* Specifies whether the a {@link Match} or a {@link MatchResource} is currently selected in this viewer.
*
* @return <code>true</code> if an instance of a {@link Match} or a {@link MatchResource} is selected,
@@ -1209,6 +1225,7 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
});
} else {
SWTUtil.safeSyncExec(new Runnable() {
+
public void run() {
refresh();
toolBar.selectionChanged(
@@ -1384,6 +1401,7 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
// StructureMergeViewerGrouper.
if (!monitor.isCanceled()) {
SWTUtil.safeSyncExec(new Runnable() {
+
public void run() {
getViewer().setInput(input);
}
@@ -1444,6 +1462,7 @@ public class EMFCompareStructureMergeViewer extends AbstractStructuredViewerWrap
oldAdapterFactory.dispose();
}
}
+
}
void compareInputChanged(final ICompareInput input, IProgressMonitor monitor) {

Back to the top