Révision 2728

tmp/org.txm.groovy.core/src/groovy/org/txm/macro/annotation/CQLList2WordPropertiesMacro.groovy (revision 2728)
9 9
import org.eclipse.core.runtime.Status
10 10
import org.txm.annotation.kr.core.KRAnnotationEngine
11 11
import org.txm.annotation.kr.core.repository.*
12
import org.txm.rcp.commands.workspace.UpdateCorpus
12 13
import org.txm.annotation.kr.rcp.commands.SaveAnnotations
13 14
import org.txm.annotation.kr.rcp.concordance.WordAnnotationToolbar
14 15

  
......
23 24
MainCorpus mcorpus = corpus.getMainCorpus();
24 25

  
25 26
@Field @Option(name="queries_file", usage="The CQL query file to select tokens to annotate", widget="File", required=true, def="queries.tsv")
26
File queries_file
27
		File queries_file
27 28

  
28 29
@Field @Option(name="word_property", usage="The word property to annotate", widget="String", required=true, def="type")
29
String word_property
30
		String word_property
30 31

  
32
@Field @Option(name="do_not_update_corpus_indexes_and_editions", usage="Select to only update the XML-TXM files", widget="Boolean", required=true, def="false")
33
		def do_not_update_corpus_indexes_and_editions
34

  
31 35
// Open the parameters input dialog box
32 36
if (!ParametersDialog.open(this)) return
33 37

  
34
int total = 0;
38
	int total = 0;
35 39

  
36 40

  
37
	def hash = ["args":	["queries_file":queries_file, "word_property":word_property],
38
		"corpusViewSelection":corpusViewSelection, "gse":gse
39
   ]
41
def hash = ["args":	["queries_file":queries_file, "word_property":word_property],
42
	"corpusViewSelection":corpusViewSelection, "gse":gse
43
]
40 44
int n = gse.run(CQLList2WordAnnotationsMacro, hash)
41 45

  
42 46
if (n > 0) {
43 47
	println "Saving annotations..."
44
//	monitor.syncExec(new Runnable() {
45
//		public void run() {
46
			def saveJob = SaveAnnotations.save(mcorpus);
47
			if (saveJob == null || saveJob.getResult() == Status.CANCEL_STATUS) {
48
				// update editor corpus
49
				System.out.println("Fail to save annotations of the corpus."); //$NON-NLS-1$
50
				return;
51
			} else {
52
				return; // something was saved
53
			}
54
//		}
55
//	});
48
	//	monitor.syncExec(new Runnable() {
49
	//		public void run() {
50
	def saveJob = SaveAnnotations.save(mcorpus);
51
	if (saveJob == null || saveJob.getResult() == Status.CANCEL_STATUS) {
52
		// update editor corpus
53
		System.out.println("Fail to save annotations of the corpus."); //$NON-NLS-1$
54
		return;
55
	} else {
56
		if (!do_not_update_corpus_indexes_and_editions) {
57
			UpdateCorpus.update(mcorpus)
58
		}
59
		
60
		return; // something was saved
61
	}
62
	//		}
63
	//	});
56 64
} else {
57 65
	println "No annotation to save."
58 66
	return false

Formats disponibles : Unified diff