@Override public void run() { try { int documentOffset = sourceOffset; document.remove(documentOffset, caretOffset - documentOffset); document.insertString(documentOffset, text, null); } catch (BadLocationException ex) { } } });
public void run() { try { doc.removeDocumentListener(getListener()); doc.remove(0, doc.getLength()); // remove all text doc.addDocumentListener(getListener()); } catch(BadLocationException ble) { ErrorManager.getDefault().notify( ErrorManager.INFORMATIONAL, ble); } } });
@Override public void run() { try { doc.remove(0, passPrologLen + 1); // +1 it removes exclusive doc.insertString(0, "<?xml version='1.0' encoding='UTF-8' ?> \n<!-- was: " + new String(prolog, 0, passPrologLen + 1) + " -->", null); // NOI18N } catch (BadLocationException e) { if (System.getProperty("netbeans.debug.exceptions") != null) { // NOI18N Exceptions.printStackTrace(e); } } } };
public void run() { try { doc.removeDocumentListener(getListener()); doc.remove(0, doc.getLength()); // remove all text doc.addDocumentListener(getListener()); } catch(BadLocationException ble) { ErrorManager.getDefault().notify( ErrorManager.INFORMATIONAL, ble); } } });
public void clear() { try { doc.remove( 0, doc.getLength() ); } catch ( BadLocationException e ) { log.error( "Error clearing info text area", e ); } }
void clear() { try { styledDoc.remove(0, styledDoc.getLength()); } catch (BadLocationException ble1) { System.err.println("View.clear(): Couldn't remove initial text from document."); } }
public void run() { try { doc.remove(0, doc.getLength()); doc.insertString(0, out.toString(), null); } catch (BadLocationException ble) { Exceptions.printStackTrace(ble); } } });
public void run() { try { doc.remove(0, doc.getLength()); doc.insertString(0, out.toString(), null); } catch (BadLocationException ble) { Exceptions.printStackTrace(ble); } } });
public void run() { try { doc.remove(0, passPrologLen + 1); // +1 it removes exclusive doc.insertString(0, "<?xml version='1.0' encoding='UTF-8' ?> \n<!-- was: " + new String(prolog, 0, passPrologLen + 1) + " -->", null); // NOI18N } catch (BadLocationException e) { if (System.getProperty("netbeans.debug.exceptions") != null) // NOI18N e.printStackTrace(); } } };
/** * Set this text pane to a new text. Removes any previous content and adds * the new text while adding clickablel links. * * @param text */ @Override public void setText(String text) { try { doc.remove(0, doc.getLength()); } catch (BadLocationException ex) { LOGGER.warning("Bad location"); } printSpecials(text); }
/** * Clear the document. */ public void clear() { try { synchronized(doc) { doc.remove(0, doc.getLength()); } } catch(BadLocationException e) { e.printStackTrace(); } }
/** * Clear the document. */ public void clear() { try { synchronized(doc) { doc.remove(0, doc.getLength()); } } catch(BadLocationException e) { e.printStackTrace(); } }
@Override protected void done() { LOGGER.trace("Message details format and colors calculated, updating GUI"); StyledDocument styledDocument = otrosJTextWithRulerScrollPane.getjTextComponent().getStyledDocument(); try { styledDocument.remove(0, styledDocument.getLength()); } catch (BadLocationException e) { LOGGER.error("Can't clear log events text area", e); } if (!isCancelled()) { updateChanges(chunks); } LOGGER.trace("GUI updated"); }
@Override public void defaultAction(JTextComponent jtc) { try { StyledDocument doc = (StyledDocument) jtc.getDocument(); //Here we remove the characters starting at the start offset //and ending at the point where the caret is currently found: doc.remove(dotOffset, caretOffset - dotOffset); doc.insertString(dotOffset, getText(), null); //This statement will close the code completion box: Completion.get().hideAll(); } catch (BadLocationException ex) { Exceptions.printStackTrace(ex); } }
private static void removeSectionsBlock (StyledDocument document, ArrayList<SimpleSection> sectionsBlock) { Position begin = sectionsBlock.get (0).getStartPosition (); Position end = sectionsBlock.get (sectionsBlock.size () - 1).getEndPosition (); for (SimpleSection section : sectionsBlock) section.removeSection (); try { document.remove (begin.getOffset (), end.getOffset () - begin.getOffset ()); } catch (BadLocationException e) { ErrorManager.getDefault ().notify (e); } sectionsBlock.clear (); }
@Override public void run () { try { doc.remove(0,doc.getLength()); doc.insertString(0,new String( data, 0, pos, FileEncodingQuery.getEncoding(getHandle().resolveFileObject(false))), null); } catch (BadLocationException e) { if (LOG.isLoggable(Level.SEVERE)) LOG.log(Level.SEVERE, e.getMessage(), e); } } });
public void run () { try { doc.remove(0,doc.getLength()); doc.insertString(0,new String(data,0,pos,encodingName),null); } catch (BadLocationException e) { ErrorManager.getDefault().notify(e); } catch (UnsupportedEncodingException ee) { ErrorManager.getDefault().notify (ee); } } });
public void run() { try { addRemoveDocListener(getDoc(), false); getDoc().remove(0, getDoc().getLength()); addRemoveDocListener(getDoc(), true); } catch (BadLocationException ble) { ERR.log(Level.INFO, null, ble); } } }
public void replaceInput(String message, boolean preserveCaretPosition) { int oldCaretPosition = textPane.getCaretPosition(); try { document.remove(startReadLen, document.getLength() - startReadLen); document.insertString(document.getLength(), message, textPane.getInputAttributes().copyAttributes()); } catch (BadLocationException e) { e.printStackTrace(); } catch (Exception e) { logger.error("Cannot insert input text", e); } int newCaretPosition = (preserveCaretPosition && oldCaretPosition <= document.getLength()) ? oldCaretPosition : document.getLength(); textPane.setCaretPosition(newCaretPosition); }
public void appendToStyledDocument(StyledDocument styledDocument) { try { styledDocument.remove(0, styledDocument.getLength()); styledDocument.insertString(0, getString(), null); for (StyledStringMarkup markup : plainStringMarkup) { Style style = markup.getStyle(); int length = markup.getEnd() - markup.getStart(); MutableAttributeSet mas = new SimpleAttributeSet(); for (StyleAttribute styleAttribute : style.getStyleAttributes()) { StyleConstants styleConstants = styleAttribute.getTextAttribute(); Object value = styleAttribute.getTextValue(); mas.addAttribute(styleConstants, value); } styledDocument.setCharacterAttributes(markup.getStart(), length, mas, false); } } catch (BadLocationException e) { e.printStackTrace(); } }