Revision 955 org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/extension/ScriptingExtension.java
ScriptingExtension.java | ||
---|---|---|
59 | 59 |
import org.gvsig.scripting.ScriptingManager; |
60 | 60 |
import org.gvsig.scripting.ScriptingScript; |
61 | 61 |
import org.gvsig.scripting.ScriptingUnit; |
62 |
import org.gvsig.scripting.app.extension.messagewait.MessageWait; |
|
62 | 63 |
import org.gvsig.scripting.swing.api.JScriptingComposer; |
63 | 64 |
import org.gvsig.scripting.swing.api.ScriptingSwingLocator; |
64 | 65 |
import org.gvsig.scripting.swing.api.ScriptingUIManager; |
... | ... | |
84 | 85 |
|
85 | 86 |
private PluginServices plugin = null; |
86 | 87 |
|
87 |
private boolean executingAutorunScripts = false; |
|
88 | 88 |
/* |
89 | 89 |
* la funcion log y las constantes estan pensadas para usarlas desde los scripts. |
90 | 90 |
*/ |
... | ... | |
93 | 93 |
public static final int WARN = 2; |
94 | 94 |
public static final int ERROR = 3; |
95 | 95 |
private static boolean composer_initialized = false; |
96 |
private boolean executingAutorunScripts = true; |
|
97 |
private MessageWait message; |
|
96 | 98 |
|
97 | 99 |
public static void log(String message) { |
98 | 100 |
log(INFO, message, null); |
... | ... | |
142 | 144 |
winmanager.showWindow(uimanager.createLauncher().asJComponent(), uimanager.getTranslation("Scripting_Launcher"), WindowManager.MODE.TOOL); |
143 | 145 |
|
144 | 146 |
} else if( "tools-scripting-composer".equalsIgnoreCase(command) ) { |
145 |
if( executingAutorunScripts ) { |
|
146 |
ApplicationManager application = ApplicationLocator.getManager(); |
|
147 |
application.messageDialog( |
|
148 |
"Startup autorun scripts are running.\nWait to terminate and retry.", |
|
149 |
"Attention", |
|
150 |
JOptionPane.OK_OPTION |
|
151 |
); |
|
152 |
} |
|
153 |
if( composer_initialized ) { |
|
154 |
showScriptingComposer(); |
|
155 |
} else { |
|
156 |
Thread th = new Thread(new StartupAndShowScriptingComposer(), "StartupAndShowScriptingComposer"); |
|
157 |
th.start(); |
|
158 |
} |
|
147 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
148 |
message.showMessage( |
|
149 |
i18n.getTranslation("_notice"), |
|
150 |
i18n.getTranslation("_Initializing_the_scripting_plugin_Xhorizontal_ellipsisX") + "\n" + |
|
151 |
i18n.getTranslation("_Waiting_to_terminate"), |
|
152 |
new MessageWait.WaitingCondition() { |
|
153 |
private Thread th = null; |
|
154 |
|
|
155 |
@Override |
|
156 |
public boolean stopWaiting() { |
|
157 |
if( executingAutorunScripts ) { |
|
158 |
return false; |
|
159 |
} |
|
160 |
if( composer_initialized ) { |
|
161 |
return true; |
|
162 |
} |
|
163 |
if( th == null ) { |
|
164 |
th = new Thread(new StartupScriptingComposer(), "StartupScriptingComposer"); |
|
165 |
th.start(); |
|
166 |
} |
|
167 |
return false; |
|
168 |
} |
|
169 |
}, |
|
170 |
new Runnable() { |
|
171 |
@Override |
|
172 |
public void run() { |
|
173 |
showScriptingComposer(); |
|
174 |
} |
|
175 |
} |
|
176 |
); |
|
159 | 177 |
|
178 |
|
|
160 | 179 |
} else { |
161 | 180 |
ScriptingBaseScript script = uimanager.getManager().getScript(command); |
162 | 181 |
if( script != null ) { |
... | ... | |
190 | 209 |
); |
191 | 210 |
} |
192 | 211 |
|
193 |
private class StartupAndShowScriptingComposer implements Runnable {
|
|
212 |
private class StartupScriptingComposer implements Runnable { |
|
194 | 213 |
|
195 | 214 |
@Override |
196 | 215 |
public void run() { |
... | ... | |
259 | 278 |
status.terminate(); |
260 | 279 |
composer_initialized = true; |
261 | 280 |
} |
262 |
|
|
263 |
SwingUtilities.invokeLater(new Runnable() { |
|
264 |
@Override |
|
265 |
public void run() { |
|
266 |
showScriptingComposer(); |
|
267 |
} |
|
268 |
}); |
|
269 | 281 |
} |
270 | 282 |
} |
271 | 283 |
|
... | ... | |
274 | 286 |
IconThemeHelper.registerIcon("action", "tools-scripting-launcher", this); |
275 | 287 |
IconThemeHelper.registerIcon("action", "tools-scripting-composer", this); |
276 | 288 |
IconThemeHelper.registerIcon("action", "tools-scripting-console-jython", this); |
289 |
this.message = new MessageWait(); |
|
277 | 290 |
|
278 | 291 |
initPaths(); |
279 | 292 |
Thread th = new Thread(new Runnable() { |
Also available in: Unified diff