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/ScriptUnitEditor.java
ScriptUnitEditor.java | ||
---|---|---|
22 | 22 |
import org.gvsig.tools.observer.Observable; |
23 | 23 |
import org.gvsig.tools.observer.Observer; |
24 | 24 |
import org.gvsig.tools.script.Script; |
25 |
import org.slf4j.Logger; |
|
26 |
import org.slf4j.LoggerFactory; |
|
25 | 27 |
|
26 | 28 |
public class ScriptUnitEditor extends JPanel implements JCodeEditor { |
27 | 29 |
|
30 |
private static final Logger LOGGER = LoggerFactory.getLogger(ScriptUnitEditor.class); |
|
28 | 31 |
/** |
29 | 32 |
* |
30 | 33 |
*/ |
... | ... | |
135 | 138 |
|
136 | 139 |
@Override |
137 | 140 |
public void reload() { |
138 |
int pos = this.getJTextComponent().getCaretPosition(); |
|
141 |
// LOGGER.info("reload() enter, "+threadId()); |
|
142 |
JTextComponent text = this.getJTextComponent(); |
|
143 |
int pos = text.getCaretPosition(); |
|
139 | 144 |
this.set(this.getUnit()); |
145 |
int len = text.getDocument().getLength(); |
|
146 |
if( pos > len ) { |
|
147 |
pos = len; |
|
148 |
} |
|
149 |
if( pos < 0 ) { |
|
150 |
pos = 0; |
|
151 |
} |
|
152 |
// LOGGER.info("reload() "+threadId()+", pos="+pos+", len="+len); |
|
140 | 153 |
try { |
141 |
this.getJTextComponent().setCaretPosition(pos);
|
|
154 |
text.setCaretPosition(pos);
|
|
142 | 155 |
} catch(Exception ex) { |
143 |
pos = this.getJTextComponent().getDocument().getLength();
|
|
144 |
this.getJTextComponent().setCaretPosition(pos);
|
|
156 |
LOGGER.trace("Can't restore caret position after reload", ex);
|
|
157 |
// LOGGER.info("reload():"+ ex.getMessage());
|
|
145 | 158 |
} |
159 |
// LOGGER.info("reload() exit, "+threadId()); |
|
146 | 160 |
} |
147 | 161 |
|
148 | 162 |
@Override |
Also available in: Unified diff