Java Code Examples for org.eclipse.core.runtime.MultiStatus#isOK()
The following examples show how to use
org.eclipse.core.runtime.MultiStatus#isOK() .
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: ValidateContributionItem.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
private void validate() { MultiStatus status = new MultiStatus(BusinessObjectPlugin.PLUGIN_ID, 0, "", null); if (formPage.observeWorkingCopy().getValue().getPackages().stream() .map(Package::getBusinessObjects) .flatMap(Collection::stream).count() == 0) { status.add(ValidationStatus.error(Messages.emptyBdm)); } else { BusinessObjectListValidator validator = new BusinessObjectListValidator(formPage.observeWorkingCopy()); formPage.observeWorkingCopy().getValue().getPackages().stream() .map(validator::validate) .forEach(status::add); } if (!status.isOK()) { new MultiStatusDialog(Display.getDefault().getActiveShell(), Messages.validationStatus, Messages.validatioNStatusDesc, new String[] { IDialogConstants.OK_LABEL }, status).open(); } else { MessageDialog.openInformation(Display.getDefault().getActiveShell(), Messages.validationStatus, Messages.bdmValidMessage); } }
Example 2
Source File: AbstractItemAction.java From neoscada with Eclipse Public License 1.0 | 6 votes |
@Override public void run ( final IAction action ) { final MultiStatus status = new MultiStatus ( Activator.PLUGIN_ID, 0, this.message, null ); for ( final Item item : this.items ) { try { processItem ( item ); } catch ( final PartInitException e ) { status.add ( e.getStatus () ); } } if ( !status.isOK () ) { showError ( status ); } }
Example 3
Source File: PreferencePage.java From neoscada with Eclipse Public License 1.0 | 6 votes |
protected void handleRemove () { final MultiStatus ms = new MultiStatus ( Activator.PLUGIN_ID, 0, "Removing key providers", null ); for ( final KeyProvider provider : this.selectedProviders ) { try { this.factory.remove ( provider ); } catch ( final Exception e ) { ms.add ( StatusHelper.convertStatus ( Activator.PLUGIN_ID, e ) ); } } if ( !ms.isOK () ) { ErrorDialog.openError ( getShell (), "Error", null, ms ); } }
Example 4
Source File: AbstractServerHandler.java From neoscada with Eclipse Public License 1.0 | 6 votes |
@Override public Object execute ( final ExecutionEvent event ) throws ExecutionException { final MultiStatus ms = new MultiStatus ( HivesPlugin.PLUGIN_ID, 0, getLabel (), null ); for ( final ServerLifecycle server : SelectionHelper.iterable ( getSelection (), ServerLifecycle.class ) ) { try { process ( server ); } catch ( final CoreException e ) { ms.add ( e.getStatus () ); } } if ( !ms.isOK () ) { StatusManager.getManager ().handle ( ms, StatusManager.SHOW ); } return null; }
Example 5
Source File: ExternalLibraryPreferencePage.java From n4js with Eclipse Public License 1.0 | 6 votes |
@Override public boolean performOk() { final MultiStatus multistatus = statusHelper .createMultiStatus("Status of importing target platform."); try { new ProgressMonitorDialog(getShell()).run(true, false, monitor -> { final IStatus status = store.save(monitor); if (!status.isOK()) { setMessage(status.getMessage(), ERROR); multistatus.merge(status); } else { updateInput(viewer, store.getLocations()); } }); } catch (final InvocationTargetException | InterruptedException exc) { multistatus.merge(statusHelper.createError("Error while building external libraries.", exc)); } if (multistatus.isOK()) return super.performOk(); else return false; }
Example 6
Source File: TmfExperiment.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
@Override @TmfSignalHandler public void traceOpened(TmfTraceOpenedSignal signal) { if (signal.getTrace() == this) { initializeStreamingMonitor(); /* Initialize the analysis */ MultiStatus status = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, null, null); status.add(executeAnalysis()); if (!status.isOK()) { Activator.log(status); } /* Refresh supplementary files in separate thread to prevent deadlock */ new Thread("Refresh supplementary files") { //$NON-NLS-1$ @Override public void run() { TmfTraceManager.refreshSupplementaryFiles(TmfExperiment.this); } }.start(); } }
Example 7
Source File: FlexWarStagingDelegate.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Override protected IPath getDeployArtifact(IPath safeWorkDirectory, IProgressMonitor monitor) throws CoreException { IPath war = safeWorkDirectory.append("app-to-deploy.war"); IPath tempDirectory = safeWorkDirectory.append("temp"); IStatus[] statuses = WarPublisher.publishWar(project, war, tempDirectory, monitor); if (statuses.length != 0) { MultiStatus multiStatus = StatusUtil.multi(this, "problem publishing WAR", statuses); if (!multiStatus.isOK()) { throw new CoreException(multiStatus); } } return war; }
Example 8
Source File: SARLRuntime.java From sarl with Apache License 2.0 | 5 votes |
/** * Initializes SRE extensions. */ private static void initializeSREExtensions() { final MultiStatus status = new MultiStatus(SARLEclipsePlugin.PLUGIN_ID, IStatus.OK, "Exceptions occurred", null); //$NON-NLS-1$ final IExtensionPoint extensionPoint = Platform.getExtensionRegistry().getExtensionPoint( SARLEclipsePlugin.PLUGIN_ID, SARLEclipseConfig.EXTENSION_POINT_SARL_RUNTIME_ENVIRONMENT); if (extensionPoint != null) { Object obj; for (final IConfigurationElement element : extensionPoint.getConfigurationElements()) { try { obj = element.createExecutableExtension("class"); //$NON-NLS-1$ if (obj instanceof ISREInstall) { final ISREInstall sre = (ISREInstall) obj; platformSREInstalls.add(sre.getId()); ALL_SRE_INSTALLS.put(sre.getId(), sre); } else { SARLEclipsePlugin.getDefault().logErrorMessage( "Cannot instance extension point: " + element.getName()); //$NON-NLS-1$ } } catch (CoreException e) { status.add(e.getStatus()); } } if (!status.isOK()) { //only happens on a CoreException SARLEclipsePlugin.getDefault().getLog().log(status); } } }
Example 9
Source File: CleanUpAction.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void runOnMultiple(final ICompilationUnit[] cus) { ICleanUp[] cleanUps= getCleanUps(cus); if (cleanUps == null) return; MultiStatus status= new MultiStatus(JavaUI.ID_PLUGIN, IStatus.OK, ActionMessages.CleanUpAction_MultiStateErrorTitle, null); for (int i= 0; i < cus.length; i++) { ICompilationUnit cu= cus[i]; if (!ActionUtil.isOnBuildPath(cu)) { String cuLocation= BasicElementLabels.getPathLabel(cu.getPath(), false); String message= Messages.format(ActionMessages.CleanUpAction_CUNotOnBuildpathMessage, cuLocation); status.add(new Status(IStatus.INFO, JavaUI.ID_PLUGIN, IStatus.ERROR, message, null)); } } if (!status.isOK()) { ErrorDialog.openError(getShell(), getActionName(), null, status); return; } try { performRefactoring(cus, cleanUps); } catch (InvocationTargetException e) { JavaPlugin.log(e); if (e.getCause() instanceof CoreException) showUnexpectedError((CoreException)e.getCause()); } }
Example 10
Source File: SaveParticipantRegistry.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Tells whether one of the active post save listeners needs to be informed about the changed * region in this save cycle. * * @param unit the unit which is about to be saved * @return true if the change regions need do be determined * @throws CoreException if something went wrong * @since 3.4 */ public static boolean isChangedRegionsRequired(final ICompilationUnit unit) throws CoreException { String message= SaveParticipantMessages.SaveParticipantRegistry_needsChangedRegionFailed; final MultiStatus errorStatus= new MultiStatus(JavaUI.ID_PLUGIN, IJavaStatusConstants.EDITOR_CHANGED_REGION_CALCULATION, message, null); IPostSaveListener[] listeners= JavaPlugin.getDefault().getSaveParticipantRegistry().getEnabledPostSaveListeners(unit.getJavaProject().getProject()); try { final boolean result[]= new boolean[] {false}; for (int i= 0; i < listeners.length; i++) { final IPostSaveListener listener= listeners[i]; SafeRunner.run(new ISafeRunnable() { public void run() throws Exception { if (listener.needsChangedRegions(unit)) result[0]= true; } public void handleException(Throwable ex) { String msg= Messages.format("The save participant ''{0}'' caused an exception.", new String[] { listener.getId() }); //$NON-NLS-1$ JavaPlugin.log(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IJavaStatusConstants.EDITOR_POST_SAVE_NOTIFICATION, msg, ex)); final String participantName= listener.getName(); msg= Messages.format(SaveParticipantMessages.SaveParticipantRegistry_needsChangedRegionCausedException, new String[] { participantName, ex.toString() }); errorStatus.add(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, IJavaStatusConstants.EDITOR_CHANGED_REGION_CALCULATION, msg, null)); } }); if (result[0]) return true; } } finally { if (!errorStatus.isOK()) throw new CoreException(errorStatus); } return false; }
Example 11
Source File: FileTransferDragAdapter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void handleRefresh() { final Set<IResource> roots= collectRoots(getResources()); WorkspaceModifyOperation op= new WorkspaceModifyOperation() { @Override public void execute(IProgressMonitor monitor) throws CoreException { try { monitor.beginTask(PackagesMessages.DragAdapter_refreshing, roots.size()); MultiStatus status= createMultiStatus(); Iterator<IResource> iter= roots.iterator(); while (iter.hasNext()) { IResource r= iter.next(); try { r.refreshLocal(IResource.DEPTH_ONE, new SubProgressMonitor(monitor, 1)); } catch (CoreException e) { status.add(e.getStatus()); } } if (!status.isOK()) { throw new CoreException(status); } } finally { monitor.done(); } } }; runOperation(op, true, false); }
Example 12
Source File: FileTransferDragAdapter.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
void handleDropMove() { final List<IResource> elements= getResources(); if (elements == null || elements.size() == 0) return; WorkspaceModifyOperation op= new WorkspaceModifyOperation() { @Override public void execute(IProgressMonitor monitor) throws CoreException { try { monitor.beginTask(PackagesMessages.DragAdapter_deleting, elements.size()); MultiStatus status= createMultiStatus(); Iterator<IResource> iter= elements.iterator(); while(iter.hasNext()) { IResource resource= iter.next(); try { monitor.subTask(BasicElementLabels.getPathLabel(resource.getFullPath(), true)); resource.delete(true, null); } catch (CoreException e) { status.add(e.getStatus()); } finally { monitor.worked(1); } } if (!status.isOK()) { throw new CoreException(status); } } finally { monitor.done(); } } }; runOperation(op, true, false); }
Example 13
Source File: NewClientBundleWizardPage.java From gwt-eclipse-plugin with Eclipse Public License 1.0 | 5 votes |
@Override protected void createTypeMembers(IType newType, ImportsManager imports, IProgressMonitor monitor) throws CoreException { boolean addComments = isAddComments(); final MultiStatus status = new MultiStatus(GWTPlugin.PLUGIN_ID, 0, "Click the Details button for more information", null); // Create an accessor method for each bundled resource for (ClientBundleResource resource : bundledResourcesBlock.getResources()) { try { resource.addToClientBundle(newType, imports, addComments, monitor); } catch (CoreException e) { status.add(e.getStatus()); } } // We want to handle any errors here, since if we let it escape this method // it short-circuits NewTypeWizardPage.createType, which ends up creating // a new ClientBundle source file with no content. if (!status.isOK()) { Display.getDefault().syncExec(new Runnable() { public void run() { ErrorDialog.openError( getShell(), "Error Adding Resources", "One or more selected resources could not be added to the ClientBundle.", status); } }); } }
Example 14
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 15
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 16
Source File: NpmCLI.java From n4js with Eclipse Public License 1.0 | 5 votes |
private Collection<LibraryChange> batchInstallInternal(IProgressMonitor monitor, MultiStatus status, Collection<LibraryChange> requestedChanges, FileURI target) { SubMonitor subMonitor = SubMonitor.convert(monitor, 1); subMonitor.setTaskName("Installing npm packages."); // Convert platform URI to local (e.g. file) URI File installPath = target.toJavaIoFile(); // for installation, we invoke npm only once for all packages final List<Pair<N4JSProjectName, String>> packageNamesAndVersions = Lists.newArrayList(); for (LibraryChange reqChg : requestedChanges) { if (reqChg.type == LibraryChangeType.Install) { packageNamesAndVersions.add(Tuples.pair(reqChg.name, "@" + reqChg.version)); } } IStatus installStatus = install(packageNamesAndVersions, installPath); subMonitor.worked(1); Set<LibraryChange> actualChanges; MultiStatus batchStatus = statusHelper.createMultiStatus("Installing npm packages."); if (installStatus == null || !installStatus.isOK()) { actualChanges = Collections.emptySet(); batchStatus.merge(installStatus); } else { actualChanges = computeActualChanges(installPath.toPath(), requestedChanges, batchStatus); } if (!batchStatus.isOK()) { logger.logInfo("Some packages could not be installed due to errors, see log for details."); status.merge(batchStatus); } return actualChanges; }
Example 17
Source File: N4JSPackageJsonQuickfixProviderExtension.java From n4js with Eclipse Public License 1.0 | 5 votes |
private Collection<? extends IChange> wrapWithMonitor(String msg, String errMsg, Function<IProgressMonitor, IStatus> f) throws Exception { MultiStatus multiStatus = statusHelper.createMultiStatus(msg); new ProgressMonitorDialog(UIUtils.getShell()).run(true, false, (monitor) -> { try { IStatus status = f.apply(monitor); multiStatus.merge(status); } catch (Exception e) { multiStatus.merge(statusHelper.createError(errMsg, e)); } }); if (!multiStatus.isOK()) { N4JSActivator.getInstance().getLog().log(multiStatus); UIUtils.getDisplay().asyncExec(new Runnable() { @Override public void run() { String title = "Failed: " + msg; String descr = StatusUtils.getErrorMessage(multiStatus, true); ErrorDialog.openError(UIUtils.getShell(), title, descr, multiStatus); } }); } return Collections.emptyList(); }
Example 18
Source File: OpenTraceStressTest.java From tracecompass with Eclipse Public License 2.0 | 4 votes |
/** * Main test case to test opening and closing of traces concurrently. */ @Test public void testOpenAndCloseConcurrency() { SWTBotUtils.createProject(TRACE_PROJECT_NAME); File fTestFile = new File(CtfTmfTestTraceUtils.getTrace(CTF_TRACE).getPath()); CtfTmfTestTraceUtils.dispose(CTF_TRACE); String path = fTestFile.getAbsolutePath(); assertNotNull(fTestFile); assumeTrue(fTestFile.exists()); /* * This opening and closing of traces will trigger several threads for analysis which * will be closed concurrently. There used to be a concurrency bug (447434) which should * be fixed by now and this test should run without any exceptions. * * Since the failure depends on timing it only happened sometimes before the bug fix * using this test. */ final MultiStatus status = new MultiStatus("lttn2.kernel.ui.swtbot.tests", IStatus.OK, null, null); IJobManager mgr = Job.getJobManager(); JobChangeAdapter changeListener = new JobChangeAdapter() { @Override public void done(IJobChangeEvent event) { Job job = event.getJob(); // Check for analysis failure String jobNamePrefix = NLS.bind(Messages.TmfAbstractAnalysisModule_RunningAnalysis, ""); if ((job.getName().startsWith(jobNamePrefix)) && (job.getResult().getSeverity() == IStatus.ERROR)) { status.add(job.getResult()); } } }; mgr.addJobChangeListener(changeListener); for (int i = 0; i < 10; i++) { SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false); SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false); SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false); SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false); SWTBotUtils.openTrace(TRACE_PROJECT_NAME, path, TRACE_TYPE, false); // Wait for editor so that threads have a chance to start workbenchbot.editorByTitle(fTestFile.getName()); workbenchbot.closeAllEditors(); if (!status.isOK()) { SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, workbenchbot); fail(handleErrorStatus(status)); } } SWTBotUtils.deleteProject(TRACE_PROJECT_NAME, workbenchbot); }
Example 19
Source File: LibraryManager.java From n4js with Eclipse Public License 1.0 | 4 votes |
/** * NOTE: if the target points to a member project in a yarn workspace, this method will *NOT* switch to the yarn * workspace root folder for executing yarn! Rationale: in case an explicitly mentioned npm package is installed * (e.g. "yarn add lodash") it makes a difference whether that command is being executed in the member project's * root folder or the yarn workspace root folder (i.e. the newly installed npm package will be added to a different * package.json file in each case) and we want to support both cases. */ private IStatus installNPMsInternal(Map<N4JSProjectName, NPMVersionRequirement> versionedNPMs, boolean forceReloadAll, FileURI target, IProgressMonitor monitor) { String msg = getMessage(versionedNPMs); MultiStatus status = statusHelper.createMultiStatus(msg); logger.logInfo(msg); boolean usingYarn = npmCli.isYarnUsed(target); IStatus binaryStatus = checkBinary(usingYarn); if (!binaryStatus.isOK()) { status.merge(binaryStatus); return status; } try (Measurement mes = N4JSDataCollectors.dcLibMngr.getMeasurement("installDependenciesInternal");) { final int steps = forceReloadAll ? 3 : 2; SubMonitor subMonitor = SubMonitor.convert(monitor, steps + 4); Map<N4JSProjectName, NPMVersionRequirement> npmsToInstall = new LinkedHashMap<>(versionedNPMs); SubMonitor subMonitor1 = subMonitor.split(2); subMonitor1.setTaskName("Installing packages... [step 1 of " + steps + "]"); List<LibraryChange> actualChanges = installNPMs(subMonitor1, status, npmsToInstall, target); if (!status.isOK()) { return status; } // if forceReloadAll, unregister all currently-registered projects from // the workspace and remove them from the index if (forceReloadAll) { SubMonitor subMonitor2 = subMonitor.split(1); subMonitor2.setTaskName("Clean all packages... [step 2 of 3]"); externalLibraryWorkspace.deregisterAllProjects(subMonitor2); } try (Measurement m = N4JSDataCollectors.dcIndexSynchronizer.getMeasurement("synchronizeNpms")) { SubMonitor subMonitor3 = subMonitor.split(4); subMonitor3.setTaskName("Building installed packages... [step " + steps + " of " + steps + "]"); indexSynchronizer.synchronizeNpms(subMonitor3, actualChanges); } return status; } finally { monitor.done(); } }
Example 20
Source File: NpmCLI.java From n4js with Eclipse Public License 1.0 | 4 votes |
/** * Uninstalls an npm package. The path to the npm package (passed via {@code requestedChange.location}) must conform * to either one of two the following scenarios: * * <pre> * Scenario 1: The npm is a direct child of a {@code node_modules} folder * * MyProject * package.json * node_modules * express <- uninstall * </pre> * * <pre> * Scenario 2: The npm is a direct child of {@code @n4jsd} folder which in turn is a direct child of {@code node_modules} * * MyProject * package.json * node_modules * @n4jsd * express <- uninstall * </pre> * * @param monitor * progress monitor tracking the progress of the action * @param status * status, into which the status of the method call can be merged * @param requestedChange * change object containing the information (e.g. change type, path and version of npm package etc.) * about the npm to be uninstalled. * @return collection of actual changes * @throws IllegalArgumentException * if the requested change is not of type {@code LibraryChangeType.Uninstall} * @throws IllegalStateException * if the the npm is neither direct child of {@code node_modules} nor {@code node_modules/@n4jsd} */ public Collection<LibraryChange> uninstall(IProgressMonitor monitor, MultiStatus status, LibraryChange requestedChange) { if (requestedChange.type != LibraryChangeType.Uninstall) { throw new IllegalArgumentException( "The expected change type is " + LibraryChangeType.Uninstall + " but is " + requestedChange.type); } String msg = "Uninstalling npm package '" + requestedChange.name + "'"; MultiStatus resultStatus = statusHelper.createMultiStatus(msg); SubMonitor subMonitor = SubMonitor.convert(monitor, 2); SafeURI<?> nodeModulesLocationURI = externalLibraryWorkspace .getRootLocationForResource(requestedChange.location); List<N4JSProjectName> packageNames = new ArrayList<>(); if ((requestedChange.type == LibraryChangeType.Uninstall) && ExternalLibraryPreferenceModel.isNodeModulesLocation(nodeModulesLocationURI)) { packageNames.add(requestedChange.name); } File nodeModulesLocation = nodeModulesLocationURI.getParent().toJavaIoFile(); // Assume that the parent of node_modules folder is the root of the project which contains package.json // We call npm uninstall in this root folder IStatus installStatus = uninstall(packageNames, nodeModulesLocation); subMonitor.worked(1); Collection<LibraryChange> actualChanges = new LinkedList<>(); if (installStatus == null || !installStatus.isOK()) { resultStatus.merge(installStatus); } else { File npmDirectory = requestedChange.location.toJavaIoFile(); String actualVersion = getActualVersion(npmDirectory.toPath()); if (actualVersion.isEmpty()) { actualChanges.add(new LibraryChange(LibraryChangeType.Removed, requestedChange.location, requestedChange.name, requestedChange.version)); } } if (!resultStatus.isOK()) { logger.logInfo("Some packages could not be uninstalled due to errors, see log for details."); status.merge(resultStatus); } return actualChanges; }