comparison src/de/mpg/mpiwg/itgroup/digilib/plugin/editors/DigilibLinkEditorContributor.java @ 28:0205c3f41d1d default tip

repackaging (separate textgridlab and dgilib local parts more rigorously
author dwinter
date Fri, 24 Aug 2012 09:42:57 +0200
parents
children
comparison
equal deleted inserted replaced
27:361d8c89338a 28:0205c3f41d1d
1 package de.mpg.mpiwg.itgroup.digilib.plugin.editors;
2
3 import org.eclipse.jface.action.*;
4 import org.eclipse.jface.dialogs.MessageDialog;
5 import org.eclipse.ui.IActionBars;
6 import org.eclipse.ui.IEditorPart;
7 import org.eclipse.ui.IWorkbenchActionConstants;
8 import org.eclipse.ui.PlatformUI;
9 import org.eclipse.ui.actions.ActionFactory;
10 import org.eclipse.ui.ide.IDE;
11 import org.eclipse.ui.ide.IDEActionFactory;
12 import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
13 import org.eclipse.ui.texteditor.ITextEditor;
14 import org.eclipse.ui.texteditor.ITextEditorActionConstants;
15
16 /**
17 * Manages the installation/deinstallation of global actions for multi-page editors.
18 * Responsible for the redirection of global actions to the active editor.
19 * Multi-page contributor replaces the contributors for the individual editors in the multi-page editor.
20 */
21 public class DigilibLinkEditorContributor extends MultiPageEditorActionBarContributor {
22 private IEditorPart activeEditorPart;
23 //private Action sampleAction;
24 /**
25 * Creates a multi-page contributor.
26 */
27 public DigilibLinkEditorContributor() {
28 super();
29 //createActions();
30 }
31 /**
32 * Returns the action registed with the given text editor.
33 * @return IAction or null if editor is null.
34 */
35 protected IAction getAction(ITextEditor editor, String actionID) {
36 return (editor == null ? null : editor.getAction(actionID));
37 }
38 /* (non-JavaDoc)
39 * Method declared in AbstractMultiPageEditorActionBarContributor.
40 */
41
42 public void setActivePage(IEditorPart part) {
43 if (activeEditorPart == part)
44 return;
45
46 activeEditorPart = part;
47
48 IActionBars actionBars = getActionBars();
49 if (actionBars != null) {
50
51 ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null;
52
53 actionBars.setGlobalActionHandler(
54 ActionFactory.DELETE.getId(),
55 getAction(editor, ITextEditorActionConstants.DELETE));
56 actionBars.setGlobalActionHandler(
57 ActionFactory.UNDO.getId(),
58 getAction(editor, ITextEditorActionConstants.UNDO));
59 actionBars.setGlobalActionHandler(
60 ActionFactory.REDO.getId(),
61 getAction(editor, ITextEditorActionConstants.REDO));
62 actionBars.setGlobalActionHandler(
63 ActionFactory.CUT.getId(),
64 getAction(editor, ITextEditorActionConstants.CUT));
65 actionBars.setGlobalActionHandler(
66 ActionFactory.COPY.getId(),
67 getAction(editor, ITextEditorActionConstants.COPY));
68 actionBars.setGlobalActionHandler(
69 ActionFactory.PASTE.getId(),
70 getAction(editor, ITextEditorActionConstants.PASTE));
71 actionBars.setGlobalActionHandler(
72 ActionFactory.SELECT_ALL.getId(),
73 getAction(editor, ITextEditorActionConstants.SELECT_ALL));
74 actionBars.setGlobalActionHandler(
75 ActionFactory.FIND.getId(),
76 getAction(editor, ITextEditorActionConstants.FIND));
77 actionBars.setGlobalActionHandler(
78 IDEActionFactory.BOOKMARK.getId(),
79 getAction(editor, IDEActionFactory.BOOKMARK.getId()));
80 actionBars.updateActionBars();
81 }
82 }
83 private void createActions() {
84 // sampleAction = new Action() {
85 // public void run() {
86 // MessageDialog.openInformation(null, "digilibClient", "Sample Action Executed");
87 // }
88 // };
89 // sampleAction.setText("Sample Action");
90 // sampleAction.setToolTipText("Sample Action tool tip");
91 // sampleAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
92 // getImageDescriptor(IDE.SharedImages.IMG_OBJS_TASK_TSK));
93 }
94 public void contributeToMenu(IMenuManager manager) {
95 // IMenuManager menu = new MenuManager("Editor &Menu");
96 // manager.prependToGroup(IWorkbenchActionConstants.MB_ADDITIONS, menu);
97 // menu.add(sampleAction);
98 }
99 public void contributeToToolBar(IToolBarManager manager) {
100 //manager.add(new Separator());
101 //manager.add(sampleAction);
102 }
103 }