Revision 1272 org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.swing/org.gvsig.scripting.swing.impl/src/main/java/org/gvsig/scripting/swing/impl/composer/editors/TextEditor.java
TextEditor.java | ||
---|---|---|
211 | 211 |
// LOGGER.info("reload() enter, "+threadId()); |
212 | 212 |
JTextComponent text = this.getJTextComponent(); |
213 | 213 |
int pos = text.getCaretPosition(); |
214 |
this.set(this.getUnit()); |
|
214 | 215 |
int len = text.getDocument().getLength(); |
216 |
if( pos > len ) { |
|
217 |
pos = len; |
|
218 |
} |
|
219 |
if( pos < 0 ) { |
|
220 |
pos = 0; |
|
221 |
} |
|
215 | 222 |
// LOGGER.info("reload() "+threadId()+", pos="+pos+", len="+len); |
216 |
this.set(this.getUnit()); |
|
217 | 223 |
try { |
218 | 224 |
text.setCaretPosition(pos); |
219 | 225 |
} catch(Exception ex) { |
226 |
LOGGER.trace("Can't restore caret position after reload", ex); |
|
220 | 227 |
// LOGGER.info("reload():"+ ex.getMessage()); |
221 |
text.setCaretPosition(len); |
|
222 | 228 |
} |
223 | 229 |
// LOGGER.info("reload() exit, "+threadId()); |
224 | 230 |
} |
Also available in: Unified diff