Révision 1619

tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/messages/messages.properties (revision 1619)
1 1
savingP0Annotations=Saving {0} annotations...
2 2
annotationSuccessfullyWritten=Annotations successfully written.
3
savingAnnotations=Saving annotations
4
annotationSuccesfullyWritten=Annotations successfully written in the {0} file.
3
annotationSuccesfullyWrittenIntheP0File=Annotations successfully written in the {0} file.
4
savingAnnotations=Saving annotations.
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/messages/messages_fr.properties (revision 1619)
1 1
savingP0Annotations=Enregistrement de {0} annotations...
2 2
annotationSuccessfullyWritten=Annotations enregistrées.
3 3
savingAnnotations=Enregistrement des annotations
4
annotationSuccesfullyWritten=Annotations enregistrées dans le fichier {0}.
4
annotationSuccesfullyWritten=Annotations enregistrées.
5
annotationSuccesfullyWrittenIntheP0File=Annotations enregistrées dans le fichier {0}.
tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/GroovyScriptedImportEngine.java (revision 1619)
130 130
				Boolean readyToLoad = (Boolean)ready;
131 131
				//System.out.println("TRY TO LOAD THE BINARY CORPUS CREATED: "+basedir);
132 132
				if (readyToLoad) {
133
//					
133
					
134
					project.saveParameters(true);
135
					
134 136
					Log.info(GroovyMessages.restartingToolboxSearchengines);
135 137
					Toolbox.getEngineManager(EngineType.SEARCH).restartEngines();
136 138
					Log.info(TXMCoreMessages.common_done);
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZPager.groovy (revision 1619)
124 124
				}
125 125
			} catch(Exception e) {
126 126
				println "Error: could not create $txmFile 'default' edition: "+e
127
				e.printStackTrace()
127 128
			}
128 129
		}
129 130

  
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZDefaultPagerStep.groovy (revision 1619)
92 92
	def noteElements = new HashSet<String>();
93 93
	def outOfTextElements = new HashSet<String>();
94 94
	XTZPager pager;
95
	
95

  
96 96
	/**
97 97
	 * Instantiates a new pager.
98 98
	 *
......
122 122
		inputData = new BufferedInputStream(url.openStream());
123 123
		factory = XMLInputFactory.newInstance();
124 124
		parser = factory.createXMLStreamReader(inputData);
125
		
125

  
126 126
		String notesListString = pager.getImportModule().getProject().getTextualPlan("Note")
127 127
		if (notesListString != null) for (def s : notesListString.split(",")) noteElements << s;
128
		
128

  
129 129
		String elems = pager.getImportModule().getProject().getTextualPlan("OutSideTextTagsAndKeepContent")
130 130
		if (elems != null) for (def s : elems.split(",")) outOfTextElements << s;
131
		
131

  
132 132
		//process();
133 133
	}
134
	
134

  
135 135
	public String getAttributeValue(def parser, String ns, String name) {
136 136
		for (int i = 0 ; i < parser.getAttributeCount() ; i++) {
137 137
			if (name == parser.getAttributeLocalName(i)) {
......
144 144
	private def closeMultiWriter() {
145 145
		if (pagedWriter != null) {
146 146
			def tags = pagedWriter.getTagStack().clone();
147

  
147
//			println "STACK="+pagedWriter.getTagStack()
148
//			def stack = Thread.currentThread().getStackTrace();
149
//			int m = Math.min(15, stack.size()-1)
150
//			for (def s : stack[1..m]) println s
151
//			println "FILE ="+outfile
148 152
			if (firstWord) { // there was no words
149 153
				pagedWriter.writeCharacters("");
150 154
				this.idxstart.add("${wordTag}_0")
......
152 156
				//				}
153 157
			}
154 158
			pagedWriter.writeEndElements();
155

  
159
			// write notes
156 160
			if (notes.size() > 0) {
157 161
				pagedWriter.writeEmptyElement("hr", ["id":"notes", "width":"20%", "align":"left"]);
158 162
				//pagedWriter.writeStartElement("ol");
......
166 170
					pagedWriter.writeEndElement() // </a>
167 171
					pagedWriter.writeCharacters(note)
168 172
					pagedWriter.writeEmptyElement("br")
169
					//pagedWriter.writeEndElement() // </li>
170 173
					i++;
171 174
				}
172
				//pagedWriter.writeEndElement() // </ol>
173 175
				notes.clear()
174 176
			}
175 177

  
176 178
			pagedWriter.close();
179
			
180
//			println "STACK TO REWRITE: $tags"
181
			for (int i = 0 ; i < tags.size() ; i++) {
182
				String tag = tags.remove(0)
183
				i--
184
//				println "	tag=$tag"
185
				if (tag == "div") {
186
					break; // remove elements until first "div" tag
187
				}
188
			}
189
//			println "STACK TO REWRITE2: $tags"
190
			
177 191
			return tags;
178 192
		} else {
179 193
			return [];
......
188 202
	private boolean createNextOutput() {
189 203
		wordcount = 0;
190 204
		try {
191

  
192 205
			def tags = closeMultiWriter();
193
			for (int i = 0 ; i < tags.size() ; i++) {
194
				String tag = tags[i]
195
				if ("div" != tag) {
196
					tags.remove(i--)
197
				} else {
198
					tags.remove(i--) // remove first "div"
199
					break; // remove elements until first "div" tag
200
				}
201
			}
202
			File outfile = new File(outdir, txtname+"_"+(++pagecount)+".html")
206
			
207
			outfile = new File(outdir, txtname+"_"+(++pagecount)+".html")
203 208
			pages.add(outfile);
204 209
			firstWord = true; // waiting for next word
205 210

  
......
222 227
			pagedWriter.writeCharacters("\n")
223 228
			pagedWriter.writeStartElement("body") //<body>
224 229
			pagedWriter.writeStartElement("div", ["class": "txmeditionpage"]) //<div>
230
//			println "OPENING: $tags"
225 231
			pagedWriter.writeStartElements(tags);
226 232
			return true;
227 233
		} catch (Exception e) {
......
282 288
	 * Process.
283 289
	 */
284 290
	public boolean process() {
285
		boolean flagNote = false;
286
		String noteContent = "";
287
		String rend = ""
288
		goToText();
289 291

  
290
		String localname = "";
291
		createNextOutput();
292
		try {
293
			boolean flagNote = false;
294
			String noteContent = "";
295
			String rend = ""
296
			goToText();
292 297

  
293
		for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) {
294
			rend = "";
295
			switch (event) {
296
				case XMLStreamConstants.START_ELEMENT:
297
					localname = parser.getLocalName();
298
					if (outOfTextElements.contains(localname)) {
299
						currentOutOfTextElements << localname
300
						writeOutOfTextToEditText = true;
301
					} else if (currentOutOfTextElements.size() > 0) {
302
						currentOutOfTextElements << localname
303
					}			
304
					
305
					if (localname == paginationElement) {
306
						createNextOutput();
307
						wordcount=0;
308
						pagedWriter.write("\n");
309
						if (getAttributeValue(parser, null,"n") != null) {
310
							pagedWriter.writeElement("p", ["class":"txmeditionpb", "align":"center"], getAttributeValue(parser, null,"n"))
298
			String localname = "";
299
			if (!createNextOutput()) {
300
				return false;
301
			}
302

  
303
			for (int event = parser.next(); event != XMLStreamConstants.END_DOCUMENT; event = parser.next()) {
304
				rend = "";
305
				switch (event) {
306
					case XMLStreamConstants.START_ELEMENT:
307
						localname = parser.getLocalName();
308
						if (outOfTextElements.contains(localname)) {
309
							currentOutOfTextElements << localname
310
							writeOutOfTextToEditText = true;
311
						} else if (currentOutOfTextElements.size() > 0) {
312
							currentOutOfTextElements << localname
311 313
						}
312
					}
313
					
314
					rend = getAttributeValue(parser, null, "rend")
315
					if (rend == null) rend = "";
316
					switch (localname) {
317
						case "text":
318
							LinkedHashMap attributes = new LinkedHashMap();
319
							for (int i = 0 ; i < parser.getAttributeCount() ; i++) {
320
								attributes[parser.getAttributeLocalName(i)] = parser.getAttributeValue(i).toString()
321
							}
322
							
314

  
315
						if (localname == paginationElement) {
316
							createNextOutput();
317
							wordcount=0;
323 318
							pagedWriter.write("\n");
324
							pagedWriter.writeStartElement("p")
325
							pagedWriter.writeAttribute("class", rend);
326
							if (attributes.containsKey("id")) {
327
								pagedWriter.writeElement("h3", attributes["id"])
319
							if (getAttributeValue(parser, null,"n") != null) {
320
								pagedWriter.writeElement("p", ["class":"txmeditionpb", "align":"center"], getAttributeValue(parser, null,"n"))
328 321
							}
322
						}
329 323

  
330
							pagedWriter.writeStartElement("table");
331
							for (String k : attributes.keySet()) {
332
								if (k == "id") continue;
333
								if (k == "rend") continue;
324
						rend = getAttributeValue(parser, null, "rend")
325
						if (rend == null) rend = "";
326
						switch (localname) {
327
							case "text":
328
								LinkedHashMap attributes = new LinkedHashMap();
329
								for (int i = 0 ; i < parser.getAttributeCount() ; i++) {
330
									attributes[parser.getAttributeLocalName(i)] = parser.getAttributeValue(i).toString()
331
								}
334 332

  
335
								pagedWriter.writeStartElement("tr");
336
								pagedWriter.writeElement("td", k);
337
								pagedWriter.writeElement("td", attributes[k]);
338
								pagedWriter.writeEndElement();
339
							}
340
							pagedWriter.writeEndElement() // table
341
							pagedWriter.writeEndElement() // p
342
							pagedWriter.writeCharacters("");
343
							break;
344
						case "ref":
345
							pagedWriter.writeStartElement("a")
346
							pagedWriter.writeAttribute("href", getAttributeValue(parser, null, "target"));
347
							pagedWriter.writeAttribute("target", "_blank");
348
							pagedWriter.writeAttribute("class", rend);
349
							break;
350
						case "head":
351
							pagedWriter.write("\n");
352
							pagedWriter.writeStartElement("h2", ["class":rend])
353
							break;
354
						case "graphic":
355
							pagedWriter.write("\n");
356
							String url = getAttributeValue(parser, null, "url")
357
							if (url != null) {
358
								// TEI <graphic rend="left-image" url="image.png"/> -> <center class="left-image"><img href="image.png"/></center> + <moncorpus>.css avec rule ".left-image"
359
								pagedWriter.writeStartElement("center", ["class":rend]) // css -> .<rend> { ... } styles OR
360
								pagedWriter.writeEmptyElement("img", ["src":url, "align":"middle"])
361
								pagedWriter.writeEndElement() // div
362
							}
363
							break;
364
						case "table":
365
							pagedWriter.writeStartElement("table", ["class":rend])
366
							pagedWriter.write("\n");
367
							break;
368
						case "row":
369
							pagedWriter.writeStartElement("tr", ["class":rend])
370
							break;
371
						case "cell":
372
							pagedWriter.writeStartElement("td", ["class":rend])
373
							break;
374
						case "list":
375
							String type = getAttributeValue(parser, null,"type");
376
							if ("unordered" == type) {
377
								pagedWriter.writeStartElement("ul", ["class":rend])
378
							} else {
379
								pagedWriter.writeStartElement("ol", ["class":rend])
380
							}
381
							break
382
						case "item":
383
							pagedWriter.writeStartElement("li", ["class":rend])
384
							break;
385
						case "hi":
386
						case "emph":
387
							if ("i".equals(rend) || "italic".equals(rend)) {
388
								pagedWriter.writeStartElement("i", ["class":rend])
389
							} else if ("b".equals(rend) || "bold".equals(rend)) {
390
								pagedWriter.writeStartElement("b", ["class":rend])
391
							} else {
392
								if ("emph".equals(localname)) {
333
								pagedWriter.write("\n");
334
								pagedWriter.writeStartElement("p")
335
								pagedWriter.writeAttribute("class", rend);
336
								if (attributes.containsKey("id")) {
337
									pagedWriter.writeElement("h3", attributes["id"])
338
								}
339

  
340
								pagedWriter.writeStartElement("table");
341
								for (String k : attributes.keySet()) {
342
									if (k == "id") continue;
343
									if (k == "rend") continue;
344

  
345
									pagedWriter.writeStartElement("tr");
346
									pagedWriter.writeElement("td", k);
347
									pagedWriter.writeElement("td", attributes[k]);
348
									pagedWriter.writeEndElement(); //tr
349
								}
350
								pagedWriter.writeEndElement() // table
351
								pagedWriter.writeEndElement() // p
352
								pagedWriter.writeCharacters("\n");
353
								break;
354
							case "ref":
355
								pagedWriter.writeStartElement("a")
356
								pagedWriter.writeAttribute("href", getAttributeValue(parser, null, "target"));
357
								pagedWriter.writeAttribute("target", "_blank");
358
								pagedWriter.writeAttribute("class", rend);
359
								break;
360
							case "head":
361
								pagedWriter.write("\n");
362
								pagedWriter.writeStartElement("h2", ["class":rend])
363
								break;
364
							case "graphic":
365
								pagedWriter.write("\n");
366
								String url = getAttributeValue(parser, null, "url")
367
								if (url != null) {
368
									// TEI <graphic rend="left-image" url="image.png"/> -> <center class="left-image"><img href="image.png"/></center> + <moncorpus>.css avec rule ".left-image"
369
									pagedWriter.writeStartElement("center", ["class":rend]) // css -> .<rend> { ... } styles OR
370
									pagedWriter.writeEmptyElement("img", ["src":url, "align":"middle"])
371
									pagedWriter.writeEndElement() // center
372
								}
373
								break;
374
							case "table":
375
								pagedWriter.writeStartElement("table", ["class":rend])
376
								pagedWriter.write("\n");
377
								break;
378
							case "row":
379
								pagedWriter.writeStartElement("tr", ["class":rend])
380
								break;
381
							case "cell":
382
								pagedWriter.writeStartElement("td", ["class":rend])
383
								break;
384
							case "list":
385
								String type = getAttributeValue(parser, null,"type");
386
								if ("unordered" == type) {
387
									pagedWriter.writeStartElement("ul", ["class":rend])
388
								} else {
389
									pagedWriter.writeStartElement("ol", ["class":rend])
390
								}
391
								break
392
							case "item":
393
								pagedWriter.writeStartElement("li", ["class":rend])
394
								break;
395
							case "hi":
396
							case "emph":
397
								if ("i".equals(rend) || "italic".equals(rend)) {
393 398
									pagedWriter.writeStartElement("i", ["class":rend])
394
								} else { // hi
399
								} else if ("b".equals(rend) || "bold".equals(rend)) {
395 400
									pagedWriter.writeStartElement("b", ["class":rend])
401
								} else {
402
									if ("emph".equals(localname)) {
403
										pagedWriter.writeStartElement("i", ["class":rend])
404
									} else { // hi
405
										pagedWriter.writeStartElement("b", ["class":rend])
406
									}
396 407
								}
397
							}
398
							break;
399
						case "p":
400
						//case "lg":
401
							pagedWriter.write("\n");
402
							pagedWriter.writeStartElement("p", ["class":rend])
403
							break;
404
						case "div":
405
						case "div1":
406
						case "div2":
407
						case "div3":
408
						case "div4":
409
						case "div5":
410
							pagedWriter.writeStartElement("div", ["class":rend, "type":localname])
411
							break;
412
						case "lb":
413
						//case "l":
414
							pagedWriter.writeEmptyElement("br", ["class":rend])
415
							break;
416
						case wordTag:
417
							wordid = getAttributeValue(parser, null,"id");
418
							
419
							wordcount++;
420
							if (wordcount >= wordmax) {
421
								createNextOutput();
422
							}
423
							
424
							if (firstWord) {
425
								firstWord = false;
426
								this.idxstart.add(wordid);
427
							}
428
							
429
							break;
430
						case "ana":
431
							flaginterp=true;
432
							interpvalue+=" "+getAttributeValue(parser, null, "type").substring(1)+":"
433
							break;
434
						case "form":
435
							wordvalue="";
436
							interpvalue ="";
437
							flagform=true;
438
							break;
439
						default:
440
							if (noteElements.contains(localname)) {
441
								flagNote = true;
442
								noteContent = ""
443
							}
444
//							 else {
445
//								pagedWriter.writeStartElement("span", ["class":localname])
446
//							}
447
							break;
448
					}
449
					break;
450
				case XMLStreamConstants.END_ELEMENT:
451
					localname = parser.getLocalName();
452
					if (currentOutOfTextElements.size() > 0) currentOutOfTextElements.pop()
453
					writeOutOfTextToEditText = currentOutOfTextElements.size() > 0
454
					
455
					switch (localname) {
456
						case "p":
457
						//case "lg":
458
							pagedWriter.writeEndElement() // </p>
459
							pagedWriter.write("\n");
460
							break;
461
						case "div":
462
						case "div1":
463
						case "div2":
464
						case "div3":
465
						case "div4":
466
						case "div5":
467
							pagedWriter.writeEndElement() // </div>
468
							pagedWriter.write("\n");
469
						case "head":
470
							pagedWriter.writeEndElement() // </h2>
471
							pagedWriter.write("\n");
472
							break;
473
						case "list":
474
							pagedWriter.writeEndElement(); // ul or ol
475
							pagedWriter.write("\n");
476
							break
477
						case "item":
478
							pagedWriter.writeEndElement(); // li
479
							pagedWriter.write("\n");
480
							break;
481
						case "hi":
482
							pagedWriter.writeEndElement(); // b
483
							break;
484
						case "emph":
485
							pagedWriter.writeEndElement(); // i
486
							break;
487
						case "table":
488
							pagedWriter.writeEndElement(); // table
489
							pagedWriter.write("\n");
490
							break;
491
						case "row":
492
							pagedWriter.writeEndElement(); // tr
493
							break;
494
						case "cell":
495
							pagedWriter.writeEndElement(); // td
496
							break;
497
						case "ref":
498
							pagedWriter.writeEndElement() // </a>
499
							break;
500
						case "form":
501
							flagform = false
502
							break;
503
						case "ana":
504
							flaginterp = false
505
							break;
506
						case wordTag:
507
							int l = lastword.length();
508
							String endOfLastWord = "";
509
							if (l > 0)
510
								endOfLastWord = lastword.subSequence(l-1, l);
408
								break;
409
							case "p":
410
							//case "lg":
411
								pagedWriter.write("\n");
412
								pagedWriter.writeStartElement("p", ["class":rend])
413
								break;
414
							case "div":
415
							case "div1":
416
							case "div2":
417
							case "div3":
418
							case "div4":
419
							case "div5":
420
								pagedWriter.writeStartElement("div", ["class":rend, "type":localname])
421
								break;
422
							case "lb":
423
							//case "l":
424
								pagedWriter.writeEmptyElement("br", ["class":rend])
425
								break;
426
							case wordTag:
427
								wordid = getAttributeValue(parser, null,"id");
511 428

  
512
							if (interpvalue != null)
513
								interpvalue = interpvalue;
429
								wordcount++;
430
								if (wordcount >= wordmax) {
431
									createNextOutput();
432
								}
514 433

  
515
							if (NoSpaceBefore.contains(wordvalue) ||
516
							NoSpaceAfter.contains(lastword) ||
517
							wordvalue.startsWith("-") ||
518
							NoSpaceAfter.contains(endOfLastWord)) {
519
								pagedWriter.writeStartElement("span", ["title":interpvalue, "id":wordid]);
520
							} else {
521
								pagedWriter.writeCharacters(" ");
522
								pagedWriter.writeStartElement("span", ["title":interpvalue, "id":wordid]);
523
							}
434
								if (firstWord) {
435
									firstWord = false;
436
									this.idxstart.add(wordid);
437
								}
524 438

  
525
							pagedWriter.writeCharacters(wordvalue);
526
							pagedWriter.writeEndElement();
527
							pagedWriter.writeComment("\n")
528
							lastword=wordvalue;
529
							break;
530
						default:
531
							if (noteElements.contains(localname)) {
532
								flagNote = false;
533
								if (noteContent.length() > 0) {
534
									notes << noteContent;
535
									pagedWriter.writeStartElement("a", ["href":"#note_"+notes.size(), "name":"noteref_"+notes.size(), "title":noteContent]);
536
									pagedWriter.writeStartElement("sup")
537
									pagedWriter.writeCharacters(""+notes.size())
538
									pagedWriter.writeEndElement() // </sub>
539
									pagedWriter.writeEndElement() // </span>
439
								break;
440
							case "ana":
441
								flaginterp=true;
442
								interpvalue+=" "+getAttributeValue(parser, null, "type").substring(1)+":"
443
								break;
444
							case "form":
445
								wordvalue="";
446
								interpvalue ="";
447
								flagform=true;
448
								break;
449
							default:
450
								if (noteElements.contains(localname)) {
451
									flagNote = true;
452
									noteContent = ""
540 453
								}
541
							} 
542
//							else {
543
//								pagedWriter.writeEndElement() // the element
544
//							}
545
							break;
546
					}
547
					break;
548
				case XMLStreamConstants.CHARACTERS:
549
					if (flagform && parser.getText().length() > 0) {
550
						wordvalue+=(parser.getText());
551
						if (flagNote == parser.getText().length() > 0)
454
							//							 else {
455
							//								pagedWriter.writeStartElement("span", ["class":localname])
456
							//							}
457
								break;
458
						}
459
						break;
460
					case XMLStreamConstants.END_ELEMENT:
461
						localname = parser.getLocalName();
462
						if (currentOutOfTextElements.size() > 0) currentOutOfTextElements.pop()
463
						writeOutOfTextToEditText = currentOutOfTextElements.size() > 0
464

  
465
						switch (localname) {
466
							case "text":
467
								break;
468
							case "p":
469
							//case "lg":
470
								pagedWriter.writeEndElement() // </p>
471
								pagedWriter.write("\n");
472
								break;
473
							case "div":
474
							case "div1":
475
							case "div2":
476
							case "div3":
477
							case "div4":
478
							case "div5":
479
								pagedWriter.writeEndElement() // </div>
480
								pagedWriter.write("\n");
481
								break;
482
							case "head":
483
								pagedWriter.writeEndElement() // </h2>
484
								pagedWriter.write("\n");
485
								break;
486
							case "list":
487
								pagedWriter.writeEndElement(); // ul or ol
488
								pagedWriter.write("\n");
489
								break
490
							case "item":
491
								pagedWriter.writeEndElement(); // li
492
								pagedWriter.write("\n");
493
								break;
494
							case "hi":
495
								pagedWriter.writeEndElement(); // b
496
								break;
497
							case "emph":
498
								pagedWriter.writeEndElement(); // i
499
								break;
500
							case "table":
501
								pagedWriter.writeEndElement(); // table
502
								pagedWriter.write("\n");
503
								break;
504
							case "row":
505
								pagedWriter.writeEndElement(); // tr
506
								break;
507
							case "cell":
508
								pagedWriter.writeEndElement(); // td
509
								break;
510
							case "ref":
511
								pagedWriter.writeEndElement() // </a>
512
								break;
513
							case "form":
514
								flagform = false
515
								break;
516
							case "ana":
517
								flaginterp = false
518
								break;
519
							case wordTag:
520
								int l = lastword.length();
521
								String endOfLastWord = "";
522
								if (l > 0)
523
									endOfLastWord = lastword.subSequence(l-1, l);
524

  
525
								if (interpvalue != null)
526
									interpvalue = interpvalue;
527

  
528
								if (NoSpaceBefore.contains(wordvalue) ||
529
								NoSpaceAfter.contains(lastword) ||
530
								wordvalue.startsWith("-") ||
531
								NoSpaceAfter.contains(endOfLastWord)) {
532
									pagedWriter.writeStartElement("span", ["title":interpvalue, "id":wordid]);
533
								} else {
534
									pagedWriter.writeCharacters("\n");
535
									pagedWriter.writeStartElement("span", ["title":interpvalue, "id":wordid]);
536
								}
537

  
538
								pagedWriter.writeCharacters(wordvalue);
539
								pagedWriter.writeEndElement();
540
								//pagedWriter.writeComment("\n")
541
								lastword=wordvalue;
542
								break;
543
							default:
544
								if (noteElements.contains(localname)) {
545
									flagNote = false;
546
									if (noteContent.length() > 0) {
547
										notes << noteContent;
548
										pagedWriter.writeStartElement("a", ["href":"#note_"+notes.size(), "name":"noteref_"+notes.size(), "title":noteContent]);
549
										pagedWriter.writeStartElement("sup")
550
										pagedWriter.writeCharacters(""+notes.size())
551
										pagedWriter.writeEndElement() // </sub>
552
										pagedWriter.writeEndElement() // </a>
553
									}
554
								}
555
							//							else {
556
							//								pagedWriter.writeEndElement() // the element
557
							//							}
558
								break;
559
						}
560
						break;
561
					case XMLStreamConstants.CHARACTERS:
562
						if (flagform && parser.getText().length() > 0) {
563
							wordvalue+=(parser.getText());
564
							if (flagNote == parser.getText().length() > 0)
565
								noteContent += parser.getText().replace("\n", " ");
566
						} else	if (flaginterp && parser.getText().length() > 0) {
567
							interpvalue+=(parser.getText());
568
						} else if (flagNote == parser.getText().length() > 0) {
552 569
							noteContent += parser.getText().replace("\n", " ");
553
					} else	if (flaginterp && parser.getText().length() > 0) {
554
						interpvalue+=(parser.getText());
555
					} else if (flagNote == parser.getText().length() > 0) {
556
						noteContent += parser.getText().replace("\n", " ");
557
					} else if (writeOutOfTextToEditText) {
558
						pagedWriter.writeCharacters(parser.getText())
559
					}
560
					break;
570
						} else if (writeOutOfTextToEditText) {
571
							pagedWriter.writeCharacters(parser.getText())
572
						}
573
						break;
574
				}
561 575
			}
576
			closeMultiWriter();
577
		} catch(Exception e) {
578
			println "** Fail to build $infile edition: $e at "+parser.getLocation()
579
			println "** resulting file: $outfile"
580
			println "** Stax stack: "+pagedWriter.getTagStack()
581
			e.printStackTrace();
582
			pagedWriter.close()
583
			return false;
562 584
		}
563
		closeMultiWriter();
585
		return true;
564 586
	}
565 587
}
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/annotation/AnnotationInjectionFilter.groovy (revision 1619)
120 120
			switch (localname) {
121 121
				case "w":
122 122
					start = false
123
					if (data.keySet().size() > 0) writer.writeCharacters("\n");
123
					if (data.keySet().size() > 0) writer.writeComment("\n");
124 124
					// write remaining properties
125 125
					if (debug) if (data.size() > 0) println "new ana: " +data
126 126
					for (def prop : data.keySet()) { // (1)
......
130 130
						writer.writeAttribute("type", "#$prop")
131 131
						writer.writeCharacters(data.get(prop))
132 132
						writer.writeEndElement()
133
						writer.writeCharacters("\n")
133
						writer.writeComment("\n")
134 134
						println " create annotation $prop with "+data.get(prop)
135 135
					}
136 136
					break;
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/nlp/TT2XMLInDirectoryMacro.groovy (revision 1619)
64 64
				writer.writeAttribute("frlemma", sent_m[0][3])
65 65
				writer.writeCharacters(sent_m[0][3])
66 66
				writer.writeEndElement() // close w		
67
				writer.writeCharacters("\n")
67
				writer.writeComment("\n")
68 68
				writer.writeEndElement() // close s
69 69
				writer.writeEndElement() // close p (sent)
70 70
				writer.writeCharacters("\n")
tmp/org.txm.groovy.core/src/groovy/org/txm/macro/xml/XMLStatistics.groovy (revision 1619)
1
package org.txm.scripts.scripts
1
package org.txm.macro.xml
2 2

  
3 3
import java.text.Collator;
4 4
import java.util.Locale;
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/WordAnnotationToolbar.java (revision 1619)
18 18
import org.eclipse.jface.viewers.ISelectionChangedListener;
19 19
import org.eclipse.jface.viewers.IStructuredSelection;
20 20
import org.eclipse.jface.viewers.SelectionChangedEvent;
21
import org.eclipse.jface.viewers.StructuredSelection;
21 22
import org.eclipse.jface.viewers.TableViewer;
22 23
import org.eclipse.jface.viewers.TableViewerColumn;
23 24
import org.eclipse.jface.viewers.ViewerCell;
......
256 257
			@Override
257 258
			public void run() {
258 259
				try {
260
					annotationColumn.setText("*"+typesList.get(0).getName());
259 261
					editor.refresh(false);
260 262
				} catch (Exception e) {
261 263
					// TODO Auto-generated catch block
......
293 295
			@Override
294 296
			public void run() {
295 297
				try {
298
					annotationColumn.setText("*"+typesList.get(0).getName());
296 299
					editor.refresh(false);
297 300
				} catch (Exception e) {
298 301
					// TODO Auto-generated catch block
......
465 468
					String name = annotationTypesCombo.getCombo().getText();
466 469
					if (currentKnowledgeRepository.getType(name) == null) {
467 470
						createNewType(e, name);
471
					} else {
472
						for (AnnotationType type : typesList) {
473
							if (name.equals(type.getId())) {
474
								StructuredSelection selection = new StructuredSelection(type);
475
								annotationTypesCombo.setSelection(selection, true);
476
								break;
477
							}
478
						}
468 479
					}
469 480
				}
470 481
			}
......
485 496
		annotationTypesCombo.addSelectionChangedListener(new ISelectionChangedListener() {
486 497
			@Override
487 498
			public void selectionChanged(SelectionChangedEvent event) {
488
				IStructuredSelection sel = (IStructuredSelection) annotationTypesCombo.getSelection();
489
				AnnotationType type = (AnnotationType) sel.getFirstElement();
490
				if (type == null) return;
491
				if (type.getSize() != AnnotationType.ValuesSize.LARGE) {
492
					try {
493
						KnowledgeRepository kr = KnowledgeRepositoryManager.getKnowledgeRepository(type.getKnowledgeRepository());
494
						typeValuesList = kr.getValues(type);
495
					} catch (Exception e) {
496
						// TODO Auto-generated catch block
497
						e.printStackTrace();
498
					}
499
				}
500

  
501
				annotationColumn.setText(type.getName());
502
				annotations.setViewAnnotation(type);
503
				annotations.setAnnotationOverlap(true);
504
				try {
505
					editor.refresh(false);
506
				} catch (Exception e) {
507
					// TODO Auto-generated catch block
508
					e.printStackTrace();
509
				}
510

  
511
				updateAnnotationWidgetStates();
499
				onAnnotationTypeSelected(event);
512 500
			}
513 501
		});
514 502

  
......
620 608
		return true;
621 609
	}
622 610

  
611
	protected void onAnnotationTypeSelected(SelectionChangedEvent event) {
612
		IStructuredSelection sel = (IStructuredSelection) annotationTypesCombo.getSelection();
613
		AnnotationType type = (AnnotationType) sel.getFirstElement();
614
		if (type == null) return;
615
		
616
		if (type.getSize() != AnnotationType.ValuesSize.LARGE) {
617
			try {
618
				KnowledgeRepository kr = KnowledgeRepositoryManager.getKnowledgeRepository(type.getKnowledgeRepository());
619
				typeValuesList = kr.getValues(type);
620
			} catch (Exception e) {
621
				// TODO Auto-generated catch block
622
				e.printStackTrace();
623
			}
624
		}
625

  
626
		annotationColumn.setText(type.getName());
627
		annotations.setViewAnnotation(type);
628
		annotations.setAnnotationOverlap(true);
629
		try {
630
			editor.refresh(false);
631
		} catch (Exception e) {
632
			// TODO Auto-generated catch block
633
			e.printStackTrace();
634
		}
635

  
636
		updateAnnotationWidgetStates();
637
	}
638

  
623 639
	protected void createNewType(TypedEvent e, String typeName) {
624 640
		
625 641
		if (currentKnowledgeRepository == null) return;
......
640 656
			AnnotationType type = kr.addType(name, id, ""); //$NON-NLS-1$
641 657
			type.setEffect(AnnotationEffect.TOKEN);
642 658
			typesList.add(type);
659
			annotationTypesCombo.refresh();
660
			StructuredSelection selection = new StructuredSelection(type);
661
			annotationTypesCombo.setSelection(selection, true);
643 662

  
644
			if (annotationTypesCombo != null) annotationTypesCombo.refresh();
645
			if (typesList.size() == 1) {
646
				if (annotationTypesCombo != null) annotationTypesCombo.getCombo().select(0);
647
				annotations.setViewAnnotation(type);
648
				annotations.setAnnotationOverlap(true);
649
				try {
650
					editor.refresh(false);
651
				} catch (Exception e1) {
652
					// TODO Auto-generated catch block
653
					e1.printStackTrace();
654
				}
655
				annotationArea.layout(true);
656
			} else {
657
				if (typesList.size() > 1) {
658
					if (annotationTypesCombo != null) {
659
						annotationTypesCombo.getCombo().select(typesList.size()-1);
660
					}
661
				}
662
			}
663
			KRView.refresh();
664
			updateAnnotationWidgetStates();
663
//			if (annotationTypesCombo != null) annotationTypesCombo.refresh();
664
//			if (typesList.size() == 1) {
665
//				if (annotationTypesCombo != null) annotationTypesCombo.getCombo().select(0);
666
//				annotations.setViewAnnotation(type);
667
//				annotations.setAnnotationOverlap(true);
668
//				try {
669
//					editor.refresh(false);
670
//				} catch (Exception e1) {
671
//					// TODO Auto-generated catch block
672
//					e1.printStackTrace();
673
//				}
674
//				annotationArea.layout(true);
675
//			} else {
676
//				if (typesList.size() > 1) {
677
//					if (annotationTypesCombo != null) {
678
//						annotationTypesCombo.getCombo().select(typesList.size()-1);
679
//					}
680
//				}
681
//			}
682
//			KRView.refresh();
683
//			updateAnnotationWidgetStates();
684
			
685
			//onAnnotationTypeSelected(null);
665 686
		} else {
666 687
			System.out.println("Creation aborted."); //$NON-NLS-1$
667 688
		}
......
686 707
			ex.printStackTrace();
687 708
			return false;
688 709
		}
710
		annotationColumn.setText(typesList.get(0).getName());
689 711
		return true;
690 712
	}
691 713

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/UpdateCorpus.java (revision 1619)
21 21
public class UpdateCorpus extends AbstractHandler {
22 22

  
23 23
	public static final String ID = UpdateCorpus.class.getCanonicalName();
24
	
24

  
25 25
	@Override
26 26
	public Object execute(ExecutionEvent event) throws ExecutionException {
27
		
27

  
28 28
		ISelection sel = (IStructuredSelection) HandlerUtil.getCurrentSelection(event);
29 29
		if (!(sel instanceof IStructuredSelection)) return null;
30 30
		IStructuredSelection selection = (IStructuredSelection) sel;
......
34 34
			return null;
35 35
		MainCorpus corpus = (MainCorpus) s;
36 36
		update(corpus);
37
		
37

  
38 38
		return corpus;
39 39
	}
40
	
40

  
41 41
	public static JobHandler update(final MainCorpus corpus) {
42
		
42

  
43 43
		final Project project = corpus.getProject();
44 44
		if (project == null)  return null;
45
		
46
		if (!project.getImportModuleName().matches("xtz|txt|hyperbase|cnr|alceste|xml")) {
45

  
46
		String iname = project.getImportModuleName();
47
		if (!iname.matches("xtz|txt|hyperbase|cnr|alceste|xml|xmltxm")) {
47 48
			System.out.println("Can't update a corpus not imported with the XTZ import module.");
48 49
			return null;
49 50
		}
50
		
51
		Display.getDefault().syncExec(new Runnable() {
52
			@Override
53
			public void run() {CloseEditorsUsing.corpus(corpus);}
54
		});
55
		
51

  
52
		Display d = Display.getCurrent();
53
		if (d == null) {
54
			d = Display.getDefault();
55
		}
56
		if (d != null) {
57
			d.syncExec(new Runnable() {
58
				@Override
59
				public void run() {CloseEditorsUsing.corpus(corpus);}
60
			});
61
		}
62

  
56 63
		project.setDirty();
57 64
		project.setNeedToBuild();
58 65
		project.setDoMultiThread(false); //too soon
59 66
		project.setDoUpdate(true);
60 67
		project.setImportModuleName("xtz");
61
		
68

  
62 69
		JobHandler job = new JobHandler("Updating corpus "+corpus+" using "+project) {
63
			
70

  
64 71
			@Override
65 72
			protected IStatus run(IProgressMonitor monitor) {
66 73
				if (project.compute(monitor)) {
67
					
74

  
68 75
					this.syncExec(new Runnable() {
69
						
76

  
70 77
						@Override
71 78
						public void run() {
72 79
							RestartTXM.reloadViews();
......
78 85
				}
79 86
			}
80 87
		};
81
		
88

  
82 89
		job.schedule();
83
		
84
////		String txmhome = Toolbox.getTxmHomePath();
85
////		File scriptDir = new File(txmhome, "scripts/groovy/user/org/txm/scripts/importer/xtz");
86
////		File script = new File(scriptDir, "xtzLoader.groovy");
87
//		System.out.println();
88
//		JobHandler ret = ExecuteImportScript.executeScript(project);
89
//		
90

  
91
		////		String txmhome = Toolbox.getTxmHomePath();
92
		////		File scriptDir = new File(txmhome, "scripts/groovy/user/org/txm/scripts/importer/xtz");
93
		////		File script = new File(scriptDir, "xtzLoader.groovy");
94
		//		System.out.println();
95
		//		JobHandler ret = ExecuteImportScript.executeScript(project);
96
		//		
90 97
		return job;
91 98
	}
92 99
}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 1619)
457 457
			//			}
458 458

  
459 459

  
460
			if (this.getResult().isLocked()) {
460
			if (this.getResult() != null && this.getResult().isLocked()) {
461 461
				this.setLocked(true);
462 462
			}
463 463

  
tmp/org.txm.rcp/plugin.xml (revision 1619)
1007 1007
                  visible="true">
1008 1008
            </separator>
1009 1009
            <command
1010
                  commandId="org.txm.rcp.commands.workspace.UpdateCorpus"
1011
                  icon="icons/functions/update.png"
1012
                  label="Re-import corpus"
1013
                  style="push">
1014
               <visibleWhen
1015
                     checkEnabled="false">
1016
                  <or>
1017
                     <reference
1018
                           definitionId="OneMainCorpusSelected">
1019
                     </reference>
1020
                  </or>
1021
               </visibleWhen>
1022
            </command>
1023
            <command
1010 1024
                  commandId="org.txm.rcp.handlers.results.DeleteObject"
1011 1025
                  icon="icons/functions/Delete.png"
1012 1026
                  style="push">
tmp/org.txm.core/src/java/org/txm/scripts/importer/StaxStackWriter.groovy (revision 1619)
12 12
	XMLStreamWriter writer;
13 13
	OutputStream output;
14 14
	def events = [];
15
	def debug = false
15 16
	
16 17
	public StaxStackWriter(File file) {
17 18
		this(new BufferedOutputStream(new FileOutputStream(file)));
......
185 186
	@Override
186 187
	public void writeEndElement () throws XMLStreamException {
187 188
		writer.writeEndElement();
188
		events.pop()
189
		events.remove(events.size()-1)
190
		if (debug) println "END: $events"
189 191

  
190 192
	}
191 193

  
......
233 235
	public void writeStartElement (String localName) throws XMLStreamException {
234 236
		writer.writeStartElement(localName);
235 237
		events << localName
238
		if (debug) println "START $localName $events"
236 239

  
237 240
	}
238 241
	
......
248 251
	throws XMLStreamException {
249 252
		writer.writeStartElement(namespaceURI, localName);
250 253
		events << localName
254
		if (debug) println "START $localName $events"
251 255
	}
252 256

  
253 257
	@Override
......
255 259
	String namespaceURI) throws XMLStreamException {
256 260
		writer.writeStartElement(prefix, localName, namespaceURI);
257 261
		events << localName
262
		if (debug) println "START $localName $prefix $events"
258 263
	}
259 264
}

Formats disponibles : Unified diff