Java Code Examples for org.eclipse.core.runtime.MultiStatus#add()
The following examples show how to use
org.eclipse.core.runtime.MultiStatus#add() .
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: ComparisonExpressionValidator.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
public IStatus validateXtextResource(final Injector injector, Resource resource, ResourceSet resourceSet) throws OperationCanceledError { final IResourceValidator xtextResourceChecker = injector.getInstance(IResourceValidator.class); final MultiStatus status = new MultiStatus(ExpressionEditorPlugin.PLUGIN_ID, 0, "", null); final ConditionModelJavaValidator validator = injector.getInstance(ConditionModelJavaValidator.class); validator.setCurrentResourceSet(resourceSet); final List<Issue> issues = xtextResourceChecker.validate(resource, CheckMode.FAST_ONLY, null); if(issues.isEmpty()){ updateDependencies(resource); } for(final Issue issue : issues){ int severity = IStatus.ERROR; final Severity issueSeverity = issue.getSeverity(); if(issueSeverity == Severity.WARNING){ severity = IStatus.WARNING; } status.add(new Status(severity, ExpressionEditorPlugin.PLUGIN_ID, issue.getMessage())); } return status; }
Example 2
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 3
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 4
Source File: Resources.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static IStatus addOutOfSync(IStatus status, IResource resource) { IStatus entry= new Status( IStatus.ERROR, ResourcesPlugin.PI_RESOURCES, IResourceStatus.OUT_OF_SYNC_LOCAL, Messages.format(CorextMessages.Resources_outOfSync, BasicElementLabels.getPathLabel(resource.getFullPath(), false)), null); if (status == null) { return entry; } else if (status.isMultiStatus()) { ((MultiStatus)status).add(entry); return status; } else { MultiStatus result= new MultiStatus( ResourcesPlugin.PI_RESOURCES, IResourceStatus.OUT_OF_SYNC_LOCAL, CorextMessages.Resources_outOfSyncResources, null); result.add(status); result.add(entry); return result; } }
Example 5
Source File: BusinessObjectNameValidator.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override public IStatus validate(BusinessObject businessObject) { String name = businessObject.getSimpleName(); if (name == null || name.isEmpty()) { return ValidationStatus.error(Messages.boNameRequired); } MultiStatus status = new MultiStatus(BusinessObjectPlugin.PLUGIN_ID, 0, "", null); status.add(validateNameLength(name)); status.add(validateUniqueness((businessObject), name)); status.add(validateWhiteSpaceCharacter(name)); status.add(validateUnderscoreCharacter(name)); status.add(validateSqlValidity(name)); status.add(validateJavaConvention(name)); return status; }
Example 6
Source File: QueryNameValidationConstraint.java From bonita-studio with GNU General Public License v2.0 | 6 votes |
@Override protected IStatus performBatchValidation(final IValidationContext context) { final BusinessObjectModelFileStore modelFileStore = getCurrentBDM(); final MultiStatus multiStatus = new MultiStatus(ValidationPlugin.PLUGIN_ID, 0, null, null); if (modelFileStore != null) { for (final BusinessObject bo : modelFileStore.getBusinessObjects()) { for (final Query q : BDMQueryUtil.createProvidedQueriesForBusinessObject(bo)) { for (final Query customQuery : bo.getQueries()) { if (Objects.equal(customQuery.getName().toLowerCase(), q.getName().toLowerCase())) { multiStatus.add( context.createFailureStatus(NLS.bind(Messages.conflictingQueryNamesInBusinessObject, bo.getSimpleName(), q.getName()))); } } } } return multiStatus; } return context.createSuccessStatus(); }
Example 7
Source File: TypeScriptUIPlugin.java From typescript.java with MIT License | 5 votes |
public static void logErrorStatus(String message, IStatus status) { if (status == null) { logErrorMessage(message); return; } MultiStatus multi = new MultiStatus(PLUGIN_ID, INTERNAL_ERROR, message, null); multi.add(status); log(multi); }
Example 8
Source File: ExportSarlApplicationPage.java From sarl with Apache License 2.0 | 5 votes |
@Override protected IPackageFragmentRoot[] getRequiredPackageFragmentRoots(IPath[] classpathEntries, String projectName, MultiStatus status) { final List<IPackageFragmentRoot> result = new ArrayList<>(); final IJavaProject[] searchOrder = getProjectSearchOrder(projectName); final IJavaProject project = getJavaProject(projectName); for (int i = 0; i < classpathEntries.length; ++i) { final IPath entry = classpathEntries[i]; final IPackageFragmentRoot[] elements = findRootsForClasspath(entry, searchOrder); if (elements == null) { final IPackageFragmentRoot element; final File file = entry.toFile(); if (file.exists()) { element = project.getPackageFragmentRoot(file.getAbsolutePath()); } else { element = null; } if (element != null) { result.add(element); } else { status.add(new Status(IStatus.WARNING, JavaUI.ID_PLUGIN, org.eclipse.jdt.internal.corext.util.Messages.format( FatJarPackagerMessages.FatJarPackageWizardPage_error_missingClassFile, getPathLabel(entry, false)))); } } else { for (int j = 0; j < elements.length; ++j) { result.add(elements[j]); } } } return result.toArray(new IPackageFragmentRoot[result.size()]); }
Example 9
Source File: TextSearchVisitor.java From eclipse.jdt.ls with Eclipse Public License 2.0 | 5 votes |
@Override protected IStatus run(IProgressMonitor inner) { MultiStatus multiStatus= new MultiStatus(IConstants.PLUGIN_ID, IStatus.OK, "Problems encountered during text search.", null); SubMonitor subMonitor= SubMonitor.convert(inner, fEnd - fBegin); this.fileCharSequenceProvider= new FileCharSequenceProvider(); for (int i= fBegin; i < fEnd && !fFatalError; i++) { IStatus status= processFile(fFiles[i], subMonitor.split(1)); // Only accumulate interesting status if (!status.isOK()) { multiStatus.add(status); // Group cancellation is propagated to this job's monitor. // Stop processing and return the status for the completed jobs. } } if (charsequenceForPreviousLocation != null) { try { fileCharSequenceProvider.releaseCharSequence(charsequenceForPreviousLocation); } catch (IOException e) { JavaLanguageServerPlugin.logException(e.getMessage(), e); } finally { charsequenceForPreviousLocation= null; } } fileCharSequenceProvider= null; previousLocationFromFile= null; occurencesForPreviousLocation= null; return multiStatus; }
Example 10
Source File: CompositeSearchQuery.java From xtext-eclipse with Eclipse Public License 2.0 | 5 votes |
@Override public IStatus run(IProgressMonitor monitor) throws OperationCanceledException { SubMonitor progress = SubMonitor.convert(monitor, children.size()); MultiStatus multiStatus = new MultiStatus(getPluginId(), IStatus.OK, "Composite search state", null); for(ISearchQuery child: children) { IStatus status = child.run(progress.newChild(1)); multiStatus.add(status); if(progress.isCanceled()) { return Status.CANCEL_STATUS; } } return multiStatus; }
Example 11
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 12
Source File: StatusUtilTest.java From google-cloud-eclipse with Apache License 2.0 | 5 votes |
@Test public void testFilter_multiStatus() { MultiStatus multi = StatusUtil.multi(StatusUtil.class, "test"); multi.add(Status.OK_STATUS); multi.add(StatusUtil.error(StatusUtil.class, "test error msg")); multi.add(Status.OK_STATUS); IStatus result = StatusUtil.filter(multi); assertEquals(IStatus.ERROR, result.getSeverity()); assertThat(result, instanceOf(MultiStatus.class)); assertEquals(1, ((MultiStatus) result).getChildren().length); verifyStatus(((MultiStatus) result).getChildren()[0], IStatus.ERROR, "test error msg"); }
Example 13
Source File: CopyFilesAndFoldersOperation.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Checks whether the resources with the given names exist. * * @param resources * IResources to checl * @return Multi status with one error message for each missing file. */ IStatus checkExist(IResource[] resources) { MultiStatus multiStatus = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, getProblemsMessage(), null); for (int i = 0; i < resources.length; i++) { IResource resource = resources[i]; if (resource != null) { URI location = resource.getLocationURI(); String message = null; if (location != null) { IFileInfo info = IDEResourceInfoUtils.getFileInfo(location); if (info == null || info.exists() == false) { if (resource.isLinked()) { message = NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_missingLinkTarget, resource.getName()); } else { message = NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_resourceDeleted, resource.getName()); } } } if (message != null) { IStatus status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, message, null); multiStatus.add(status); } } } return multiStatus; }
Example 14
Source File: CordovaPlugin.java From thym with Eclipse Public License 1.0 | 5 votes |
/** * Checks if the given engine is compatible with this plug-in. Returns a * {@link MultiStatus} as there may be more than one reason for an engine to * fail. * * @param engine * @return A WARNING or OK level status * */ public IStatus isEngineCompatible(HybridMobileEngine engine) { if (supportedEngines == null || supportedEngines.isEmpty()) return Status.OK_STATUS; MultiStatus status = new MultiStatus(HybridCore.PLUGIN_ID, 0, NLS.bind("Plug-in {0} is not compatible with {1} version {2}", new Object[] { getLabel(), engine.getName(), engine.getSpec() }), null); for (EngineDefinition definition : supportedEngines) { status.add(isDefinitionSatisfied(definition, engine)); } return status; }
Example 15
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 16
Source File: DeployArtifactsHandler.java From bonita-studio with GNU General Public License v2.0 | 5 votes |
private IRunnableWithProgress performFinish(RepositoryAccessor repositoryAccessor, Collection<Artifact> artifactsToDeploy, Map<String, Object> deployOptions, MultiStatus status) { return monitor -> { new IndexingUIDOperation().run(monitor); GetApiSessionOperation apiSessionOperation = new GetApiSessionOperation(); apiSessionOperation.run(monitor); try { APISession session = apiSessionOperation.getSession(); DeployTenantResourcesOperation deployTenantResourcesOperation = new DeployTenantResourcesOperation( artifactsToDeploy.stream().filter(TenantArtifact.class::isInstance) .map(TenantArtifact.class::cast).collect(Collectors.toList()), session, deployOptions); monitor.beginTask(Messages.deploy, artifactsToDeploy.size()); deployTenantResourcesOperation.run(monitor); addToMultiStatus(deployTenantResourcesOperation.getStatus(), status); if ((boolean) deployOptions.get(DeployOptions.RUN_VALIDATION)) { ValidateProjectOperation operation = new ValidateProjectOperation(artifactsToDeploy); operation.run(monitor); status.add(operation.getStatus()); } if (status.getSeverity() != IStatus.ERROR) { addToMultiStatus(deploy(artifactsToDeploy, session, monitor), status); } } finally { monitor.done(); apiSessionOperation.logout(); } if (monitor.isCanceled()) { status.add(ValidationStatus.cancel(Messages.abort)); } }; }
Example 17
Source File: FatJarPackageWizardPage.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void exportAntScript(MultiStatus status) { if (!fAntScriptSaveCheckbox.getSelection()) return; if (canCreateAntScript(getShell())) { LaunchConfigurationElement element= fLauchConfigurationModel.get(fLaunchConfigurationCombo.getSelectionIndex()); Assert.isNotNull(element); FatJarAntExporter antExporter= getLibraryHandler().getAntExporter(fAntScriptLocation, fJarPackage.getAbsoluteJarLocation(), element.getLaunchConfiguration()); try { antExporter.run(status); } catch (CoreException e) { status.add(new Status(IStatus.ERROR, JavaUI.ID_PLUGIN, FatJarPackagerMessages.FatJarPackageWizardPage_error_ant_script_generation_failed, e)); } } }
Example 18
Source File: CopyFilesAndFoldersOperation.java From Pydev with Eclipse Public License 1.0 | 5 votes |
/** * Checks whether the infos exist. * * @param stores * the file infos to test * @return Multi status with one error message for each missing file. */ IStatus checkExist(IFileStore[] stores) { MultiStatus multiStatus = new MultiStatus(PlatformUI.PLUGIN_ID, IStatus.OK, getProblemsMessage(), null); for (int i = 0; i < stores.length; i++) { if (stores[i].fetchInfo().exists() == false) { String message = NLS.bind(IDEWorkbenchMessages.CopyFilesAndFoldersOperation_resourceDeleted, stores[i].getName()); IStatus status = new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, IStatus.OK, message, null); multiStatus.add(status); } } return multiStatus; }
Example 19
Source File: WriteAttributesOperationWizard.java From neoscada with Eclipse Public License 1.0 | 5 votes |
public void handleError ( final Map<String, Variant> attributes, final WriteAttributeResults results ) { final MultiStatus status = new MultiStatus ( Activator.PLUGIN_ID, 0, Messages.getString ( "WriteAttributesOperationWizard.Status_Message" ), null ); //$NON-NLS-1$ if ( attributes.size () != results.size () ) { status.add ( new OperationStatus ( IStatus.WARNING, Activator.PLUGIN_ID, 0, String.format ( Messages.getString ( "WriteAttributesOperationWizard.SummaryText" ), results.size (), attributes.size () ), null ) ); //$NON-NLS-1$ } for ( final Map.Entry<String, WriteAttributeResult> entry : results.entrySet () ) { if ( entry.getValue ().isError () ) { status.add ( new OperationStatus ( IStatus.ERROR, Activator.PLUGIN_ID, 0, String.format ( Messages.getString ( "WriteAttributesOperationWizard.EntryMessage" ), entry.getKey (), entry.getValue ().getError ().getMessage () ), null ) ); //$NON-NLS-1$ } } for ( final String name : attributes.keySet () ) { if ( !results.containsKey ( name ) ) { status.add ( new OperationStatus ( IStatus.WARNING, Activator.PLUGIN_ID, 0, String.format ( Messages.getString ( "WriteAttributesOperationWizard.Message_MissingAttribute" ), name ), null ) ); //$NON-NLS-1$ } } final ErrorDialog dialog = new ErrorDialog ( getShell (), Messages.getString ( "WriteAttributesOperationWizard.WriteError_Title" ), Messages.getString ( "WriteAttributesOperationWizard.ErrorDialog_Description" ), status, IStatus.ERROR | IStatus.WARNING ); //$NON-NLS-1$ //$NON-NLS-2$ Display.getDefault ().syncExec ( new Runnable () { @Override public void run () { dialog.open (); } } ); }
Example 20
Source File: GraphViz.java From eclipsegraphviz with Eclipse Public License 1.0 | 4 votes |
/** * Higher-level API for launching a GraphViz transformation. * * @return the resulting image, never <code>null</code> * @throws CoreException * if any error occurs */ public static byte[] load(final InputStream input, String format, int dimensionX, int dimensionY) throws CoreException { MultiStatus status = new MultiStatus(GraphVizActivator.ID, 0, "Errors occurred while running Graphviz", null); File dotInputFile = null, dotOutputFile = null; // we keep the input in memory so we can include it in error messages ByteArrayOutputStream dotContents = new ByteArrayOutputStream(); try { // determine the temp input and output locations dotInputFile = File.createTempFile(TMP_FILE_PREFIX, DOT_EXTENSION); dotOutputFile = File.createTempFile(TMP_FILE_PREFIX, "." + format); // we created the output file just so we would know an output // location to pass to dot dotOutputFile.delete(); // dump the contents from the input stream into the temporary file // to be submitted to dot byte[] contentsAsArray = null; try (FileOutputStream tmpDotOutputStream = new FileOutputStream(dotInputFile)) { IOUtils.copy(input, dotContents); contentsAsArray = dotContents.toByteArray(); IOUtils.copy(new ByteArrayInputStream(contentsAsArray), tmpDotOutputStream); } IStatus result = runDot(format, dimensionX, dimensionY, dotInputFile, dotOutputFile); status.add(result); status.add(logInput(contentsAsArray)); if (dotOutputFile.isFile()) { if (!result.isOK() && Platform.inDebugMode()) LogUtils.log(status); return FileUtils.readFileToByteArray(dotOutputFile); } } catch (IOException e) { status.add(new Status(IStatus.ERROR, GraphVizActivator.ID, "", e)); } finally { dotInputFile.delete(); dotOutputFile.delete(); IOUtils.closeQuietly(input); } throw new CoreException(status); }