@Override String getText(ISelection selection) { ITextSelection ts= (ITextSelection)selection; return ts.getText(); }
@Override boolean isMultiline(ISelection selection) { ITextSelection ts= (ITextSelection)selection; return ts.getEndLine() > ts.getStartLine(); }
@Override ISelection makeReplaceSelection(ISelection selection, String replacement) { ITextSelection ts= (ITextSelection)selection; return new TextSelection(fDocument, ts.getOffset() + replacement.length(), 0); } };
/** * Returns the selected text. */ public String getSelectedText() { String sql = null; if (getSelectionProvider() == null) { return null; } //get the selection ITextSelection selection = (ITextSelection) getSelectionProvider().getSelection(); if (!selection.isEmpty() && selection.getText() != null && !selection.getText().equals("")) //$NON-NLS-1$ { sql = selection.getText(); } return sql; }
@Override boolean isEmpty(ISelection selection) { ITextSelection ts= (ITextSelection)selection; return ts.getLength() <= 0; }
@Override protected boolean isValidSelection(ITextSelection selection) { return selection != null && !selection.isEmpty(); } }
@Override public int getStartLine() { return textSelection.getStartLine(); }
@Override public int getEndLine() { return textSelection.getEndLine(); }
protected IndexedRegion getCursorIndexedRegion(IDocument document, ITextSelection textSelection) { IndexedRegion indexedRegion = null; indexedRegion = getIndexedRegion(document, textSelection.getOffset()); return indexedRegion; }
@Override protected boolean isValidSelection(ITextSelection selection) { return selection != null && !selection.isEmpty(); }
public void run() { lineNumber[0] = textSelection.getStartLine() + 1; ASTParser parser = ASTParser.newParser(AST.JLS3); parser.setSource(document.get().toCharArray()); CompilationUnit compilationUnit= (CompilationUnit)parser.createAST(null); ValidBreakpointLocationLocator locator= new ValidBreakpointLocationLocator(compilationUnit, lineNumber[0], false, false); compilationUnit.accept(locator); validLine[0]= locator.getLineLocation(); typeName[0]= locator.getFullyQualifiedTypeName(); } };
@Override int getCoveredLines(ISelection selection) throws BadLocationException { ITextSelection ts= (ITextSelection)selection; return ts.getEndLine() - ts.getStartLine() + 1; }