KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > ide > undo > DeleteMarkersOperation


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui.ide.undo;
13
14 import org.eclipse.core.resources.IMarker;
15 import org.eclipse.core.runtime.CoreException;
16 import org.eclipse.core.runtime.IAdaptable;
17 import org.eclipse.core.runtime.IProgressMonitor;
18 import org.eclipse.core.runtime.IStatus;
19 import org.eclipse.core.runtime.NullProgressMonitor;
20 import org.eclipse.ui.internal.ide.undo.UndoMessages;
21
22 /**
23  * A DeleteMarkersOperation represents an undoable operation for deleting one or
24  * more markers in the workspace. Clients may call the public API from a
25  * background thread.
26  *
27  * This class is intended to be instantiated and used by clients. It is not
28  * intended to be subclassed by clients.
29  *
30  * @since 3.3
31  *
32  */

33 public class DeleteMarkersOperation extends AbstractMarkersOperation {
34
35     /**
36      * Create an undoable operation that can delete the specified markers.
37      *
38      * @param markers
39      * the markers to be deleted
40      * @param name
41      * the name used to describe the operation that deletes the
42      * markers
43      */

44     public DeleteMarkersOperation(IMarker[] markers, String JavaDoc name) {
45         super(markers, null, null, name);
46     }
47
48     /*
49      * (non-Javadoc)
50      *
51      * Map execution to marker deletion.
52      *
53      * @see org.eclipse.ui.ide.undo.AbstractWorkspaceOperation#doExecute(org.eclipse.core.runtime.IProgressMonitor,
54      * org.eclipse.core.runtime.IAdaptable)
55      */

56     protected void doExecute(IProgressMonitor monitor, IAdaptable info)
57             throws CoreException {
58         if (monitor == null) {
59             monitor = new NullProgressMonitor();
60         }
61         monitor.beginTask("", 100); //$NON-NLS-1$
62
monitor.setTaskName(UndoMessages.MarkerOperation_DeleteProgress);
63         deleteMarkers(100, monitor);
64         monitor.done();
65     }
66
67     /*
68      * (non-Javadoc)
69      *
70      * Map undo to marker creation.
71      *
72      * @see org.eclipse.ui.ide.undo.AbstractWorkspaceOperation#doUndo(org.eclipse.core.runtime.IProgressMonitor,
73      * org.eclipse.core.runtime.IAdaptable)
74      */

75     protected void doUndo(IProgressMonitor monitor, IAdaptable info)
76             throws CoreException {
77         if (monitor == null) {
78             monitor = new NullProgressMonitor();
79         }
80         monitor.beginTask("", 100); //$NON-NLS-1$
81
monitor.setTaskName(UndoMessages.MarkerOperation_CreateProgress);
82         createMarkers(100, monitor);
83         monitor.done();
84     }
85
86     /*
87      * (non-Javadoc)
88      *
89      * Map the undo status to marker creation status.
90      *
91      * @see org.eclipse.ui.ide.undo.AbstractMarkersOperation#getBasicUndoStatus()
92      */

93     protected IStatus getBasicUndoStatus() {
94         return getMarkerCreationStatus();
95     }
96
97     /*
98      * (non-Javadoc)
99      *
100      * Map the redo status to marker deletion status.
101      *
102      * @see org.eclipse.ui.ide.undo.AbstractMarkersOperation#getBasicRedoStatus()
103      */

104     protected IStatus getBasicRedoStatus() {
105         return getMarkerDeletionStatus();
106     }
107 }
108
Popular Tags