KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > texteditor > TaskRulerAction


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 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
13 package org.eclipse.ui.texteditor;
14
15
16 import java.util.ResourceBundle JavaDoc;
17
18 import org.eclipse.core.resources.IMarker;
19 import org.eclipse.core.resources.IResource;
20
21 import org.eclipse.jface.action.IAction;
22 import org.eclipse.jface.text.source.IVerticalRulerInfo;
23
24 import org.eclipse.ui.views.tasklist.TaskPropertiesDialog;
25
26
27
28 /**
29  * Adapter for the marker ruler action creating/removing tasks.
30  *
31  * @since 2.0
32  */

33 public class TaskRulerAction extends AbstractRulerActionDelegate {
34
35     /**
36      * Adds a task marker over the ruler context menu. Uses the Workbench's Task properties dialog.
37      */

38     static class TaskMarkerRulerAction extends MarkerRulerAction {
39
40         /**
41          * Creates a new action for the given ruler and editor. The action configures
42          * its visual representation from the given resource bundle.
43          *
44          * @param bundle the resource bundle
45          * @param prefix a prefix to be prepended to the various resource keys
46          * (described in <code>ResourceAction</code> constructor), or
47          * <code>null</code> if none
48          * @param editor the text editor
49          * @param ruler the vertical ruler info
50          * @see MarkerRulerAction#MarkerRulerAction(ResourceBundle, String, ITextEditor, IVerticalRulerInfo, String, boolean)
51          */

52         public TaskMarkerRulerAction(ResourceBundle JavaDoc bundle, String JavaDoc prefix, ITextEditor editor, IVerticalRulerInfo ruler) {
53             super(bundle, prefix, editor, ruler, IMarker.TASK, false);
54         }
55
56         /*
57          * @see MarkerRulerAction#addMarker()
58          */

59         protected void addMarker() {
60             IResource resource= getResource();
61             if (resource == null)
62                 return;
63
64            TaskPropertiesDialog dialog = new TaskPropertiesDialog(getTextEditor().getSite().getShell());
65             dialog.setResource(resource);
66             dialog.setInitialAttributes(getInitialAttributes());
67             dialog.open();
68         }
69     }
70
71     /*
72      * @see AbstractRulerActionDelegate#createAction(ITextEditor, IVerticalRulerInfo)
73      */

74     protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) {
75         return new TaskMarkerRulerAction(TextEditorMessages.getBundleForConstructedKeys(), "Editor.ManageTasks.", editor, rulerInfo); //$NON-NLS-1$
76
}
77 }
78
Popular Tags