public int adjustLimitPos(BaseDocument doc, int limitPos) { origLimitPos = limitPos; try { return Utilities.getRowStart(doc, limitPos); } catch (BadLocationException e) { return limitPos; } }
public int adjustLimitPos(BaseDocument doc, int limitPos) { origLimitPos = limitPos; try { return Utilities.getRowStart(doc, limitPos); } catch (BadLocationException e) { return limitPos; } }
public int adjustStartPos(BaseDocument doc, int startPos) { origStartPos = startPos; try { return Utilities.getRowStart(doc, startPos); } catch (BadLocationException e) { return startPos; } }
public int adjustStartPos(BaseDocument doc, int startPos) { origStartPos = startPos; try { return Utilities.getRowStart(doc, startPos); } catch (BadLocationException e) { return startPos; } }
public int adjustStartPos(BaseDocument doc, int startPos) { origStartPos = startPos; try { return Utilities.getRowStart(doc, startPos); } catch (BadLocationException e) { return startPos; } }
/** Get the starting position of the row. * @param doc document to operate on * @param offset position in document where to start searching * @return position of the start of the row or -1 for invalid position */ public static int getRowStart(BaseDocument doc, int offset) throws BadLocationException { return getRowStart(doc, offset, 0); }
/** * Get the starting position of the row. * * @param c * text component to operate on * @param offset * position in document where to start searching * @return position of the start of the row or -1 for invalid position */ public static int getRowStart(JTextComponent c, int offset) throws BadLocationException { return getRowStart((BaseDocument) c.getDocument(), offset, 0); }
public void setStartOffset(int offset) { currentWord = null; currentStartOffset = (-1); this.ignoreBefore = offset; try { this.nextSearchOffset = Utilities.getRowStart(doc, offset); } catch (BadLocationException ex) { Logger.getLogger(AbstractTokenList.class.getName()).log(Level.FINE, null, ex); this.nextSearchOffset = offset; } }
public void setStartOffset (int offset) { currentWord = null; currentStartOffset = (-1); this.ignoreBefore = offset; try { this.nextSearchOffset = Utilities.getRowStart (doc, offset); } catch (BadLocationException ex) { Logger.getLogger (AbstractTokenList.class.getName ()).log (Level.FINE, null, ex); this.nextSearchOffset = offset; } }
public static int getFirstNonEmptyRow(BaseDocument doc, int offset, boolean downDir) throws BadLocationException { while (offset != -1 && isRowEmpty(doc, offset)) { offset = getRowStart(doc, offset, downDir ? +1 : -1); } return offset; }
private boolean allComments(BaseDocument doc, int startOffset, int lineCount) throws BadLocationException { for (int offset = startOffset; lineCount > 0; lineCount--) { int firstNonWhitePos = Utilities.getRowFirstNonWhite(doc, offset); if (firstNonWhitePos != -1) { // Ignore empty lines if (!isLineCommented(doc, firstNonWhitePos)) { return false; } } offset = Utilities.getRowStart(doc, offset, +1); } return true; }
/** Reformat the line around the given position. */ public static void reformatLine(BaseDocument doc, int pos) throws BadLocationException { int lineStart = getRowStart(doc, pos); int lineEnd = getRowEnd(doc, pos); reformat(doc, lineStart, lineEnd); }
public static String getLine(final JTextComponent component, final int offset) { final BaseDocument workingDocument=org.netbeans.editor.Utilities.getDocument(component); try { final int lineStartOffset = org.netbeans.editor.Utilities.getRowStart(workingDocument, offset); final int lineEndOffset = org.netbeans.editor.Utilities.getRowEnd(workingDocument, offset); return String.valueOf(workingDocument.getChars(lineStartOffset, lineEndOffset - lineStartOffset)); } catch (BadLocationException ble) { return ""; } } }
private void modifyUnderWriteLock(Context context) { try { context.modifyIndent(Utilities.getRowStart((BaseDocument) context.document(), context.caretOffset()), indentation); } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); } }
public static String getLine(final JTextComponent component, final int offset) { final BaseDocument workingDocument = org.netbeans.editor.Utilities.getDocument(component); try { final int lineStartOffset = org.netbeans.editor.Utilities.getRowStart(workingDocument, offset); final int lineEndOffset = org.netbeans.editor.Utilities.getRowEnd(workingDocument, offset); return String.valueOf(workingDocument.getChars(lineStartOffset, lineEndOffset - lineStartOffset)); } catch (BadLocationException ble) { return ""; } }
/** Toggle the bookmark for the current line */ public boolean toggleBookmark(int pos) throws BadLocationException { pos = Utilities.getRowStart(this, pos); boolean marked = bookmarkChain.toggleMark(pos); BaseDocumentEvent evt = createDocumentEvent(pos, 0, DocumentEvent.EventType.CHANGE); fireChangedUpdate(evt); return marked; }
/** Toggle the bookmark for the current line */ public boolean toggleBookmark(int pos) throws BadLocationException { pos = Utilities.getRowStart(this, pos); boolean marked = bookmarkChain.toggleMark(pos); BaseDocumentEvent evt = createDocumentEvent(pos, 0, DocumentEvent.EventType.CHANGE); fireChangedUpdate(evt); return marked; }
public void run() { try { final int start=Utilities.getRowStart(doc,offset); final int end=Utilities.getRowEnd(doc,offset); doc.remove(start,end-start+1); } catch (BadLocationException ble) { ErrorManager.getDefault().notify(ble); } RecommentAction.actionPerformed(doc); } });
@Override public void implement() throws Exception { int templateOffset = getOffset(); EditList edits = new EditList(doc); edits.replace(templateOffset, oldName.toString().length(), getGeneratedCode(), true, 0); //NOI18N edits.apply(); UiUtils.open(scope.getFileObject(), Utilities.getRowStart(doc, templateOffset)); }
@Override public void implement() throws Exception { int templateOffset = getOffset(); EditList edits = new EditList(doc); edits.replace(templateOffset, 0, "\n" + getGeneratedCode(), true, 0); //NOI18N edits.apply(); UiUtils.open(scope.getFileObject(), Utilities.getRowStart(doc, getOffsetRange().getEnd())); }