Java Code Examples for org.eclipse.core.runtime.IStatus#OK

The following examples show how to use org.eclipse.core.runtime.IStatus#OK . 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: DartLog.java    From dartboard with Eclipse Public License 2.0 6 votes vote down vote up
public static void applyToStatusLine(DialogPage page, IStatus status) {
	String message = status.getMessage();
	switch (status.getSeverity()) {
	case IStatus.OK:
		page.setMessage(message, IMessageProvider.NONE);
		page.setErrorMessage(null);
		break;
	case IStatus.WARNING:
		page.setMessage(message, IMessageProvider.WARNING);
		page.setErrorMessage(null);
		break;
	case IStatus.INFO:
		page.setMessage(message, IMessageProvider.INFORMATION);
		page.setErrorMessage(null);
		break;
	default:
		if (message.isEmpty()) {
			message = null;
		}
		page.setMessage(null);
		page.setErrorMessage(message);
		break;
	}
}
 
Example 2
Source File: EclipseLogHandler.java    From eclipse-cs with GNU Lesser General Public License v2.1 6 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void publish(LogRecord record) {

  // translate log levels into severity
  int severity = 0;
  Level level = record.getLevel();
  if (Level.CONFIG.equals(level) || Level.INFO.equals(level) || Level.FINE.equals(level)
          || Level.FINER.equals(level) || Level.FINEST.equals(level)) {
    severity = IStatus.INFO;
  } else if (Level.WARNING.equals(level)) {
    severity = IStatus.WARNING;
  } else if (Level.SEVERE.equals(level)) {
    severity = IStatus.ERROR;
  }

  // get message
  String message = record.getMessage();

  // get throwable
  Throwable t = record.getThrown();

  Status status = new Status(severity, mPluginID, IStatus.OK,
          NLS.bind(Messages.CheckstyleLog_msgStatusPrefix, message), t);
  mPluginLog.log(status);
}
 
Example 3
Source File: ContractConstraintInputValidator.java    From bonita-studio with GNU General Public License v2.0 6 votes vote down vote up
@Override
public IStatus validate(final Object value) {
    checkArgument(value instanceof ContractConstraint);
    final ContractConstraint constraint = (ContractConstraint) value;
    final List<String> constraintInputNames = constraint.getInputNames();
    if (constraintInputNames.isEmpty()) {
        return ValidationStatus.error(Messages.bind(Messages.noInputReferencedInConstraintExpression, constraint.getName()));
    }
    final Set<String> existingInputNames = allContractInputNames(ModelHelper.getFirstContainerOfType(constraint, Contract.class));
    final MultiStatus status = new MultiStatus(ContractPlugin.PLUGIN_ID, IStatus.OK, "", null);
    for (final String name : constraintInputNames) {
        if (!existingInputNames.contains(name)) {
            status.add(ValidationStatus.error(Messages.bind(Messages.unknownInputReferencedInConstraintExpression, name, constraint.getName())));
        }
    }
    return status;
}
 
Example 4
Source File: IDEFileReportProvider.java    From birt with Eclipse Public License 1.0 6 votes vote down vote up
public void saveReport( ModuleHandle moduleHandle, Object element,
		IPath origReportPath, IProgressMonitor monitor )
{
	if ( element instanceof IFileEditorInput )
	{
		IFileEditorInput input = (IFileEditorInput) element;
		IFile file = input.getFile( );
		if ( ResourcesPlugin.getWorkspace( ).validateEdit( new IFile[]{
			file
		}, IWorkspace.VALIDATE_PROMPT ).getSeverity( ) == IStatus.OK )
		{
			saveFile( moduleHandle, file, origReportPath, monitor );
		}
	}
	else if ( element instanceof IEditorInput )
	{
		IPath path = getInputPath( (IEditorInput) element );
		if ( path != null )
		{
			saveFile( moduleHandle, path.toFile( ), origReportPath, monitor );
		}
	}

}
 
Example 5
Source File: SelectLanguageConfigurationWizardPage.java    From tm4e with Eclipse Public License 1.0 6 votes vote down vote up
private static void applyToStatusLine(DialogPage page, IStatus status) {
	String message = Status.OK_STATUS.equals(status) ? null : status.getMessage();
	switch (status.getSeverity()) {
	case IStatus.OK:
		page.setMessage(message, IMessageProvider.NONE);
		page.setErrorMessage(null);
		break;
	case IStatus.WARNING:
		page.setMessage(message, IMessageProvider.WARNING);
		page.setErrorMessage(null);
		break;
	case IStatus.INFO:
		page.setMessage(message, IMessageProvider.INFORMATION);
		page.setErrorMessage(null);
		break;
	default:
		if (message != null && message.length() == 0) {
			message = null;
		}
		page.setMessage(null);
		page.setErrorMessage(message);
		break;
	}
}
 
Example 6
Source File: ValidateAction.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
private static int diagnosticToStatusSeverity(int diagnosticSeverity) {
	if (diagnosticSeverity == Diagnostic.OK) {
		return IStatus.OK;
	} else if (diagnosticSeverity == Diagnostic.INFO) {
		return IStatus.INFO;
	} else if (diagnosticSeverity == Diagnostic.WARNING) {
		return IStatus.WARNING;
	} else if (diagnosticSeverity == Diagnostic.ERROR || diagnosticSeverity == Diagnostic.CANCEL) {
		return IStatus.ERROR;
	}
	return IStatus.INFO;
}
 
Example 7
Source File: TextSearchVisitor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
public TextSearchVisitor(TextSearchRequestor collector, Pattern searchPattern) {
	fCollector= collector;
	fStatus = new MultiStatus(IConstants.PLUGIN_ID, IStatus.OK, "Problems encountered during text search.", null);

	fSearchPattern= searchPattern;

	fIsLightweightAutoRefresh= Platform.getPreferencesService().getBoolean(ResourcesPlugin.PI_RESOURCES, ResourcesPlugin.PREF_LIGHTWEIGHT_AUTO_REFRESH, false, null);
}
 
Example 8
Source File: RemoveBoundaryWithItsFlows.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
protected IStatus doExecute(final IProgressMonitor monitor, final IAdaptable info) throws ExecutionException {
    /*
     * Remove the BoundaryEvent from the list and
     * its incoming and outgoing transition
     */
    boundaryHolder.getBoundaryIntermediateEvents().remove(boundaryToRemove);
    cleanExceptionFlow();
    cleanMessageFlow();

    return new Status(IStatus.OK, "org.bonitasoft.studio.diagram.common", "Remove boundary child succeeded");
}
 
Example 9
Source File: PropertyHandleInputDialog.java    From birt with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * 
 * @param severity
 * @param message
 * @return
 */
protected Status getMiscStatus( int severity, String message )
{
	return new Status( severity,
			PlatformUI.PLUGIN_ID,
			IStatus.OK,
			message,
			null );
}
 
Example 10
Source File: CustomXmlTraceValidTest.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Test all the invalid xml files
 */
@Test
public void testValid() {
    IStatus valid = getTrace().validate(null, getPath());
    if (IStatus.OK != valid.getSeverity()) {
        fail(valid.toString());
    }
}
 
Example 11
Source File: TextSearchVisitor.java    From eclipse.jdt.ls with Eclipse Public License 2.0 5 votes vote down vote up
@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 12
Source File: PDFMigrationReportWriter.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private com.itextpdf.text.Image getImageForStatus(int status) throws BadElementException, MalformedURLException, IOException {
	switch (status) {
	case IStatus.OK: Image im =  Image.getInstance(FileLocator.toFileURL(MigrationPlugin.getDefault().getBundle().getResource("/icons/valid.png")));im.setCompressionLevel(12);im.scaleToFit(12, 12);return im;
	case IStatus.WARNING:  im = Image.getInstance(FileLocator.toFileURL(MigrationPlugin.getDefault().getBundle().getResource("/icons/warning.gif")));im.setCompressionLevel(12);im.scaleToFit(16, 16);return im;
	case IStatus.ERROR:  im = Image.getInstance(FileLocator.toFileURL(MigrationPlugin.getDefault().getBundle().getResource("/icons/error.png")));im.setCompressionLevel(12);im.scaleToFit(12, 12);return im;
	default:break;
	}

	return null;
}
 
Example 13
Source File: StatusColumnLabelProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
@Override
public String getToolTipText(Object element) {
	int status =  ((Change) element).getStatus();
	switch (status) {
	case IStatus.OK: return Messages.okStatusTooltip;
	case IStatus.WARNING: return Messages.warningStatusTooltip;
	case IStatus.ERROR: return Messages.errorStatusTooltip;
	default:break;
	}
	return super.getToolTipText(element);
}
 
Example 14
Source File: StatusCollectors.java    From bonita-studio with GNU General Public License v2.0 4 votes vote down vote up
private static Supplier<MultiStatus> multiStatusSupplier() {
    return () -> new MultiStatus("unknownId", IStatus.OK, "", null);
}
 
Example 15
Source File: StatusInfo.java    From xtext-eclipse with Eclipse Public License 2.0 4 votes vote down vote up
public void setOK() {
	fStatusMessage = null;
	fSeverity = IStatus.OK;
}
 
Example 16
Source File: CompletionProposalComputerDescriptor.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private IStatus createExceptionStatus(InvalidRegistryObjectException x) {
	// extension has become invalid - log & disable
	String blame= createBlameMessage();
	String reason= JavaTextMessages.CompletionProposalComputerDescriptor_reason_invalid;
	return new Status(IStatus.INFO, JavaPlugin.getPluginId(), IStatus.OK, blame + " " + reason, x); //$NON-NLS-1$
}
 
Example 17
Source File: DotCorpusSerializer.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
/**
 * Writes the <code>DotCorpus</code> instance to the given <code>OutputStream</code>.
 * 
 * @param dotCorpus
 *          the {@link DotCorpus} object to serialize.
 * @param out
 *          - the stream to write the current <code>DotCorpus</code> instance.
 * @throws CoreException -
 */
public static void serialize(DotCorpus dotCorpus, OutputStream out) throws CoreException {

  XMLSerializer xmlSerializer = new XMLSerializer(out, true);
  ContentHandler xmlSerHandler = xmlSerializer.getContentHandler();

  try {
    xmlSerHandler.startDocument();
    xmlSerHandler.startElement("", CONFIG_ELEMENT, CONFIG_ELEMENT, new AttributesImpl());

    for (String corpusFolder : dotCorpus.getCorpusFolderNameList()) {
      AttributesImpl corpusFolderAttributes = new AttributesImpl();
      corpusFolderAttributes.addAttribute("", "", CORPUS_FOLDER_ATTRIBUTE, "", corpusFolder);

      xmlSerHandler.startElement("", CORPUS_ELEMENT, CORPUS_ELEMENT, corpusFolderAttributes);
      xmlSerHandler.endElement("", CORPUS_ELEMENT, CORPUS_ELEMENT);
    }

    for (AnnotationStyle style : dotCorpus.getAnnotationStyles()) {
      AttributesImpl styleAttributes = new AttributesImpl();
      styleAttributes.addAttribute("", "", STYLE_TYPE_ATTRIBUTE, "", style.getAnnotation());
      styleAttributes.addAttribute("", "", STYLE_STYLE_ATTRIBUTE, "", style.getStyle().name());

      Color color = style.getColor();
      int colorInt = new Color(color.getRed(), color.getGreen(), color.getBlue()).getRGB();
      styleAttributes.addAttribute("", "", STYLE_COLOR_ATTRIBUTE, "", Integer.toString(colorInt));
      styleAttributes.addAttribute("", "", STYLE_LAYER_ATTRIBUTE, "", Integer.toString(style
              .getLayer()));
      if (style.getConfiguration() != null) {
        styleAttributes.addAttribute("", "", STYLE_CONFIG_ATTRIBUTE, "", style
                .getConfiguration());
      }

      xmlSerHandler.startElement("", STYLE_ELEMENT, STYLE_ELEMENT, styleAttributes);
      xmlSerHandler.endElement("", STYLE_ELEMENT, STYLE_ELEMENT);
    }

    for (String type : dotCorpus.getShownTypes()) {
      
      AttributesImpl shownAttributes = new AttributesImpl();
      shownAttributes.addAttribute("", "", SHOWN_TYPE_ATTRIBUTE, "", type);
      shownAttributes.addAttribute("", "", SHOWN_IS_VISISBLE_ATTRIBUTE, "", "true");
      
      xmlSerHandler.startElement("", SHOWN_ELEMENT, SHOWN_ELEMENT, shownAttributes);
      xmlSerHandler.endElement("", SHOWN_ELEMENT, SHOWN_ELEMENT);
    }
    
    if (dotCorpus.getTypeSystemFileName() != null) {
      AttributesImpl typeSystemFileAttributes = new AttributesImpl();
      typeSystemFileAttributes.addAttribute("", "", TYPESYTEM_FILE_ATTRIBUTE, "", dotCorpus
              .getTypeSystemFileName());

      xmlSerHandler.startElement("", TYPESYSTEM_ELEMENT, TYPESYSTEM_ELEMENT,
              typeSystemFileAttributes);
      xmlSerHandler.endElement("", TYPESYSTEM_ELEMENT, TYPESYSTEM_ELEMENT);
    }

    for (String folder : dotCorpus.getCasProcessorFolderNames()) {
      AttributesImpl taggerConfigAttributes = new AttributesImpl();
      taggerConfigAttributes.addAttribute("", "", CAS_PROCESSOR_FOLDER_ATTRIBUTE, "", folder);

      xmlSerHandler.startElement("", CAS_PROCESSOR_ELEMENT, CAS_PROCESSOR_ELEMENT,
              taggerConfigAttributes);
      xmlSerHandler.endElement("", CAS_PROCESSOR_ELEMENT, CAS_PROCESSOR_ELEMENT);
    }

    if (dotCorpus.getEditorLineLengthHint() != DotCorpus.EDITOR_LINE_LENGTH_HINT_DEFAULT) {
      AttributesImpl editorLineLengthHintAttributes = new AttributesImpl();
      editorLineLengthHintAttributes.addAttribute("", "", EDITOR_LINE_LENGTH_ATTRIBUTE, "",
              Integer.toString(dotCorpus.getEditorLineLengthHint()));

      xmlSerHandler.startElement("", EDITOR_ELEMENT, EDITOR_ELEMENT,
              editorLineLengthHintAttributes);
      xmlSerHandler.endElement("", EDITOR_ELEMENT, EDITOR_ELEMENT);
    }

    xmlSerHandler.endElement("", CONFIG_ELEMENT, CONFIG_ELEMENT);
    xmlSerHandler.endDocument();
  } catch (SAXException e) {
    String message = e.getMessage() != null ? e.getMessage() : "";

    IStatus s = new Status(IStatus.ERROR, CasEditorPlugin.ID, IStatus.OK, message, e);
    throw new CoreException(s);
  }
}
 
Example 18
Source File: StatusInfo.java    From Pydev with Eclipse Public License 1.0 4 votes vote down vote up
/**
 *  Returns if the status' severity is OK.
 */
@Override
public boolean isOK() {
    return fSeverity == IStatus.OK;
}
 
Example 19
Source File: RenameRefactoringProcessor.java    From xds-ide with Eclipse Public License 1.0 4 votes vote down vote up
protected RefactoringStatus findMatches(IProgressMonitor monitor,
		CheckConditionsContext context) {
	ifile2SymbolMatches.clear();
	
	
	IModulaSymbol symbol = renameRefactoringInfo.getSymbolFromSelection();
	IFile activeIFile = renameRefactoringInfo.getActiveIFile();
	
	if (symbol.isAttributeSet(SymbolAttribute.ALREADY_DEFINED)) {
		if (symbol instanceof IBlockSymbolTextBinding) {
			IBlockSymbolTextBinding binding = (IBlockSymbolTextBinding) symbol;
			Collection<ITextRegion> nameTextRegions = binding.getNameTextRegions();
			for (ITextRegion textRegion : nameTextRegions) {
				putMatchIfAbsent(new ModulaSymbolMatch(activeIFile, symbol, new TextPosition(-1, -1, textRegion.getOffset())));
			}
		}
		else {
			putMatchIfAbsent(new ModulaSymbolMatch(activeIFile, symbol, symbol.getPosition()));
		}
	}
	else {
		SymbolModelManager.instance().waitUntilModelIsUpToDate();
		ModulaSearchInput m2SearchInput = new ModulaSearchInput(ResourceUtils.getProject(activeIFile));
		m2SearchInput.setLimitTo(ModulaSearchInput.LIMIT_TO_USAGES | ModulaSearchInput.LIMIT_TO_DECLARATIONS);
		m2SearchInput.setSearchFor(ModulaSearchInput.SEARCH_FOR_ANY_ELEMENT);
		m2SearchInput.setSearchInFlags(ModulaSearchInput.SEARCH_IN_ALL_SOURCES);
		m2SearchInput.setSearchModifiers(ModulaSearchInput.MODIFIER_ALL_NAME_OCCURENCES);
		IProject project = renameRefactoringInfo.getProject();
		m2SearchInput.setSearchScope(FileTextSearchScope.newSearchScope(new IResource[]{project}, new String[]{"*"}, false)); //$NON-NLS-1$
		m2SearchInput.setSearchFor(ModulaSearchUtils.getSearchForConstant(symbol));
		Set<String> symbolQualifiedNames = ModulaSearchUtils.getSymbolQualifiedNames(symbol);
		m2SearchInput.setSymbolQualifiedNames(symbolQualifiedNames);
		
		ISearchResultCollector searchResultCollector = new ISearchResultCollector() {
			@Override
			public void accept(Object objMatch) {
				if (objMatch instanceof ModulaSymbolMatch) {
					ModulaSymbolMatch match = (ModulaSymbolMatch)objMatch;
					putMatchIfAbsent(match);
				}
			}
		};
		ModulaSearchOperation op = new ModulaSearchOperation(m2SearchInput, searchResultCollector);
		MultiStatus status = new MultiStatus(CoreRefactoringPlugin.PLUGIN_ID, IStatus.OK, Messages.RenameRefactoringProcessor_ErrorWhileComputingLocationsToRename, null);
		op.execute(monitor, status);
		
		SymbolModelManager.instance().waitUntilModelIsUpToDate();
		
		if (ifile2SymbolMatches.keySet().size() > 0) {
			IConditionChecker checker = context.getChecker( ValidateEditChecker.class );
			ValidateEditChecker editChecker = ( ValidateEditChecker )checker;
			editChecker.addFiles( ifile2SymbolMatches.keySet().toArray(new IFile[0]) );
		}
		
		monitor.done();
	}
	
	return new RefactoringStatus();
}
 
Example 20
Source File: NLSSearchQuery.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public IStatus run(IProgressMonitor monitor) {
	monitor.beginTask("", 5 * fWrapperClass.length); //$NON-NLS-1$

	try {
		final AbstractTextSearchResult textResult= (AbstractTextSearchResult) getSearchResult();
		textResult.removeAll();

		for (int i= 0; i < fWrapperClass.length; i++) {
			IJavaElement wrapperClass= fWrapperClass[i];
			IFile propertieFile= fPropertiesFile[i];
			if (! wrapperClass.exists())
				return JavaUIStatus.createError(0, Messages.format(NLSSearchMessages.NLSSearchQuery_wrapperNotExists, JavaElementLabels.getElementLabel(wrapperClass, JavaElementLabels.ALL_DEFAULT)), null);
			if (! propertieFile.exists())
				return JavaUIStatus.createError(0, Messages.format(NLSSearchMessages.NLSSearchQuery_propertiesNotExists, BasicElementLabels.getResourceName(propertieFile)), null);

			SearchPattern pattern= SearchPattern.createPattern(wrapperClass, IJavaSearchConstants.REFERENCES, SearchUtils.GENERICS_AGNOSTIC_MATCH_RULE);
			SearchParticipant[] participants= new SearchParticipant[] {SearchEngine.getDefaultSearchParticipant()};

			NLSSearchResultRequestor requestor= new NLSSearchResultRequestor(propertieFile, fResult);
			try {
				SearchEngine engine= new SearchEngine();
				engine.search(pattern, participants, fScope, requestor, new SubProgressMonitor(monitor, 4));
				requestor.reportUnusedPropertyNames(new SubProgressMonitor(monitor, 1));

				ICompilationUnit compilationUnit= ((IType)wrapperClass).getCompilationUnit();
				CompilationUnitEntry groupElement= new CompilationUnitEntry(NLSSearchMessages.NLSSearchResultCollector_unusedKeys, compilationUnit);

				boolean hasUnusedPropertie= false;
				IField[] fields= ((IType)wrapperClass).getFields();
				for (int j= 0; j < fields.length; j++) {
					IField field= fields[j];
					if (isNLSField(field)) {
						ISourceRange sourceRange= field.getSourceRange();
						if (sourceRange != null) {
							String fieldName= field.getElementName();
							if (!requestor.hasPropertyKey(fieldName)) {
								fResult.addMatch(new Match(compilationUnit, sourceRange.getOffset(), sourceRange.getLength()));
							}
							if (!requestor.isUsedPropertyKey(fieldName)) {
								hasUnusedPropertie= true;
								fResult.addMatch(new Match(groupElement, sourceRange.getOffset(), sourceRange.getLength()));
							}
						}
					}
				}
				if (hasUnusedPropertie)
					fResult.addCompilationUnitGroup(groupElement);

			} catch (CoreException e) {
				return new Status(e.getStatus().getSeverity(), JavaPlugin.getPluginId(), IStatus.OK, NLSSearchMessages.NLSSearchQuery_error, e);
			}
		}
	} finally {
		monitor.done();
	}
	return 	Status.OK_STATUS;
}