Java Code Examples for org.eclipse.core.resources.IMarker#SEVERITY_WARNING

The following examples show how to use org.eclipse.core.resources.IMarker#SEVERITY_WARNING . 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: ExternalResourceManager.java    From xds-ide with Eclipse Public License 1.0 6 votes vote down vote up
private static void createLinkProblemMarkers(IProject p, Collection<IStatus> linkStatuses) throws CoreException {
	for (IStatus status : linkStatuses) {
		if (!status.isOK()) {
			int statusSeverity = status.getSeverity();
			int markerSeverity;
			if (statusSeverity == IStatus.ERROR) {
				markerSeverity = IMarker.SEVERITY_ERROR;
			}
			else if (statusSeverity == IStatus.WARNING) {
				markerSeverity = IMarker.SEVERITY_WARNING;
			}
			else {
				markerSeverity = IMarker.SEVERITY_INFO;
			}
			
			IMarker marker = p.createMarker(LINK_DIRECTORY_PROBLEM_MARKER_TYPE);
			marker.setAttribute(IMarker.MESSAGE, String.format(Messages.ExternalResourceManager_ErrorWhenLinkingExternalDirectory, status.getMessage()));
			marker.setAttribute(IMarker.SEVERITY, markerSeverity);
		}
	}
}
 
Example 2
Source File: CrossflowMarkerNavigationProvider.java    From scava with Eclipse Public License 2.0 6 votes vote down vote up
/**
* @generated
*/
public static IMarker addMarker(IFile file, String elementId, String location, String message, int statusSeverity) {
	IMarker marker = null;
	try {
		marker = file.createMarker(MARKER_TYPE);
		marker.setAttribute(IMarker.MESSAGE, message);
		marker.setAttribute(IMarker.LOCATION, location);
		marker.setAttribute(org.eclipse.gmf.runtime.common.ui.resources.IMarker.ELEMENT_ID, elementId);
		int markerSeverity = IMarker.SEVERITY_INFO;
		if (statusSeverity == IStatus.WARNING) {
			markerSeverity = IMarker.SEVERITY_WARNING;
		} else if (statusSeverity == IStatus.ERROR || statusSeverity == IStatus.CANCEL) {
			markerSeverity = IMarker.SEVERITY_ERROR;
		}
		marker.setAttribute(IMarker.SEVERITY, markerSeverity);
	} catch (CoreException e) {
		CrossflowDiagramEditorPlugin.getInstance().logError("Failed to create validation marker", e); //$NON-NLS-1$
	}
	return marker;
}
 
Example 3
Source File: ProcessValidationDecoratorProvider.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
/**
* @generated
*/
private Image getImage(int severity) {
	String imageName = ISharedImages.IMG_OBJS_ERROR_TSK;
	switch (severity) {
	case IMarker.SEVERITY_ERROR:
		imageName = ISharedImages.IMG_OBJS_ERROR_TSK;
		break;
	case IMarker.SEVERITY_WARNING:
		imageName = ISharedImages.IMG_OBJS_WARN_TSK;
		break;
	default:
		imageName = ISharedImages.IMG_OBJS_INFO_TSK;
	}
	return PlatformUI.getWorkbench().getSharedImages().getImage(imageName);
}
 
Example 4
Source File: MarkerCreator.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
private Object getSeverity(Issue issue) {
	switch (issue.getSeverity()) {
		case ERROR : 
			return IMarker.SEVERITY_ERROR;
		case WARNING : 
			return IMarker.SEVERITY_WARNING;
		case INFO : 
			return IMarker.SEVERITY_INFO;
		default:
			throw new IllegalArgumentException(String.valueOf(issue.getSeverity()));
	}
}
 
Example 5
Source File: IssueUtil.java    From xtext-eclipse with Eclipse Public License 2.0 5 votes vote down vote up
/**
 * Translates IMarker.SEVERITY to Severity
 * @param severity Severity to translate
 * @return Translated severity or <code>null</code>
 * @since 2.9
 */
protected Severity translateSeverity(int severity) {
	switch (severity) {
		case IMarker.SEVERITY_ERROR:
			return Severity.ERROR;
		case IMarker.SEVERITY_WARNING:
			return Severity.WARNING;
		case IMarker.SEVERITY_INFO:
			return Severity.INFO;
		default:
			return null;
	}
}
 
Example 6
Source File: JsonSchemaValidator.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 5 votes vote down vote up
public static int getLevel(JsonNode message) {
    if (message == null || !message.has("level")) {
        return IMarker.SEVERITY_INFO;
    }

    switch (message.get("level").asText()) {
    case "error":
    case "fatal":
        return IMarker.SEVERITY_ERROR;
    case "warning":
        return IMarker.SEVERITY_WARNING;
    default:
        return IMarker.SEVERITY_INFO;
    }
}
 
Example 7
Source File: IDETypeScriptProject.java    From typescript.java with MIT License 5 votes vote down vote up
private int getSeverity(DiagnosticCategory category) {
	switch (category) {
	case Message:
		return IMarker.SEVERITY_INFO;
	case Warning:
		return IMarker.SEVERITY_WARNING;
	default:
		return IMarker.SEVERITY_ERROR;
	}
}
 
Example 8
Source File: ErrorProcessor.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 5 votes vote down vote up
protected int getLevel(JsonNode message) {
    if (message == null || !message.has("level")) {
        return IMarker.SEVERITY_INFO;
    }

    switch (message.get("level").asText()) {
    case "error":
    case "fatal":
        return IMarker.SEVERITY_ERROR;
    case "warning":
        return IMarker.SEVERITY_WARNING;
    default:
        return IMarker.SEVERITY_INFO;
    }
}
 
Example 9
Source File: AdapterFactory.java    From tlaplus with MIT License 5 votes vote down vote up
/**
 * Retrieves the text representation of the TLA+ parse problem
 * @param problem
 * @return
 */
public static String getSeverityAsText(int severity)
{
    switch (severity) {
    case IMarker.SEVERITY_ERROR:
        return "Error";
    case IMarker.SEVERITY_WARNING:
        return "Warning";
    case IMarker.SEVERITY_INFO:
    default:
        return "Info";
    }
}
 
Example 10
Source File: GeneratorMarkerSupport.java    From n4js with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public void createMarker(Resource res, String message, Severity severity) {

	final int severityEclipse;
	switch (severity) {
	case INFO:
		severityEclipse = IMarker.SEVERITY_INFO;
		break;
	case WARNING:
		severityEclipse = IMarker.SEVERITY_WARNING;
		break;
	default:
		severityEclipse = IMarker.SEVERITY_ERROR;
		break;
	}

	try {
		IMarker marker = toIFile(res).createMarker(MARKER__ORG_ECLIPSE_IDE_N4JS_UI_COMPILER_ERROR);
		marker.setAttribute(IMarker.MESSAGE, message);
		marker.setAttribute(IMarker.SEVERITY, severityEclipse);
		marker.setAttribute(IMarker.LINE_NUMBER, 1);
	} catch (CoreException e) {
		LOGGER.error(e.getStatus());
		String resInfo = "";
		if (res != null) {
			if (res.getURI() != null) {
				resInfo = "on resource with uri=" + res.getURI();
			} else {
				resInfo = "on resource=" + res;
			}
		}
		throw new RuntimeException("Cannot create error marker with message='" + message + "' " + resInfo + ".", e);
	}
}
 
Example 11
Source File: CheckstyleMarkerFilter.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Selects markers by its severity.
 *
 * @param item
 *          the marker
 * @return <code>true</code> if the marker is selected
 */
private boolean selectBySeverity(IMarker item) {
  if (mSelectBySeverity) {
    int markerSeverity = item.getAttribute(IMarker.SEVERITY, -1);
    if (markerSeverity == IMarker.SEVERITY_ERROR) {
      return (mSeverity & SEVERITY_ERROR) > 0;
    } else if (markerSeverity == IMarker.SEVERITY_WARNING) {
      return (mSeverity & SEVERITY_WARNING) > 0;
    } else if (markerSeverity == IMarker.SEVERITY_INFO) {
      return (mSeverity & SEVERITY_INFO) > 0;
    }
  }

  return true;
}
 
Example 12
Source File: BatchValidationOperation.java    From bonita-studio with GNU General Public License v2.0 5 votes vote down vote up
private int toStatusSeverity(final int markerSeverity) {
    switch (markerSeverity) {
        case IMarker.SEVERITY_INFO:
            return IStatus.INFO;
        case IMarker.SEVERITY_WARNING:
            return IStatus.WARNING;
        case IMarker.SEVERITY_ERROR:
            return IStatus.ERROR;
        default:
            return IStatus.INFO;
    }
}
 
Example 13
Source File: ReporterMessagePlacementStrategy.java    From gwt-eclipse-plugin with Eclipse Public License 1.0 5 votes vote down vote up
private static int severityFromIMarkerSeverity(int imarkerSeverity) {
  switch (imarkerSeverity) {
    case IMarker.SEVERITY_ERROR:
      return IMessage.HIGH_SEVERITY;

    case IMarker.SEVERITY_WARNING:
      return IMessage.NORMAL_SEVERITY;

    case IMarker.SEVERITY_INFO:
      return IMessage.LOW_SEVERITY;

    default:
      return IMessage.LOW_SEVERITY;
  }
}
 
Example 14
Source File: ProblemTickUpdater.java    From typescript.java with MIT License 5 votes vote down vote up
public Image getImage(int severity, ScriptKindName scriptKind) {
	boolean jsx = ScriptKindName.JSX.equals(scriptKind) || ScriptKindName.TSX.equals(scriptKind);
	switch (severity) {
	case IMarker.SEVERITY_ERROR:
		return jsx ? JSDTTypeScriptUIImages.JSXFILE_W_ERROR.get() : JSDTTypeScriptUIImages.TSFILE_W_ERROR.get();
	case IMarker.SEVERITY_WARNING:
		return jsx ? JSDTTypeScriptUIImages.JSXFILE_W_WARNING.get() : JSDTTypeScriptUIImages.TSFILE_W_WARNING.get();
	default:
		return jsx ? JSDTTypeScriptUIImages.JSXFILE.get() : JSDTTypeScriptUIImages.TSFILE.get();
	}
}
 
Example 15
Source File: AbstractBuildParticipant.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
protected IProblem createWarning(String message, int lineNumber, int offset, int length, String sourcePath)
{
	return new Problem(IMarker.SEVERITY_WARNING, message, offset, length, lineNumber, sourcePath);
}
 
Example 16
Source File: CMakeErrorParser.java    From cmake4eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
int getSeverity() {
  return IMarker.SEVERITY_WARNING;
}
 
Example 17
Source File: CMakeErrorParser.java    From cmake4eclipse with Eclipse Public License 2.0 4 votes vote down vote up
@Override
int getSeverity() {
  return IMarker.SEVERITY_WARNING;
}
 
Example 18
Source File: Problem.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public boolean isWarning()
{
	return severity == IMarker.SEVERITY_WARNING;
}
 
Example 19
Source File: MavenPluginElement.java    From google-cloud-eclipse with Apache License 2.0 4 votes vote down vote up
public MavenPluginElement(DocumentLocation start, int length) {
  super(message, markerId, IMarker.SEVERITY_WARNING, IMessage.NORMAL_SEVERITY,
      start, length, null /* Null IQuickAssistProcessor */);
}
 
Example 20
Source File: AbstractProgramRunner.java    From texlipse with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Create a layout warning marker to the given resource.
 *
 * @param resource the file where the problem occured
 * @param message error message
 * @param lineNumber line number
 */
public static void createLayoutMarker(IResource resource, Integer lineNumber, String message) {
    String markerType = TexlipseBuilder.LAYOUT_WARNING_TYPE;
    int severity = IMarker.SEVERITY_WARNING;
    createMarker(resource, lineNumber, message, markerType, severity);
}