Search in sources :

Example 66 with MultiStatus

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

the class ImportBndWorkspaceWizard method error.

private void error(final String message, final Throwable t) {
    // Log error
    Plugin.getDefault().getLog().log(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, message, t));
    // build the error message and include the current stack trace
    final MultiStatus status = createMultiStatus(t);
    Runnable run = new Runnable() {

        @Override
        public void run() {
            // show error dialog
            ErrorDialog.openError(null, "Error", message, status);
        }
    };
    if (Display.getCurrent() == null) {
        Display.getDefault().asyncExec(run);
    } else {
        run.run();
    }
}
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 67 with MultiStatus

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

the class AddFilesToRepositoryWizard method performFinishAddFiles.

private IStatus performFinishAddFiles(IProgressMonitor monitor) {
    MultiStatus status = new MultiStatus(Plugin.PLUGIN_ID, 0, "Failed to install one or more bundles", null);
    List<File> files = fileSelectionPage.getFiles();
    selectedBundles = new LinkedList<Pair<String, String>>();
    monitor.beginTask("Processing files", files.size());
    for (File file : files) {
        monitor.subTask(file.getName());
        try (Jar jar = new Jar(file)) {
            jar.setDoNotTouchManifest();
            Attributes mainAttribs = jar.getManifest().getMainAttributes();
            String bsn = BundleUtils.getBundleSymbolicName(mainAttribs);
            String version = mainAttribs.getValue(Constants.BUNDLE_VERSION);
            if (version == null)
                version = "0";
            selectedBundles.add(Pair.newInstance(bsn, version));
        } catch (Exception e) {
            status.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Failed to analyse JAR: {0}", file.getPath()), e));
            continue;
        }
        try {
            RepositoryPlugin.PutResult result = repository.put(new BufferedInputStream(IO.stream(file)), new RepositoryPlugin.PutOptions());
            if (result.artifact != null && result.artifact.getScheme().equals("file")) {
                File newFile = new File(result.artifact);
                RefreshFileJob refreshJob = new RefreshFileJob(newFile, false);
                if (refreshJob.needsToSchedule())
                    refreshJob.schedule();
            }
        } catch (Exception e) {
            status.add(new Status(IStatus.ERROR, Plugin.PLUGIN_ID, 0, MessageFormat.format("Failed to add JAR to repository: {0}", file.getPath()), e));
            continue;
        }
        monitor.worked(1);
    }
    return status;
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) Attributes(java.util.jar.Attributes) MultiStatus(org.eclipse.core.runtime.MultiStatus) RepositoryPlugin(aQute.bnd.service.RepositoryPlugin) RefreshFileJob(bndtools.central.RefreshFileJob) CoreException(org.eclipse.core.runtime.CoreException) BufferedInputStream(java.io.BufferedInputStream) Jar(aQute.bnd.osgi.Jar) File(java.io.File) Pair(bndtools.types.Pair)

Example 68 with MultiStatus

use of org.eclipse.core.runtime.MultiStatus in project dbeaver by serge-rider.

the class DataTransferWizard method createPageControls.

@Override
public void createPageControls(Composite pageContainer) {
    super.createPageControls(pageContainer);
    if (settings.getState().hasErrors()) {
        List<Throwable> loadErrors = settings.getState().getLoadErrors();
        if (loadErrors.size() == 1) {
            DBWorkbench.getPlatformUI().showError("Error loading configuration", "Error loading data transfer configuration", loadErrors.get(0));
        } else {
            List<IStatus> childStatuses = new ArrayList<>();
            for (Throwable error : loadErrors) {
                childStatuses.add(GeneralUtils.makeExceptionStatus(error));
            }
            MultiStatus status = new MultiStatus(DTUIActivator.PLUGIN_ID, 0, childStatuses.toArray(new IStatus[0]), "Multiple configuration errors", null);
            DBWorkbench.getPlatformUI().showError("Error loading configuration", status.getMessage(), status);
        }
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) MultiStatus(org.eclipse.core.runtime.MultiStatus)

Example 69 with MultiStatus

use of org.eclipse.core.runtime.MultiStatus in project snow-owl by b2ihealthcare.

the class ApplicationContext method handleErrorStatus.

/**
 * Convenience method for handling generic exceptions.
 * @param bundle
 * @param status
 */
public static void handleErrorStatus(final Bundle bundle, final IStatus status) {
    final MultiStatus multiStatus = getServiceInfo(bundle, status.getException());
    multiStatus.add(status);
    Platform.getLog(bundle).log(status);
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus)

Example 70 with MultiStatus

use of org.eclipse.core.runtime.MultiStatus in project snow-owl by b2ihealthcare.

the class ApplicationContext method handleException.

/**
 * Convenience method for handling generic exceptions.
 *
 * @param exception
 * @param errorMessage
 */
public static void handleException(final Bundle bundle, final Exception exception, final String errorMessage) {
    final MultiStatus errorStatus = getServiceInfo(bundle, exception);
    final IStatus status = new Status(IStatus.ERROR, bundle.getSymbolicName(), IStatus.ERROR, errorMessage, exception);
    errorStatus.add(status);
    Platform.getLog(bundle).log(status);
}
Also used : MultiStatus(org.eclipse.core.runtime.MultiStatus) Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IStatus(org.eclipse.core.runtime.IStatus) 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