Refine search
public Part (Line line, PositionRef position, int length) { this.position = position; this.line = line; this.length = length; previousOffset = position.getOffset(); }
@Override public Line.Part createPart(int column, int length) { DocumentLine.Part part = new DocumentLine.Part( this, new PositionRef( pos.getCloneableEditorSupport().getPositionManager(), pos.getOffset() + column, Position.Bias.Forward ), length ); addLinePart(part); return part; }
public void open() { try { PositionRef pos = ed.getRange().getBegin(); int line = pos.getLine(); int column = pos.getColumn(); Line l = pos.getCloneableEditorSupport().getLineSet().getCurrent(line); l.show(Line.SHOW_GOTO, column); } catch (IOException ex) { Exceptions.printStackTrace(ex); } }
/** Finds the text contained in this range. * @return the text * @exception IOException if any I/O problem occurred during document loading (if that was necessary) * @exception BadLocationException if the positions are out of the bounds of the document */ public String getText() throws BadLocationException, IOException { StyledDocument doc = begin.getCloneableEditorSupport().openDocument(); int p1 = begin.getOffset(); int p2 = end.getOffset(); return doc.getText(p1, p2 - p1); }
public void run() { synchronized (editor.getLock()) { /* editor.getLock(): fixes deadlock - this lock is acquired later anyhow, so we are changing the order in which the locks are acquired */ try { // [MaM] remember doclen to compute new length // of the inserted string (the length changes // because insertString removes \r characters // from it) int docLen = doc.getLength(); int p1 = end.getOffset(); doc.insertString(p1, text, null); int p2 = (p1 + doc.getLength()) - docLen; end = editor.createPositionRef(p1, end.getPositionBias()); PositionRef posBegin = editor.createPositionRef(p1, Position.Bias.Forward); PositionRef posEnd = editor.createPositionRef(p2, Position.Bias.Backward); hold[1] = new PositionBounds(posBegin, posEnd); } catch (BadLocationException e) { hold[0] = e; } } } };
public static boolean openSource(PositionBounds position) { CloneableEditorSupport editorSupport = position.getBegin().getCloneableEditorSupport(); editorSupport.edit(); JEditorPane[] panes = editorSupport.getOpenedPanes(); if (panes != null) { JumpList.checkAddEntry(); JEditorPane pane = panes[0]; pane.setCaretPosition(position.getBegin().getOffset()); Container container = pane; while (container != null && !(container instanceof TopComponent)) { container = container.getParent(); } if (container != null) { ((TopComponent) container).requestActive(); } } return false; }
public void run() { try { int p1 = begin.getOffset(); int p2 = end.getOffset(); int len = text.length(); if (begin.getOffset() != p1) { begin = editor.createPositionRef(p1, begin.getPositionBias()); if ((end.getOffset() - p1) != len) { end = editor.createPositionRef(p1 + len, end.getPositionBias());
@Override public int hashCode() { return pos.getCloneableEditorSupport().hashCode(); }
public ErrorDescriptionNode(ErrorDescription ed, Map<ErrorDescription, List<FixDescription>> errors2Fixes) { super(new FixChildren(ed, errors2Fixes.get(ed))); this.ed = ed; int line = -1; try { line = ed.getRange().getBegin().getLine(); } catch (IOException ex) { Exceptions.printStackTrace(ex); } setDisplayName((line != (-1) ? (line + ":") : "") + ed.getDescription()); setIconBaseWithExtension("org/netbeans/modules/java/hints/analyzer/ui/warning-glyph.gif"); }
p = pos.getPosition(); } catch (IOException ex) { Logger.getLogger(DocumentLine.class.getName()).log(Level.WARNING, null, ex); CloneableEditorSupport support = pos.getCloneableEditorSupport(); pos = new PositionRef(support.getPositionManager(), lineStartOffset, Position.Bias.Forward); if (annos.size() > 0) { try { p = pos.getPosition(); } catch (IOException e) { throw new IllegalArgumentException(); // should not fail
@Override public void addError(CsmErrorInfo info) { if (interrupter.cancelled()) { return; } PositionBounds pb = createPositionBounds(dao, info.getStartOffset(), info.getEndOffset()); ErrorDescription desc = null; if( pb != null ) { try { desc = ErrorDescriptionFactory.createErrorDescription( getSeverity(info), info.getMessage(), doc, pb.getBegin().getPosition(), pb.getEnd().getPosition()); } catch (IOException ioe) { Exceptions.printStackTrace(ioe); } descriptions.add(desc); if (TRACE_ANNOTATIONS) System.err.printf("\tadded to a bag %s\n", desc.toString()); } else { if (TRACE_ANNOTATIONS) System.err.printf("\tCan't create PositionBounds for %s\n", info); } } @Override
/** Add annotation to this Annotatable class * @param anno annotation which will be attached to this class */ protected void addAnnotation(Annotation anno) { super.addAnnotation(anno); StyledDocument doc = position.getCloneableEditorSupport ().getDocument (); // document is not opened and so the annotation will be added to document later if (doc == null) return; position.getCloneableEditorSupport().prepareDocument().waitFinished(); try { if (!anno.isInDocument()) { anno.setInDocument(true); NbDocument.addAnnotation(doc, position.getPosition(), length, anno); } } catch (IOException ex) { ErrorManager.getDefault ().notify ( ErrorManager.EXCEPTION, ex); } }
public void run() { try { synchronized (getAnnotations()) { if (!anno.isInDocument()) { anno.setInDocument(true); NbDocument.addAnnotation(doc, position.getPosition(), length, anno); } } } catch (IOException ex) { Logger.getLogger(DocumentLine.class.getName()).log(Level.WARNING, null, ex); } } });
/** Create a position reference for the given offset. * The position moves as the document is modified and * reacts to closing and opening of the document. * * @param offset the offset to create position at * @param bias the Position.Bias for new creating position. * @return position reference for that offset */ public final PositionRef createPositionRef (int offset, Position.Bias bias) { return new PositionRef (getPositionManager (), offset, bias); }
public int getLineNumber () { try { return pos.getLine (); } catch (IOException ex) { // what else? return 0; } }
/** Start column of annotation */ public int getColumn() { try { return position.getColumn(); } catch (IOException ex) { return 0; //TODO: change this } }
public void run() { synchronized (editor.getLock()) { /* editor.getLock(): fixes deadlock - this lock is acquired later anyhow, so we are changing the order in which the locks are acquired */ try { // [MaM] remember doclen to compute new length // of the inserted string (the length changes // because insertString removes \r characters // from it) int docLen = doc.getLength(); int p1 = end.getOffset(); doc.insertString (p1, text, null); int p2 = p1 + doc.getLength() - docLen; end = editor.createPositionRef(p1, end.getPositionBias()); PositionRef posBegin = editor.createPositionRef(p1, Position.Bias.Forward); PositionRef posEnd = editor.createPositionRef(p2, Position.Bias.Backward); hold[1] = new PositionBounds(posBegin, posEnd); } catch (BadLocationException e) { hold[0] = e; } } } };
/** Finds the text contained in this range. * @return the text * @exception IOException if any I/O problem occurred during document loading (if that was necessary) * @exception BadLocationException if the positions are out of the bounds of the document */ public String getText() throws BadLocationException, IOException { StyledDocument doc = begin.getCloneableEditorSupport().openDocument(); int p1 = begin.getOffset(); int p2 = end.getOffset(); return doc.getText(p1, p2 - p1); }