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