/** * Creates and initializes the action for the given text editor. The action * configures its visual representation from the given resource bundle. * * @param bundle the resource bundle * @param prefix a prefix to be prepended to the various resource keys * (described in <code>ResourceAction</code> constructor), or * <code>null</code> if none * @param editor the text editor * @see ResourceAction#ResourceAction(ResourceBundle, String) */ protected TextEditorAction(ResourceBundle bundle, String prefix, ITextEditor editor) { super(bundle, prefix); setEditor(editor); update(); }
/** * Always enables this action if it is connected to a text editor. * If the associated editor is <code>null</code>, the action is disabled. * Subclasses may override. */ public void update() { setEnabled(getTextEditor() != null); }
public void update() { /* * Update only works if we're updated from the ruler action * (see AbstractDecoratedTextEditor.rulerContextMenuAboutToShow). */ super.update(); setEnabled(computeEnablement()); }
@Override public void setEditor(ITextEditor editor) { super.setEditor(editor); fOperationTarget= null; }
TextEditorAction revertDeletion= new RestoreAction(this, true); revertSelection.update(); revertBlock.update(); revertLine.update(); revertDeletion.update(); if (revertSelection.isEnabled()) menu.appendToGroup(ITextEditorActionConstants.GROUP_RESTORE, revertSelection); else if (revertBlock.isEnabled()) menu.appendToGroup(ITextEditorActionConstants.GROUP_RESTORE, revertBlock); if (revertLine.isEnabled()) menu.appendToGroup(ITextEditorActionConstants.GROUP_RESTORE, revertLine); if (revertDeletion.isEnabled()) menu.appendToGroup(ITextEditorActionConstants.GROUP_RESTORE, revertDeletion);
/** * Computes, caches and returns the internal state, including enablement. * * @return <code>true</code> if the action is enabled, <code>false</code> * if it is not */ protected boolean computeEnablement() { if (!super.isEnabled()) return false; if (!canModifyEditor()) return false; fLastLine= computeLine(fIsRulerAction); return true; }
/** * Checks and validates the editor's modifiable state. Returns <code>true</code> if an action * can proceed modifying the editor's input, <code>false</code> if it should not. * * <p>If the editor implements <code>ITextEditorExtension2</code>, * this method returns {@link ITextEditorExtension2#validateEditorInputState()};<br> else if the editor * implements <code>ITextEditorExtension</code>, it returns {@link ITextEditorExtension#isEditorInputReadOnly()};<br> * else, {@link ITextEditor#isEditable()} is returned, or <code>false</code> if the editor is <code>null</code>.</p> * * <p>There is only a difference to {@link #canModifyEditor()} if the editor implements * <code>ITextEditorExtension2</code>.</p> * * @return <code>true</code> if a modifying action can proceed to modify the underlying document, <code>false</code> otherwise * @since 3.0 */ protected boolean validateEditorInputState() { ITextEditor editor= getTextEditor(); if (editor instanceof ITextEditorExtension2) return ((ITextEditorExtension2) editor).validateEditorInputState(); else if (editor instanceof ITextEditorExtension) return !((ITextEditorExtension) editor).isEditorInputReadOnly(); else if (editor != null) return editor.isEditable(); else return false; } }
@Override public void update() { super.update(); setEnabled(canModifyEditor()); }
@Override public void setEditor(ITextEditor editor) { super.setEditor(editor); fOperationTarget= null; }
TextEditorAction revertDeletion= new RestoreAction(this, true); revertSelection.update(); revertBlock.update(); revertLine.update(); revertDeletion.update(); if (revertSelection.isEnabled()) menu.appendToGroup(ITextEditorActionConstants.GROUP_RESTORE, revertSelection); else if (revertBlock.isEnabled()) menu.appendToGroup(ITextEditorActionConstants.GROUP_RESTORE, revertBlock); if (revertLine.isEnabled()) menu.appendToGroup(ITextEditorActionConstants.GROUP_RESTORE, revertLine); if (revertDeletion.isEnabled()) menu.appendToGroup(ITextEditorActionConstants.GROUP_RESTORE, revertDeletion);
/** * Computes, caches and returns the internal state, including enablement. * * @return <code>true</code> if the action is enabled, <code>false</code> * if it is not */ protected boolean computeEnablement() { if (!super.isEnabled()) return false; if (!canModifyEditor()) return false; fLastLine= computeLine(fIsRulerAction); return true; }
/** * Checks the editor's modifiable state. Returns <code>true</code> if the editor can be modified, * taking in account the possible editor extensions. * * <p>If the editor implements <code>ITextEditorExtension2</code>, * this method returns {@link ITextEditorExtension2#isEditorInputModifiable()};<br> else if the editor * implements <code>ITextEditorExtension</code>, it returns {@link ITextEditorExtension#isEditorInputReadOnly()};<br> * else, {@link ITextEditor#isEditable()} is returned, or <code>false</code> if the editor is <code>null</code>.</p> * * <p>There is only a difference to {@link #validateEditorInputState()} if the editor implements * <code>ITextEditorExtension2</code>.</p> * * @return <code>true</code> if a modifying action should be enabled, <code>false</code> otherwise * @since 3.0 */ protected boolean canModifyEditor() { ITextEditor editor= getTextEditor(); if (editor instanceof ITextEditorExtension2) return ((ITextEditorExtension2) editor).isEditorInputModifiable(); else if (editor instanceof ITextEditorExtension) return !((ITextEditorExtension) editor).isEditorInputReadOnly(); else if (editor != null) return editor.isEditable(); else return false; }
@Override public void update() { super.update(); setEnabled(canModifyEditor()); }
/** * @see TextEditorAction#setEditor(ITextEditor) */ @Override public void setEditor(ITextEditor editor) { super.setEditor(editor); fOperationTarget= null; } }
/** * Creates and initializes the action for the given text editor. The action * configures its visual representation from the given resource bundle. * * @param bundle the resource bundle * @param prefix a prefix to be prepended to the various resource keys * (described in <code>ResourceAction</code> constructor), or * <code>null</code> if none * @param editor the text editor * @see ResourceAction#ResourceAction(ResourceBundle, String) */ protected TextEditorAction(ResourceBundle bundle, String prefix, ITextEditor editor) { super(bundle, prefix); setEditor(editor); update(); }
/** * Computes, caches and returns the internal state, including enablement. * * @return <code>true</code> if the action is enabled, <code>false</code> * if it is not */ protected boolean computeEnablement() { if (!super.isEnabled()) return false; if (!canModifyEditor()) return false; fLastLine= computeLine(fIsRulerAction); return true; }
/** * Always enables this action if it is connected to a text editor. * If the associated editor is <code>null</code>, the action is disabled. * Subclasses may override. */ @Override public void update() { setEnabled(getTextEditor() != null); }
/** * Checks and validates the editor's modifiable state. Returns <code>true</code> if an action * can proceed modifying the editor's input, <code>false</code> if it should not. * * <p>If the editor implements <code>ITextEditorExtension2</code>, * this method returns {@link ITextEditorExtension2#validateEditorInputState()};<br> else if the editor * implements <code>ITextEditorExtension</code>, it returns {@link ITextEditorExtension#isEditorInputReadOnly()};<br> * else, {@link ITextEditor#isEditable()} is returned, or <code>false</code> if the editor is <code>null</code>.</p> * * <p>There is only a difference to {@link #canModifyEditor()} if the editor implements * <code>ITextEditorExtension2</code>.</p> * * @return <code>true</code> if a modifying action can proceed to modify the underlying document, <code>false</code> otherwise * @since 3.0 */ protected boolean validateEditorInputState() { ITextEditor editor= getTextEditor(); if (editor instanceof ITextEditorExtension2) return ((ITextEditorExtension2) editor).validateEditorInputState(); else if (editor instanceof ITextEditorExtension) return !((ITextEditorExtension) editor).isEditorInputReadOnly(); else if (editor != null) return editor.isEditable(); else return false; } }
public void update() { /* * Update only works if we're updated from the ruler action * (see AbstractDecoratedTextEditor.rulerContextMenuAboutToShow). */ super.update(); setEnabled(computeEnablement()); }
@Override public void setEditor(ITextEditor editor) { super.setEditor(editor); fOperationTarget= null; }