Java Code Examples for org.eclipse.core.resources.IResource.createMarker()

The following are Jave code examples for showing how to use createMarker() of the org.eclipse.core.resources.IResource class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: gemoc-studio-modeldebugging   File: SiriusEditorUtils.java   View Source Code Vote up 6 votes
/**
 * Show the given {@link EObject instruction}.
 * 
 * @param editorPart
 *            the opened {@link DialectEditor}
 * @param instruction
 *            the {@link EObject instruction} to show
 */
public static void showInstruction(DialectEditor editorPart, EObject instruction) {
	final URI resourceURI = instruction.eResource().getURI();
	if (resourceURI.isPlatformResource()) {
		final String resourcePath = resourceURI.toPlatformString(true);
		final IResource resource = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(
				resourcePath));
		try {
			final IMarker marker = resource.createMarker(EValidator.MARKER);
			marker.setAttribute(EValidator.URI_ATTRIBUTE, EcoreUtil.getURI(instruction).toString());
			final TraceabilityMarkerNavigationProvider navigationProvider = new TraceabilityMarkerNavigationProvider(
					(DialectEditor)editorPart);
			navigationProvider.gotoMarker(marker);
			marker.delete();
		} catch (CoreException e) {
			DebugSiriusIdeUiPlugin.INSTANCE.log(e);
		}
	}
}
 
Example 2
Project: Equella   File: JPFManifestBuilder.java   View Source Code Vote up 5 votes
private void reportError(IResource resource, String message)
{
	try
	{
		IMarker marker = resource.createMarker(JPFClasspathPlugin.MARKER_ID);
		marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
		marker.setAttribute(IMarker.MESSAGE, message);
		marker.setAttribute(IMarker.LINE_NUMBER, 1);
	}
	catch( CoreException e )
	{
		// nothing
	}
}
 
Example 3
Project: gemoc-studio   File: Marker.java   View Source Code Vote up 5 votes
static public void addMarker(IResource resource, String markerType, String message, int lineNumber, int severity) throws CoreException
{
	IMarker marker = resource.createMarker(markerType);
	marker.setAttribute(IMarker.MESSAGE, message);
	marker.setAttribute(IMarker.SEVERITY, severity);
	if (lineNumber == -1) {
		lineNumber = 1;
	}
	marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
}
 
Example 4
Project: eclipse-batch-editor   File: AbstractMarkerHelper.java   View Source Code Vote up 4 votes
/**
 * Creates a marker on the given resource with the given type and
 * attributes.
 * <p>
 * This method modifies the workspace (progress is not reported to the
 * user).
 * </p>
 *
 * @param resource
 *            the resource
 * @param attributes
 *            the attribute map
 * @param markerType
 *            the type of marker
 * @throws CoreException
 *             if this method fails
 * @see IResource#createMarker(java.lang.String)
 */
private void internalCreateMarker(final IResource resource, final Map<String, Object> attributes,
		final String markerType) throws CoreException {

	IWorkspaceRunnable r = new IWorkspaceRunnable() {
		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			IMarker marker = resource.createMarker(markerType);
			marker.setAttributes(attributes);
			handleMarkerAdded(marker);

		}
	};

	resource.getWorkspace().run(r, null, IWorkspace.AVOID_UPDATE, null);
}
 
Example 5
Project: eclipse-bash-editor   File: AbstractMarkerHelper.java   View Source Code Vote up 4 votes
/**
 * Creates a marker on the given resource with the given type and
 * attributes.
 * <p>
 * This method modifies the workspace (progress is not reported to the
 * user).
 * </p>
 *
 * @param resource
 *            the resource
 * @param attributes
 *            the attribute map
 * @param markerType
 *            the type of marker
 * @throws CoreException
 *             if this method fails
 * @see IResource#createMarker(java.lang.String)
 */
private void internalCreateMarker(final IResource resource, final Map<String, Object> attributes,
		final String markerType) throws CoreException {

	IWorkspaceRunnable r = new IWorkspaceRunnable() {
		@Override
		public void run(IProgressMonitor monitor) throws CoreException {
			IMarker marker = resource.createMarker(markerType);
			marker.setAttributes(attributes);
			handleMarkerAdded(marker);

		}
	};

	resource.getWorkspace().run(r, null, IWorkspace.AVOID_UPDATE, null);
}
 
Example 6
Project: ec4e   File: MarkerUtils.java   View Source Code Vote up 4 votes
public static IMarker createEditorConfigMarker(IResource resource) throws CoreException {
	return resource.createMarker(EC_PROBLEM_MARKER_TYPE);
}