1 11 package org.eclipse.ant.internal.ui.editor.actions; 12 13 import org.eclipse.ant.internal.ui.editor.AntEditor; 14 import org.eclipse.jface.action.IAction; 15 import org.eclipse.jface.action.IMenuManager; 16 17 import org.eclipse.jface.text.source.ISourceViewer; 18 import org.eclipse.jface.text.source.IVerticalRulerInfo; 19 import org.eclipse.jface.text.source.projection.ProjectionViewer; 20 21 import org.eclipse.ui.IEditorPart; 22 import org.eclipse.ui.editors.text.IFoldingCommandIds; 23 import org.eclipse.ui.texteditor.AbstractRulerActionDelegate; 24 import org.eclipse.ui.texteditor.ITextEditor; 25 import org.eclipse.ui.texteditor.TextOperationAction; 26 27 public class FoldingToggleRulerAction extends AbstractRulerActionDelegate { 28 29 private IAction fUIAction; 30 private TextOperationAction fAction; 31 private ITextEditor fTextEditor; 32 33 36 protected IAction createAction(ITextEditor editor, IVerticalRulerInfo rulerInfo) { 37 fTextEditor= editor; 38 fAction= new TextOperationAction(AntEditorActionMessages.getResourceBundle(), "Projection.Toggle.", editor, ProjectionViewer.TOGGLE, true); fAction.setActionDefinitionId(IFoldingCommandIds.FOLDING_TOGGLE); 40 41 return fAction; 42 } 43 44 47 public void setActiveEditor(IAction callerAction, IEditorPart targetEditor) { 48 fUIAction= callerAction; 49 super.setActiveEditor(callerAction, targetEditor); 50 } 51 52 55 public void menuAboutToShow(IMenuManager manager) { 56 update(); 57 super.menuAboutToShow(manager); 58 } 59 60 private void update() { 61 if (fTextEditor instanceof AntEditor) { 62 ISourceViewer viewer= ((AntEditor) fTextEditor).getViewer(); 63 if (viewer instanceof ProjectionViewer) { 64 boolean enabled= ((ProjectionViewer) viewer).getProjectionAnnotationModel() != null; 65 fUIAction.setChecked(enabled); 66 } 67 } 68 } 69 } 70 | Popular Tags |