1 11 package org.eclipse.jdt.internal.debug.ui.display; 12 13 14 import org.eclipse.core.runtime.IAdaptable; 15 import org.eclipse.jface.action.Action; 16 import org.eclipse.jface.text.ITextOperationTarget; 17 import org.eclipse.ui.texteditor.IUpdate; 18 19 20 public class DisplayViewAction extends Action implements IUpdate { 21 22 23 private int fOperationCode= -1; 24 25 private ITextOperationTarget fOperationTarget; 26 27 private IAdaptable fTargetProvider; 28 29 30 public DisplayViewAction(ITextOperationTarget target, int operationCode) { 31 super(); 32 fOperationTarget= target; 33 fOperationCode= operationCode; 34 update(); 35 } 36 37 public DisplayViewAction(IAdaptable targetProvider, int operationCode) { 38 super(); 39 fTargetProvider= targetProvider; 40 fOperationCode= operationCode; 41 update(); 42 } 43 44 49 public void run() { 50 if (fOperationCode != -1 && fOperationTarget != null) 51 fOperationTarget.doOperation(fOperationCode); 52 } 53 54 60 public void update() { 61 if (fOperationTarget == null && fTargetProvider != null && fOperationCode != -1){ 62 fOperationTarget= (ITextOperationTarget) fTargetProvider.getAdapter(ITextOperationTarget.class); 63 } 64 65 boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode)); 66 setEnabled(isEnabled); 67 } 68 } 69 | Popular Tags |