Revision 702 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/DefaultJScriptingComposer.java
DefaultJScriptingComposer.java | ||
---|---|---|
1033 | 1033 |
BrowserActionEvent e2 = (BrowserActionEvent) e; |
1034 | 1034 |
switch (e.getID()) { |
1035 | 1035 |
case JScriptingBrowser.DEFAULT_ACTION: |
1036 |
scriptEdit(e2.getScript()); |
|
1036 |
if( uimanager.hasEditor(e2.getUnit()) ) { |
|
1037 |
scriptEdit(e2.getUnit()); |
|
1038 |
} |
|
1037 | 1039 |
break; |
1038 | 1040 |
case JScriptingBrowser.DROPDOWN_ACTION: |
1039 | 1041 |
case JScriptingBrowser.SELECTION_ACTION: |
... | ... | |
1157 | 1159 |
* @return Selected ScriptingUnit on the tree |
1158 | 1160 |
*/ |
1159 | 1161 |
private ScriptingUnit getLauncherSelectedScript() { |
1160 |
JScriptingLauncher launcher = this.getProjects(); |
|
1161 |
JScriptingBrowser browser = launcher.getSelectedBrowser(); |
|
1162 |
JScriptingBrowser browser = this.getCurrentBrowser(); |
|
1162 | 1163 |
ScriptingUnit unit = browser.getSelectedNode(); |
1163 | 1164 |
return unit; |
1164 | 1165 |
} |
1165 |
|
|
1166 |
/** |
|
1167 |
* Lanza la ejecuci?n de un ScriptingBaseScript |
|
1168 |
* |
|
1169 |
* @param unit |
|
1170 |
*/ |
|
1171 |
private void scriptExecute(ScriptingUnit unit) { |
|
1172 |
if (unit instanceof ScriptingBaseScript) { |
|
1173 |
((ScriptingBaseScript) unit).run(); |
|
1174 |
} |
|
1166 |
|
|
1167 |
private JScriptingBrowser getCurrentBrowser() { |
|
1168 |
JScriptingLauncher launcher = this.getProjects(); |
|
1169 |
JScriptingBrowser browser = launcher.getSelectedBrowser(); |
|
1170 |
return browser; |
|
1175 | 1171 |
} |
1176 | 1172 |
|
1177 |
public void scriptEdit(ScriptingBaseScript unit) { |
|
1178 |
String id = unit.getScriptFile().getAbsolutePath(); |
|
1173 |
// /** |
|
1174 |
// * Lanza la ejecuci?n de un ScriptingBaseScript |
|
1175 |
// * |
|
1176 |
// * @param unit |
|
1177 |
// */ |
|
1178 |
// private void scriptExecute(ScriptingUnit unit) { |
|
1179 |
// if (unit instanceof ScriptingBaseScript) { |
|
1180 |
// ((ScriptingBaseScript) unit).run(); |
|
1181 |
// } |
|
1182 |
// } |
|
1183 |
|
|
1184 |
public void scriptEdit(ScriptingUnit unit) { |
|
1185 |
String id = unit.getFile().getAbsolutePath(); |
|
1179 | 1186 |
DockedPanel x = this.dock.get(id); |
1180 | 1187 |
if (x != null) { |
1181 | 1188 |
x.select(); |
... | ... | |
1209 | 1216 |
} |
1210 | 1217 |
}); |
1211 | 1218 |
} |
1212 |
ScriptingScript script = editor.getScript();
|
|
1213 |
if (script != null) {
|
|
1214 |
script.addObserver(this);
|
|
1219 |
ScriptingUnit xx = editor.getUnit();
|
|
1220 |
if (xx instanceof ScriptingScript ) {
|
|
1221 |
((ScriptingScript)xx).addObserver(this);
|
|
1215 | 1222 |
} |
1216 | 1223 |
} |
1217 | 1224 |
|
... | ... | |
1223 | 1230 |
*/ |
1224 | 1231 |
public void scriptNew() throws Exception { |
1225 | 1232 |
JNewScriptModel model = new JNewScriptModel(manager); |
1233 |
model.setSelectionPath(this.getCurrentBrowser().getSelectionPath()); |
|
1226 | 1234 |
JDialogContent dialog = new JDialogContent( |
1227 | 1235 |
uimanager, |
1228 | 1236 |
"document-new", |
... | ... | |
1421 | 1429 |
case JOptionPane.YES_OPTION: |
1422 | 1430 |
for (DockedPanel panel : modifiedPanels) { |
1423 | 1431 |
JEditor editor = (JEditor) panel.getComponent(); |
1424 |
if (editor.getScript() != null) {
|
|
1425 |
editor.getScript().setSaved(true);
|
|
1432 |
if (editor.getUnit()!= null) {
|
|
1433 |
editor.getUnit().setSaved(true);
|
|
1426 | 1434 |
} |
1427 | 1435 |
editor.save(); |
1428 | 1436 |
panel.remove(); |
... | ... | |
1431 | 1439 |
case JOptionPane.NO_OPTION: |
1432 | 1440 |
for (DockedPanel panel : modifiedPanels) { |
1433 | 1441 |
JEditor editor = (JEditor) panel.getComponent(); |
1434 |
if (editor.getScript() != null) {
|
|
1435 |
editor.getScript().setSaved(true);
|
|
1442 |
if (editor.getUnit() != null) {
|
|
1443 |
editor.getUnit().setSaved(true);
|
|
1436 | 1444 |
} |
1437 | 1445 |
panel.remove(); |
1438 | 1446 |
} |
... | ... | |
1452 | 1460 |
problems.removeAll(); |
1453 | 1461 |
} |
1454 | 1462 |
JScriptingConsole console = this.getConsole(); |
1455 |
if (console != null) { |
|
1463 |
if (console == null) { |
|
1464 |
addConsolePanel(); |
|
1465 |
} else { |
|
1456 | 1466 |
console.clear(); |
1457 | 1467 |
} |
1458 | 1468 |
script.addObserver(this); |
... | ... | |
1537 | 1547 |
if (editor == null) { |
1538 | 1548 |
return null; |
1539 | 1549 |
} |
1540 |
return editor.getScript(); |
|
1550 |
ScriptingUnit unit = editor.getUnit(); |
|
1551 |
if( unit instanceof ScriptingScript ) { |
|
1552 |
return (ScriptingScript) unit; |
|
1553 |
} |
|
1554 |
return null; |
|
1541 | 1555 |
} |
1542 | 1556 |
|
1543 | 1557 |
private RSyntaxTextArea getCurrentRSyntaxTextArea() { |
Also available in: Unified diff