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 | ||
---|---|---|
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 |
} |
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 | ||
---|---|---|
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