root / tmp / org.txm.groovy.core / src / groovy / org / txm / macro / imports / OpenImportFormMacro.groovy @ 2769
History | View | Annotate | Download (1.1 kB)
1 |
package org.txm.macro.imports
|
---|---|
2 |
|
3 |
import org.kohsuke.args4j.* |
4 |
import groovy.transform.Field |
5 |
import org.txm.rcp.swt.widget.parameters.* |
6 |
import org.txm.rcp.commands.* |
7 |
import org.txm.Toolbox |
8 |
|
9 |
@Field @Option(name="scriptFile", usage="an example file", widget="File", required=true, def="xxxLoader.groovy") |
10 |
File scriptFile
|
11 |
|
12 |
if (!ParametersDialog.open(this)) return; |
13 |
|
14 |
File script = scriptFile // if not done, using scriptFile raise a Cast exception to 'groovy.lang.Reference' |
15 |
|
16 |
if (!script.getName().endsWith(".groovy")) { |
17 |
println "Error: the selected file is not a Groovy script"
|
18 |
return
|
19 |
} |
20 |
|
21 |
println "Opening import form with $scriptFile"
|
22 |
monitor.syncExec(new Runnable() { |
23 |
public void run() { |
24 |
try {
|
25 |
String path = script.getAbsolutePath()
|
26 |
String rootpath = new File(Toolbox.getTxmHomePath(), "scripts/groovy/user/org/txm/scripts/importer") |
27 |
|
28 |
if (path.startsWith(rootpath)) {
|
29 |
OpenImportForm.openfile(path.substring(Toolbox.getTxmHomePath().length())); |
30 |
} else {
|
31 |
println "Error: import start script must be included in $rootpath"
|
32 |
} |
33 |
} catch (Exception e) { |
34 |
e.printStackTrace(); |
35 |
} |
36 |
} |
37 |
}); |