/** * Returns the double-click strategy ready to be used in this viewer when double clicking * onto text of the given content type. This implementation always returns a new instance of * <code>DefaultTextDoubleClickStrategy</code>. * * @param sourceViewer the source viewer to be configured by this configuration * @param contentType the content type for which the strategy is applicable * @return a double-click strategy or <code>null</code> if double clicking should not be supported */ public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) { return new DefaultTextDoubleClickStrategy(); }
/** * Tries to find the word at the given offset. * * @param document the document * @param offset the offset * @return the word or <code>null</code> if none * @since 3.5 */ protected IRegion findWord(IDocument document, int offset) { return findWord(document, offset, getWordBreakIterator()); }
@Override public void doubleClicked(ITextViewer text) { int offset= text.getSelectedRange().x; if (offset < 0) return; final IDocument document= text.getDocument(); IRegion region= findExtendedDoubleClickSelection(document, offset); if (region == null) region= findWord(document, offset); if (region != null) text.setSelectedRange(region.getOffset(), region.getLength()); }
@Override protected IRegion findExtendedDoubleClickSelection(IDocument document, int offset) { IRegion match= super.findExtendedDoubleClickSelection(document, offset); if (match != null) return match; try { ITypedRegion region= TextUtilities.getPartition(document, fPartitioning, offset, true); if (offset == region.getOffset() + fHitDelta || offset == region.getOffset() + region.getLength() - fHitDelta) { if (fLeftBorder == 0 && fRightBorder == 0) return region; if (fRightBorder == -1) { String delimiter= document.getLineDelimiter(document.getLineOfOffset(region.getOffset() + region.getLength() - 1)); if (delimiter == null) fRightBorder= 0; else fRightBorder= delimiter.length(); } return new Region(region.getOffset() + fLeftBorder, region.getLength() - fLeftBorder - fRightBorder); } } catch (BadLocationException e) { return null; } return null; } }
IRegion wordRegion= findWord(document, offset, getPOSIXWordBreakIterator()); if (wordRegion != null) { int wordStart= wordRegion.getOffset();
super.doubleClicked(part);
@Override public void doubleClicked(ITextViewer text) { int offset= text.getSelectedRange().x; if (offset < 0) return; final IDocument document= text.getDocument(); IRegion region= findExtendedDoubleClickSelection(document, offset); if (region == null) region= findWord(document, offset); if (region != null) text.setSelectedRange(region.getOffset(), region.getLength()); }
@Override protected IRegion findExtendedDoubleClickSelection(IDocument document, int offset) { IRegion match= super.findExtendedDoubleClickSelection(document, offset); if (match != null) return match; try { ITypedRegion region= TextUtilities.getPartition(document, fPartitioning, offset, true); if (offset == region.getOffset() + fHitDelta || offset == region.getOffset() + region.getLength() - fHitDelta) { if (fLeftBorder == 0 && fRightBorder == 0) return region; if (fRightBorder == -1) { String delimiter= document.getLineDelimiter(document.getLineOfOffset(region.getOffset() + region.getLength() - 1)); if (delimiter == null) fRightBorder= 0; else fRightBorder= delimiter.length(); } return new Region(region.getOffset() + fLeftBorder, region.getLength() - fLeftBorder - fRightBorder); } } catch (BadLocationException e) { return null; } return null; } }
IRegion wordRegion= findWord(document, offset, getPOSIXWordBreakIterator()); if (wordRegion != null) { int wordStart= wordRegion.getOffset();
LdifEditorConstants.PREFERENCE_LDIFEDITOR_DOUBLECLICK_USELDIFDOUBLECLICK ) ) delegateDoubleClickStrategy.doubleClicked( viewer ); delegateDoubleClickStrategy.doubleClicked( viewer );
/** * Returns the double-click strategy ready to be used in this viewer when double clicking * onto text of the given content type. This implementation always returns a new instance of * <code>DefaultTextDoubleClickStrategy</code>. * * @param sourceViewer the source viewer to be configured by this configuration * @param contentType the content type for which the strategy is applicable * @return a double-click strategy or <code>null</code> if double clicking should not be supported */ public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) { return new DefaultTextDoubleClickStrategy(); }
/** * Tries to find the word at the given offset. * * @param document the document * @param offset the offset * @return the word or <code>null</code> if none * @since 3.5 */ protected IRegion findWord(IDocument document, int offset) { return findWord(document, offset, getWordBreakIterator()); }
protected void processTextDoubleClicked() { if (fDoubleClickCount == 1) { super.doubleClicked(fStructuredTextViewer);
public LdifDoubleClickStrategy() { this.delegateDoubleClickStrategy = new DefaultTextDoubleClickStrategy(); }
public ITextDoubleClickStrategy getDoubleClickStrategy(ISourceViewer sourceViewer, String contentType) { if (IJavaPartitions.JAVA_DOC.equals(contentType)) return new JavadocDoubleClickStrategy(); if (IJavaPartitions.JAVA_MULTI_LINE_COMMENT.equals(contentType) || IJavaPartitions.JAVA_SINGLE_LINE_COMMENT.equals(contentType)) return new DefaultTextDoubleClickStrategy(); else if (IJavaPartitions.JAVA_STRING.equals(contentType) || IJavaPartitions.JAVA_CHARACTER.equals(contentType)) return new JavaStringDoubleClickSelector(getConfiguredDocumentPartitioning(sourceViewer)); if (fJavaDoubleClickSelector == null) { fJavaDoubleClickSelector= new JavaDoubleClickSelector(); fJavaDoubleClickSelector.setSourceVersion(fPreferenceStore.getString(JavaCore.COMPILER_SOURCE)); } return fJavaDoubleClickSelector; }
setTextDoubleClickStrategy(new DefaultTextDoubleClickStrategy(), IDocument.DEFAULT_CONTENT_TYPE); activatePlugins();