1 11 12 package org.eclipse.ui.texteditor; 13 14 15 import java.util.ResourceBundle ; 16 17 import org.eclipse.jface.text.IMarkRegionTarget; 18 19 24 public class MarkAction extends TextEditorAction { 25 26 27 public static final int SET_MARK= 0; 28 29 public static final int CLEAR_MARK= 1; 30 31 public static final int SWAP_MARK= 2; 32 33 34 private final int fType; 35 36 47 public MarkAction(ResourceBundle bundle, String prefix, ITextEditor editor, int type) { 48 super(bundle, prefix, editor); 49 fType= type; 50 } 51 52 55 public void run() { 56 57 ITextEditor editor= getTextEditor(); 58 if (editor == null) 59 return; 60 61 IMarkRegionTarget target= (IMarkRegionTarget) editor.getAdapter(IMarkRegionTarget.class); 62 if (target == null) 63 return; 64 65 switch (fType) { 66 case SET_MARK: 67 target.setMarkAtCursor(true); 68 break; 69 70 case CLEAR_MARK: 71 target.setMarkAtCursor(false); 72 break; 73 74 case SWAP_MARK: 75 target.swapMarkAndCursor(); 76 break; 77 } 78 } 79 } 80 | Popular Tags |