Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Platform » Marker problem
Marker problem [message #326252] Thu, 13 March 2008 08:32 Go to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

I detected a problem with markers inside my rcp appliction.
I use markers (IMarker.TASK) inside a special editior to mark lines for a special purpose. I created actions to create them and delete them.

Code Snippet for deletion:

IMarker[] markersfind = findMyMarkers(resource);
for (int i = 0; i < markersfind.length; i++) {
try {
markersfind[i].delete();
} catch (CoreException e) {

e.printStackTrace();
}
}


When i delete them and the file or lines are not changed everythings work like expected.
I can shutdown and restart the application and the markers are still deleted.
But the case is different if i change the file with the markers present (e.g. insert a line).
If i then delete the markers shutdown the application and restart
it again the before deleted markers are present again
(Also if i delete them in the Task view).
I guess somehow they are stored somewhere in the platform and i
have to delete this information, too.

My question now is, how can i delete markers definitely?
Do i need custom markers which are not by default persistent
(Eclipse API)like the markers i use (in my case they don't need to be saved)?

It would also be nice if someone can give me a hint for a good tutorial or code snippets are also appreciated
about custom markers because i can't find any on the web.
(i've read the article "Mark my words"!).

Thanks in advance for any answers
Re: Marker problem [message #326273 is a reply to message #326252] Thu, 13 March 2008 13:02 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Marcel,

You're sure you're not getting exceptions and just not seeing them in
the console perhaps because you aren't running with a console? It's
usually better to log problems rather than print them to stderr. You're
also sure the markers aren't being recreated as opposed to failing to
delete?


Marcel wrote:
> I detected a problem with markers inside my rcp appliction.
> I use markers (IMarker.TASK) inside a special editior to mark lines for a special purpose. I created actions to create them and delete them.
>
> Code Snippet for deletion:
>
> IMarker[] markersfind = findMyMarkers(resource);
> for (int i = 0; i < markersfind.length; i++) {
> try {
> markersfind[i].delete();
> } catch (CoreException e) {
>
> e.printStackTrace();
> }
> }
>
>
> When i delete them and the file or lines are not changed everythings work like expected.
> I can shutdown and restart the application and the markers are still deleted.
> But the case is different if i change the file with the markers present (e.g. insert a line).
> If i then delete the markers shutdown the application and restart
> it again the before deleted markers are present again
> (Also if i delete them in the Task view).
> I guess somehow they are stored somewhere in the platform and i
> have to delete this information, too.
>
> My question now is, how can i delete markers definitely?
> Do i need custom markers which are not by default persistent
> (Eclipse API)like the markers i use (in my case they don't need to be saved)?
>
> It would also be nice if someone can give me a hint for a good tutorial or code snippets are also appreciated
> about custom markers because i can't find any on the web.
> (i've read the article "Mark my words"!).
>
> Thanks in advance for any answers
>
Re: Marker problem [message #326301 is a reply to message #326273] Fri, 14 March 2008 08:20 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

I've integrated a console but i got no exceptions.
I also closed the editor and opened the file again
to see if the markers stayed deleted and they did.

Only after a complete restart of the rcp application
the markers appear again. Somwhere internally in the workbench they are saved and i want to have them deleted.
Re: Marker problem [message #326308 is a reply to message #326301] Fri, 14 March 2008 12:13 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: merks.ca.ibm.com

Marcel,

You've looked in the error log itself to see there are no exceptions?
I know that workspace state is stored when you shutdown, so I suppose
it's possible that shutdown is not properly saving the final state. You
mentioned saving the file is an important part of reproducing the
problem. Are you properly using the workspace APIs to do the save as
opposed to writing directly to the file system? If you do the save,
close the editor, and reopen the editor, does that work properly? Are
your markers only created via an explicit action not a builder of some sort?


Marcel wrote:
> I've integrated a console but i got no exceptions.
> I also closed the editor and opened the file again
> to see if the markers stayed deleted and they did.
>
> Only after a complete restart of the rcp application
> the markers appear again. Somwhere internally in the workbench they are saved and i want to have them deleted.
>
Re: Marker problem [message #326333 is a reply to message #326308] Sat, 15 March 2008 09:12 Go to previous message
Eclipse UserFriend
Originally posted by: automatic.javalobby.org

You were absolutely right with the workspace.

In the .metadata/.log file i found out that i don't save the workspace. I completely missed that because only recognized
this error with the markers in this special afore mentioned situation.

I included the following lines of code in my exit method from the
eclipse FAQ and everything works like expected.

IRunnableWithProgress runnable = new IRunnableWithProgress() {
public void run(IProgressMonitor monitor) {
try {
IWorkspace ws = ResourcesPlugin.getWorkspace();
ws.save(true, monitor);
} catch (CoreException e) {
System.out.println(e.getMessage());

}
}
};

try {
new ProgressMonitorDialog(null).run(false, false, runnable);
} catch (InvocationTargetException e) {

e.printStackTrace();
} catch (InterruptedException e) {

e.printStackTrace();
}

Thank you very much for your help!
Previous Topic:Best way to update Outline view without stilling much UI cycles in the UI thread?
Next Topic:Library to layout printed documents
Goto Forum:
  


Current Time: Mon Aug 19 15:55:20 GMT 2024

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

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

Back to the top