Bug 79401 [ErrorHandling] Duplicate presentation of error messages
1) Create a simple project with a simple folder inside it. 2) In Windows Explorer, expand the project and select the folder in the left pane. 3) Back in the Navigator view, try to rename the project. -> Rename fails because it cannot rename because Windows won't let you delete a folder that is being viewed in Windows Explorer. This is expected. Platform core returns a MultiStatus of the following form: MultiStatus ("problems encountered moving resources") MultiStatus ("Copy successful, but problems occurred removing old resources") Status ("Could not delete: d:\eclipse\test2\simple") The UI Error dialog shows the following in the details area: Problems occurred renaming the selected resource. Problems encountered while moving resources. Copy successful, but problems occurred removing old resources Could not delete: d:\eclipse\test2\simple\abc. Copy successful, but problems occurred removing old resources Could not delete: d:\eclipse\test2\simple\abc. Notice that the child MultiStatus from core is displayed twice. The root of this duplication is WorkspaceAction.recordError: private void recordError(CoreException error) { if (errorStatus == null) errorStatus = new MultiStatus(IDEWorkbenchPlugin.IDE_WORKBENCH, IStatus.ERROR, getProblemsMessage(), error); errorStatus.merge(error.getStatus()); } Observe that it stores the CoreException in the MultiStatus, *and* adds the error's status as a child of the MultiStatus. The JFace ErrorDialog class, when presented with this MultiStatus, recursively prints all MultiStatus objects, and all statuses contained within CoreExceptions. Since this MultiStatus contains both the original MultiStatus and the CoreException that carried it, it will get printed twice. The suggested fix is to not include the CoreException in the MultiStatus in recordError: private void recordError(CoreException error) { if (errorStatus == null) errorStatus = new MultiStatus(IDEWorkbenchPlugin.IDE_WORKBENCH, IStatus.ERROR, getProblemsMessage(), null); errorStatus.merge(error.getStatus()); } I tested this fix, and it produced an error dialog containing: Problems occurred renaming the selected resource. Copy successful, but problems occurred removing old resources Could not delete: d:\eclipse\test2\simon\abc.
bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/WorkspaceAction.java
* @see #shouldPerformResourcePruning
     */
    List pruneResources(List resourceCollection) {
        List prunedList = new ArrayList(resourceCollection);
        Iterator elementsEnum = prunedList.iterator();
        while (elementsEnum.hasNext()) {
            IResource currentResource = (IResource) elementsEnum.next();
            if (isDescendent(prunedList, currentResource))
                elementsEnum.remove(); 
        }
        return prunedList;
    }
    /**
     * Records the core exception to be displayed to the user
     * once the action is finished.
     *
     * @param error a <code>CoreException</code>
     */
    MultiStatus recordError(MultiStatus errors, CoreException error) {
        if (errors == null)
        	errors = new MultiStatus(IDEWorkbenchPlugin.IDE_WORKBENCH,
                    IStatus.ERROR, getProblemsMessage(), error);
        errors.merge(error.getStatus());
        return errors;
    }
    /**
     * The <code>CoreWrapperAction</code> implementation of this <code>IAction</code>
     * method uses a <code>ProgressMonitorDialog</code> to run the operation. The
     * operation calls <code>execute</code> (which, in turn, calls 
     * <code>invokeOperation</code>). Afterwards, any <code>CoreException</code>s