blob: a2dbdd6eba237dc52f75e6940946dbe45189ced4 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
/*******************************************************************************
* Copyright (c) 2009 Tasktop Technologies and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tasktop Technologies - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.internal.tasks.ui.actions;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.Separator;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.mylyn.commons.ui.SelectionProviderAdapter;
import org.eclipse.mylyn.commons.workbench.WorkbenchActionSupport;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.ui.editors.TaskEditor;
/**
* @author Steffen Pingel
*/
public class TaskEditorActionGroup extends RepositoryElementActionGroup {
private final WorkbenchActionSupport actionSupport;
private final SynchronizeEditorAction synchronizeEditorAction = new SynchronizeEditorAction();
private final NewTaskFromSelectionAction newTaskFromSelectionAction = new NewTaskFromSelectionAction();
public TaskEditorActionGroup(WorkbenchActionSupport actionSupport) {
this.actionSupport = actionSupport;
synchronizeEditorAction.setActionDefinitionId("org.eclipse.ui.file.refresh"); //$NON-NLS-1$
synchronizeEditorAction.setEnabled(false);
}
public void fillContextMenu(IMenuManager manager, TaskEditor editor, boolean addClipboard) {
ITask task = editor.getTaskEditorInput().getTask();
SelectionProviderAdapter selectionProvider = new SelectionProviderAdapter();
setSelectionProvider(selectionProvider);
selectionProvider.setSelection(new StructuredSelection(task));
super.fillContextMenu(manager);
if (addClipboard) {
addClipboardActions(manager);
}
synchronizeEditorAction.selectionChanged(new StructuredSelection(editor));
IStructuredSelection selection = new StructuredSelection(task);
actionSupport.updateActions(selection);
newTaskFromSelectionAction.selectionChanged(selection);
manager.add(new Separator());
if (synchronizeEditorAction.isEnabled()) {
manager.appendToGroup(ID_SEPARATOR_REPOSITORY, synchronizeEditorAction);
}
}
public void addClipboardActions(IMenuManager manager) {
//manager.add(actionSupport.getUndoAction());
//manager.add(actionSupport.getRedoAction());
//manager.add(new Separator());
manager.prependToGroup(ID_SEPARATOR_EDIT, actionSupport.getCopyAction());
manager.prependToGroup(ID_SEPARATOR_EDIT, actionSupport.getCutAction());
manager.appendToGroup(ID_SEPARATOR_EDIT, actionSupport.getPasteAction());
manager.appendToGroup(ID_SEPARATOR_EDIT, actionSupport.getSelectAllAction());
manager.appendToGroup(ID_SEPARATOR_EDIT, newTaskFromSelectionAction);
}
public SynchronizeEditorAction getSynchronizeEditorAction() {
return synchronizeEditorAction;
}
public NewTaskFromSelectionAction getNewTaskFromSelectionAction() {
return newTaskFromSelectionAction;
}
}
|