1 /***********************************************************************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made
3 * available under the terms of the Common Public License v1.0 which accompanies this distribution, and is available at
4 * http://www.eclipse.org/legal/cpl-v10.html
6 * Contributors: IBM Corporation - initial API and implementation
7 **********************************************************************************************************************************/
9 package net.sourceforge.phpeclipse.wiki.editor;
12 import org.eclipse.jface.action.IMenuManager;
13 import org.eclipse.ui.IActionBars;
14 import org.eclipse.ui.IEditorPart;
15 import org.eclipse.ui.IWorkbenchPage;
16 import org.eclipse.ui.texteditor.BasicTextEditorActionContributor;
17 import org.eclipse.ui.texteditor.ITextEditor;
18 import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
19 import org.eclipse.ui.texteditor.RetargetTextEditorAction;
21 public class WikiEditorContributor extends BasicTextEditorActionContributor {
23 private static final String CONTENTASSIST_ACTION = "net.sourceforge.phpeclipse.wiki.editor.ContentAssist";
25 private RetargetTextEditorAction fContentAssist;
26 public WikiEditorContributor() {
28 fContentAssist = new RetargetTextEditorAction(WikiEditorPlugin.getDefault().getResourceBundle(), "ContentAssistProposal.");
29 fContentAssist.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
32 public void setActiveEditor(IEditorPart part) {
33 super.setActiveEditor(part);
34 ITextEditor editor = (part instanceof ITextEditor) ? (ITextEditor) part : null;
35 fContentAssist.setAction(getAction(editor, CONTENTASSIST_ACTION));
37 BrowserUtil.setBrowserPreview(editor);
40 public void contributeToMenu(IMenuManager menu) {
42 super.contributeToMenu(menu);
46 public void init(IActionBars bars, IWorkbenchPage page) {
47 super.init(bars, page);
48 bars.setGlobalActionHandler(CONTENTASSIST_ACTION, fContentAssist);
52 public void dispose() {
53 setActiveEditor(null);