diff options
author | Michael Valenta | 2005-03-14 21:43:42 +0000 |
---|---|---|
committer | Michael Valenta | 2005-03-14 21:43:42 +0000 |
commit | 6c332998ff79a689ed729443ded6cd4afd602fc4 (patch) | |
tree | 9db4b454540da5f7eeb106f88c8a28ebdad7107d | |
parent | 914b290676b1fd7a3666c900d58270d0de8eef8f (diff) | |
download | eclipse.platform.team-6c332998ff79a689ed729443ded6cd4afd602fc4.tar.gz eclipse.platform.team-6c332998ff79a689ed729443ded6cd4afd602fc4.tar.xz eclipse.platform.team-6c332998ff79a689ed729443ded6cd4afd602fc4.zip |
3 files changed, 51 insertions, 28 deletions
diff --git a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSStatus.java b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSStatus.java index ab689ae24..5c10399ea 100644 --- a/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSStatus.java +++ b/bundles/org.eclipse.team.cvs.core/src/org/eclipse/team/internal/ccvs/core/CVSStatus.java @@ -10,6 +10,7 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.core; +import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; public class CVSStatus extends Status { @@ -68,4 +69,45 @@ public class CVSStatus extends Status { return message; } + /** + * Return whether this status is wrapping an internal error. + * An internal error is any error for which the wrapped exception + * is not a CVS exception. Check deeply to make sure there isn't + * an internal error buried deep down. + * @return whether this status is wrapping an internal error + */ + public boolean isInternalError() { + Throwable ex = getException(); + if (ex instanceof CVSException) { + CVSException cvsEx = (CVSException) ex; + IStatus status = cvsEx.getStatus(); + return isInternalError(status); + } + return ex != null; + } + + /** + * Return whether this status is wrapping an internal error. + * An internal error is any error for which the wrapped exception + * is not a CVS exception. Check deeply to make sure there isn't + * an internal error buried deep down. + * @return whether this status is wrapping an internal error + */ + public static boolean isInternalError(IStatus status) { + if (status instanceof CVSStatus) { + return ((CVSStatus)status).isInternalError(); + } + if (status.isMultiStatus()) { + IStatus[] children = status.getChildren(); + for (int i = 0; i < children.length; i++) { + IStatus child = children[i]; + if (isInternalError(child)) { + return true; + } + } + return false; + } + return true; + } + } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java index eb2042bf2..30d3e3e87 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CVSOperation.java @@ -182,27 +182,27 @@ public abstract class CVSOperation extends TeamOperation { * Subclasses may override. * @throws CVSException an exception if appropriate */ - protected void handleErrors(IStatus[] errors) throws CVSException { + protected final void handleErrors(IStatus[] errors) throws CVSException { // We are only concerned with reportable errors. // Others will appear in the console - List serverErrors = new ArrayList(); + List reportableErrors = new ArrayList(); for (int i = 0; i < errors.length; i++) { IStatus status = errors[i]; if (isReportableError(status)) { - serverErrors.add(status); + reportableErrors.add(status); } else if (status.isMultiStatus()) { IStatus[] children = status.getChildren(); for (int j = 0; j < children.length; j++) { IStatus child = children[j]; if (isReportableError(child)) { - serverErrors.add(status); + reportableErrors.add(status); break; } } } } - if (!serverErrors.isEmpty()) - asException((IStatus[]) serverErrors.toArray(new IStatus[serverErrors.size()])); + if (!reportableErrors.isEmpty()) + asException((IStatus[]) reportableErrors.toArray(new IStatus[reportableErrors.size()])); } /** @@ -212,10 +212,10 @@ public abstract class CVSOperation extends TeamOperation { * @return whether the status is reportable or should be ignored */ protected boolean isReportableError(IStatus status) { - return status.getCode() == CVSStatus.SERVER_ERROR; + return status.getCode() == CVSStatus.SERVER_ERROR || CVSStatus.isInternalError(status); } - - protected String getErrorMessage(IStatus[] failures, int totalOperations) { + + protected String getErrorMessage(IStatus[] failures, int totalOperations) { return Policy.bind("CVSOperation.0", String.valueOf(failures.length), String.valueOf(totalOperations)); //$NON-NLS-1$ } diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java index 207e7b406..84e3aa43a 100644 --- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java +++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/operations/CommitOperation.java @@ -10,9 +10,6 @@ *******************************************************************************/ package org.eclipse.team.internal.ccvs.ui.operations; -import java.util.ArrayList; -import java.util.List; - import org.eclipse.core.resources.mapping.ResourceMapping; import org.eclipse.core.resources.mapping.ResourceMappingContext; import org.eclipse.core.runtime.IProgressMonitor; @@ -47,22 +44,6 @@ public class CommitOperation extends SingleCommandOperation { } /* (non-Javadoc) - * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#handleErrors(org.eclipse.core.runtime.IStatus[]) - */ - protected void handleErrors(IStatus[] errors) throws CVSException { - // We are only concerned with server errors - List serverErrors = new ArrayList(); - for (int i = 0; i < errors.length; i++) { - IStatus status = errors[i]; - if (status.getCode() == CVSStatus.SERVER_ERROR) { - serverErrors.add(status); - } - } - if (serverErrors.isEmpty()) return; - super.handleErrors((IStatus[]) serverErrors.toArray(new IStatus[serverErrors.size()])); - } - - /* (non-Javadoc) * @see org.eclipse.team.internal.ccvs.ui.operations.CVSOperation#getTaskName() */ protected String getTaskName() { |