01: /*******************************************************************************
02: * Copyright (c) 2000, 2005 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.texteditor;
11:
12: import java.util.ResourceBundle;
13:
14: import org.eclipse.core.resources.IMarker;
15: import org.eclipse.core.resources.IResource;
16:
17: import org.eclipse.jface.action.IAction;
18: import org.eclipse.jface.text.source.IVerticalRulerInfo;
19:
20: import org.eclipse.ui.views.tasklist.TaskPropertiesDialog;
21:
22: /**
23: * Adapter for the marker ruler action creating/removing tasks.
24: *
25: * @since 2.0
26: */
27: public class TaskRulerAction extends AbstractRulerActionDelegate {
28:
29: /**
30: * Adds a task marker over the ruler context menu. Uses the Workbench's Task properties dialog.
31: */
32: static class TaskMarkerRulerAction extends MarkerRulerAction {
33:
34: /**
35: * Creates a new action for the given ruler and editor. The action configures
36: * its visual representation from the given resource bundle.
37: *
38: * @param bundle the resource bundle
39: * @param prefix a prefix to be prepended to the various resource keys
40: * (described in <code>ResourceAction</code> constructor), or
41: * <code>null</code> if none
42: * @param editor the text editor
43: * @param ruler the vertical ruler info
44: * @see MarkerRulerAction#MarkerRulerAction(ResourceBundle, String, ITextEditor, IVerticalRulerInfo, String, boolean)
45: */
46: public TaskMarkerRulerAction(ResourceBundle bundle,
47: String prefix, ITextEditor editor,
48: IVerticalRulerInfo ruler) {
49: super (bundle, prefix, editor, ruler, IMarker.TASK, false);
50: }
51:
52: /*
53: * @see MarkerRulerAction#addMarker()
54: */
55: protected void addMarker() {
56: IResource resource = getResource();
57: if (resource == null)
58: return;
59:
60: TaskPropertiesDialog dialog = new TaskPropertiesDialog(
61: getTextEditor().getSite().getShell());
62: dialog.setResource(resource);
63: dialog.setInitialAttributes(getInitialAttributes());
64: dialog.open();
65: }
66: }
67:
68: /*
69: * @see AbstractRulerActionDelegate#createAction(ITextEditor, IVerticalRulerInfo)
70: */
71: protected IAction createAction(ITextEditor editor,
72: IVerticalRulerInfo rulerInfo) {
73: return new TaskMarkerRulerAction(TextEditorMessages
74: .getBundleForConstructedKeys(),
75: "Editor.ManageTasks.", editor, rulerInfo); //$NON-NLS-1$
76: }
77: }
|