Skip to main content



      Home
Home » Eclipse Projects » Eclipse Platform » please, help me with persistent markers!!!!
please, help me with persistent markers!!!! [message #253341] Wed, 16 June 2004 14:18 Go to next message
Eclipse UserFriend
Originally posted by: ra.ra.com

Hi,
I'm trying to set programmatically a persistent marker on some files in
a project, but without success.

What I need to do is this: in my own special project there is one file
called "main file". Each other file in the project must remember the
name of this file. I want to set a custom marker on each file, having as
attribute name "mainFilePath", and value the path of the main file.
The main file will then have to be available in an action added to the
popup menu in the Resources Navigator.

What is happening is that everything works as long as I don't close the
project, but when I close it and open it again the marker is not
restored. It should be persistent, so what am I doing wrong?

Thanks,

RA


In the plugin I'm doing:

<extension
id="myfilemarker"
name="File Marker"
point="org.eclipse.core.resources.markers">
<persistent
value="true">
</persistent>
<attribute
name="mainFilePath">
</attribute>
</extension>


During the creation of the project, in a resource visitor I do:


IMarker marker = r.createMarker("myfilemarker");
marker.setAttribute("mainFilePath", theMainFile);



In the selectionChanged method of an IViewActionDelegate (the action in
the popup menu), I have:

public void selectionChanged(IAction action, ISelection selection) {
if (selection instanceof StructuredSelection) {
StructuredSelection structSel = (StructuredSelection)selection;
if (structSel.size() > 0) {
Object[] paths = structSel.toArray();
if (paths[0] instanceof IFile){
IFile selectedFile = (IFile)paths[0];
try{
IMarker[] markers =
selectedFile.findMarkers("myfilemarker", false,
IFile.DEPTH_ZERO);
if (markers.length > 0){
IMarker marker = markers[0];
String mainFileName =
(String)marker.getAttribute("mainFilePath");
System.out.println("main file is "+mainFileName);
}
}catch(Throwable t) {
t.printStackTrace();
}
}
}
}
}
Re: please, help me with persistent markers!!!! [message #254764 is a reply to message #253341] Tue, 22 June 2004 15:09 Go to previous message
Eclipse UserFriend
Originally posted by: john.eclipsefaq.org

The marker type that is passed to IResource.create is of the form
<plugin-id>.<extension-id>, so if your code is in a plugin called
com.xyz.foo, then your code should look like:

IMarker marker = r.createMarker("com.xyz.foo.myfilemarker");
--


ra wrote:
> During the creation of the project, in a resource visitor I do:
>
>
> IMarker marker = r.createMarker("myfilemarker");
> marker.setAttribute("mainFilePath", theMainFile);
Previous Topic:Is there lag time between creating and finding markers?
Next Topic:how to show propress bar in status line?
Goto Forum:
  


Current Time: Sat Aug 30 21:16:07 EDT 2025

Powered by FUDForum. Page generated in 0.03735 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top