Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / macro / imports / OpenImportFormMacro.groovy @ 479

History | View | Annotate | Download (828 Bytes)

1
package org.txm.macro.imports
2

    
3
import org.kohsuke.args4j.*
4
import groovy.transform.Field
5
import org.txm.rcpapplication.swt.widget.parameters.*
6
import org.txm.rcpapplication.commands.*
7

    
8
@Field @Option(name="scriptFile", usage="an example file", widget="File", required=true, def="xxxLoader.groovy")
9
File scriptFile
10

    
11
if (!ParametersDialog.open(this)) return;
12

    
13
File script = scriptFile // if not done, using scriptFile raise a Cast exception to 'groovy.lang.Reference'
14

    
15
if (!script.getName().endsWith(".groovy")) {
16
        println "Error: the selected file is not a Groovy script"
17
        return
18
}
19

    
20
println "Opening import form with $scriptFile"
21
monitor.syncExec(new Runnable() {
22
        public void run() {
23
                try {
24
                        String path = script.getAbsolutePath()
25
                        OpenImportForm.openfile(path);
26
                } catch (Exception e) {
27
                        e.printStackTrace();
28
                }
29
        }
30
});