Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 7448 - IMarker cannot be deleted by user even if set to DONE
Summary: IMarker cannot be deleted by user even if set to DONE
Status: RESOLVED INVALID
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 1.0   Edit
Hardware: PC Windows 2000
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Nick Edgar CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-01-10 13:32 EST by rolarenfan CLA
Modified: 2002-01-10 16:33 EST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description rolarenfan CLA 2002-01-10 13:32:00 EST
build 137 

org.eclipse.core.resources.IMarker

compare bug 7244, item "d)" and the thread "(New) Question on deleting 
(in)complete tasks..." on the newsgroup eclipse.tools

I programmatically create a new Task (per the code in "Mark My Words" at 
www.eclipse.org/articles), and it shows up in the Tasks View, it is not a 
compiler error or anything like that, but is something which a user might wish 
to delete.

But even if I programmatically mark it as completed, there is no way for the 
user to delete it: that Task's context-menu item "Delete" is never enabled, and 
there is no user interface (that I can find) for marking the Task as completed.

Here is some xml and code, from my plugin "LineCounter1": 

<extension
      id="counter"
      name="counter"
      point="org.eclipse.core.resources.markers">
   <super
         type="org.eclipse.core.resources.problemmarker">
   </super>
   <transient
         value="false">
   </transient>
</extension>

=========================================================================

    public void setActiveEditor(IAction arg0, IEditorPart edPart) {
        this.edPart = edPart;
        IEditorInput iei = (IEditorInput) this.edPart.getEditorInput();
        if (iei instanceof IFileEditorInput) {
            try {
                IFile ifile = ((IFileEditorInput) iei).getFile();
                // clear out any old ones
                IMarker[] markers =
                    ifile.findMarkers(COUNT_TYPE, true, 
                                      IResource.DEPTH_INFINITE);
                for (int i = 0; i < markers.length; ++i) {
                    if ((null == this.marker) || 
                        (this.marker.getId() != markers[i].getId())) {
                        markers[i].delete();
                    }
                }
                if (null == this.marker || !this.marker.exists()) {
                    this.marker = ifile.createMarker(COUNT_TYPE);
                    this.marker.setAttribute(IMarker.DONE, true);
                    // so user can delete if desired -- @@ FAILS @@ 
                }
            }
            catch (CoreException ce) {
                ce.printStackTrace();
            }
        }
        else {
            System.out.println(
                "setActiveEditor(): IEditorInput is a " + iei.getClass());
        }
    } // end setActiveEditor() 

    private IEditorPart edPart;
    private IMarker marker;
    private static final String COUNT_TYPE = "LineCounter1.counter";
Comment 1 DJ Houghton CLA 2002-01-10 13:46:56 EST
User's problem has to do with enablement of context menu operations based on 
marker attribute values. 

Moving to Platform/UI.
Comment 2 Nick Edgar CLA 2002-01-10 16:33:14 EST
This works as intended.  You cannot delete problem markers from the UI, only 
task markers.  Problem markers are usually generated programmatically, e.g. by 
the Java builder, and should not be modified or deleted by the user.
Try creating your marker as a subtype of org.eclipse.core.resources.taskmarker 
instead.

Note that you don't have to change the done status before deleting it.