((AbstractDocument)doc).replace(start, end - start, str, null); } catch (BadLocationException e) {
public void run() { String text = field.getText().trim(); if (text.length() > 0 && Character.isLowerCase(text.charAt(0))) { boolean wasEditing = userEdit; try { userEdit = false; ((AbstractDocument)field.getDocument()).replace(0, 1, ""+Character.toUpperCase(text.charAt(0)), null); } catch (BadLocationException ble) { Exceptions.printStackTrace(ble); } finally { userEdit = wasEditing; } } } });
if (mDocument instanceof AbstractDocument) ((AbstractDocument)mDocument).replace(0, mDocument.getLength(), pContent, null);
public void replaceRange(String str, int start, int end) { if (end < start) { throw new IllegalArgumentException("end before start"); } Document doc = getDocument(); if (doc != null) { try { if (doc instanceof AbstractDocument) { ((AbstractDocument) doc).replace(start, end - start, str, null); } else { doc.remove(start, end - start); doc.insertString(start, str, null); } } catch (BadLocationException e) { throw new IllegalArgumentException(e.getMessage()); } } }
/** * Accessor for text area. * This is used by Actions that need to act on the text area of the View. */ public void replaceRange(String str, int start, int end) { //editor.replaceRange(str, start, end); if (end < start) { throw new IllegalArgumentException("end before start"); } Document doc = getDocument(); if (doc != null) { try { if (doc instanceof AbstractDocument) { ((AbstractDocument) doc).replace(start, end - start, str, null); } else { doc.remove(start, end - start); doc.insertString(start, str, null); } } catch (BadLocationException e) { throw new IllegalArgumentException(e.getMessage()); } } }
public void actionPerformed(ActionEvent e) { try { int pos = comp.getCaretPosition(); xlDoc.replace(wordStart, wordLength, replacement, null); comp.setCaretPosition(pos); } catch (BadLocationException exc) { Log.log(exc); } } });
try { if (doc instanceof AbstractDocument) { ((AbstractDocument)doc).replace(start, end - start, str, null);
private boolean plainReplaceText(String message, StyleData styleData) { if(overwriteOffset >= document.getLength()) { overwriteOffset = -1; } if(overwriteOffset < 0) return plainInsertMessage(message, styleData); String styleName = getStyle(styleData); int oldStartReadLen = startReadLen; if(startReadLen > overwriteOffset) { startReadLen = overwriteOffset; } boolean result = true; try { int len = Math.min(document.getLength() - overwriteOffset, message.length()); ((AbstractDocument) document).replace(overwriteOffset, len, message, document.getStyle(styleName)); overwriteOffset += message.length(); } catch (BadLocationException e) { logger.error("Cannot replace text", e); startReadLen = oldStartReadLen; result = false; } return result; }
public static void setTextToDocument(final PlainDocument document, final String text) { GuiUtilities.invokeLater(() -> { try { ((AbstractDocument) document).replace(0, document.getLength(), text, null); } catch (final BadLocationException exception) { logger.log(ILevel.FATAL, exception.getLocalizedMessage(), exception); } }); }
((AbstractDocument)doc).replace(start, end - start, str, null); } catch (BadLocationException e) {
((AbstractDocument)doc).replace(start, end - start, str, null); } catch (BadLocationException e) {
((AbstractDocument)doc).replace(start, end - start, str, null); } catch (BadLocationException e) {
try { if (doc instanceof AbstractDocument) { ((AbstractDocument)doc).replace(start, end - start, str, null);
((AbstractDocument)doc).replace(start, len, replacement, null);
private void maybeUpdateDoc( int iOffset, int iLength, String pattern ) { Path file = getNode().getFile().getFileOrDir(); EditorHost editor = LabFrame.instance().getGosuPanel().findTab( file ); if( editor == null ) { return; } editor.getUndoManager().beginUndoAtom( "Replace" ); try { ((AbstractDocument)editor.getEditor().getDocument()).replace( iOffset, iLength, pattern, null ); } catch( Exception e ) { throw new RuntimeException( e ); } finally { editor.getUndoManager().endUndoAtom(); } IType type = getNode().getFile().getType(); if( type != null ) { TypeSystem.refresh( (ITypeRef)type ); } }