1 11 package org.eclipse.ui.internal.browser; 12 13 import org.eclipse.jface.action.Action; 14 import org.eclipse.jface.action.IToolBarManager; 15 import org.eclipse.ui.IActionBars; 16 import org.eclipse.ui.IEditorPart; 17 import org.eclipse.ui.actions.ActionFactory; 18 import org.eclipse.ui.part.EditorActionBarContributor; 19 23 public class WebBrowserEditorActionBarContributor extends EditorActionBarContributor { 24 protected WebBrowserEditor editor; 25 protected Action back; 26 protected Action forward; 27 protected Updater updater = new Updater(); 28 29 class Updater implements BrowserViewer.IBackNextListener { 30 public void updateBackNextBusy() { 31 if (back == null) 32 return; 33 back.setEnabled(getWebBrowser().isBackEnabled()); 34 forward.setEnabled(getWebBrowser().isForwardEnabled()); 35 } 37 } 38 39 42 public WebBrowserEditorActionBarContributor() { 43 super(); 44 } 45 46 49 public void setActiveEditor(IEditorPart targetEditor) { 50 if (targetEditor instanceof WebBrowserEditor) { 51 editor = (WebBrowserEditor) targetEditor; 52 WebBrowserEditorInput input = editor.getWebBrowserEditorInput(); 53 54 if (input == null || input.isLocationBarLocal()) { 55 IActionBars actionBars = getActionBars(); 56 actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(), editor.getCopyAction()); 57 actionBars.setGlobalActionHandler(ActionFactory.CUT.getId(), editor.getCutAction()); 58 actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(), editor.getPasteAction()); 59 } 60 61 64 } else 66 editor = null; 67 } 68 69 protected BrowserViewer getWebBrowser() { 70 if (editor == null) 71 return null; 72 73 return editor.webBrowser; 74 } 75 76 79 public void contributeToToolBar(IToolBarManager toolBarManager) { 80 if (editor == null) 81 return; 82 268 269 278 } 279 } 280 | Popular Tags |