Difference between revisions of "FAQ How do I create my own tasks, problems, bookmarks, and so on?"

From Eclipsepedia

Jump to: navigation, search
 
m
 
Line 1: Line 1:
Annotations can be added to resources in the workspace by creating
+
Annotations can be added to resources in the workspace by creating <tt>IMarker</tt> 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 <tt>IMarker</tt> 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:
<tt>IMarker</tt> 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 <tt>IMarker</tt> 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:
+
 
<pre>
 
<pre>
 
   final IFile file = null;
 
   final IFile file = null;
Line 18: Line 7:
 
   marker.delete();
 
   marker.delete();
 
</pre>
 
</pre>
When markers are created, modified, or deleted, a resource change
+
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 <tt>findMarkers</tt> methods on <tt>IResource</tt>.
event will be broadcast, telling interested parties about the change.
+
You can search for markers by using the <tt>findMarkers</tt> methods
+
on <tt>IResource</tt>.
+
 
+
The <tt>org.eclipse.core.resources.markers</tt> extension point can
+
be used to declaratively define new marker types.
+
See its documentation for an explanation and examples.
+
  
 +
The <tt>org.eclipse.core.resources.markers</tt> extension point can be used to declaratively define new marker types. See its documentation for an explanation and examples.
  
 
== See Also: ==
 
== See Also: ==
 +
*[[FAQ How can I be notified of changes to the workspace?]]
 +
*[[FAQ Why don't my markers appear in the editor's vertical ruler?]]
 +
*[[FAQ How do I create problem markers for my compiler?]]
 +
*Go to '''Platform Plug-in Developer Guide &gt; Programmer&#146;s Guide &gt; Resources overview &gt; Resource markers'''
 +
*Eclipse online article [http://www.eclipse.org/articles/Article-Mark%20My%20Words/mark-my-words.html "Mark My Words"]
  
[[FAQ_How_can_I_be_notified_of_changes_to_the_workspace%3F]]
+
{{Template:FAQ_Tagline}}
 
+
[[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%3F]]
+
 
+
Go to '''Platform Plug-in Developer Guide &gt; Programmer&#146;s Guide
+
&gt; Resources overview &gt; Resource markers''',
+
Eclipse online article &#147;Mark My Words&#148;
+
 
+
<hr><font size=-2>This FAQ was originally published in [http://www.eclipsefaq.org Official Eclipse 3.0 FAQs]. Copyright 2004, Pearson Education, Inc. All rights reserved. This text is made available here under the terms of the [http://www.eclipse.org/legal/epl-v10.html Eclipse Public License v1.0].</font>
+

Latest revision as of 23:40, 18 June 2006

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.

[edit] See Also:


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.