| Home >> All >> com >> port80 >> eclipse >> jdt >> [ actions Javadoc ] |
Source code: com/port80/eclipse/jdt/actions/ConvertCrAction.java
1 /* 2 * Created on Apr 27, 2003 3 */ 4 package com.port80.eclipse.jdt.actions; 5 6 import org.eclipse.jface.action.IAction; 7 import org.eclipse.jface.action.IStatusLineManager; 8 import org.eclipse.jface.viewers.ISelection; 9 import org.eclipse.ui.IEditorActionDelegate; 10 import org.eclipse.ui.IEditorPart; 11 import org.eclipse.ui.IWorkbenchWindow; 12 import org.eclipse.ui.IWorkbenchWindowActionDelegate; 13 import org.eclipse.ui.internal.WorkbenchWindow; 14 import org.eclipse.ui.texteditor.ConvertLineDelimitersAction; 15 import org.eclipse.ui.texteditor.StatusTextEditor; 16 17 import com.port80.eclipse.jdt.JdtPlugin; 18 19 /** 20 * Goto character offset in active editor. 21 * @author chrisl 22 */ 23 public class ConvertCrAction implements IWorkbenchWindowActionDelegate, IEditorActionDelegate { 24 25 //////////////////////////////////////////////////////////////////////// 26 27 private static final String NAME = "ConvertCrAction"; 28 private static final String ID = "com.port80.eclipse.jdt.actions.ConvertCrAction"; 29 private static final boolean DEBUG = true; 30 31 //////////////////////////////////////////////////////////////////////// 32 33 public ConvertCrAction() { 34 super(); 35 } 36 37 //////////////////////////////////////////////////////////////////////// 38 39 public void run(IAction action) { 40 Object part = JdtPlugin.getActiveWorkbenchWindow().getActivePage().getActivePart(); 41 if (DEBUG) 42 System.err.println(NAME + ".run(): " + part); 43 if (part instanceof StatusTextEditor) { 44 StatusTextEditor editor = (StatusTextEditor) part; 45 new ConvertLineDelimitersAction(editor, "\n").run(); 46 } else { 47 JdtPlugin.getActiveWorkbenchShell().getDisplay().beep(); 48 WorkbenchWindow window = (WorkbenchWindow) JdtPlugin.getActiveWorkbenchWindow(); 49 IStatusLineManager status = window.getActionBars().getStatusLineManager(); 50 status.setErrorMessage("Active part is not a StatueTextEditor."); 51 } 52 } 53 54 public void dispose() { 55 } 56 57 public void init(IWorkbenchWindow window) { 58 } 59 60 public void selectionChanged(IAction action, ISelection selection) { 61 } 62 63 //////////////////////////////////////////////////////////////////////// 64 65 /* 66 * @see org.eclipse.ui.IEditorActionDelegate#setActiveEditor(org.eclipse.jface.action.IAction, org.eclipse.ui.IEditorPart) 67 */ 68 public void setActiveEditor(IAction action, IEditorPart targetEditor) { 69 } 70 71 //////////////////////////////////////////////////////////////////////// 72 73 }