Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomasz Zarna2008-08-01 09:08:19 -0400
committerTomasz Zarna2008-08-01 09:08:19 -0400
commit47acf08fa9037c55fc7672e51706a172b4a2bf57 (patch)
treefdbd75f42d9c56a5f6af2e1a2c02533e606bba11
parent5703b819297f84980f45e50e80e4929ad6d94c07 (diff)
downloadeclipse.platform.team-branch_20080710_CompareWithDialog.tar.gz
eclipse.platform.team-branch_20080710_CompareWithDialog.tar.xz
eclipse.platform.team-branch_20080710_CompareWithDialog.zip
bug 239959: Adding content to "Compare with other resource" dialog by drag&dropping, patch #7branch_20080710_CompareWithDialog
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java16
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java4
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties8
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceAction.java45
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java19
-rw-r--r--bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java48
6 files changed, 78 insertions, 62 deletions
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java
index 839f003ae..01cd0061d 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation 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
@@ -8,17 +8,17 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Matt McCutchen (hashproduct+eclipse@gmail.com) - Bug 35390 Three-way compare cannot select (mis-selects) )ancestor resource
+ * Aleksandra Wozniak (aleksandra.k.wozniak@gmail.com) - Bug 239959
*******************************************************************************/
package org.eclipse.compare.internal;
+import org.eclipse.compare.CompareConfiguration;
+import org.eclipse.compare.CompareUI;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
-
import org.eclipse.ui.IObjectActionDelegate;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.compare.CompareConfiguration;
-import org.eclipse.compare.CompareUI;
/*
@@ -26,16 +26,16 @@ import org.eclipse.compare.CompareUI;
*/
public class CompareAction extends BaseCompareAction implements IObjectActionDelegate {
- private ResourceCompareInput fInput;
- private IWorkbenchPage fWorkbenchPage;
-
+ protected ResourceCompareInput fInput;
+ protected IWorkbenchPage fWorkbenchPage;
+ protected boolean showSelectAncestorDialog = true;
public void run(ISelection selection) {
if (fInput != null) {
// Pass the shell so setSelection can prompt the user for which
// resource should be the ancestor
boolean ok = fInput.setSelection(selection,
- fWorkbenchPage.getWorkbenchWindow().getShell());
+ fWorkbenchPage.getWorkbenchWindow().getShell(), showSelectAncestorDialog);
if (!ok) return;
fInput.initializeCompareConfiguration();
CompareUI.openCompareEditorOnPage(fInput, fWorkbenchPage);
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java
index 919b64cdc..1a8ea13ec 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation 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
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Matt McCutchen (hashproduct+eclipse@gmail.com) - Bug 35390 Three-way compare cannot select (mis-selects) )ancestor resource
+ * Aleksandra Wozniak (aleksandra.k.wozniak@gmail.com) - Bug 239959
*******************************************************************************/
package org.eclipse.compare.internal;
@@ -118,6 +119,7 @@ public final class CompareMessages extends NLS {
public static String CompareWithOther_error_empty;
public static String CompareWithOther_clear;
public static String CompareWithOther_warning_two_way;
+ public static String CompareWithOther_info;
static {
NLS.initializeMessages(BUNDLE_NAME, CompareMessages.class);
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties
index 28804f040..ee8570ee6 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareMessages.properties
@@ -1,5 +1,5 @@
###############################################################################
-# Copyright (c) 2000, 2007 IBM Corporation and others.
+# Copyright (c) 2000, 2008 IBM Corporation 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
@@ -8,6 +8,7 @@
# Contributors:
# IBM Corporation - initial API and implementation
# Matt McCutchen (hashproduct+eclipse@gmail.com) - Bug 35390 Three-way compare cannot select (mis-selects) )ancestor resource
+# Aleksandra Wozniak (aleksandra.k.wozniak@gmail.com) - Bug 239959
###############################################################################
ComparePlugin_internal_error= Internal Error
@@ -128,5 +129,6 @@ CompareWithOther_dialogTitle=Compare with Other Resource
CompareWithOther_dialogMessage=Select resources to compare
CompareWithOther_error_not_comparable=Selected resources are not comparable.
CompareWithOther_error_empty=Both left and right panel must contain a valid path.
-CompareWithOther_warning_two_way=Ancestor is not a valid resource. Two-way compare will be performed.
-CompareWithOther_clear=Clear \ No newline at end of file
+CompareWithOther_warning_two_way=Ancestor is not a valid resource. Two-way compare will be performed.
+CompareWithOther_clear=Clear
+CompareWithOther_info=Drag files from a view or between dialog's fields.
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceAction.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceAction.java
index 6782156ad..e0c74cf8f 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceAction.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceAction.java
@@ -10,51 +10,26 @@
*******************************************************************************/
package org.eclipse.compare.internal;
-import org.eclipse.core.resources.IResource;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.viewers.ISelection;
-import org.eclipse.jface.viewers.StructuredSelection;
-import org.eclipse.swt.widgets.Shell;
-import org.eclipse.ui.IObjectActionDelegate;
-import org.eclipse.ui.IWorkbenchPart;
-import org.eclipse.ui.PlatformUI;
/**
* The "Compare with other resource" action
*
* @since 3.4
*/
-public class CompareWithOtherResourceAction implements IObjectActionDelegate {
+public class CompareWithOtherResourceAction extends CompareAction {
- private Shell shell;
- private ISelection fSelection;
- private IWorkbenchPart fWorkbenchPart;
-
- public CompareWithOtherResourceAction() {
- shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
- }
-
- public void setActivePart(IAction action, IWorkbenchPart targetPart) {
- fWorkbenchPart = targetPart;
- }
-
- public void run(IAction action) {
- CompareWithOtherResourceDialog dialog = new CompareWithOtherResourceDialog(shell, fSelection);
- int returnCode = dialog.open();
-
- if (returnCode == IDialogConstants.OK_ID) {
- IResource[] resources = dialog.getResult();
- StructuredSelection ss = new StructuredSelection(resources);
- CompareAction ca = new CompareAction();
- ca.setActivePart(null, fWorkbenchPart);
- if (ca.isEnabled(ss))
- ca.run(ss);
- }
+ public void run(ISelection selection) {
+ // Show CompareWithOtherResourceDialog which return resources to compare
+ // and ancestor if specified. Don't need to display the other dialog
+ showSelectAncestorDialog = false;
+ super.run(selection);
}
- public void selectionChanged(IAction action, ISelection selection) {
- fSelection = selection;
+ protected boolean isEnabled(ISelection selection) {
+ // ignore returned value
+ super.isEnabled(selection);
+ return true;
}
}
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java
index b404395c3..cdfea56c3 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/CompareWithOtherResourceDialog.java
@@ -49,7 +49,7 @@ import org.eclipse.ui.part.ResourceTransfer;
/**
* This is a dialog that can invoke the compare editor on chosen files.
- *
+ *
* @since 3.4
*/
public class CompareWithOtherResourceDialog extends TitleAreaDialog {
@@ -166,7 +166,7 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog {
createContents(parent);
}
- public InternalSection() {
+ private InternalSection() {
// not to instantiate
}
@@ -337,7 +337,7 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog {
/**
* Creates the dialog.
- *
+ *
* @param shell
* a shell
* @param selection
@@ -353,7 +353,7 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog {
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets
* .Composite)
@@ -389,7 +389,7 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog {
/*
* (non-Javadoc)
- *
+ *
* @see
* org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar(org.eclipse
* .swt.widgets.Composite)
@@ -398,6 +398,7 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog {
super.createButtonsForButtonBar(parent);
okButton = getButton(IDialogConstants.OK_ID);
updateErrorInfo();
+ setMessage(CompareMessages.CompareWithOther_info);
}
private void setSelection(ISelection selection) {
@@ -419,7 +420,7 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog {
}
}
- private boolean comparePossible() {
+ private boolean isComparePossible() {
IResource[] resources;
if (ancestorPanel.getResource() == null) {
resources = new IResource[] { leftPanel.getResource(),
@@ -445,13 +446,13 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog {
&& ancestorPanel.fileText.getText() != "") { //$NON-NLS-1$
setMessage(CompareMessages.CompareWithOther_warning_two_way,
IMessageProvider.WARNING);
- } else if (!comparePossible()) {
+ } else if (!isComparePossible()) {
setMessage(
CompareMessages.CompareWithOther_error_not_comparable,
IMessageProvider.ERROR);
okButton.setEnabled(false);
} else {
- setMessage(null);
+ setMessage(CompareMessages.CompareWithOther_info);
okButton.setEnabled(true);
}
}
@@ -462,7 +463,7 @@ public class CompareWithOtherResourceDialog extends TitleAreaDialog {
* the ancestor panel, table has only two elements -- resources chosen in
* left and right panel. In the other case table contains all three
* resources.
- *
+ *
* @return table with selected resources
*/
public IResource[] getResult() {
diff --git a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
index fcacd04f4..1ab061f11 100644
--- a/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
+++ b/bundles/org.eclipse.compare/plugins/org.eclipse.compare/compare/org/eclipse/compare/internal/ResourceCompareInput.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2007 IBM Corporation and others.
+ * Copyright (c) 2000, 2008 IBM Corporation 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
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Matt McCutchen (hashproduct+eclipse@gmail.com) - Bug 35390 Three-way compare cannot select (mis-selects) )ancestor resource
+ * Aleksandra Wozniak (aleksandra.k.wozniak@gmail.com) - Bug 239959
*******************************************************************************/
package org.eclipse.compare.internal;
@@ -196,12 +197,16 @@ class ResourceCompareInput extends CompareEditorInput {
}
};
}
-
// If the compare is three-way, this method asks the user which resource
- // to use as the ancestor. Returns false if the user cancels the prompt,
+ // to use as the ancestor. Depending on the value of
+ // showSelectAncestorDialog flag it uses different dialogs to get the
+ // feedback from the user. Returns false if the user cancels the prompt,
// true otherwise.
- boolean setSelection(ISelection s, Shell shell) {
-
+ boolean setSelection(ISelection s, Shell shell, boolean showSelectAncestorDialog) {
+
+ if (!showSelectAncestorDialog)
+ return showCompareWithOtherResourceDialog(shell, s);
+
IResource[] selection= Utilities.getResources(s);
fThreeWay= selection.length == 3;
@@ -223,12 +228,43 @@ class ResourceCompareInput extends CompareEditorInput {
fLeftResource= selection[0];
fRightResource= selection[1];
}
+ fLeft= getStructure(fLeftResource);
+ fRight= getStructure(fRightResource);
+ return true;
+ }
+
+ private boolean showCompareWithOtherResourceDialog(Shell shell, ISelection s) {
+ CompareWithOtherResourceDialog dialog = new CompareWithOtherResourceDialog(shell, s);
+ if (dialog.open() != IDialogConstants.OK_ID)
+ return false;
+ IResource[] selection = dialog.getResult();
+ if (!checkSelection(selection))
+ return false;
+ fThreeWay = selection.length == 3;
+ if (fThreeWay) {
+ fAncestorResource = selection[0];
+ fAncestor = getStructure(fAncestorResource);
+ fLeftResource = selection[1];
+ fRightResource = selection[2];
+ } else {
+ fAncestorResource = null;
+ fAncestor = null;
+ fLeftResource = selection[0];
+ fRightResource = selection[1];
+ }
fLeft= getStructure(fLeftResource);
fRight= getStructure(fRightResource);
return true;
}
-
+
+ private boolean checkSelection(IResource[] resources) {
+ for (int i = 0; i < resources.length; i++)
+ if (resources[i] == null)
+ return false;
+ return true;
+ }
+
/*
* Returns true if compare can be executed for the given selection.
*/

Back to the top