Better event handling for browser preview refreshs
[phpeclipse.git] / archive / net.sourceforge.phpeclipse.wiki / src / net / sourceforge / phpeclipse / wiki / editor / WikiEditorContributor.java
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
5  * 
6  * Contributors: IBM Corporation - initial API and implementation
7  **********************************************************************************************************************************/
8
9 package net.sourceforge.phpeclipse.wiki.editor;
10
11
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;
20
21 public class WikiEditorContributor extends BasicTextEditorActionContributor {
22
23   private static final String CONTENTASSIST_ACTION = "net.sourceforge.phpeclipse.wiki.editor.ContentAssist";
24
25   private RetargetTextEditorAction fContentAssist;
26   public WikiEditorContributor() {
27     super();
28     fContentAssist = new RetargetTextEditorAction(WikiEditorPlugin.getDefault().getResourceBundle(), "ContentAssistProposal.");
29     fContentAssist.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
30   }
31
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));
36  
37     BrowserUtil.setBrowserPreview(editor);
38   }
39
40   public void contributeToMenu(IMenuManager menu) {
41         
42         super.contributeToMenu(menu);
43         
44 }
45   
46   public void init(IActionBars bars, IWorkbenchPage page) {
47     super.init(bars, page);
48     bars.setGlobalActionHandler(CONTENTASSIST_ACTION, fContentAssist);
49     
50   }
51         
52   public void dispose() {
53     setActiveEditor(null);
54     super.dispose();
55   }
56 }