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 | ||
---|---|---|
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() { |
org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/extension/messagewait/MessageWaitView.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<object classname="com.jeta.forms.store.memento.FormPackage"> |
|
4 |
<at name="fileversion"> |
|
5 |
<object classname="com.jeta.forms.store.memento.FormsVersion2"> |
|
6 |
<at name="major">2</at> |
|
7 |
<at name="minor">0</at> |
|
8 |
<at name="sub">0</at> |
|
9 |
</object> |
|
10 |
</at> |
|
11 |
<at name="form"> |
|
12 |
<object classname="com.jeta.forms.store.memento.FormMemento"> |
|
13 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
14 |
<at name="cellconstraints"> |
|
15 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
16 |
<at name="column">1</at> |
|
17 |
<at name="row">1</at> |
|
18 |
<at name="colspan">1</at> |
|
19 |
<at name="rowspan">1</at> |
|
20 |
<at name="halign">default</at> |
|
21 |
<at name="valign">default</at> |
|
22 |
<at name="insets" object="insets">0,0,0,0</at> |
|
23 |
</object> |
|
24 |
</at> |
|
25 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
|
26 |
</super> |
|
27 |
<at name="id">/home/jjdelcerro/datos/devel/org.gvsig.scripting/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/extension/messagewait/MessageWaitView.xml</at> |
|
28 |
<at name="rowspecs">CENTER:4DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE</at> |
|
29 |
<at name="colspecs">FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE</at> |
|
30 |
<at name="components"> |
|
31 |
<object classname="java.util.LinkedList"> |
|
32 |
<item > |
|
33 |
<at name="value"> |
|
34 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
35 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
36 |
<at name="cellconstraints"> |
|
37 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
38 |
<at name="column">4</at> |
|
39 |
<at name="row">2</at> |
|
40 |
<at name="colspan">1</at> |
|
41 |
<at name="rowspan">1</at> |
|
42 |
<at name="halign">left</at> |
|
43 |
<at name="valign">top</at> |
|
44 |
<at name="insets" object="insets">0,0,0,0</at> |
|
45 |
</object> |
|
46 |
</at> |
|
47 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
48 |
</super> |
|
49 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
50 |
<at name="beanclass">com.jeta.forms.components.label.JETALabel</at> |
|
51 |
<at name="beanproperties"> |
|
52 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
53 |
<at name="classname">com.jeta.forms.components.label.JETALabel</at> |
|
54 |
<at name="properties"> |
|
55 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
56 |
<at name="border"> |
|
57 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
58 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
59 |
<at name="name">border</at> |
|
60 |
</super> |
|
61 |
<at name="borders"> |
|
62 |
<object classname="java.util.LinkedList"> |
|
63 |
<item > |
|
64 |
<at name="value"> |
|
65 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
66 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
67 |
<at name="name">border</at> |
|
68 |
</super> |
|
69 |
</object> |
|
70 |
</at> |
|
71 |
</item> |
|
72 |
</object> |
|
73 |
</at> |
|
74 |
</object> |
|
75 |
</at> |
|
76 |
<at name="name">lblMsg</at> |
|
77 |
<at name="width">12</at> |
|
78 |
<at name="fill"> |
|
79 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
|
80 |
<at name="name">fill</at> |
|
81 |
</object> |
|
82 |
</at> |
|
83 |
<at name="height">12</at> |
|
84 |
</object> |
|
85 |
</at> |
|
86 |
</object> |
|
87 |
</at> |
|
88 |
</object> |
|
89 |
</at> |
|
90 |
</item> |
|
91 |
<item > |
|
92 |
<at name="value"> |
|
93 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
94 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
95 |
<at name="cellconstraints"> |
|
96 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
97 |
<at name="column">4</at> |
|
98 |
<at name="row">4</at> |
|
99 |
<at name="colspan">1</at> |
|
100 |
<at name="rowspan">1</at> |
|
101 |
<at name="halign">right</at> |
|
102 |
<at name="valign">default</at> |
|
103 |
<at name="insets" object="insets">0,0,0,0</at> |
|
104 |
</object> |
|
105 |
</at> |
|
106 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
107 |
</super> |
|
108 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
109 |
<at name="beanclass">javax.swing.JButton</at> |
|
110 |
<at name="beanproperties"> |
|
111 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
112 |
<at name="classname">javax.swing.JButton</at> |
|
113 |
<at name="properties"> |
|
114 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
115 |
<at name="border"> |
|
116 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
117 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
118 |
<at name="name">border</at> |
|
119 |
</super> |
|
120 |
<at name="borders"> |
|
121 |
<object classname="java.util.LinkedList"> |
|
122 |
<item > |
|
123 |
<at name="value"> |
|
124 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
125 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
126 |
<at name="name">border</at> |
|
127 |
</super> |
|
128 |
</object> |
|
129 |
</at> |
|
130 |
</item> |
|
131 |
</object> |
|
132 |
</at> |
|
133 |
</object> |
|
134 |
</at> |
|
135 |
<at name="actionCommand">_Cancel</at> |
|
136 |
<at name="name">btnCancel</at> |
|
137 |
<at name="width">76</at> |
|
138 |
<at name="text">_Cancel</at> |
|
139 |
<at name="height">22</at> |
|
140 |
</object> |
|
141 |
</at> |
|
142 |
</object> |
|
143 |
</at> |
|
144 |
</object> |
|
145 |
</at> |
|
146 |
</item> |
|
147 |
<item > |
|
148 |
<at name="value"> |
|
149 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
150 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
151 |
<at name="cellconstraints"> |
|
152 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
153 |
<at name="column">2</at> |
|
154 |
<at name="row">2</at> |
|
155 |
<at name="colspan">1</at> |
|
156 |
<at name="rowspan">1</at> |
|
157 |
<at name="halign">center</at> |
|
158 |
<at name="valign">top</at> |
|
159 |
<at name="insets" object="insets">0,0,0,0</at> |
|
160 |
</object> |
|
161 |
</at> |
|
162 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
163 |
</super> |
|
164 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
165 |
<at name="beanclass">com.jeta.forms.components.label.JETALabel</at> |
|
166 |
<at name="beanproperties"> |
|
167 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
168 |
<at name="classname">com.jeta.forms.components.label.JETALabel</at> |
|
169 |
<at name="properties"> |
|
170 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
171 |
<at name="border"> |
|
172 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
173 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
174 |
<at name="name">border</at> |
|
175 |
</super> |
|
176 |
<at name="borders"> |
|
177 |
<object classname="java.util.LinkedList"> |
|
178 |
<item > |
|
179 |
<at name="value"> |
|
180 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
181 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
182 |
<at name="name">border</at> |
|
183 |
</super> |
|
184 |
</object> |
|
185 |
</at> |
|
186 |
</item> |
|
187 |
</object> |
|
188 |
</at> |
|
189 |
</object> |
|
190 |
</at> |
|
191 |
<at name="name">lblIcon</at> |
|
192 |
<at name="width">12</at> |
|
193 |
<at name="fill"> |
|
194 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
|
195 |
<at name="name">fill</at> |
|
196 |
</object> |
|
197 |
</at> |
|
198 |
<at name="height">12</at> |
|
199 |
</object> |
|
200 |
</at> |
|
201 |
</object> |
|
202 |
</at> |
|
203 |
</object> |
|
204 |
</at> |
|
205 |
</item> |
|
206 |
</object> |
|
207 |
</at> |
|
208 |
<at name="properties"> |
|
209 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
210 |
<at name="classname">com.jeta.forms.gui.form.GridView</at> |
|
211 |
<at name="properties"> |
|
212 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
213 |
<at name="border"> |
|
214 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
215 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
216 |
<at name="name">border</at> |
|
217 |
</super> |
|
218 |
<at name="borders"> |
|
219 |
<object classname="java.util.LinkedList"/> |
|
220 |
</at> |
|
221 |
</object> |
|
222 |
</at> |
|
223 |
<at name="name"></at> |
|
224 |
<at name="fill"> |
|
225 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
|
226 |
<at name="name">fill</at> |
|
227 |
</object> |
|
228 |
</at> |
|
229 |
<at name="scollBars"> |
|
230 |
<object classname="com.jeta.forms.store.properties.ScrollBarsProperty"> |
|
231 |
<at name="name">scollBars</at> |
|
232 |
<at name="verticalpolicy">21</at> |
|
233 |
<at name="horizontalpolicy">31</at> |
|
234 |
<at name="border"> |
|
235 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
236 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
237 |
<at name="name">border</at> |
|
238 |
</super> |
|
239 |
<at name="borders"> |
|
240 |
<object classname="java.util.LinkedList"> |
|
241 |
<item > |
|
242 |
<at name="value"> |
|
243 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
244 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
245 |
<at name="name">border</at> |
|
246 |
</super> |
|
247 |
</object> |
|
248 |
</at> |
|
249 |
</item> |
|
250 |
</object> |
|
251 |
</at> |
|
252 |
</object> |
|
253 |
</at> |
|
254 |
</object> |
|
255 |
</at> |
|
256 |
</object> |
|
257 |
</at> |
|
258 |
</object> |
|
259 |
</at> |
|
260 |
<at name="cellpainters"> |
|
261 |
<object classname="com.jeta.forms.store.support.Matrix"> |
|
262 |
<at name="rows"> |
|
263 |
<object classname="[Ljava.lang.Object;" size="5"> |
|
264 |
<at name="item" index="0"> |
|
265 |
<object classname="[Ljava.lang.Object;" size="5"/> |
|
266 |
</at> |
|
267 |
<at name="item" index="1"> |
|
268 |
<object classname="[Ljava.lang.Object;" size="5"/> |
|
269 |
</at> |
|
270 |
<at name="item" index="2"> |
|
271 |
<object classname="[Ljava.lang.Object;" size="5"/> |
|
272 |
</at> |
|
273 |
<at name="item" index="3"> |
|
274 |
<object classname="[Ljava.lang.Object;" size="5"/> |
|
275 |
</at> |
|
276 |
<at name="item" index="4"> |
|
277 |
<object classname="[Ljava.lang.Object;" size="5"/> |
|
278 |
</at> |
|
279 |
</object> |
|
280 |
</at> |
|
281 |
</object> |
|
282 |
</at> |
|
283 |
<at name="rowgroups"> |
|
284 |
<object classname="com.jeta.forms.store.memento.FormGroupSet"> |
|
285 |
<at name="groups"> |
|
286 |
<object classname="java.util.HashMap"/> |
|
287 |
</at> |
|
288 |
</object> |
|
289 |
</at> |
|
290 |
<at name="colgroups"> |
|
291 |
<object classname="com.jeta.forms.store.memento.FormGroupSet"> |
|
292 |
<at name="groups"> |
|
293 |
<object classname="java.util.HashMap"/> |
|
294 |
</at> |
|
295 |
</object> |
|
296 |
</at> |
|
297 |
</object> |
|
298 |
</at> |
|
299 |
</object> |
org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/extension/messagewait/MessageWaitView.java | ||
---|---|---|
1 |
package org.gvsig.scripting.app.extension.messagewait; |
|
2 |
|
|
3 |
import com.jeta.open.i18n.I18NUtils; |
|
4 |
import com.jgoodies.forms.layout.CellConstraints; |
|
5 |
import com.jgoodies.forms.layout.FormLayout; |
|
6 |
import java.awt.BorderLayout; |
|
7 |
import java.awt.ComponentOrientation; |
|
8 |
import java.awt.Container; |
|
9 |
import java.awt.Dimension; |
|
10 |
import javax.swing.Box; |
|
11 |
import javax.swing.ImageIcon; |
|
12 |
import javax.swing.JButton; |
|
13 |
import javax.swing.JFrame; |
|
14 |
import javax.swing.JLabel; |
|
15 |
import javax.swing.JPanel; |
|
16 |
|
|
17 |
|
|
18 |
public class MessageWaitView extends JPanel |
|
19 |
{ |
|
20 |
JLabel lblMsg = new JLabel(); |
|
21 |
JButton btnCancel = new JButton(); |
|
22 |
JLabel lblIcon = new JLabel(); |
|
23 |
|
|
24 |
/** |
|
25 |
* Default constructor |
|
26 |
*/ |
|
27 |
public MessageWaitView() |
|
28 |
{ |
|
29 |
initializePanel(); |
|
30 |
} |
|
31 |
|
|
32 |
/** |
|
33 |
* Adds fill components to empty cells in the first row and first column of the grid. |
|
34 |
* This ensures that the grid spacing will be the same as shown in the designer. |
|
35 |
* @param cols an array of column indices in the first row where fill components should be added. |
|
36 |
* @param rows an array of row indices in the first column where fill components should be added. |
|
37 |
*/ |
|
38 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
|
39 |
{ |
|
40 |
Dimension filler = new Dimension(10,10); |
|
41 |
|
|
42 |
boolean filled_cell_11 = false; |
|
43 |
CellConstraints cc = new CellConstraints(); |
|
44 |
if ( cols.length > 0 && rows.length > 0 ) |
|
45 |
{ |
|
46 |
if ( cols[0] == 1 && rows[0] == 1 ) |
|
47 |
{ |
|
48 |
/** add a rigid area */ |
|
49 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
|
50 |
filled_cell_11 = true; |
|
51 |
} |
|
52 |
} |
|
53 |
|
|
54 |
for( int index = 0; index < cols.length; index++ ) |
|
55 |
{ |
|
56 |
if ( cols[index] == 1 && filled_cell_11 ) |
|
57 |
{ |
|
58 |
continue; |
|
59 |
} |
|
60 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
|
61 |
} |
|
62 |
|
|
63 |
for( int index = 0; index < rows.length; index++ ) |
|
64 |
{ |
|
65 |
if ( rows[index] == 1 && filled_cell_11 ) |
|
66 |
{ |
|
67 |
continue; |
|
68 |
} |
|
69 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
|
70 |
} |
|
71 |
|
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* Helper method to load an image file from the CLASSPATH |
|
76 |
* @param imageName the package and name of the file to load relative to the CLASSPATH |
|
77 |
* @return an ImageIcon instance with the specified image file |
|
78 |
* @throws IllegalArgumentException if the image resource cannot be loaded. |
|
79 |
*/ |
|
80 |
public ImageIcon loadImage( String imageName ) |
|
81 |
{ |
|
82 |
try |
|
83 |
{ |
|
84 |
ClassLoader classloader = getClass().getClassLoader(); |
|
85 |
java.net.URL url = classloader.getResource( imageName ); |
|
86 |
if ( url != null ) |
|
87 |
{ |
|
88 |
ImageIcon icon = new ImageIcon( url ); |
|
89 |
return icon; |
|
90 |
} |
|
91 |
} |
|
92 |
catch( Exception e ) |
|
93 |
{ |
|
94 |
e.printStackTrace(); |
|
95 |
} |
|
96 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
|
97 |
} |
|
98 |
|
|
99 |
/** |
|
100 |
* Method for recalculating the component orientation for |
|
101 |
* right-to-left Locales. |
|
102 |
* @param orientation the component orientation to be applied |
|
103 |
*/ |
|
104 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
|
105 |
{ |
|
106 |
// Not yet implemented... |
|
107 |
// I18NUtils.applyComponentOrientation(this, orientation); |
|
108 |
super.applyComponentOrientation(orientation); |
|
109 |
} |
|
110 |
|
|
111 |
public JPanel createPanel() |
|
112 |
{ |
|
113 |
JPanel jpanel1 = new JPanel(); |
|
114 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:4DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:4DLU:NONE,CENTER:DEFAULT:NONE,CENTER:4DLU:NONE"); |
|
115 |
CellConstraints cc = new CellConstraints(); |
|
116 |
jpanel1.setLayout(formlayout1); |
|
117 |
|
|
118 |
lblMsg.setName("lblMsg"); |
|
119 |
jpanel1.add(lblMsg,new CellConstraints(4,2,1,1,CellConstraints.LEFT,CellConstraints.TOP)); |
|
120 |
|
|
121 |
btnCancel.setActionCommand("_Cancel"); |
|
122 |
btnCancel.setName("btnCancel"); |
|
123 |
btnCancel.setText("_Cancel"); |
|
124 |
jpanel1.add(btnCancel,new CellConstraints(4,4,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT)); |
|
125 |
|
|
126 |
lblIcon.setName("lblIcon"); |
|
127 |
jpanel1.add(lblIcon,new CellConstraints(2,2,1,1,CellConstraints.CENTER,CellConstraints.TOP)); |
|
128 |
|
|
129 |
addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5 }); |
|
130 |
return jpanel1; |
|
131 |
} |
|
132 |
|
|
133 |
/** |
|
134 |
* Initializer |
|
135 |
*/ |
|
136 |
protected void initializePanel() |
|
137 |
{ |
|
138 |
setLayout(new BorderLayout()); |
|
139 |
add(createPanel(), BorderLayout.CENTER); |
|
140 |
} |
|
141 |
|
|
142 |
|
|
143 |
} |
org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/java/org/gvsig/scripting/app/extension/messagewait/MessageWait.java | ||
---|---|---|
1 |
package org.gvsig.scripting.app.extension.messagewait; |
|
2 |
|
|
3 |
import java.awt.Dimension; |
|
4 |
import java.awt.event.ActionEvent; |
|
5 |
import java.awt.event.ActionListener; |
|
6 |
import java.net.URL; |
|
7 |
import javax.swing.ImageIcon; |
|
8 |
import javax.swing.SwingUtilities; |
|
9 |
import org.gvsig.tools.ToolsLocator; |
|
10 |
import org.gvsig.tools.i18n.I18nManager; |
|
11 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
12 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
13 |
|
|
14 |
|
|
15 |
public class MessageWait extends MessageWaitView { |
|
16 |
|
|
17 |
private static final long serialVersionUID = 6668980523307140920L; |
|
18 |
private WaitingCondition condition; |
|
19 |
private int seconds = 3; |
|
20 |
private boolean cancelled = false; |
|
21 |
private Runnable action; |
|
22 |
|
|
23 |
public interface WaitingCondition { |
|
24 |
|
|
25 |
public boolean stopWaiting(); |
|
26 |
} |
|
27 |
|
|
28 |
public MessageWait() { |
|
29 |
this.btnCancel.addActionListener(new ActionListener() { |
|
30 |
@Override |
|
31 |
public void actionPerformed(ActionEvent e) { |
|
32 |
cancelled = true; |
|
33 |
setVisible(false); |
|
34 |
} |
|
35 |
}); |
|
36 |
URL url = this.getClass().getResource("/images/spinner.gif"); |
|
37 |
ImageIcon icon = new ImageIcon(url); |
|
38 |
this.lblIcon.setIcon(icon); |
|
39 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
40 |
this.btnCancel.setText(i18n.getTranslation("Cancel")); |
|
41 |
} |
|
42 |
|
|
43 |
public void showMessage(String title, String msg, WaitingCondition condition, Runnable action) { |
|
44 |
this.showMessage(title, msg, condition, action, 300, -1, 3); |
|
45 |
} |
|
46 |
|
|
47 |
public void showMessage(String title, String msg, WaitingCondition condition, Runnable action, int width, int height, int seconds) { |
|
48 |
if( condition.stopWaiting() ) { |
|
49 |
SwingUtilities.invokeLater(action); |
|
50 |
return; |
|
51 |
} |
|
52 |
this.setVisible(true); |
|
53 |
this.condition = condition; |
|
54 |
this.seconds = seconds; |
|
55 |
this.action = action; |
|
56 |
this.cancelled = false; |
|
57 |
this.lblMsg.setText("<html>"+msg.replace("\n", "<br>\n")+"</html>"); |
|
58 |
Dimension d = this.getPreferredSize(); |
|
59 |
if( height<d.height ) { |
|
60 |
height = d.height; |
|
61 |
} |
|
62 |
if( width<d.width ) { |
|
63 |
width = d.width; |
|
64 |
} |
|
65 |
this.setPreferredSize(new Dimension(width, height)); |
|
66 |
WindowManager winmgr = ToolsSwingLocator.getWindowManager(); |
|
67 |
winmgr.showWindow(this, title, WindowManager.MODE.TOOL); |
|
68 |
Thread th = new Thread(new Runnable() { |
|
69 |
@Override |
|
70 |
public void run() { |
|
71 |
doWait(); |
|
72 |
} |
|
73 |
}, "MessageWait"); |
|
74 |
th.start(); |
|
75 |
} |
|
76 |
|
|
77 |
private void doWait() { |
|
78 |
while( true ) { |
|
79 |
if( this.condition.stopWaiting() ) { |
|
80 |
break; |
|
81 |
} |
|
82 |
try { |
|
83 |
Thread.sleep(this.seconds*1000); |
|
84 |
} catch (InterruptedException ex) { |
|
85 |
|
|
86 |
} |
|
87 |
} |
|
88 |
if( this.cancelled ) { |
|
89 |
return; |
|
90 |
} |
|
91 |
SwingUtilities.invokeLater(new Runnable() { |
|
92 |
@Override |
|
93 |
public void run() { |
|
94 |
setVisible(false); |
|
95 |
action.run(); |
|
96 |
} |
|
97 |
}); |
|
98 |
} |
|
99 |
} |
org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/resources-plugin/i18n/text.properties | ||
---|---|---|
135 | 135 |
_Running_autorun_script_from_XnameX=Ejecutando script de autoarranque desde "{0}" |
136 | 136 |
_The_script_XscriptnameX_is_modified=El script "{0}" ha sido modificado. |
137 | 137 |
_Save_changes_XquestionX=\u00bf Guardar cambios ? |
138 |
_Do_you_want_to_save_changes_XquestionX=\u00bf Desea guardar los cambios ? |
|
138 |
_Do_you_want_to_save_changes_XquestionX=\u00bf Desea guardar los cambios ? |
|
139 |
|
|
140 |
_notice=Aviso |
|
141 |
_Initializing_the_scripting_plugin_Xhorizontal_ellipsisX=Inicializando el plugin de scripting... |
|
142 |
_Waiting_to_terminate=Esperando que termine. |
org.gvsig.scripting/trunk/org.gvsig.scripting/org.gvsig.scripting.app/org.gvsig.scripting.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties | ||
---|---|---|
137 | 137 |
_Running_autorun_script_from_XnameX=Running autorun script from "{0}" |
138 | 138 |
_The_script_XscriptnameX_is_modified=The script "{0}" has been modified. |
139 | 139 |
_Save_changes_XquestionX=Save changes ? |
140 |
_Do_you_want_to_save_changes_XquestionX=Do you want to save changes ? |
|
140 |
_Do_you_want_to_save_changes_XquestionX=Do you want to save changes ? |
|
141 |
|
|
142 |
_notice=Notice |
|
143 |
_Initializing_the_scripting_plugin_Xhorizontal_ellipsisX=Initializing the scripting plugin... |
|
144 |
_Waiting_to_terminate=Waiting to terminate. |
Also available in: Unified diff