01: /*******************************************************************************
02: * Copyright (c) 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.internal.ui.editor.cheatsheet.simple;
11:
12: import org.eclipse.jface.action.IMenuManager;
13: import org.eclipse.jface.action.Separator;
14: import org.eclipse.pde.internal.core.icheatsheet.simple.ISimpleCSModel;
15: import org.eclipse.pde.internal.ui.editor.PDEFormTextEditorContributor;
16: import org.eclipse.pde.internal.ui.editor.cheatsheet.simple.actions.SimpleCSPreviewAction;
17:
18: /**
19: * SimpleCSFormEditorContributor
20: *
21: */
22: public class SimpleCSEditorContributor extends
23: PDEFormTextEditorContributor {
24:
25: private SimpleCSPreviewAction fPreviewAction;
26:
27: /**
28: * @param menuName
29: */
30: public SimpleCSEditorContributor() {
31: super ("&Simple Cheat Sheet"); //$NON-NLS-1$
32: fPreviewAction = null;
33: }
34:
35: /* (non-Javadoc)
36: * @see org.eclipse.pde.internal.ui.editor.PDEFormEditorContributor#makeActions()
37: */
38: protected void makeActions() {
39: super .makeActions();
40: // Make the preview action
41: fPreviewAction = new SimpleCSPreviewAction();
42: }
43:
44: /* (non-Javadoc)
45: * @see org.eclipse.pde.internal.ui.editor.PDEFormEditorContributor#contextMenuAboutToShow(org.eclipse.jface.action.IMenuManager, boolean)
46: */
47: public void contextMenuAboutToShow(IMenuManager manager,
48: boolean addClipboard) {
49: // Get the model
50: ISimpleCSModel model = (ISimpleCSModel) getEditor()
51: .getAggregateModel();
52: // Set the cheat sheet object
53: fPreviewAction.setDataModelObject(model.getSimpleCS());
54: // Set the editor input
55: fPreviewAction.setEditorInput(getEditor().getEditorInput());
56: // Add the preview action to the context menu
57: manager.add(fPreviewAction);
58: manager.add(new Separator());
59: super .contextMenuAboutToShow(manager, addClipboard);
60: }
61:
62: /**
63: * @return
64: */
65: public SimpleCSPreviewAction getPreviewAction() {
66: return fPreviewAction;
67: }
68:
69: /* (non-Javadoc)
70: * @see org.eclipse.pde.internal.ui.editor.PDEFormTextEditorContributor#supportsHyperlinking()
71: */
72: public boolean supportsHyperlinking() {
73: return true;
74: }
75:
76: }
|