Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJean Michel-Lemieux2002-02-26 20:04:08 +0000
committerJean Michel-Lemieux2002-02-26 20:04:08 +0000
commitcef705c95a345e904f50cc0abd34d3929aac66e8 (patch)
tree6590e4c314e1dfc36c9f2f88b98623cac5f53afe
parent0d41a84d0066a4d891dd7c0f8d27cf4c2a06a7a1 (diff)
downloadeclipse.platform.team-cef705c95a345e904f50cc0abd34d3929aac66e8.tar.gz
eclipse.platform.team-cef705c95a345e904f50cc0abd34d3929aac66e8.tar.xz
eclipse.platform.team-cef705c95a345e904f50cc0abd34d3929aac66e8.zip
Changes to support automated ui testing. Mostly just refactoring prompting
code into methods that can be overiden from the tests.
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java10
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java41
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CommitSyncAction.java52
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/UpdateSyncAction.java74
4 files changed, 117 insertions, 60 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java
index ee609c6a4..6685c74f0 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CommitAction.java
@@ -34,7 +34,7 @@ public class CommitAction extends TeamAction {
public void execute(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
try {
RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
- String comment = manager.promptForComment(getShell());
+ String comment = promptForComment(manager);
if (comment != null) {
manager.commit(getSelectedResources(), comment, monitor);
}
@@ -61,4 +61,12 @@ public class CommitAction extends TeamAction {
}
return true;
}
+
+ /**
+ * Prompts the user for a release comment.
+ * @return the comment, or null to cancel
+ */
+ protected String promptForComment(RepositoryManager manager) {
+ return manager.promptForComment(getShell());
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java
index 470550b5e..030f05d31 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java
@@ -43,24 +43,10 @@ public class TagAction extends TeamAction {
run(new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
- final Shell s = getShell();
final String[] result = new String[1];
- s.getDisplay().syncExec(new Runnable() {
+ getShell().getDisplay().syncExec(new Runnable() {
public void run() {
- // Prompt for the tag
- IInputValidator validator = new IInputValidator() {
- public String isValid(String tagName) {
- IStatus status = CVSTag.validateTagName(tagName);
- if (status.isOK()) {
- return null;
- } else {
- return status.getMessage();
- }
- }
- };
- InputDialog dialog = new InputDialog(s, Policy.bind("TagAction.tagResources"), Policy.bind("TagAction.enterTag"), previousTag, validator);
- if (dialog.open() != InputDialog.OK) return;
- result[0] = dialog.getValue();
+ result[0] = promptForTag();
}
});
if (result[0] == null) return;
@@ -83,6 +69,7 @@ public class TagAction extends TeamAction {
}, Policy.bind("TagAction.tag"), this.PROGRESS_DIALOG);
}
+
/*
* @see TeamAction#isEnabled()
*/
@@ -97,5 +84,27 @@ public class TagAction extends TeamAction {
}
return true;
}
+
+ /**
+ * Prompts the user for a tag name.
+ * @return the tag, or null to cancel
+ */
+ protected String promptForTag() {
+ // Prompt for the tag
+ IInputValidator validator = new IInputValidator() {
+ public String isValid(String tagName) {
+ IStatus status = CVSTag.validateTagName(tagName);
+ if (status.isOK()) {
+ return null;
+ } else {
+ return status.getMessage();
+ }
+ }
+ };
+ InputDialog dialog = new InputDialog(getShell(),
+ Policy.bind("TagAction.tagResources"), Policy.bind("TagAction.enterTag"), previousTag, validator);
+ if (dialog.open() != InputDialog.OK) return null;
+ return dialog.getValue();
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CommitSyncAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CommitSyncAction.java
index a19ad8af2..1b75bba31 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CommitSyncAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/CommitSyncAction.java
@@ -41,22 +41,7 @@ public class CommitSyncAction extends MergeAction {
protected SyncSet run(SyncSet syncSet, IProgressMonitor monitor) {
// If there is a conflict in the syncSet, we need to prompt the user before proceeding.
if (syncSet.hasConflicts() || syncSet.hasIncomingChanges()) {
- String[] buttons = new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL};
- String question = Policy.bind("CommitSyncAction.questionRelease");
- String title = Policy.bind("CommitSyncAction.titleRelease");
- String[] tips = new String[] {
- Policy.bind("CommitSyncAction.releaseAll"),
- Policy.bind("CommitSyncAction.releasePart"),
- Policy.bind("CommitSyncAction.cancelRelease")
- };
- Shell shell = getShell();
- final ToolTipMessageDialog dialog = new ToolTipMessageDialog(shell, title, null, question, MessageDialog.QUESTION, buttons, tips, 0);
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- dialog.open();
- }
- });
- switch (dialog.getReturnCode()) {
+ switch (promptForConflicts(syncSet)) {
case 0:
// Yes, synchronize conflicts as well
break;
@@ -129,7 +114,7 @@ public class CommitSyncAction extends MergeAction {
}
try {
RepositoryManager manager = CVSUIPlugin.getPlugin().getRepositoryManager();
- String comment = manager.promptForComment(getShell());
+ String comment = promptForComment(manager);
if (comment == null) {
// User cancelled. Remove the nodes from the sync set.
return null;
@@ -189,7 +174,7 @@ public class CommitSyncAction extends MergeAction {
} catch (final TeamException e) {
getShell().getDisplay().syncExec(new Runnable() {
public void run() {
- ErrorDialog.openError(getShell(), Policy.bind("error"), Policy.bind("CommitSyncAction.errorCommitting"), e.getStatus());
+ ErrorDialog.openError(getShell(), null, null, e.getStatus());
}
});
return null;
@@ -232,4 +217,35 @@ public class CommitSyncAction extends MergeAction {
protected boolean isEnabled(ITeamNode node) {
return true;
}
+
+ /**
+ * Prompts the user to determine how conflicting changes should be handled.
+ * @return 0 to sync conflicts, 1 to sync all non-conflicts, 2 to cancel
+ */
+ protected int promptForConflicts(SyncSet syncSet) {
+ String[] buttons = new String[] {IDialogConstants.YES_LABEL, IDialogConstants.NO_LABEL, IDialogConstants.CANCEL_LABEL};
+ String question = Policy.bind("CommitSyncAction.questionRelease");
+ String title = Policy.bind("CommitSyncAction.titleRelease");
+ String[] tips = new String[] {
+ Policy.bind("CommitSyncAction.releaseAll"),
+ Policy.bind("CommitSyncAction.releasePart"),
+ Policy.bind("CommitSyncAction.cancelRelease")
+ };
+ Shell shell = getShell();
+ final ToolTipMessageDialog dialog = new ToolTipMessageDialog(shell, title, null, question, MessageDialog.QUESTION, buttons, tips, 0);
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ dialog.open();
+ }
+ });
+ return dialog.getReturnCode();
+ }
+
+ /**
+ * Prompts the user for a release comment.
+ * @return the comment, or null to cancel
+ */
+ protected String promptForComment(RepositoryManager manager) {
+ return manager.promptForComment(getShell());
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/UpdateSyncAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/UpdateSyncAction.java
index 8edc2aef1..bcf7c933d 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/UpdateSyncAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/sync/UpdateSyncAction.java
@@ -108,32 +108,22 @@ public class UpdateSyncAction extends MergeAction {
protected SyncSet run(final SyncSet syncSet, IProgressMonitor monitor) {
// If there are conflicts or outgoing changes in the syncSet, we need to warn the user.
- final boolean doAutomerge[] = new boolean[] {false};
+ boolean onlyUpdateAutomergeable = false;
if (syncSet.hasConflicts() || syncSet.hasOutgoingChanges()) {
- final Shell shell = getShell();
if (syncSet.hasAutoMergeableConflicts()) {
- final int[] result = new int[] {Dialog.CANCEL};
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- ConfirmDialog dialog = new ConfirmDialog(shell);
- result[0] = dialog.open();
- doAutomerge[0] = dialog.getAutomerge();
- }
- });
- if (result[0] == Dialog.CANCEL) return null;
- if (doAutomerge[0]) {
- syncSet.removeNonMergeableNodes();
- }
+ switch (promptForMergeableConflicts()) {
+ case 0: // cancel
+ return null;
+ case 1: // only update auto-mergeable conflicts
+ onlyUpdateAutomergeable = true;
+ syncSet.removeNonMergeableNodes();
+ break;
+ case 2: // update all conflicts
+ onlyUpdateAutomergeable = false;
+ break;
+ }
} else {
- final boolean[] result = new boolean[] { false };
- shell.getDisplay().syncExec(new Runnable() {
- public void run() {
- result[0] = MessageDialog.openQuestion(shell, Policy.bind("UpdateSyncAction.Overwrite_local_changes__5"), Policy.bind("UpdateSyncAction.You_have_local_changes_you_are_about_to_overwrite._Do_you_wish_to_continue__6")); //$NON-NLS-1$ //$NON-NLS-2$
- }
- });
- if (!result[0]) {
- return null;
- }
+ if (! promptForConflicts()) return null;
}
}
@@ -207,7 +197,7 @@ public class UpdateSyncAction extends MergeAction {
break;
case Differencer.CHANGE:
// Depends on the flag.
- if (doAutomerge[0] && (changed[i].getKind() & IRemoteSyncElement.AUTOMERGE_CONFLICT) != 0) {
+ if (onlyUpdateAutomergeable && (changed[i].getKind() & IRemoteSyncElement.AUTOMERGE_CONFLICT) != 0) {
updateShallow.add(resource);
} else {
updateIgnoreLocalShallow.add(resource);
@@ -278,7 +268,7 @@ public class UpdateSyncAction extends MergeAction {
} catch (final TeamException e) {
getShell().getDisplay().syncExec(new Runnable() {
public void run() {
- ErrorDialog.openError(getShell(), Policy.bind("error"), Policy.bind("UpdateSyncAction.errorUpdating"), e.getStatus());
+ ErrorDialog.openError(getShell(), null, null, e.getStatus());
}
});
return null;
@@ -322,4 +312,38 @@ public class UpdateSyncAction extends MergeAction {
protected boolean isEnabled(ITeamNode node) {
return true;
}
+
+ /**
+ * Prompt for mergeable conflicts.
+ * @return 0 to cancel, 1 to only update mergeable conflicts, 2 to overwrite if unmergeable
+ */
+ protected int promptForMergeableConflicts() {
+ final boolean doAutomerge[] = new boolean[] {false};
+ final int[] result = new int[] {Dialog.CANCEL};
+ final Shell shell = getShell();
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ ConfirmDialog dialog = new ConfirmDialog(shell);
+ result[0] = dialog.open();
+ doAutomerge[0] = dialog.getAutomerge();
+ }
+ });
+ if (result[0] == Dialog.CANCEL) return 0;
+ return doAutomerge[0] ? 1 : 2;
+ }
+
+ /**
+ * Prompt for non-automergeable conflicts.
+ * @return false to cancel, true to overwrite local changes
+ */
+ protected boolean promptForConflicts() {
+ final boolean[] result = new boolean[] { false };
+ final Shell shell = getShell();
+ shell.getDisplay().syncExec(new Runnable() {
+ public void run() {
+ result[0] = MessageDialog.openQuestion(shell, Policy.bind("UpdateSyncAction.Overwrite_local_changes__5"), Policy.bind("UpdateSyncAction.You_have_local_changes_you_are_about_to_overwrite._Do_you_wish_to_continue__6")); //$NON-NLS-1$ //$NON-NLS-2$
+ }
+ });
+ return result[0];
+ }
}

Back to the top