# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /home/hmichel/projetos/netbeans/main # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: xml.text/src/org/netbeans/modules/xml/text/completion/ValueResultItem.java --- xml.text/src/org/netbeans/modules/xml/text/completion/ValueResultItem.java Base (BASE) +++ xml.text/src/org/netbeans/modules/xml/text/completion/ValueResultItem.java Locally Modified (Based On LOCAL) @@ -1,7 +1,7 @@ /* * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. * - * Copyright 1997-2009 Sun Microsystems, Inc. All rights reserved. + * Copyright 1997-2010 Sun Microsystems, Inc. All rights reserved. * * The contents of this file are subject to the terms of either the GNU * General Public License Version 2 only ("GPL") or the Common @@ -43,6 +43,11 @@ import java.awt.Color; import java.beans.BeanInfo; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.text.BadLocationException; +import javax.swing.text.JTextComponent; +import org.netbeans.editor.BaseDocument; import org.netbeans.modules.xml.api.model.*; @@ -60,6 +65,7 @@ * @author Petr Kuzel */ class ValueResultItem extends XMLResultItem { + private static final Logger _logger = Logger.getLogger(ValueResultItem.class.getName()); private final String replacementText; @@ -77,6 +83,32 @@ } @Override + boolean replaceText(final JTextComponent component, + final String replaceToText, final int offset, final int len) { + //+++ fix for issue #173691 + // (http://netbeans.org/bugzilla/show_bug.cgi?id=173691) + final BaseDocument doc = (BaseDocument)component.getDocument(); + doc.runAtomic(new Runnable() { + @Override + public void run() { + try { + int newLen = len; + if (component.getSelectedText() != null) { + newLen += component.getSelectionEnd() - component. + getCaretPosition(); + } + doc.remove(offset, newLen); + doc.insertString(offset, replaceToText, null); + } catch (BadLocationException e) { + _logger.log(Level.SEVERE, e.getMessage() == null ? e. + getClass().getName() : e.getMessage(), e); + } + } + }); + return true; + } + + @Override Color getPaintColor() { return Color.blue; } }