Statistics
| Revision:

root / tmp / org.txm.groovy.core / src / groovy / org / txm / macro / office / SetOfficeMacro.groovy @ 534

History | View | Annotate | Download (1.1 kB)

1
// STANDARD DECLARATIONS
2
package org.txm.macro.office
3

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

    
8
// BEGINNING OF PARAMETERS
9

    
10
@Field @Option(name="office_path", usage="Path to LibreOffice or OpenOffice installation directory", widget="Folder", required=false, def="libreoffice or openoffice install directory")
11
def office_path
12

    
13
// Open the parameters input dialog box
14
if (!ParametersDialog.open(this)) return;
15

    
16
// END OF PARAMETERS
17

    
18
if (office_path == null) {
19
        println "No path to office directory given."
20
        return
21
}
22

    
23
if (!office_path.exists()) {
24
        println "'$office_path' directory not found."
25
        return
26
}
27

    
28
if (!office_path.isDirectory()) {
29
        println "'$office_path' exists but is not a directory."
30
        return
31
}
32

    
33
if (!office_path.canExecute()) {
34
        println "'$office_path' exists but has not sufficent rights to be used."
35
        return
36
}
37

    
38
def old = System.getProperty("office.home")
39
System.setProperty("office.home", office_path.getAbsolutePath())
40
println "Office path set to '"+System.getProperty("office.home")+"'."
41
if (old != null) {
42
        println "        Previous path was '${old}'."
43
}