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();
}
}
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;
}
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);
}
}
}
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);
}
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);
}
Aggregations