Java Code Examples for org.eclipse.core.runtime.IStatus#isMultiStatus()
The following examples show how to use
org.eclipse.core.runtime.IStatus#isMultiStatus() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LabelProviderBuilder.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private Function<T, Optional<String>> tooltipProvider() { return element -> { if (statusProvider.isPresent()) { final IStatus status = statusProvider.get().apply(element); if (!status.isOK()) { if (status.isMultiStatus()) { return Optional.ofNullable(Arrays.asList(((MultiStatus) status).getChildren()).stream() .filter(s -> !s.isOK()) .map(IStatus::getMessage) .reduce((message1, message2) -> String.format("%s\n%s", message1, message2)).orElse("")); } return Optional.ofNullable(status.getMessage()); } } if (tooltipFunction.isPresent()) { return Optional.ofNullable(tooltipFunction.get().apply(element)); } return Optional.empty(); }; }
Example 2
Source File: AbstractLiveValidationMarkerConstraint.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private static Set<EObject> collectTargetElements(final IStatus status, final Set<EObject> targetElementCollector, final List allConstraintStatuses) { if (status instanceof IConstraintStatus) { targetElementCollector .add(((IConstraintStatus) status).getTarget()); allConstraintStatuses.add(status); } if (status.isMultiStatus()) { final IStatus[] children = status.getChildren(); for (int i = 0; i < children.length; i++) { collectTargetElements(children[i], targetElementCollector, allConstraintStatuses); } } return targetElementCollector; }
Example 3
Source File: LogUtils.java From eclipsegraphviz with Eclipse Public License 1.0 | 6 votes |
public static void log(Supplier<IStatus> statusSupplier) { IStatus status = statusSupplier.get(); if (!Platform.isRunning()) { System.err.println(status.getMessage()); if (status.getException() != null) status.getException().printStackTrace(); if (status.isMultiStatus()) for (IStatus child : status.getChildren()) log(child); return; } Bundle bundle = Platform.getBundle(status.getPlugin()); if (bundle == null) { String thisPluginId = LogUtils.class.getPackage().getName(); bundle = Platform.getBundle(thisPluginId); Platform.getLog(bundle).log( new Status(IStatus.WARNING, thisPluginId, "Could not find a plugin " + status.getPlugin() + " for logging as")); } Platform.getLog(bundle).log(status); }
Example 4
Source File: ModelEditor.java From tlaplus with MIT License | 6 votes |
private static IStatus shortenStatusMessage(IStatus status) { if (status.isMultiStatus()) { final IStatus[] convertedChildren = new Status[status.getChildren().length]; // convert nested status objects. final IStatus[] children = status.getChildren(); for (int i = 0; i < children.length; i++) { final IStatus child = children[i]; convertedChildren[i] = new Status(child.getSeverity(), child.getPlugin(), child.getCode(), substring(child.getMessage()), child.getException()); } return new MultiStatus(status.getPlugin(), status.getCode(), convertedChildren, substring(status.getMessage()), status.getException()); } else { return new Status(status.getSeverity(), status.getPlugin(), status.getCode(), substring(status.getMessage()), status.getException()); } }
Example 5
Source File: NavigatorResourceDropAssistant.java From gama with GNU General Public License v3.0 | 6 votes |
/** * Opens an error dialog if necessary. Takes care of complex rules necessary for making the error dialog look nice. */ private void openError(final IStatus status) { if (status == null) { return; } final String genericTitle = WorkbenchNavigatorMessages.DropAdapter_title; final int codes = IStatus.ERROR | IStatus.WARNING; // simple case: one error, not a multistatus if (!status.isMultiStatus()) { ErrorDialog.openError(getShell(), genericTitle, null, status, codes); return; } // one error, single child of multistatus final IStatus[] children = status.getChildren(); if (children.length == 1) { ErrorDialog.openError(getShell(), status.getMessage(), null, children[0], codes); return; } // several problems ErrorDialog.openError(getShell(), genericTitle, null, status, codes); }
Example 6
Source File: SVNOperation.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
protected void handleErrors(IStatus[] errors) throws SVNException { if (errors.length == 0) return; if (errors.length == 1 && statusCount == 1) { throw new SVNException(errors[0]); } MultiStatus result = new MultiStatus(SVNUIPlugin.ID, 0, getErrorMessage(errors, statusCount), null); for (int i = 0; i < errors.length; i++) { IStatus s = errors[i]; if (s.isMultiStatus()) { result.add(new SVNStatus(s.getSeverity(), s.getMessage(), s.getException())); result.addAll(s); } else { result.add(s); } } throw new SVNException(result); }
Example 7
Source File: Resources.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static IStatus addModified(IStatus status, IFile file) { IStatus entry= JavaUIStatus.createError( IJavaStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT, Messages.format(CorextMessages.Resources_fileModified, BasicElementLabels.getPathLabel(file.getFullPath(), false)), null); if (status == null) { return entry; } else if (status.isMultiStatus()) { ((MultiStatus)status).add(entry); return status; } else { MultiStatus result= new MultiStatus(JavaPlugin.getPluginId(), IJavaStatusConstants.VALIDATE_EDIT_CHANGED_CONTENT, CorextMessages.Resources_modifiedResources, null); result.add(status); result.add(entry); return result; } }
Example 8
Source File: StatusUtil.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Returns a string representation of a given status by collecting all the messages and put each one in a line of * its own. Note that this is most useful when dealing with {@link MultiStatus} instances.<br> * The class recursively drill down and collect all messages. Even from a nested {@link MultiStatus} children of the * given status. * * @param status * @return A string representation containing all the statuses messages. */ public static String toString(IStatus status) { StringBuilder builder = new StringBuilder(status.getMessage()); IStatus[] children = status.getChildren(); if (!ArrayUtil.isEmpty(children)) { builder.append(FileUtil.NEW_LINE); for (IStatus child : children) { if (child.isMultiStatus()) { // make a recursive call builder.append(toString(child)); } else { builder.append(child.getMessage()); } builder.append(FileUtil.NEW_LINE); } } return builder.toString(); }
Example 9
Source File: RepositoryStatusHelper.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
private static void deeplyPrint(IStatus status, PrintStream strm, boolean stackTrace, int level) { appendLevelString(strm, level); String msg = status.getMessage(); strm.println(msg); Throwable cause = status.getException(); if (cause != null) { strm.print("Caused by: "); //$NON-NLS-1$ if (stackTrace || !(msg.equals(cause.getMessage()) || msg.equals(cause.toString()))) deeplyPrint(cause, strm, stackTrace, level); } if (status.isMultiStatus()) { IStatus[] children = status.getChildren(); for (int i = 0; i < children.length; i++) deeplyPrint(children[i], strm, stackTrace, level + 1); } }
Example 10
Source File: StatusUtil.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
private static void print(PrintStream printStream, String indent, IStatus status) { if (status.isMultiStatus()) { String severityString = getSeverityString(status.getSeverity()); printStream.print("[" + severityString + "] " + indent + status.getMessage()); String childIndent = indent + " "; for (IStatus c : status.getChildren()) { print(printStream, childIndent, c); } } else if (status instanceof ObjectStatus) { ObjectStatus os = (ObjectStatus) status; printStream.println((os != null) ? os.getObject().toString() : null); } else { printStream.println(indent + status.getMessage()); } }
Example 11
Source File: ValidationTestBase.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private void collectStatuses(final IStatus status, final List<IStatus> statuses) { if (status.isMultiStatus()) { final IStatus[] children = status.getChildren(); for (final IStatus element : children) { collectStatuses(element, statuses); } } else { statuses.add(status); } }
Example 12
Source File: Repository.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void logErrorStatus(final IStatus status) { final StringBuilder sb = new StringBuilder(); if (status.isMultiStatus()) { for (final IStatus childStatus : status.getChildren()) { sb.append(childStatus.getMessage()).append("\n"); } } BonitaStudioLog.error("Export to archive failed.\n" + status.getMessage() + "\n" + sb.toString(), CommonRepositoryPlugin.PLUGIN_ID); }
Example 13
Source File: ExceptionHandler.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * @param e * @return */ @SuppressWarnings("unused") private boolean isInvalidResouceName(CoreException e) { IStatus status = e.getStatus(); if (status == null) { return false; } if (!ResourcesPlugin.PI_RESOURCES.equals(status.getPlugin())) { return false; } if (status.isMultiStatus()) { final IStatus[] children = status.getChildren(); for (int i = 0; i < children.length; ++i) { final IStatus child = children[i]; if (!(ResourcesPlugin.PI_RESOURCES.equals(status.getPlugin()) && child.getCode() == IResourceStatus.INVALID_RESOURCE_NAME)) { return false; } } return true; } else { if (status.getCode() == IResourceStatus.INVALID_RESOURCE_NAME) { return true; } } return false; }
Example 14
Source File: SVNException.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
public static SVNException wrapException(CoreException e) { IStatus status = e.getStatus(); // If the exception is not a multi-status, wrap the exception to keep the original stack trace. // If the exception is a multi-status, the interesting stack traces should be in the childen already if ( ! status.isMultiStatus()) { status = new SVNStatus(status.getSeverity(), status.getCode(), status.getMessage(), e); } return new SVNException(status); }
Example 15
Source File: ValidateAction.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @generated */ private static Set<EObject> collectTargetElements(IStatus status, Set<EObject> targetElementCollector, List allConstraintStatuses) { if (status instanceof IConstraintStatus) { targetElementCollector.add(((IConstraintStatus) status).getTarget()); allConstraintStatuses.add(status); } if (status.isMultiStatus()) { IStatus[] children = status.getChildren(); for (int i = 0; i < children.length; i++) { collectTargetElements(children[i], targetElementCollector, allConstraintStatuses); } } return targetElementCollector; }
Example 16
Source File: RcpCliParser.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private static IStatus addStatus(IStatus currentStatus, IStatus status) { if (currentStatus.isOK()) { return status; } else if (currentStatus.isMultiStatus()) { ((MultiStatus) currentStatus).add(status); return currentStatus; } else { MultiStatus baseStatus = new MultiStatus(TracingRcpPlugin.PLUGIN_ID, 1, Messages.CliParser_OpeningTraces, null); baseStatus.add(currentStatus); baseStatus.add(status); return baseStatus; } }
Example 17
Source File: StatusUtil.java From elexis-3-core with Eclipse Public License 1.0 | 5 votes |
public static void print(Logger log, String indent, IStatus status) { if (status.isMultiStatus()) { log.warn(indent + status.getMessage().replace('\n', ' ')); String childIndent = indent + " "; for (IStatus c : status.getChildren()) { print(log, childIndent, c); } } else { log.warn(indent + status.getMessage().replace('\n', ' ')); } }
Example 18
Source File: ValidateAction.java From scava with Eclipse Public License 2.0 | 5 votes |
/** * @generated */ private static Set<EObject> collectTargetElements(IStatus status, Set<EObject> targetElementCollector, List allConstraintStatuses) { if (status instanceof IConstraintStatus) { targetElementCollector.add(((IConstraintStatus) status).getTarget()); allConstraintStatuses.add(status); } if (status.isMultiStatus()) { IStatus[] children = status.getChildren(); for (int i = 0; i < children.length; i++) { collectTargetElements(children[i], targetElementCollector, allConstraintStatuses); } } return targetElementCollector; }
Example 19
Source File: SVNUIPlugin.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
/** * Convenience method for showing an error dialog * @param shell a valid shell or null * @param exception the exception to be report * @param title the title to be displayed * @param flags customizing attributes for the error handling * @return IStatus the status that was displayed to the user */ public static IStatus openError(Shell providedShell, String title, String message, Throwable exception, int flags) { // Unwrap InvocationTargetExceptions if (exception instanceof InvocationTargetException) { Throwable target = ((InvocationTargetException)exception).getTargetException(); // re-throw any runtime exceptions or errors so they can be handled by the workbench if (target instanceof RuntimeException) { throw (RuntimeException)target; } if (target instanceof Error) { throw (Error)target; } return openError(providedShell, title, message, target, flags); } // Determine the status to be displayed (and possibly logged) IStatus status = null; boolean log = false; if (exception instanceof CoreException) { status = ((CoreException)exception).getStatus(); log = ((flags & LOG_CORE_EXCEPTIONS) > 0); } else if (exception instanceof TeamException) { status = ((TeamException)exception).getStatus(); log = ((flags & LOG_TEAM_EXCEPTIONS) > 0); } else if (exception instanceof InterruptedException) { return new SVNStatus(IStatus.OK, Policy.bind("ok")); //$NON-NLS-1$ } else if (exception != null) { status = new SVNStatus(IStatus.ERROR, Policy.bind("internal"), exception); //$NON-NLS-1$ log = ((flags & LOG_OTHER_EXCEPTIONS) > 0); if (title == null) title = Policy.bind("SimpleInternal"); //$NON-NLS-1$ } // Check for a build error and report it differently if (status.getCode() == IResourceStatus.BUILD_FAILED) { message = Policy.bind("buildError"); //$NON-NLS-1$ log = true; } // Check for multi-status with only one child if (status.isMultiStatus() && status.getChildren().length == 1) { status = status.getChildren()[0]; } if (status.isOK()) return status; // Log if the user requested it if (log) SVNUIPlugin.log(status); // Create a runnable that will display the error status String svnInterface = SVNUIPlugin.getPlugin().getPreferenceStore().getString(ISVNUIConstants.PREF_SVNINTERFACE); boolean loadError = svnInterface.equals("javahl") && status != null && status.getMessage() != null && status.getMessage().equals(SVNClientManager.UNABLE_TO_LOAD_DEFAULT_CLIENT); if (!loadError || loadErrorHandled) { final String displayTitle = title; final String displayMessage = message; final IStatus displayStatus = status; final IOpenableInShell openable = new IOpenableInShell() { public void open(Shell shell) { if (displayStatus.getSeverity() == IStatus.INFO && !displayStatus.isMultiStatus()) { MessageDialog.openInformation(shell, Policy.bind("information"), displayStatus.getMessage()); //$NON-NLS-1$ } else { ErrorDialog.openError(shell, displayTitle, displayMessage, displayStatus); } } }; openDialog(providedShell, openable, flags); } if (loadError) loadErrorHandled = true; // return the status we display return status; }
Example 20
Source File: StatusUtil.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
/** * Log a status to the corresponding log-level; does nothing if * {@link Status#isOK()} * * @param prependMessage an optional message to prepend the status * message * @param log * @param status * @param includeExceptionIfAvailable * @param logDebugIfOk log to level debug if the status is ok */ public static void logStatus(String prependMessage, @NonNull Logger log, @NonNull IStatus status, boolean includeExceptionIfAvailable, boolean logDebugIfOk) { if (status.isOK() && !logDebugIfOk) { return; } StringBuilder sb = new StringBuilder(); if (status.isMultiStatus()) { sb.append("[MULTISTATUS] "); } if (prependMessage != null) { sb.append(prependMessage + " "); } sb.append("(c" + status.getCode() + "/s" + status.getSeverity() + ") "); sb.append(status.getMessage()); String message = sb.toString(); boolean includeException = (includeExceptionIfAvailable && status.getException() != null); int severity = status.getSeverity(); switch (severity) { case Status.ERROR: if (includeException) { log.error(message, status.getException()); } else { log.error(message); } break; case Status.WARNING: if (includeException) { log.warn(message, status.getException()); } else { log.warn(message); } break; case Status.INFO: case Status.CANCEL: if (includeException) { log.info(message, status.getException()); } else { log.info(message); } break; case Status.OK: log.debug(message); break; default: break; } if (status.isMultiStatus()) { Arrays.asList(status.getChildren()).stream().forEach(c -> logStatus(prependMessage, log, c, true, false)); } }