Search in sources :

Example 86 with MultiStatus

use of org.eclipse.core.runtime.MultiStatus in project eclipse-integration-commons by spring-projects.

the class LegacyWorkspaceConverter method convert.

public IStatus convert(IProgressMonitor monitor) {
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    SubMonitor sub = SubMonitor.convert(monitor, 4);
    IStatus[] statuses = new IStatus[4];
    statuses[0] = copyPluginPreferences(sub);
    // nothing to do for grails any more
    // statuses[1] = convertGrailsWorkspacePreferences(sub);
    statuses[1] = Status.OK_STATUS;
    statuses[2] = convertRooWorkspacePreferences(sub);
    statuses[3] = convertSTSPreferences(sub);
    IStatus result = new MultiStatus(FrameworkCoreActivator.PLUGIN_ID, 0, statuses, "Result of converting legacy STS 2.x workspace preferences to 3.x", // $NON-NLS-1$
    null);
    // FrameworkCoreActivator.getDefault().getLog().log(result);
    if (result.isOK()) {
        PREFERENCE_STORE.setValue(LEGACY_MIGRATION_ALREADY_DONE, true);
    }
    return result;
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) SubMonitor(org.eclipse.core.runtime.SubMonitor) MultiStatus(org.eclipse.core.runtime.MultiStatus)

Example 87 with MultiStatus

use of org.eclipse.core.runtime.MultiStatus in project webtools.sourceediting by eclipse.

the class WSTWebPlugin method logError.

public static void logError(String message, CoreException exception) {
    MultiStatus status = new MultiStatus(PLUGIN_ID, IStatus.ERROR, new IStatus[] { exception.getStatus() }, message, exception);
    Platform.getLog(Platform.getBundle(PLUGIN_ID)).log(status);
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus)

Example 88 with MultiStatus

use of org.eclipse.core.runtime.MultiStatus in project webtools.sourceediting by eclipse.

the class TaskScanningJob method run.

protected IStatus run(IProgressMonitor monitor) {
    if (frameworkIsShuttingDown())
        return Status.CANCEL_STATUS;
    cleanupRememberedProjectList();
    IStatus status = null;
    List currentQueue = retrieveQueue();
    try {
        Thread.currentThread().setPriority(Thread.MIN_PRIORITY);
    } catch (SecurityException e) {
    // not a critical problem
    }
    List errors = null;
    int ticks = currentQueue.size();
    String taskName = null;
    if (Logger.DEBUG_TASKSJOB) {
        // $NON-NLS-1$ //$NON-NLS-2$
        taskName = SSECoreMessages.TaskScanningJob_0 + " (" + ticks + " work items)";
    } else {
        taskName = SSECoreMessages.TaskScanningJob_0;
    }
    monitor.beginTask(taskName, ticks);
    IProgressMonitor scanMonitor = null;
    while (!currentQueue.isEmpty()) {
        Object o = currentQueue.remove(0);
        if (frameworkIsShuttingDown() || monitor.isCanceled())
            return Status.CANCEL_STATUS;
        try {
            scanMonitor = new SubProgressMonitor(monitor, 1, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
            if (o instanceof IResourceDelta) {
                WorkspaceTaskScanner.getInstance().scan((IResourceDelta) o, scanMonitor);
            } else if (o instanceof IProject) {
                WorkspaceTaskScanner.getInstance().scan((IProject) o, scanMonitor);
                if (!scanMonitor.isCanceled()) {
                    String[] projectsPreviouslyScanned = getScannedProjects();
                    HashSet updatedProjects = new HashSet(Arrays.asList(projectsPreviouslyScanned));
                    updatedProjects.add(((IProject) o).getName());
                    setScannedProjects((String[]) updatedProjects.toArray(new String[updatedProjects.size()]));
                }
                if (!((IProject) o).isAccessible()) {
                    String[] projectsPreviouslyScanned = getScannedProjects();
                    HashSet updatedProjects = new HashSet(Arrays.asList(projectsPreviouslyScanned));
                    updatedProjects.remove(((IProject) o).getName());
                    setScannedProjects((String[]) updatedProjects.toArray(new String[updatedProjects.size()]));
                }
            }
        } catch (Exception e) {
            if (errors == null) {
                errors = new ArrayList();
            }
            // $NON-NLS-1$
            errors.add(new Status(IStatus.ERROR, SSECorePlugin.ID, IStatus.ERROR, "", e));
        }
    }
    monitor.done();
    if (errors == null || errors.isEmpty()) {
        status = Status.OK_STATUS;
    } else {
        if (errors.size() == 1) {
            status = (IStatus) errors.get(0);
        } else {
            IStatus[] statii = (IStatus[]) errors.toArray(new IStatus[errors.size()]);
            status = new MultiStatus(SSECorePlugin.ID, IStatus.ERROR, statii, SSECoreMessages.TaskScanningJob_1, null);
        }
    }
    SSECorePlugin.getDefault().savePluginPreferences();
    return status;
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) ArrayList(java.util.ArrayList) MultiStatus(org.eclipse.core.runtime.MultiStatus) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor) IProject(org.eclipse.core.resources.IProject) IOException(java.io.IOException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) ArrayList(java.util.ArrayList) List(java.util.List) IResourceDelta(org.eclipse.core.resources.IResourceDelta) HashSet(java.util.HashSet)

Example 89 with MultiStatus

use of org.eclipse.core.runtime.MultiStatus in project webtools.sourceediting by eclipse.

the class ToggleBreakpointAction method createBreakpoints.

protected boolean createBreakpoints(int lineNumber) {
    /*
		 * Note: we'll always allow processing to continue, even for a "read
		 * only" IStorageEditorInput, for the ActiveScript debugger. But this
		 * means sometimes the ActiveScript provider might get an input from
		 * CVS or something that is not related to debugging.
		 */
    ITextEditor editor = getTextEditor();
    IEditorInput input = editor.getEditorInput();
    IDocument document = editor.getDocumentProvider().getDocument(input);
    if (document == null)
        return false;
    String contentType = getContentType(document);
    IBreakpointProvider[] providers = BreakpointProviderBuilder.getInstance().getBreakpointProviders(editor, contentType, getFileExtension(input));
    int pos = -1;
    ISourceEditingTextTools tools = editor.getAdapter(ISourceEditingTextTools.class);
    if (tools != null) {
        pos = tools.getCaretOffset();
    }
    final int n = providers.length;
    List<IStatus> errors = new ArrayList<>(0);
    for (int i = 0; i < n; i++) {
        try {
            if (Debug.debugBreakpoints)
                // $NON-NLS-1$
                System.out.println(providers[i].getClass().getName() + " adding breakpoint to line " + lineNumber);
            IStatus status = providers[i].addBreakpoint(document, input, lineNumber, pos);
            if (status != null && !status.isOK()) {
                errors.add(status);
            }
        } catch (CoreException e) {
            errors.add(e.getStatus());
        } catch (Exception t) {
            // $NON-NLS-1$
            Logger.logException("exception while adding breakpoint", t);
        }
    }
    IStatus status = null;
    if (errors.size() > 0) {
        Shell shell = editor.getSite().getShell();
        if (errors.size() > 1) {
            // $NON-NLS-1$
            status = new MultiStatus(SSEUIPlugin.ID, IStatus.OK, errors.toArray(new IStatus[0]), SSEUIMessages.ManageBreakpoints_error_adding_message1, null);
        } else {
            status = errors.get(0);
        }
        if ((status.getSeverity() > IStatus.INFO) || (Platform.inDebugMode() && !status.isOK())) {
            Platform.getLog(SSEUIPlugin.getDefault().getBundle()).log(status);
        }
        /*
			 * Show for conditions more severe than INFO or when no
			 * breakpoints were created
			 */
        if (status.getSeverity() > IStatus.INFO && getBreakpoints(getMarkers()).length < 1) {
            // $NON-NLS-1$ //$NON-NLS-2$
            ErrorDialog.openError(shell, SSEUIMessages.ManageBreakpoints_error_adding_title1, status.getMessage(), status);
            return false;
        }
    }
    /*
		 * Although no errors were reported, no breakpoints exist on this line
		 * after having run the existing providers. Run the fallback action.
		 */
    if ((status == null || status.getSeverity() < IStatus.WARNING) && fFallbackAction != null && !hasMarkers()) {
        if (fFallbackAction instanceof ISelectionListener) {
            ((ISelectionListener) fFallbackAction).selectionChanged(null, null);
        }
        fFallbackAction.run();
    }
    return true;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) ArrayList(java.util.ArrayList) MultiStatus(org.eclipse.core.runtime.MultiStatus) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) CoreException(org.eclipse.core.runtime.CoreException) ISelectionListener(org.eclipse.ui.ISelectionListener) Shell(org.eclipse.swt.widgets.Shell) CoreException(org.eclipse.core.runtime.CoreException) ISourceEditingTextTools(org.eclipse.wst.sse.ui.internal.provisional.extensions.ISourceEditingTextTools) IBreakpointProvider(org.eclipse.wst.sse.ui.internal.provisional.extensions.breakpoint.IBreakpointProvider) IEditorInput(org.eclipse.ui.IEditorInput) IDocument(org.eclipse.jface.text.IDocument)

Example 90 with MultiStatus

use of org.eclipse.core.runtime.MultiStatus in project webtools.servertools by eclipse.

the class PreviewServerBehaviour method throwException.

/**
 * Utility method to throw a CoreException based on the contents of a list of
 * error and warning status.
 *
 * @param status a List containing error and warning IStatus
 * @throws CoreException
 */
private static void throwException(IStatus[] status) throws CoreException {
    if (status == null || status.length == 0)
        return;
    if (status.length == 1)
        throw new CoreException(status[0]);
    String message = Messages.errorPublish;
    MultiStatus status2 = new MultiStatus(PreviewPlugin.PLUGIN_ID, 0, status, message, null);
    throw new CoreException(status2);
}
Also used : CoreException(org.eclipse.core.runtime.CoreException) MultiStatus(org.eclipse.core.runtime.MultiStatus)

Aggregations

MultiStatus (org.eclipse.core.runtime.MultiStatus)146 IStatus (org.eclipse.core.runtime.IStatus)102 Status (org.eclipse.core.runtime.Status)62 CoreException (org.eclipse.core.runtime.CoreException)41 ArrayList (java.util.ArrayList)29 File (java.io.File)24 SubMonitor (org.eclipse.core.runtime.SubMonitor)24 IOException (java.io.IOException)14 InvocationTargetException (java.lang.reflect.InvocationTargetException)13 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)13 List (java.util.List)11 HashMap (java.util.HashMap)10 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)10 IPath (org.eclipse.core.runtime.IPath)8 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)8 FileNotFoundException (java.io.FileNotFoundException)7 HashSet (java.util.HashSet)7 IProject (org.eclipse.core.resources.IProject)7 IContainer (org.eclipse.core.resources.IContainer)6 URI (java.net.URI)5