/** * Returns the information presenter (creates it if necessary). * * @return the information presenter * @since 3.6 */ private FocusedInformationPresenter getInformationPresenter() { if (fInformationPresenter == null) { fInformationPresenter= new FocusedInformationPresenter(getSourceViewer(), getSourceViewerConfiguration()); } return fInformationPresenter; }
/** * 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 * @param upwards <code>true</code>if the selected lines should be moved upwards, * <code>false</code> if downwards * @param copy if <code>true</code>, the action will copy lines instead of moving them * @see TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor) * @deprecated As of 3.5, replaced by * {@link #MoveLinesAction(ResourceBundle, String, ITextEditor, ITextViewer, boolean, boolean)} */ @Deprecated public MoveLinesAction(ResourceBundle bundle, String prefix, AbstractTextEditor editor, boolean upwards, boolean copy) { this(bundle, prefix, editor, editor != null ? editor.getSourceViewer() : null, upwards, copy); }
/** * 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 * @param upwards <code>true</code>if the selected lines should be moved upwards, * <code>false</code> if downwards * @param copy if <code>true</code>, the action will copy lines instead of moving them * @see TextEditorAction#TextEditorAction(ResourceBundle, String, ITextEditor) * @deprecated As of 3.5, replaced by * {@link #MoveLinesAction(ResourceBundle, String, ITextEditor, ITextViewer, boolean, boolean)} */ @Deprecated public MoveLinesAction(ResourceBundle bundle, String prefix, AbstractTextEditor editor, boolean upwards, boolean copy) { this(bundle, prefix, editor, editor != null ? editor.getSourceViewer() : null, upwards, copy); }
/** * Returns the information presenter (creates it if necessary). * * @return the information presenter * @since 3.6 */ private FocusedInformationPresenter getInformationPresenter() { if (fInformationPresenter == null) { fInformationPresenter= new FocusedInformationPresenter(getSourceViewer(), getSourceViewerConfiguration()); } return fInformationPresenter; }
/** * 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; }
/** * 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; }
/** * 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; }
@Override public void setEditor(ITextEditor editor) { ITextEditor currentEditor= getTextEditor(); if (currentEditor != editor && currentEditor != null && editor != null) { if (editor instanceof AbstractTextEditor) fTextViewer= ((AbstractTextEditor)editor).getSourceViewer(); else fTextViewer= null; } super.setEditor(editor); }
@Override public void setEditor(ITextEditor editor) { ITextEditor currentEditor= getTextEditor(); if (currentEditor != editor && currentEditor != null && editor != null) { if (editor instanceof AbstractTextEditor) fTextViewer= ((AbstractTextEditor)editor).getSourceViewer(); else fTextViewer= null; } super.setEditor(editor); }
/** * @see org.eclipse.ui.texteditor.ITextEditorExtension5#isBlockSelectionModeEnabled() * @since 3.5 */ @Override public final boolean isBlockSelectionModeEnabled() { ISourceViewer viewer= getSourceViewer(); if (viewer != null) { StyledText styledText= viewer.getTextWidget(); if (styledText != null) return styledText.getBlockSelection(); } return false; }
/** * @see org.eclipse.ui.texteditor.ITextEditorExtension5#isBlockSelectionModeEnabled() * @since 3.5 */ @Override public final boolean isBlockSelectionModeEnabled() { ISourceViewer viewer= getSourceViewer(); if (viewer != null) { StyledText styledText= viewer.getTextWidget(); if (styledText != null) return styledText.getBlockSelection(); } return false; }
/** * Ends the compound change. */ private void beginCompoundEdit() { if (fEditInProgress || fEditor == null) return; fEditInProgress= true; fStrategy.arm(fEditor.getSourceViewer()); IRewriteTarget target= (IRewriteTarget)fEditor.getAdapter(IRewriteTarget.class); if (target != null) { target.beginCompoundChange(); } }
/** * Install codemining providers. * * @since 3.11 */ protected void installCodeMiningProviders() { ICodeMiningProvider[] providers = TextEditorPlugin.getDefault().getCodeMiningProviderRegistry() .getProviders(this.getSourceViewer(), this); ((ISourceViewerExtension5) fSourceViewer).setCodeMiningProviders(providers); }
/** * <code>true</code> if word wrap is supported and enabled, <code>false</code> otherwise * @return the receiver's word wrap state if word wrap is supported * @since 3.10 * @see AbstractTextEditor#isWordWrapSupported() */ @Override public final boolean isWordWrapEnabled() { if (!isWordWrapSupported()) { return false; } ISourceViewer viewer= getSourceViewer(); if (viewer != null) { StyledText styledText= viewer.getTextWidget(); if (styledText != null) { return styledText.getWordWrap(); } } return false; }
/** * <code>true</code> if word wrap is supported and enabled, <code>false</code> otherwise * @return the receiver's word wrap state if word wrap is supported * @since 3.10 * @see AbstractTextEditor#isWordWrapSupported() */ @Override public final boolean isWordWrapEnabled() { if (!isWordWrapSupported()) { return false; } ISourceViewer viewer= getSourceViewer(); if (viewer != null) { StyledText styledText= viewer.getTextWidget(); if (styledText != null) { return styledText.getWordWrap(); } } return false; }
/** * Perform the next completion. */ private void completeNext() { try { fDocument.replace(fLastCompletion.startOffset, fLastCompletion.length, fLastCompletion.next()); //next() will already advance } catch (BadLocationException e) { // we should never get here. different from other places to notify the user. log(e); clearState(); return; } // move the caret to the insertion point ISourceViewer sourceViewer= ((AbstractTextEditor) getTextEditor()).getSourceViewer(); sourceViewer.setSelectedRange(fLastCompletion.startOffset + fLastCompletion.length, 0); sourceViewer.revealRange(fLastCompletion.startOffset, fLastCompletion.length); fExitStrategy.arm(((AbstractTextEditor) getTextEditor()).getSourceViewer()); }
/** * Perform the next completion. */ private void completeNext() { try { fDocument.replace(fLastCompletion.startOffset, fLastCompletion.length, fLastCompletion.next()); //next() will already advance } catch (BadLocationException e) { // we should never get here. different from other places to notify the user. log(e); clearState(); return; } // move the caret to the insertion point ISourceViewer sourceViewer= ((AbstractTextEditor) getTextEditor()).getSourceViewer(); sourceViewer.setSelectedRange(fLastCompletion.startOffset + fLastCompletion.length, 0); sourceViewer.revealRange(fLastCompletion.startOffset, fLastCompletion.length); fExitStrategy.arm(((AbstractTextEditor) getTextEditor()).getSourceViewer()); }
/** * Perform the next completion. */ private void completeNext() { try { fDocument.replace(fLastCompletion.startOffset, fLastCompletion.length, fLastCompletion.suggestions[fLastCompletion.nextSuggestion]); } catch (BadLocationException e) { // we should never get here. different from other places to notify the user. log(e); clearState(); return; } // advance the suggestion state fLastCompletion.advance(); // move the caret to the insertion point ISourceViewer sourceViewer= ((AbstractTextEditor) getTextEditor()).getSourceViewer(); sourceViewer.setSelectedRange(fLastCompletion.startOffset + fLastCompletion.length, 0); sourceViewer.revealRange(fLastCompletion.startOffset, fLastCompletion.length); fExitStrategy.arm(((AbstractTextEditor) getTextEditor()).getSourceViewer()); }
public void run() { ITextEditor editor= getTextEditor(); if (!(editor instanceof AbstractTextEditor)) return; ISourceViewer viewer= ((AbstractTextEditor)editor).getSourceViewer(); if (viewer == null) return; StyledText st= viewer.getTextWidget(); if (st == null) return; // compute the number of lines displayed int height= st.getClientArea().height; int lineHeight= st.getLineHeight(); int caretOffset= st.getCaretOffset(); int caretLine= st.getLineAtOffset(caretOffset); int topLine= Math.max(0, (caretLine - (height / (lineHeight * 2)))); st.setTopIndex(topLine); } }
public void saveState(IMemento memento) { ISelection selection= doGetSelection(); if (selection instanceof ITextSelection) { memento.putInteger(TAG_SELECTION_OFFSET, ((ITextSelection)selection).getOffset()); memento.putInteger(TAG_SELECTION_LENGTH, ((ITextSelection)selection).getLength()); // https://bugs.eclipse.org/bugs/show_bug.cgi?id=168524 memento.putInteger(TAG_SELECTION_HPIXEL, getSourceViewer().getTextWidget().getHorizontalPixel()); } }