Java Code Examples for org.eclipse.core.runtime.MultiStatus#getChildren()
The following examples show how to use
org.eclipse.core.runtime.MultiStatus#getChildren() .
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: TestingEnvironment.java From dacapobench with Apache License 2.0 | 6 votes |
/** * Handles a core exception thrown during a testing environment operation */ private void handleCoreException(CoreException e) { e.printStackTrace(); IStatus status = e.getStatus(); String message = e.getMessage(); if (status.isMultiStatus()) { MultiStatus multiStatus = (MultiStatus) status; IStatus[] children = multiStatus.getChildren(); StringBuffer buffer = new StringBuffer(); for (int i = 0, max = children.length; i < max; i++) { IStatus child = children[i]; if (child != null) { buffer.append(child.getMessage()); buffer.append(System.getProperty("line.separator"));//$NON-NLS-1$ Throwable childException = child.getException(); if (childException != null) { childException.printStackTrace(); } } } message = buffer.toString(); } Assert.isTrue(false, "Core exception in testing environment: " + message); //$NON-NLS-1$ }
Example 2
Source File: MarkerUtils.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
/** * Delete all Markers with the given type. * * @param resource * @param type * @param includeSubtypes * @return IMarker[] * @throws CoreException * with a multi-status problems in case some markers where not successfully deleted. */ public static void deleteMarkers(IUniformResource resource, String type, boolean includeSubtypes) throws CoreException { IMarker[] toDelete = findMarkers(resource, type, includeSubtypes); MultiStatus status = new MultiStatus(CorePlugin.PLUGIN_ID, 0, "Errors deleting markers", null); //$NON-NLS-1$ for (IMarker marker : toDelete) { try { marker.delete(); } catch (CoreException e) { status.add(new Status(IStatus.ERROR, CorePlugin.PLUGIN_ID, e.getMessage(), e)); } } if (status.getChildren().length > 0) { throw new CoreException(status); } }
Example 3
Source File: ResourceTransferDragAdapter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private void handleFinishedDropMove(DragSourceEvent event) { MultiStatus status= new MultiStatus( JavaPlugin.getPluginId(), IJavaStatusConstants.INTERNAL_ERROR, JavaUIMessages.ResourceTransferDragAdapter_cannot_delete_resource, null); List<IResource> resources= convertSelection(); for (Iterator<IResource> iter= resources.iterator(); iter.hasNext();) { IResource resource= iter.next(); try { resource.delete(true, null); } catch (CoreException e) { status.add(e.getStatus()); } } int childrenCount= status.getChildren().length; if (childrenCount > 0) { Shell parent= SWTUtil.getShell(event.widget); ErrorDialog error= new ErrorDialog(parent, JavaUIMessages.ResourceTransferDragAdapter_moving_resource, childrenCount == 1 ? JavaUIMessages.ResourceTransferDragAdapter_cannot_delete_files_singular : Messages.format( JavaUIMessages.ResourceTransferDragAdapter_cannot_delete_files_plural, String.valueOf(childrenCount)), status, IStatus.ERROR); error.open(); } }
Example 4
Source File: ServerDescriptorImpl.java From neoscada with Eclipse Public License 1.0 | 5 votes |
public void throwMultiStatus ( final MultiStatus ms ) throws CoreException { if ( !ms.isOK () ) { if ( ms.getChildren ().length == 1 ) { throw new CoreException ( ms.getChildren ()[0] ); } else { throw new CoreException ( ms ); } } }
Example 5
Source File: PreviewHandler.java From neoscada with Eclipse Public License 1.0 | 5 votes |
@Override public Object execute ( final ExecutionEvent event ) throws ExecutionException { final MultiStatus ms = new MultiStatus ( Activator.PLUGIN_ID, 0, "Opening preview", null ); for ( final IFile file : SelectionHelper.iterable ( getSelection (), IFile.class ) ) { final IEditorInput input = new FileEditorInput ( file ); try { getActivePage ().openEditor ( input, PreviewEditorImpl.EDITOR_ID, true, IWorkbenchPage.MATCH_ID ); } catch ( final PartInitException e ) { ms.add ( e.getStatus () ); } } if ( !ms.isOK () ) { final IStatus[] childs = ms.getChildren (); if ( childs.length < 2 ) { StatusManager.getManager ().handle ( childs[0], StatusManager.SHOW ); } else { StatusManager.getManager ().handle ( ms, StatusManager.SHOW ); } } return null; }
Example 6
Source File: OpenTraceStressTest.java From tracecompass with Eclipse Public License 2.0 | 5 votes |
private static String handleErrorStatus(MultiStatus status) { // Build a string with all the children status messages, exception // messages and stack traces StringBuilder sb = new StringBuilder(); for (IStatus childStatus : status.getChildren()) { StringBuilder childSb = new StringBuilder(); if (!childStatus.getMessage().isEmpty()) { childSb.append(childStatus.getMessage() + '\n'); } Throwable childException = childStatus.getException(); if (childException != null) { String reason = childException.getMessage(); // Some system exceptions have no message if (reason == null) { reason = childException.toString(); } String stackMessage = getExceptionStackMessage(childException); if (stackMessage == null) { stackMessage = reason; } childSb.append(stackMessage); } if (childSb.length() > 0) { childSb.insert(0, '\n'); sb.append(childSb.toString()); } } return sb.toString(); }
Example 7
Source File: BatchValidationOperation.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private boolean statusExists(final MultiStatus multi, final String message) { for (final IStatus s : multi.getChildren()) { if (s.getMessage().equals(message)) { return true; } } return false; }
Example 8
Source File: DialogSupport.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
/** * @noreference This method is not intended to be referenced by clients. */ protected void handleStatusException() { if (currentStatus.getException() != null) { logThrowable(currentStatus.getException()); } else if (currentStatus instanceof MultiStatus) { MultiStatus multiStatus = (MultiStatus) currentStatus; for (int i = 0; i < multiStatus.getChildren().length; i++) { IStatus status = multiStatus.getChildren()[i]; if (status.getException() != null) { logThrowable(status.getException()); } } } }
Example 9
Source File: ScanWorkspaceOperation.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected void scanStatus(String text) { final String[] scannedRepo = text.replace("$SCAN_PROGRESS_", "").split(":"); final String repoName = scannedRepo[0]; final String repoVersion = scannedRepo[1]; final String repoEdition = scannedRepo[2].trim(); final String connected = scannedRepo[3].trim(); final ImportRepositoryModel repositoryModel = new ImportRepositoryModel(repoName, repoVersion, repoEdition); final MultiStatus repoStatus = new MultiStatus(BosArchiveImporterPlugin.PLUGIN_ID, 0, "", null); if ("Shared".equals(connected)) { repoStatus.add(ValidationStatus.error(String.format(Messages.projectConnectorToVCS, repoName))); } if (!ProductVersion.canBeImported(repoVersion)) { repoStatus.add(ValidationStatus .error(String.format(Messages.cannotImportWorkspaceWithVersion, repoName, repoVersion))); } final IStatus editionValid = isEditionValid(repoName, repoEdition); if (!editionValid.isOK()) { repoStatus.add(editionValid); } if (repoStatus.getChildren().length == 0) { repoStatus.add( new Status(IStatus.OK, BosArchiveImporterPlugin.PLUGIN_ID, validRepositoryMessage(repositoryModel))); } repositoryModel.setStatus(repoStatus); workspaceModel.addRepository(repositoryModel); }
Example 10
Source File: ImportStatusDialog.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
protected String createMessageForMultiStatus(final MultiStatus status) { final StringBuilder sb = new StringBuilder(); for (final IStatus childStatus : status.getChildren()) { if (!childStatus.isOK()) { sb.append(childStatus.getMessage()); sb.append(SWT.CR); } } return sb.toString(); }