01: package com.xoetrope.editor.eclipse.visualizer;
02:
03: import org.eclipse.jface.action.Action;
04: import org.eclipse.jface.action.IAction;
05: import org.eclipse.jface.action.IMenuManager;
06: import org.eclipse.jface.action.IToolBarManager;
07: import org.eclipse.ui.IActionBars;
08: import org.eclipse.ui.IEditorPart;
09: import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
10: import org.eclipse.ui.texteditor.ITextEditor;
11:
12: public class DataVisualiserContributor extends
13: MultiPageEditorActionBarContributor {
14: private IEditorPart activeEditorPart;
15:
16: private Action sampleAction;
17:
18: /**
19: * Creates a multi-page contributor.
20: */
21: public DataVisualiserContributor() {
22: super ();
23: createActions();
24: }
25:
26: /**
27: * Returns the action registered with the given text editor.
28: *
29: * @return IAction or null if editor is null.
30: */
31: protected IAction getAction(ITextEditor editor, String actionID) {
32: return (editor == null ? null : editor.getAction(actionID));
33: }
34:
35: /*
36: * (non-JavaDoc) Method declared in
37: * AbstractMultiPageEditorActionBarContributor.
38: */
39:
40: public void setActivePage(IEditorPart part) {
41: if (activeEditorPart == part)
42: return;
43:
44: activeEditorPart = part;
45:
46: IActionBars actionBars = getActionBars();
47: if (actionBars != null) {
48: //
49: // ITextEditor editor = ( part instanceof ITextEditor ) ? (ITextEditor)part : null;
50: //
51: // actionBars.setGlobalActionHandler( ActionFactory.DELETE.getId(), getAction( editor, ITextEditorActionConstants.DELETE ) );
52: // actionBars.setGlobalActionHandler( ActionFactory.UNDO.getId(), getAction( editor, ITextEditorActionConstants.UNDO ) );
53: // actionBars.setGlobalActionHandler( ActionFactory.REDO.getId(), getAction( editor, ITextEditorActionConstants.REDO ) );
54: // actionBars.setGlobalActionHandler( ActionFactory.CUT.getId(), getAction( editor, ITextEditorActionConstants.CUT ) );
55: // actionBars.setGlobalActionHandler( ActionFactory.COPY.getId(), getAction( editor, ITextEditorActionConstants.COPY ) );
56: // actionBars.setGlobalActionHandler( ActionFactory.PASTE.getId(), getAction( editor, ITextEditorActionConstants.PASTE ) );
57: // actionBars.setGlobalActionHandler( ActionFactory.SELECT_ALL.getId(), getAction( editor, ITextEditorActionConstants.SELECT_ALL ) );
58: // actionBars.setGlobalActionHandler( ActionFactory.FIND.getId(), getAction( editor, ITextEditorActionConstants.FIND ) );
59: // actionBars.setGlobalActionHandler( IDEActionFactory.BOOKMARK.getId(), getAction( editor, IDEActionFactory.BOOKMARK.getId() ) );
60: //
61: // actionBars.setGlobalActionHandler( ActionFactory.MAXIMIZE.getId(), getAction( editor, ITextEditorActionConstants.FIND ) );
62: // actionBars.updateActionBars();
63: }
64: }
65:
66: private void createActions() {
67: // sampleAction = new Action() {
68: // public void run() {
69: // MessageDialog.openInformation(null, "Kalideoscope Plug-in", "Sample
70: // Action Executed");
71: // }
72: // };
73: // sampleAction.setText("Sample Action");
74: // sampleAction.setToolTipText("Sample Action tool tip");
75: // sampleAction.setImageDescriptor(PlatformUI.getWorkbench().getSharedImages().
76: // getImageDescriptor(IDE.SharedImages.IMG_OBJS_TASK_TSK));
77: }
78:
79: public void contributeToMenu(IMenuManager manager) {
80: // IMenuManager menu = new MenuManager("Editor &Menu");
81: // manager.prependToGroup(IWorkbenchActionConstants.MB_ADDITIONS, menu);
82: // menu.add(sampleAction);
83: }
84:
85: public void contributeToToolBar(IToolBarManager manager) {
86: // manager.add(new Separator());
87: // manager.add(sampleAction);
88: }
89: }
|