Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

FAQ How do I create my own tasks, problems, bookmarks, and so on?

Revision as of 16:31, 14 March 2006 by Claffra (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Annotations can be added to resources in the workspace by creating IMarker objects. These markers are used to represent compile errors, to-do items, bookmarks, search results, and many other types of annotations. You can create your own marker types for storing annotations for use by your own plug-in. Each marker can store an arbitrary set of attributes. Attributes are keyed by a string, and the values can be strings, Booleans, or integers. The IMarker interface defines some common attribute types, but you are free to create your own attribute names for your markers. Here is an example snippet that creates a marker, adds some attributes, and then deletes it:

   final IFile file = null;
   IMarker marker = file.createMarker(IMarker.MARKER);
   marker.setAttribute(IMarker.MESSAGE, "This is my marker");
   marker.setAttribute("Age", 5);
   marker.delete();

When markers are created, modified, or deleted, a resource change event will be broadcast, telling interested parties about the change. You can search for markers by using the findMarkers methods on IResource.

The org.eclipse.core.resources.markers extension point can be used to declaratively define new marker types. See its documentation for an explanation and examples.


See Also:

FAQ_How_can_I_be_notified_of_changes_to_the_workspace?

[[FAQ_Why_don%26%23146%3Bt_my_markers_appear_in_the_editor%26%23146%3Bs_vertical_ruler%3F]]

FAQ_How_do_I_create_problem_markers_for_my_compiler?

Go to Platform Plug-in Developer Guide > Programmer’s Guide > Resources overview > Resource markers, Eclipse online article “Mark My Words”


This FAQ was originally published in Official Eclipse 3.0 FAQs. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the Eclipse Public License v1.0.

Back to the top