1
2
3
4
5
6
7
8
9
10
11
12 package sk.uniba.euromath.editor.textEditor.actions;
13
14 import org.eclipse.swt.dnd.Clipboard;
15 import org.eclipse.ui.IWorkbenchPart;
16
17 import sk.uniba.euromath.editor.textEditor.IClipboardProvider;
18 import sk.uniba.euromath.editor.xmlEditor.actions.XMLAccessModifyAction;
19
20 /***
21 * Common clipboard action.
22 *
23 * @author Tomáš Studva 8.7.2005
24 */
25 public class ClipboardAction extends XMLAccessModifyAction {
26
27 /***
28 * System clipboard instance.
29 */
30 private Clipboard clipboard;
31
32 /***
33 * Constructor.
34 *
35 * @param part
36 * workbench part to associate
37 */
38 public ClipboardAction(IWorkbenchPart part) {
39 super(part);
40 }
41
42 /***
43 * Returns clipboard provider.
44 *
45 * @return clipboard provider
46 */
47 protected IClipboardProvider getClipboardProvider() {
48 if (getWorkbenchPart() != null)
49 return (IClipboardProvider) (getWorkbenchPart()
50 .getAdapter(IClipboardProvider.class));
51 return null;
52 }
53
54 /***
55 * Returns system clipboard reference
56 *
57 * @return clipboard
58 */
59 protected Clipboard getClipboard() {
60 if (this.clipboard != null)
61 return this.clipboard;
62 return getClipboardProvider().getClipboard();
63 }
64
65 }