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