View Javadoc

1   /*
2    * $Id: OWLEditorActionBarContributor.java,v 1.2 2005/02/28 22:39:40 jlerner Exp $
3    *
4    * Copyright (c) 1999-2004, BBN Technologies, LLC.
5    * All rights reserved.
6    * http://www.daml.org/legal/opensource/bbn_license.html
7    */
8    
9   package com.bbn.swede.editor;
10  
11  import org.eclipse.ui.IActionBars;
12  import org.eclipse.ui.IEditorPart;
13  import org.eclipse.ui.actions.ActionFactory;
14  import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
15  import org.eclipse.ui.texteditor.ITextEditor;
16  import org.eclipse.ui.texteditor.ITextEditorActionConstants;
17  
18  /***
19   * This class conforms with the Eclipse style for enabling global 
20   * actions for an editor.  This implementation enables the cut, 
21   * copy, paste, undo, redo and print actions, making them available
22   * in the Edit and context menus when the editor is active.  
23   * @author aperezlo
24   */
25  public class OWLEditorActionBarContributor extends MultiPageEditorActionBarContributor
26  {
27     /* (non-Javadoc)
28      * @see org.eclipse.ui.part.MultiPageEditorActionBarContributor#setActivePage(org.eclipse.ui.IEditorPart)
29      */
30     public void setActivePage(IEditorPart activeEditor)
31     {
32        IActionBars bars = getActionBars();
33        ITextEditor ed = null;
34        if(activeEditor instanceof ITextEditor)
35        {
36           ed = (ITextEditor) activeEditor;
37           if(bars != null)
38           {
39              bars.setGlobalActionHandler(ActionFactory.CUT.getId(), ed.getAction(ITextEditorActionConstants.CUT));
40              bars.setGlobalActionHandler(ActionFactory.COPY.getId(), ed.getAction(ITextEditorActionConstants.COPY));
41              bars.setGlobalActionHandler(ActionFactory.PASTE.getId(), ed.getAction(ITextEditorActionConstants.PASTE));
42              bars.setGlobalActionHandler(ActionFactory.UNDO.getId(), ed.getAction(ITextEditorActionConstants.UNDO));
43              bars.setGlobalActionHandler(ActionFactory.REDO.getId(), ed.getAction(ITextEditorActionConstants.REDO));
44              bars.setGlobalActionHandler(ActionFactory.PRINT.getId(), ed.getAction(ITextEditorActionConstants.PRINT));
45              bars.updateActionBars();
46           }
47        }
48     }
49  
50  }