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 package de.nierbeck.timeTrack.actions;
28
29 import org.eclipse.jface.action.IAction;
30 import org.eclipse.jface.dialogs.MessageDialog;
31 import org.eclipse.jface.viewers.ISelection;
32 import org.eclipse.jface.viewers.IStructuredSelection;
33 import org.eclipse.jface.viewers.TableViewer;
34 import org.eclipse.swt.widgets.Shell;
35 import org.eclipse.ui.IObjectActionDelegate;
36 import org.eclipse.ui.IWorkbenchPart;
37
38 import de.nierbeck.timeTrack.model.impl.EntryTypeImpl;
39 import de.nierbeck.timeTrack.views.EditEntryDialog;
40
41 /***
42 * Action class for DoubleClick Action
43 *
44 * @author Achim
45 *
46 */
47 public class DoubleClickAction implements IObjectActionDelegate {
48
49 private TableViewer tableViewer;
50
51 /***
52 * Constructor for DoubleClickAction.
53 */
54 public DoubleClickAction() {
55 super();
56 }
57
58 /***
59 * Constructor for DoubleClickAction taking the TableViewer.
60 *
61 * @param tbv - the Tableviewer
62 */
63 public DoubleClickAction(TableViewer tbv) {
64 super();
65 this.tableViewer = tbv;
66 }
67
68 /***
69 * @param action - does nothing
70 * @param targetPart - does nothing
71 * @see IObjectActionDelegate#setActivePart(IAction, IWorkbenchPart)
72 */
73 public void setActivePart(IAction action, IWorkbenchPart targetPart) {
74 }
75
76 /***
77 * @param action - the given Action runing on
78 * @see IActionDelegate#run(IAction)
79 */
80 public final void run(IAction action) {
81 Shell shell = new Shell();
82 MessageDialog.openInformation(shell, "TimeTrack Plug-in",
83 "New Action was executed.");
84 }
85
86 /***
87 * @param selection - the Selection on which this method runs
88 */
89 public final void run(ISelection selection) {
90 Shell shell = new Shell();
91 EntryTypeImpl obj = (EntryTypeImpl) ((IStructuredSelection) selection)
92 .getFirstElement();
93 EditEntryDialog dialog = new EditEntryDialog(shell, obj);
94 dialog.open();
95 tableViewer.refresh(obj);
96 }
97
98 /***
99 * @param action - does nothing
100 * @param selection - does nothing
101 * @see IActionDelegate#selectionChanged(IAction, ISelection)
102 */
103 public void selectionChanged(IAction action, ISelection selection) {
104 }
105
106 }