Search in sources :

Example 61 with MultiStatus

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

the class InstallableItem method install.

public IStatus install(File base, IProgressMonitor monitor) {
    File targetLocation = getTargetLocation(base);
    targetLocation.mkdirs();
    MultiStatus result = new MultiStatus(Activator.PLUGIN_ID, 0, NLS.bind("Installation of {0} failed", getName()), null);
    List<AbstractInstallOperation> operations = getInstallOperations();
    SubMonitor progress = SubMonitor.convert(monitor, NLS.bind("Installing {0}", getName()), operations.size());
    for (AbstractInstallOperation operation : operations) {
        try {
            operation.setSourceBase(getSourceLocation());
        } catch (CoreException e) {
            return e.getStatus();
        }
        operation.setTargetBase(targetLocation);
        IStatus status = operation.install(progress.newChild(1));
        result.add(status);
    }
    return result;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) CoreException(org.eclipse.core.runtime.CoreException) AbstractInstallOperation(org.springsource.ide.eclipse.commons.internal.configurator.operations.AbstractInstallOperation) SubMonitor(org.eclipse.core.runtime.SubMonitor) MultiStatus(org.eclipse.core.runtime.MultiStatus) File(java.io.File)

Example 62 with MultiStatus

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

the class AdvancedOptionsDialog method createStatus.

// TODO... This was copied from WindowUtility. Is there an easier way to
// create a status object?
// If not, we should open an eclipse bug or add a similar utility to
// baseExtensionsUI.
// 
private static IStatus createStatus(String reason, String msg) {
    String pluginId = XMLUIPlugin.getDefault().getBundle().getSymbolicName();
    MultiStatus multiStatus = new MultiStatus(pluginId, 0, reason, null);
    Status status = new Status(IStatus.ERROR, pluginId, 0, msg, null);
    multiStatus.add(status);
    return multiStatus;
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) MultiStatus(org.eclipse.core.runtime.MultiStatus)

Example 63 with MultiStatus

use of org.eclipse.core.runtime.MultiStatus in project bndtools by bndtools.

the class Central method toStatus.

/**
 * Convert a processor to a status object
 */
public static IStatus toStatus(Processor processor, String message) {
    int severity = IStatus.INFO;
    List<IStatus> statuses = new ArrayList<IStatus>();
    for (String error : processor.getErrors()) {
        Status status = new Status(IStatus.ERROR, BndtoolsConstants.CORE_PLUGIN_ID, error);
        statuses.add(status);
        severity = IStatus.ERROR;
    }
    for (String warning : processor.getWarnings()) {
        Status status = new Status(IStatus.WARNING, BndtoolsConstants.CORE_PLUGIN_ID, warning);
        statuses.add(status);
        severity = IStatus.WARNING;
    }
    IStatus[] array = statuses.toArray(new IStatus[0]);
    return new // 
    MultiStatus(// 
    BndtoolsConstants.CORE_PLUGIN_ID, // 
    severity, array, message, null);
}
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) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) MultiStatus(org.eclipse.core.runtime.MultiStatus)

Example 64 with MultiStatus

use of org.eclipse.core.runtime.MultiStatus in project bndtools by bndtools.

the class OSGiFrameworkContentProvider method refreshProviders.

private IStatus refreshProviders() {
    List<IStatus> statuses = new ArrayList<>();
    IConfigurationElement[] configElements = Platform.getExtensionRegistry().getConfigurationElementsFor(Plugin.PLUGIN_ID, "osgiFrameworks");
    for (IConfigurationElement element : configElements) {
        String frameworkName = element.getAttribute("name");
        String bsn = element.getAttribute("bsn");
        URL iconUrl = null;
        String iconPath = element.getAttribute("icon");
        if (iconPath != null) {
            Bundle contributorBundle = BundleUtils.findBundle(Plugin.getDefault().getBundleContext(), element.getContributor().getName(), null);
            if (contributorBundle != null)
                iconUrl = contributorBundle.getEntry(iconPath);
        }
        List<RepositoryPlugin> repositories;
        try {
            repositories = (workspace != null) ? workspace.getRepositories() : Collections.<RepositoryPlugin>emptyList();
        } catch (Exception e) {
            return new Status(IStatus.ERROR, Plugin.PLUGIN_ID, e.getMessage(), e);
        }
        for (RepositoryPlugin repo : repositories) {
            try {
                SortedSet<Version> versions = repo.versions(bsn);
                if (versions != null)
                    for (Version version : versions) {
                        try {
                            File framework = repo.get(bsn, version, null);
                            if (framework != null)
                                frameworks.add(new OSGiFramework(frameworkName, bsn, version, iconUrl));
                        } catch (Exception e) {
                            String msg = String.format("Error finding repository entry for OSGi framework %s, version %s.", bsn, version.toString());
                            logger.logError(msg, e);
                            statuses.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, msg, e));
                        }
                    }
            } catch (Exception e) {
                String msg = String.format("Error searching repository for OSGi framework %s.", bsn);
                logger.logError(msg, e);
                statuses.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, msg, e));
            }
        }
    }
    Display.getDefault().asyncExec(new Runnable() {

        @Override
        public void run() {
            structuredViewer.refresh(true);
        }
    });
    if (statuses.size() > 0) {
        return new MultiStatus(Plugin.PLUGIN_ID, IStatus.ERROR, statuses.toArray(new IStatus[0]), "Errors while refreshing OSGi framework providers.", null);
    }
    return Status.OK_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) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) MultiStatus(org.eclipse.core.runtime.MultiStatus) IConfigurationElement(org.eclipse.core.runtime.IConfigurationElement) URL(java.net.URL) Version(aQute.bnd.version.Version) File(java.io.File)

Example 65 with MultiStatus

use of org.eclipse.core.runtime.MultiStatus in project bndtools by bndtools.

the class ImportBndWorkspaceWizard method createMultiStatus.

/*
     * TODO probably something to move to Plugin creates a MultiStatus including StackTrace
     */
private static MultiStatus createMultiStatus(Throwable t) {
    List<Status> childStatuses = new ArrayList<>();
    StackTraceElement[] stackTraces = Thread.currentThread().getStackTrace();
    for (StackTraceElement stackTrace : stackTraces) {
        Status status = new Status(IStatus.ERROR, Plugin.PLUGIN_ID, stackTrace.toString());
        childStatuses.add(status);
    }
    MultiStatus ms = new MultiStatus(Plugin.PLUGIN_ID, IStatus.ERROR, childStatuses.toArray(new Status[] {}), t.toString(), t);
    return ms;
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) ArrayList(java.util.ArrayList) 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