Révision 3303
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/macro/edition/OpenIndexMacro.groovy (revision 3303) | ||
---|---|---|
1 |
// Copyright © 2021 ENS Lyon |
|
2 |
// Licensed under the terms of the GNU General Public License version 3 (http://www.gnu.org/licenses/gpl-3.0.html) |
|
3 |
// @author sheiden |
|
4 |
|
|
5 |
// STANDARD DECLARATIONS |
|
6 |
package org.txm.macro.edition |
|
7 |
|
|
8 |
import org.kohsuke.args4j.* |
|
9 |
import groovy.transform.Field |
|
10 |
import org.txm.rcp.swt.widget.parameters.* |
|
11 |
import org.txm.Toolbox |
|
12 |
import org.txm.macro.cqp.CQPUtils |
|
13 |
import org.txm.rcp.commands.* |
|
14 |
|
|
15 |
scriptName = this.class.getSimpleName() |
|
16 |
|
|
17 |
utils = new CQPUtils() |
|
18 |
|
|
19 |
corpora = utils.getCorpora(this) |
|
20 |
|
|
21 |
if ((corpora == null) || corpora.size() > 1) { |
|
22 |
println "** $scriptName: please select a corpus in the Corpus view or provide a corpus name. Aborting." |
|
23 |
return false |
|
24 |
} |
|
25 |
|
|
26 |
corpus = corpora[0].getMainCorpus() |
|
27 |
corpusName = corpus.getName() |
|
28 |
|
|
29 |
indexPath = new File(Toolbox.getTxmHomePath(), "corpora/$corpusName/HTML/$corpusName/default/index.html") |
|
30 |
|
|
31 |
if (!(indexPath.exists())) { |
|
32 |
println "** $scriptName: cannot find $indexPath. Aborting." |
|
33 |
return false |
|
34 |
} |
|
35 |
|
|
36 |
if (!(indexPath.canRead())) { |
|
37 |
println "** $scriptName: cannot open $indexPath. Aborting." |
|
38 |
return false |
|
39 |
} |
|
40 |
|
|
41 |
monitor.syncExec(new Runnable() { |
|
42 |
@Override |
|
43 |
public void run() { |
|
44 |
try { |
|
45 |
OpenBrowser.openfile(indexPath.getAbsolutePath()) |
|
46 |
} catch (e) { |
|
47 |
println "** $scriptName: error while opening file $indexPath. Aborting." |
|
48 |
println "** "+e.getLocalizedMessage() |
|
49 |
} |
|
50 |
} |
|
51 |
}) |
|
52 |
|
|
53 |
return true |
|
54 |
|
|
55 |
|
Formats disponibles : Unified diff