public void update() { setEnabled(getTextViewer() instanceof ITextViewerExtension2); synchronizeWithPreference(); }
/** * Toggles the painter state. * * @param newState <code>true</code> if the painter should be installed */ private void togglePainterState(boolean newState) { if (newState) installPainter(); else uninstallPainter(); } }
/** * Synchronize state with the preference. */ private void synchronizeWithPreference() { boolean checked= false; if (fStore != null) checked= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_WHITESPACE_CHARACTERS); if (checked != isChecked()) { setChecked(checked); togglePainterState(checked); } }
/** * Synchronize state with the preference. */ private void synchronizeWithPreference() { boolean checked= false; if (fStore != null) { checked= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_WHITESPACE_CHARACTERS); fShowLeadingSpaces= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_LEADING_SPACES); fShowEnclosedSpaces= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_SPACES); fShowTrailingSpaces= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_TRAILING_SPACES); fShowLeadingIdeographicSpaces= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_LEADING_IDEOGRAPHIC_SPACES); fShowEnclosedIdeographicSpaces= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES); fShowTrailingIdeographicSpace= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_TRAILING_IDEOGRAPHIC_SPACES); fShowLeadingTabs= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_LEADING_TABS); fShowEnclosedTabs= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_TABS); fShowTrailingTabs= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_TRAILING_TABS); fShowCarriageReturn= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_CARRIAGE_RETURN); fShowLineFeed= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_LINE_FEED); fAlpha= fStore.getInt(AbstractTextEditor.PREFERENCE_WHITESPACE_CHARACTER_ALPHA_VALUE); } if (checked != isChecked()) { setChecked(checked); togglePainterState(checked); } else if (checked) { uninstallPainter(); installPainter(); } }
public void run() { togglePainterState(isChecked()); if (fStore != null) fStore.setValue(AbstractTextEditor.PREFERENCE_SHOW_WHITESPACE_CHARACTERS, isChecked()); }
/** * Remove the painter from the current editor. */ private void uninstallPainter() { if (fWhitespaceCharPainter == null) return; ITextViewer viewer= getTextViewer(); if (viewer instanceof ITextViewerExtension2) ((ITextViewerExtension2)viewer).removePainter(fWhitespaceCharPainter); fWhitespaceCharPainter.deactivate(true); fWhitespaceCharPainter= null; }
/** * Sets the preference store of this action. * * @param store the preference store */ public void setPreferenceStore(IPreferenceStore store) { fStore= store; synchronizeWithPreference(); }
/** * Get the <code>ITextViewer</code> from an <code>ITextEditor</code>. * * @return the text viewer or <code>null</code> */ private ITextViewer getTextViewer() { ITextEditor editor= getTextEditor(); if (editor instanceof AbstractTextEditor) return ((AbstractTextEditor)editor).getSourceViewer(); return null; }
setAction(ITextEditorActionConstants.RECENTER, action); action= new ShowWhitespaceCharactersAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ShowWhitespaceCharacters.", this, getPreferenceStore()); //$NON-NLS-1$ action.setHelpContextId(IAbstractTextEditorHelpContextIds.SHOW_WHITESPACE_CHARACTERS_ACTION); action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHOW_WHITESPACE_CHARACTERS);
/** * Synchronize state with the preference. */ private void synchronizeWithPreference() { boolean checked= false; if (fStore != null) { checked= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_WHITESPACE_CHARACTERS); fShowLeadingSpaces= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_LEADING_SPACES); fShowEnclosedSpaces= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_SPACES); fShowTrailingSpaces= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_TRAILING_SPACES); fShowLeadingIdeographicSpaces= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_LEADING_IDEOGRAPHIC_SPACES); fShowEnclosedIdeographicSpaces= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_IDEOGRAPHIC_SPACES); fShowTrailingIdeographicSpace= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_TRAILING_IDEOGRAPHIC_SPACES); fShowLeadingTabs= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_LEADING_TABS); fShowEnclosedTabs= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_ENCLOSED_TABS); fShowTrailingTabs= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_TRAILING_TABS); fShowCarriageReturn= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_CARRIAGE_RETURN); fShowLineFeed= fStore.getBoolean(AbstractTextEditor.PREFERENCE_SHOW_LINE_FEED); fAlpha= fStore.getInt(AbstractTextEditor.PREFERENCE_WHITESPACE_CHARACTER_ALPHA_VALUE); } if (checked != isChecked()) { setChecked(checked); togglePainterState(checked); } else if (checked) { uninstallPainter(); installPainter(); } }
@Override public void run() { togglePainterState(isChecked()); if (fStore != null) fStore.setValue(AbstractTextEditor.PREFERENCE_SHOW_WHITESPACE_CHARACTERS, isChecked()); }
/** * Remove the painter from the current editor. */ private void uninstallPainter() { if (fWhitespaceCharPainter == null) return; ITextViewer viewer= getTextViewer(); if (viewer instanceof ITextViewerExtension2) ((ITextViewerExtension2)viewer).removePainter(fWhitespaceCharPainter); fWhitespaceCharPainter.deactivate(true); fWhitespaceCharPainter= null; }
/** * Sets the preference store of this action. * * @param store the preference store */ public void setPreferenceStore(IPreferenceStore store) { fStore= store; synchronizeWithPreference(); }
/** * Get the <code>ITextViewer</code> from an <code>ITextEditor</code>. * * @return the text viewer or <code>null</code> */ private ITextViewer getTextViewer() { ITextEditor editor= getTextEditor(); if (editor instanceof AbstractTextEditor) return ((AbstractTextEditor)editor).getSourceViewer(); return null; }
setAction(ITextEditorActionConstants.RECENTER, action); action= new ShowWhitespaceCharactersAction(EditorMessages.getBundleForConstructedKeys(), "Editor.ShowWhitespaceCharacters.", this, getPreferenceStore()); //$NON-NLS-1$ action.setHelpContextId(IAbstractTextEditorHelpContextIds.SHOW_WHITESPACE_CHARACTERS_ACTION); action.setActionDefinitionId(ITextEditorActionDefinitionIds.SHOW_WHITESPACE_CHARACTERS);
@Override public void update() { setEnabled(getTextViewer() instanceof ITextViewerExtension2); synchronizeWithPreference(); }
/** * Toggles the painter state. * * @param newState <code>true</code> if the painter should be installed */ private void togglePainterState(boolean newState) { if (newState) installPainter(); else uninstallPainter(); } }
@Override public void run() { togglePainterState(isChecked()); if (fStore != null) fStore.setValue(AbstractTextEditor.PREFERENCE_SHOW_WHITESPACE_CHARACTERS, isChecked()); }
/** * Remove the painter from the current editor. */ private void uninstallPainter() { if (fWhitespaceCharPainter == null) return; ITextViewer viewer= getTextViewer(); if (viewer instanceof ITextViewerExtension2) ((ITextViewerExtension2)viewer).removePainter(fWhitespaceCharPainter); fWhitespaceCharPainter.deactivate(true); fWhitespaceCharPainter= null; }
/** * Construct the action and initialize its state. * * @param resourceBundle the resource bundle to construct label and tooltip from * @param prefix the prefix to use for constructing resource bundle keys * @param editor the editor this action is associated with * @param store the preference store (may be <code>null</code>) */ public ShowWhitespaceCharactersAction(ResourceBundle resourceBundle, String prefix, ITextEditor editor, IPreferenceStore store) { super(resourceBundle, prefix, editor, IAction.AS_CHECK_BOX); fStore= store; synchronizeWithPreference(); }