Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Valenta2002-05-10 10:48:20 -0400
committerMichael Valenta2002-05-10 10:48:20 -0400
commit08530f78de0d8fc5cc792f13bf1bbc87a5fc401e (patch)
treedb61bb0b24dff88dfd8acbbfa7ff20350aeb346e /bundles/org.eclipse.team.cvs.ui
parent7dedec7c6e52f462c288e483d19b4f364187161e (diff)
downloadeclipse.platform.team-08530f78de0d8fc5cc792f13bf1bbc87a5fc401e.tar.gz
eclipse.platform.team-08530f78de0d8fc5cc792f13bf1bbc87a5fc401e.tar.xz
eclipse.platform.team-08530f78de0d8fc5cc792f13bf1bbc87a5fc401e.zip
15450: Can't tag, move tag, on files in repo explorer
Diffstat (limited to 'bundles/org.eclipse.team.cvs.ui')
-rw-r--r--bundles/org.eclipse.team.cvs.ui/plugin.xml24
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagAsVersionDialog.java6
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java166
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MoveTagAction.java130
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagAction.java93
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagInRepositoryAction.java153
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties6
7 files changed, 316 insertions, 262 deletions
diff --git a/bundles/org.eclipse.team.cvs.ui/plugin.xml b/bundles/org.eclipse.team.cvs.ui/plugin.xml
index 5c997e78a..2361db6bf 100644
--- a/bundles/org.eclipse.team.cvs.ui/plugin.xml
+++ b/bundles/org.eclipse.team.cvs.ui/plugin.xml
@@ -278,18 +278,6 @@
objectClass="org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder"
id="org.eclipse.team.ccvs.ui.RemoteFolderContributions">
<action
- label="%MoveTagAction.label"
- tooltip="%MoveTagAction.tooltip"
- class="org.eclipse.team.internal.ccvs.ui.actions.MoveTagAction"
- id="org.eclipse.team.ccvs.ui.moveTagInRepository">
- </action>
- <action
- label="%TagInRepositoryAction.label"
- tooltip="%TagInRepositoryAction.tooltip"
- class="org.eclipse.team.internal.ccvs.ui.actions.TagInRepositoryAction"
- id="org.eclipse.team.ccvs.ui.tagInRepository">
- </action>
- <action
label="%CheckoutAsAction.label"
tooltip="%CheckoutAsAction.tooltip"
class="org.eclipse.team.internal.ccvs.ui.actions.CheckoutAsAction"
@@ -432,6 +420,18 @@
enablesFor="2"
id="org.eclipse.team.ccvs.ui.compareRemoteResources">
</action>
+ <action
+ label="%MoveTagAction.label"
+ tooltip="%MoveTagAction.tooltip"
+ class="org.eclipse.team.internal.ccvs.ui.actions.MoveRemoteTagAction"
+ id="org.eclipse.team.ccvs.ui.moveTagInRepository">
+ </action>
+ <action
+ label="%TagInRepositoryAction.label"
+ tooltip="%TagInRepositoryAction.tooltip"
+ class="org.eclipse.team.internal.ccvs.ui.actions.TagInRepositoryAction"
+ id="org.eclipse.team.ccvs.ui.tagInRepository">
+ </action>
</objectContribution>
</extension>
<!-- ************** Views ********************** -->
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagAsVersionDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagAsVersionDialog.java
index 39478105d..8d370bc19 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagAsVersionDialog.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/TagAsVersionDialog.java
@@ -187,6 +187,7 @@ public class TagAsVersionDialog extends DetailsDialog {
*/
protected void updateEnablements() {
String message = null;
+ boolean exists = false;
if(tagName.length() == 0) {
message = ""; //$NON-NLS-1$
} else {
@@ -194,11 +195,6 @@ public class TagAsVersionDialog extends DetailsDialog {
if (!status.isOK()) {
message = status.getMessage();
}
-
- boolean exists = doesTagNameExists(tagName);
- if(exists) {
- message = Policy.bind("TagAction.tagAlreadyExists"); //$NON-NLS-1$
- }
}
setPageComplete(message == null);
setErrorMessage(message);
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java
index c4b7fa645..00beee131 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/CVSAction.java
@@ -10,22 +10,29 @@
******************************************************************************/
package org.eclipse.team.internal.ccvs.ui.actions;
+import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ErrorDialog;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
+import org.eclipse.team.internal.ccvs.core.CVSStatus;
import org.eclipse.team.internal.ccvs.core.CVSTag;
import org.eclipse.team.internal.ccvs.core.ICVSFolder;
import org.eclipse.team.internal.ccvs.core.ICVSResource;
@@ -45,6 +52,8 @@ import org.eclipse.ui.PlatformUI;
*/
abstract public class CVSAction extends TeamAction {
+ private List accumulatedStatus = new ArrayList();
+
/**
* Common run method for all CVS actions.
*
@@ -54,18 +63,141 @@ abstract public class CVSAction extends TeamAction {
* if they have failed.]
*/
final public void run(IAction action) {
+ accumulatedStatus.clear();
if(needsToSaveDirtyEditors()) {
if(!saveAllEditors()) {
return;
}
}
- execute(action);
+ try {
+ execute(action);
+ if ( ! accumulatedStatus.isEmpty()) {
+ handle(null);
+ }
+ } catch (InvocationTargetException e) {
+ // Handle the exception and any accumulated errors
+ handle(e);
+ } catch (InterruptedException e) {
+ // Show any problems that have occured so far
+ handle(null);
+ }
+ }
+
+ /**
+ * Add a status to the list of accumulated status.
+ * These will be provided to method handle(Exception, IStatus[])
+ * when the action completes.
+ */
+ protected void addStatus(IStatus status) {
+ accumulatedStatus.add(status);
+ }
+
+ /**
+ * Return the list of status accumulated so far by the action. This
+ * will include any OK status that were added using addStatus(IStatus)
+ */
+ protected IStatus[] getAccumulatedStatus() {
+ return (IStatus[]) accumulatedStatus.toArray(new IStatus[accumulatedStatus.size()]);
+ }
+
+ /**
+ * Return the title to be displayed on error dialogs.
+ * Sunclasses should override to present a custon message.
+ */
+ protected String getErrorTitle() {
+ return Policy.bind("CVSAction.errorTitle"); //$NON-NLS-1$
+ }
+
+ /**
+ * Return the title to be displayed on error dialogs when warnigns occur.
+ * Sunclasses should override to present a custon message.
+ */
+ protected String getWarningTitle() {
+ return Policy.bind("CVSAction.warningTitle"); //$NON-NLS-1$
+ }
+
+ /**
+ * Return the message to be used for the parent MultiStatus when
+ * mulitple errors occur during an action.
+ * Sunclasses should override to present a custon message.
+ */
+ protected String getMultiStatusMessage() {
+ return Policy.bind("CVSAction.multipleProblemsMessage"); //$NON-NLS-1$
+ }
+
+ /**
+ * Return the status to be displayed in an error dialog for the given list
+ * of non-OK status.
+ *
+ * This method can be overridden bu subclasses. Returning an OK status will
+ * prevent the error dialog from being shown.
+ */
+ protected IStatus getStatusToDisplay(IStatus[] problems) {
+ if (problems.length == 1) {
+ return problems[0];
+ }
+ MultiStatus combinedStatus = new MultiStatus(CVSUIPlugin.ID, 0, getMultiStatusMessage(), null); //$NON-NLS-1$
+ for (int i = 0; i < problems.length; i++) {
+ combinedStatus.merge(problems[i]);
+ }
+ return combinedStatus;
+ }
+
+ /**
+ * Method that implements generic handling of an exception.
+ *
+ * Thsi method will also use any accumulated status when determining what
+ * information (if any) to show the user.
+ *
+ * @param exception the exception that occured (or null if none occured)
+ * @param status any status accumulated by the action before the end of
+ * the action or the exception occured.
+ */
+ protected void handle(Exception exception) {
+ // Get the non-OK statii
+ List problems = new ArrayList();
+ IStatus[] status = getAccumulatedStatus();
+ if (status != null) {
+ for (int i = 0; i < status.length; i++) {
+ IStatus iStatus = status[i];
+ if ( ! iStatus.isOK() || iStatus.getCode() == CVSStatus.SERVER_ERROR) {
+ problems.add(iStatus);
+ }
+ }
+ }
+ // Handle the case where there are no problem statii
+ if (problems.size() == 0) {
+ if (exception == null) return;
+ handle(exception, getErrorTitle(), null);
+ return;
+ }
+
+ // For now, display both the exception and the problem status
+ // Later, we can determine how to display both together
+ if (exception != null) {
+ handle(exception, getErrorTitle(), null);
+ }
+
+ String message = null;
+ IStatus statusToDisplay = getStatusToDisplay((IStatus[]) problems.toArray(new IStatus[problems.size()]));
+ if (statusToDisplay.isOK()) return;
+ if (statusToDisplay.isMultiStatus() && statusToDisplay.getChildren().length == 1) {
+ message = statusToDisplay.getMessage();
+ statusToDisplay = statusToDisplay.getChildren()[0];
+ }
+ String title;
+ if (statusToDisplay.getSeverity() == IStatus.ERROR) {
+ title = getErrorTitle();
+ } else {
+ title = getWarningTitle();
+ }
+ ErrorDialog.openError(getShell(), title, message, statusToDisplay);
}
/**
* Actions must override to do their work.
*/
- abstract protected void execute(IAction action);
+ abstract protected void execute(IAction action) throws InvocationTargetException, InterruptedException;
/**
* Answers if the action would like dirty editors to saved
@@ -119,6 +251,36 @@ abstract public class CVSAction extends TeamAction {
}
return false;
}
+
+ /**
+ * Returns the selected CVS resources
+ */
+ protected ICVSResource[] getSelectedCVSResources() {
+ ArrayList resources = null;
+ if (!selection.isEmpty()) {
+ resources = new ArrayList();
+ Iterator elements = ((IStructuredSelection) selection).iterator();
+ while (elements.hasNext()) {
+ Object next = elements.next();
+ if (next instanceof ICVSResource) {
+ resources.add(next);
+ continue;
+ }
+ if (next instanceof IAdaptable) {
+ IAdaptable a = (IAdaptable) next;
+ Object adapter = a.getAdapter(ICVSResource.class);
+ if (adapter instanceof ICVSResource) {
+ resources.add(adapter);
+ continue;
+ }
+ }
+ }
+ }
+ if (resources != null && !resources.isEmpty()) {
+ return (ICVSResource[])resources.toArray(new ICVSResource[resources.size()]);
+ }
+ return new ICVSResource[0];
+ }
/**
* Checks if a the resources' parent's tags are different then the given tag.
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MoveTagAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MoveTagAction.java
deleted file mode 100644
index 5db05a30b..000000000
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/MoveTagAction.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2002 IBM Corporation and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Common Public License v0.5
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/cpl-v05.html
- *
- * Contributors:
- * IBM - Initial API and implementation
- ******************************************************************************/
-package org.eclipse.team.internal.ccvs.ui.actions;
-
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
-
-import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.core.runtime.IProgressMonitor;
-import org.eclipse.core.runtime.SubProgressMonitor;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.dialogs.Dialog;
-import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.team.core.TeamException;
-import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSFolder;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
-import org.eclipse.team.internal.ccvs.core.client.Command;
-import org.eclipse.team.internal.ccvs.core.client.RTag;
-import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
-import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.team.internal.ccvs.ui.TagSelectionDialog;
-import org.eclipse.team.internal.ui.actions.TeamAction;
-
-public class MoveTagAction extends TeamAction {
-
- /**
- * Returns the selected remote folders
- */
- protected ICVSFolder[] getSelectedFolders() {
- ArrayList resources = null;
- if (!selection.isEmpty()) {
- resources = new ArrayList();
- Iterator elements = ((IStructuredSelection) selection).iterator();
- while (elements.hasNext()) {
- Object next = elements.next();
- if (next instanceof ICVSFolder) {
- resources.add(next);
- continue;
- }
- if (next instanceof IAdaptable) {
- IAdaptable a = (IAdaptable) next;
- Object adapter = a.getAdapter(ICVSFolder.class);
- if (adapter instanceof ICVSFolder) {
- resources.add(adapter);
- continue;
- }
- }
- }
- }
- if (resources != null && !resources.isEmpty()) {
- return (ICVSFolder[])resources.toArray(new ICVSFolder[resources.size()]);
- }
- return new ICVSFolder[0];
- }
-
- /**
- * @see TeamAction#isEnabled()
- */
- protected boolean isEnabled() throws TeamException {
- ICVSFolder[] resources = getSelectedFolders();
- if (resources.length == 0) return false;
- return true;
- }
-
- /**
- * @see IActionDelegate#run(IAction)
- */
- public void run(IAction action) {
-
- // Setup the holders
- final CVSTag[] tag = new CVSTag[] {null};
- final ICVSFolder[] folders = getSelectedFolders();
- final boolean[] recursive = new boolean[] {false};
-
- // Show a busy cursor while display the tag selection dialog
- run(new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InterruptedException, InvocationTargetException {
-
- if(folders.length == 0) {
- // nothing to do
- return;
- }
-
- TagSelectionDialog dialog = new TagSelectionDialog(getShell(), folders,
- Policy.bind("MoveTagAction.title"), //$NON-NLS-1$
- Policy.bind("MoveTagAction.message"), false, true); //$NON-NLS-1$
- dialog.setBlockOnOpen(true);
- if (dialog.open() == Dialog.CANCEL) {
- return;
- }
- tag[0] = dialog.getResult();
- recursive[0] = dialog.getRecursive();
-
- }
- }, Policy.bind("MoveTagAction.errorMessage"), this.PROGRESS_BUSYCURSOR); //$NON-NLS-1$
-
- // Show progress while tagging remotely
- if (tag[0] == null) return;
- run(new IRunnableWithProgress() {
- public void run(IProgressMonitor monitor) throws InvocationTargetException {
- try {
- monitor.beginTask(null, 1000 * folders.length);
- LocalOption[] options;
- if(recursive[0]) {
- options = new LocalOption[] {RTag.FORCE_REASSIGNMENT, RTag.CLEAR_FROM_REMOVED};
- } else {
- options = new LocalOption[] {RTag.FORCE_REASSIGNMENT, RTag.CLEAR_FROM_REMOVED, Command.DO_NOT_RECURSE};
- }
- for (int i = 0; i < folders.length; i++) {
- ((ICVSRemoteFolder)folders[i]).tag(tag[0], options, new SubProgressMonitor(monitor, 1000));
- }
- } catch (TeamException e) {
- throw new InvocationTargetException(e);
- }
- }
- }, Policy.bind("MoveTagAction.errorMessage"), this.PROGRESS_DIALOG); //$NON-NLS-1$
- }
-
-}
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 9b6b12d14..774dd062c 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
@@ -24,6 +24,7 @@ import org.eclipse.jface.dialogs.InputDialog;
import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.team.core.RepositoryProvider;
import org.eclipse.team.core.TeamException;
+import org.eclipse.team.internal.ccvs.core.CVSException;
import org.eclipse.team.internal.ccvs.core.CVSProviderPlugin;
import org.eclipse.team.internal.ccvs.core.CVSStatus;
import org.eclipse.team.internal.ccvs.core.CVSTag;
@@ -42,20 +43,18 @@ import org.eclipse.team.internal.ui.actions.TeamAction;
/**
* TagAction tags the selected resources with a version tag specified by the user.
*/
-public class TagAction extends TeamAction {
+public class TagAction extends CVSAction {
// The previously remembered tag
private static String previousTag = ""; //$NON-NLS-1$
- /*
- * @see IActionDelegate#run(IAction)
+ /**
+ * @see CVSAction#execute(IAction)
*/
- public void run(IAction action) {
- final List messages = new ArrayList();
- final int[] failureCount = new int[] {0};
- final int[] resourceCount = new int[] {0};
+ public void execute(IAction action) throws InvocationTargetException, InterruptedException {
+ // Prompt for any uncommitted changes
PromptingDialog prompt = new PromptingDialog(getShell(), getSelectedResources(),
- getPromptCondition(), Policy.bind("TagAction.uncommittedChangesTitle"));//$NON-NLS-1$
+ getPromptCondition(), Policy.bind("TagAction.uncommittedChangesTitle"));//$NON-NLS-1$
final IResource[] resources;
try {
resources = prompt.promptForMultiple();
@@ -67,7 +66,7 @@ public class TagAction extends TeamAction {
return;
}
- resourceCount[0] = resources.length;
+ // Prompt for the tag name
final String[] result = new String[1];
getShell().getDisplay().syncExec(new Runnable() {
public void run() {
@@ -77,7 +76,8 @@ public class TagAction extends TeamAction {
});
if (result[0] == null) return;
- run(new IRunnableWithProgress() {
+ // Tag the local resources, divided by project/provider
+ CVSUIPlugin.runWithProgress(getShell(), true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
Hashtable table = getProviderMapping(resources);
Set keySet = table.keySet();
@@ -90,12 +90,12 @@ public class TagAction extends TeamAction {
List list = (List)table.get(provider);
IResource[] providerResources = (IResource[])list.toArray(new IResource[list.size()]);
CVSTag tag = new CVSTag(result[0], CVSTag.VERSION);
- IStatus status = provider.tag(providerResources, IResource.DEPTH_INFINITE, tag, subMonitor);
- if (status.getCode() != CVSStatus.OK) {
- messages.add(status);
- failureCount[0]++;
+ try {
+ addStatus(provider.tag(providerResources, IResource.DEPTH_INFINITE, tag, subMonitor));
+ } catch (CVSException e) {
+ throw new InvocationTargetException(e);
}
- // Cache the new tag creation even if the tag may of has warnings.
+ // Cache the new tag creation even if the tag may have had warnings.
CVSUIPlugin.getPlugin().getRepositoryManager().addVersionTags(
CVSWorkspaceRoot.getCVSFolderFor(provider.getProject()),
new CVSTag[] {tag});
@@ -103,41 +103,28 @@ public class TagAction extends TeamAction {
}
previousTag = result[0];
}
- }, Policy.bind("TagAction.tagProblemsMessage"), this.PROGRESS_DIALOG); //$NON-NLS-1$
+ });
+ }
+
+ /**
+ * Override to dislay the number of tag operations that succeeded
+ */
+ protected IStatus getStatusToDisplay(IStatus[] problems) {
+ // We accumulated 1 status per resource above.
+ IStatus[] status = getAccumulatedStatus();
+ int resourceCount = status.length;
- // Check for any status messages and display them
- if (!messages.isEmpty()) {
- boolean error = false;
- MultiStatus combinedStatus;
- if(resourceCount[0] == 1) {
- combinedStatus = new MultiStatus(CVSUIPlugin.ID, 0, Policy.bind("TagAction.tagProblemsMessage"), null); //$NON-NLS-1$
- } else {
- combinedStatus = new MultiStatus(CVSUIPlugin.ID, 0, Policy.bind("TagAction.tagProblemsMessageMultiple", //$NON-NLS-1$
- Integer.toString(resourceCount[0] - failureCount[0]), Integer.toString(failureCount[0])), null); //$NON-NLS-1$
- }
- for (int i = 0; i < messages.size(); i++) {
- IStatus status = (IStatus)messages.get(i);
- if (status.getSeverity() == IStatus.ERROR || status.getCode() == CVSStatus.SERVER_ERROR) {
- error = true;
- }
- combinedStatus.merge(status);
- }
- String message = null;
- IStatus statusToDisplay;
- if (combinedStatus.getChildren().length == 1) {
- message = combinedStatus.getMessage();
- statusToDisplay = combinedStatus.getChildren()[0];
- } else {
- statusToDisplay = combinedStatus;
- }
- String title;
- if (error) {
- title = Policy.bind("TagAction.tagErrorTitle"); //$NON-NLS-1$
- } else {
- title = Policy.bind("TagAction.tagWarningTitle"); //$NON-NLS-1$
- }
- ErrorDialog.openError(getShell(), title, message, statusToDisplay);
- }
+ MultiStatus combinedStatus;
+ if(resourceCount == 1) {
+ combinedStatus = new MultiStatus(CVSUIPlugin.ID, 0, Policy.bind("TagAction.tagProblemsMessage"), null); //$NON-NLS-1$
+ } else {
+ combinedStatus = new MultiStatus(CVSUIPlugin.ID, 0, Policy.bind("TagAction.tagProblemsMessageMultiple", //$NON-NLS-1$
+ Integer.toString(resourceCount - problems.length), Integer.toString(problems.length)), null); //$NON-NLS-1$
+ }
+ for (int i = 0; i < problems.length; i++) {
+ combinedStatus.merge(problems[i]);
+ }
+ return combinedStatus;
}
/*
@@ -186,5 +173,13 @@ public class TagAction extends TeamAction {
}
};
}
+
+ protected String getErrorTitle() {
+ return Policy.bind("TagAction.tagErrorTitle");
+ }
+
+ protected String getWarningTitle() {
+ return Policy.bind("TagAction.tagWarningTitle");
+ }
}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagInRepositoryAction.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagInRepositoryAction.java
index 68e28178a..33a93fcd6 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagInRepositoryAction.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/actions/TagInRepositoryAction.java
@@ -11,97 +11,122 @@
package org.eclipse.team.internal.ccvs.ui.actions;
import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.Iterator;
-import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.core.runtime.SubProgressMonitor;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.operation.IRunnableWithProgress;
-import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.team.core.TeamException;
import org.eclipse.team.internal.ccvs.core.CVSTag;
-import org.eclipse.team.internal.ccvs.core.ICVSRemoteFolder;
+import org.eclipse.team.internal.ccvs.core.ICVSFolder;
+import org.eclipse.team.internal.ccvs.core.ICVSRemoteResource;
import org.eclipse.team.internal.ccvs.core.ICVSRepositoryLocation;
-import org.eclipse.team.internal.ccvs.core.client.Checkout;
+import org.eclipse.team.internal.ccvs.core.ICVSResource;
import org.eclipse.team.internal.ccvs.core.client.Command;
+import org.eclipse.team.internal.ccvs.core.client.Command.LocalOption;
+import org.eclipse.team.internal.ccvs.ui.CVSUIPlugin;
import org.eclipse.team.internal.ccvs.ui.Policy;
-import org.eclipse.ui.actions.WorkspaceModifyOperation;
public class TagInRepositoryAction extends TagAction {
+
/**
- * Returns the selected remote folders
+ * @see TeamAction#isEnabled()
*/
- protected ICVSRemoteFolder[] getSelectedRemoteFolders() {
- ArrayList resources = null;
- if (!selection.isEmpty()) {
- resources = new ArrayList();
- Iterator elements = ((IStructuredSelection) selection).iterator();
- while (elements.hasNext()) {
- Object next = elements.next();
- if (next instanceof ICVSRemoteFolder) {
- if (!Checkout.ALIAS.isElementOf(((ICVSRemoteFolder)next).getLocalOptions())) {
- resources.add(next);
- }
- continue;
- }
- if (next instanceof IAdaptable) {
- IAdaptable a = (IAdaptable) next;
- Object adapter = a.getAdapter(ICVSRemoteFolder.class);
- if (adapter instanceof ICVSRemoteFolder) {
- if (!Checkout.ALIAS.isElementOf(((ICVSRemoteFolder)adapter).getLocalOptions())) {
- resources.add(adapter);
- }
- continue;
- }
- }
- }
- }
- if (resources != null && !resources.isEmpty()) {
- return (ICVSRemoteFolder[])resources.toArray(new ICVSRemoteFolder[resources.size()]);
+ protected boolean isEnabled() throws TeamException {
+ ICVSResource[] resources = getSelectedCVSResources();
+ if (resources.length == 0) return false;
+ for (int i = 0; i < resources.length; i++) {
+ if (resources[i] instanceof ICVSRepositoryLocation) return false;
}
- return new ICVSRemoteFolder[0];
+ return true;
+ }
+
+ /**
+ * @see CVSAction#needsToSaveDirtyEditors()
+ */
+ protected boolean needsToSaveDirtyEditors() {
+ return false;
}
- /*
- * @see IActionDelegate#run(IAction)
+ /**
+ * @see CVSAction#execute(IAction)
*/
- public void run(IAction action) {
- run(new IRunnableWithProgress() {
+ public void execute(IAction action) throws InvocationTargetException, InterruptedException {
+
+ // Prompt for the tag
+ final ICVSResource[] resources = getSelectedCVSResources();
+ final CVSTag[] tag = new CVSTag[] { null };
+ getShell().getDisplay().syncExec(new Runnable() {
+ public void run() {
+ // Collect the parent folders from which to determine the tags to show
+ ICVSFolder[] folders = new ICVSFolder[resources.length];
+ for (int i = 0; i < resources.length; i++) {
+ if (resources[i].isFolder()) {
+ folders[i] = (ICVSFolder)resources[i];
+ } else {
+ folders[i] = resources[i].getParent();
+ }
+ }
+ tag[0] = promptForTag(folders);
+ }
+ });
+ if (tag[0] == null) return;
+
+ CVSUIPlugin.runWithProgress(getShell(), true, new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) throws InvocationTargetException {
try {
- final ICVSRemoteFolder[] folders = getSelectedRemoteFolders();
- final String[] result = new String[1];
- getShell().getDisplay().syncExec(new Runnable() {
- public void run() {
- result[0] = promptForTag(folders[0]);
- }
- });
- if (result[0] == null) return;
-
- monitor.beginTask(null, 1000 * folders.length);
- CVSTag tag = new CVSTag(result[0], CVSTag.VERSION);
-
- for (int i = 0; i < folders.length; i++) {
- folders[i].tag(tag, Command.NO_LOCAL_OPTIONS, new SubProgressMonitor(monitor, 1000));
+ monitor.beginTask(null, 1000 * resources.length);
+ for (int i = 0; i < resources.length; i++) {
+ IStatus status = ((ICVSRemoteResource)resources[i]).tag(tag[0], getLocalOptions(), new SubProgressMonitor(monitor, 1000));
+ addStatus(status);
}
} catch (TeamException e) {
throw new InvocationTargetException(e);
}
}
- }, Policy.bind("TagAction.tagProblemsMessage"), this.PROGRESS_DIALOG); //$NON-NLS-1$
+ });
+ }
+
+ /**
+ * Prompt for the tag to be used by the tagging operation. The default behavior
+ * is to prompt for a name and return a version tag of that name.
+ *
+ * Subclasses can override.
+ *
+ * @param folders the folders from which to obtain a list of existing tags
+ * @return CVSTag the tag chosen
+ */
+ protected CVSTag promptForTag(ICVSFolder[] folders) {
+ String name = promptForTag(folders[0]);
+ return new CVSTag(name, CVSTag.VERSION);
}
- /*
- * @see TeamAction#isEnabled()
+ /**
+ * Return the local options that should be used with the rtag command
*/
- protected boolean isEnabled() throws TeamException {
- ICVSRemoteFolder[] resources = getSelectedRemoteFolders();
- if (resources.length == 0) return false;
- for (int i = 0; i < resources.length; i++) {
- if (resources[i] instanceof ICVSRepositoryLocation) return false;
+ protected LocalOption[] getLocalOptions() {
+ return Command.NO_LOCAL_OPTIONS;
+ }
+
+ /**
+ * Override to dislay the number of tag operations that succeeded
+ */
+ protected IStatus getStatusToDisplay(IStatus[] problems) {
+ // We accumulated 1 status per resource above.
+ IStatus[] status = getAccumulatedStatus();
+ int resourceCount = status.length;
+
+ MultiStatus combinedStatus;
+ if(resourceCount == 1) {
+ combinedStatus = new MultiStatus(CVSUIPlugin.ID, 0, Policy.bind("TagInRepositoryAction.tagProblemsMessage"), null); //$NON-NLS-1$
+ } else {
+ combinedStatus = new MultiStatus(CVSUIPlugin.ID, 0, Policy.bind("TagInRepositoryAction.tagProblemsMessageMultiple"), null); //$NON-NLS-1$
}
- return true;
+ for (int i = 0; i < problems.length; i++) {
+ combinedStatus.merge(problems[i]);
+ }
+ return combinedStatus;
}
-} \ No newline at end of file
+}
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
index 1bb326151..90e0b8341 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/messages.properties
@@ -51,6 +51,9 @@ ConsolePreferencePage.errorColor=&Error:
ConsolePreferencePage.font=Console font setting:
ConsolePreferencePage.autoOpen=&Show CVS Console when there is output
+CVSAction.errorTitle=Errors Occured
+CVSAction.warningTitle=Warnings Occured
+CVSAction.multipleProblemsMessage=Multiple problems occured:
CVSAction.mixingTagsTitle=Confirm Mixing Tags
CVSAction.mixingTags=You are mixing tags within a project. Beware that synchronization uses the tag information associated with each resource to determine the remote resource with which the local resource is compared. \n\nThis means that the part(s) of your project that you are replacing with another tag will be synchronized with the tag ''{0}'' while others resources in the project will be sychronized with another tag. \n\nDo you wish to continue?
@@ -512,6 +515,9 @@ TagAction.uncommittedChanges=You are tagging ''{0}'' that has uncommitted change
TagAction.tagAlreadyExists=Version tag already exists.
TagAction.existingVersions=Existing Versions:
+TagInRepositoryAction.tagProblemsMessage=Problems reported tagging the resource.
+TagInRepositoryAction.tagProblemsMessageMultiple=Problems reported tagging the resources.
+
UpdateAction.update=Problems encountered performing update
UpdateAction.updating=Updating...

Back to the top