Révision 3397

TXM/trunk/org.txm.core/src/java/org/txm/importer/xtz/ImportModule.java (revision 3397)
262 262
			}
263 263
		}
264 264
		
265
		if (updateEdition) {
265
		if (!updateCorpus || updateEdition) {
266 266
			Tpager.start();
267 267
		}
268 268
		
269 269
		if (multithread) Tcompiler.join(); // wait for both threads to end
270 270
		
271
		if (updateEdition) {
271
		if (!updateCorpus || updateEdition) {
272 272
			Tpager.join();
273
		} else {
274
			Log.info("Warning: editions not updated.");
273 275
		}
274 276
		
275 277
		if (isSuccessful) { // all done TODO remove this code when Text._compute() will be implemented
276
			if (updateEdition) {
277
				for (Text t : project.getTexts()) {
278
					t.compute(false);
279
				}
278
			for (Text t : project.getTexts()) {
279
				t.compute(false);
280 280
			}
281 281
			
282 282
			project.setDoUpdate(false, false);
TXM/trunk/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationExtension.java (revision 3397)
20 20
import org.eclipse.swt.widgets.ToolItem;
21 21
import org.txm.annotation.rcp.messages.AnnotationUIMessages;
22 22
import org.txm.concordance.core.functions.Concordance;
23
import org.txm.core.preferences.TBXPreferences;
24 23
import org.txm.core.results.TXMResult;
25 24
import org.txm.objects.Text;
26
import org.txm.rcp.IImageKeys;
27 25
import org.txm.rcp.commands.workspace.UpdateCorpus;
28 26
import org.txm.rcp.editors.TXMEditorExtension;
29
import org.txm.rcp.editors.TXMEditorToolBar;
30 27
import org.txm.rcp.messages.TXMUIMessages;
31 28
import org.txm.rcp.utils.JobHandler;
32 29
import org.txm.rcp.views.corpora.CorporaView;
......
81 78
			try {
82 79
				Object o = celement.createExecutableExtension("class"); //$NON-NLS-1$
83 80
				AnnotationArea aa = (AnnotationArea) o;
84
				
85
				if (!aa.getAnnotatedTXMResultClass().equals(editor.getResult().getClass())) {
81
				Class<? extends TXMResult> cc = aa.getAnnotatedTXMResultClass();
82
				TXMResult r = editor.getResult();
83
				if (r == null) return;
84
				if (!cc.equals(r.getClass())) {
86 85
					continue;
87 86
				}
88 87
				Log.finer("Installing AnnotationExtension: " + aa.getName());
......
107 106
				});
108 107
			}
109 108
			catch (Exception exx) {
110
				exx.printStackTrace();
109
				Log.printStackTrace(exx);
111 110
			}
112 111
		}
113 112
		
......
156 155
					notifyDoSave();
157 156
				}
158 157
				catch (Exception e1) {
159
					// TODO Auto-generated catch block
160
					e1.printStackTrace();
158
					Log.printStackTrace(e1);
161 159
				}
162 160
			}
163 161
			
......
348 346
						return Status.OK_STATUS;
349 347
					}
350 348
				} catch(ThreadDeath ex) {
351
					Log.info(TXMUIMessages.executionCanceled);
349
					Log.warning(TXMUIMessages.executionCanceled);
352 350
					return Status.CANCEL_STATUS;
353 351
				}
354 352
			}
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/utils/URLUtils.java (revision 3397)
1
package org.txm.rcp.utils;
2

  
3
import java.net.MalformedURLException;
4
import java.net.URL;
5
import java.net.URLEncoder;
6
import org.apache.commons.lang.StringUtils;
7

  
8
public class URLUtils {
9
	
10
	public static String encodeURL(String url) {
11
		StringBuilder buffer = new StringBuilder();
12
		int begin = url.indexOf(":/");
13
		buffer.append(url.substring(0, begin+2));
14
		url = url.substring(begin+2);
15
		String[] split = url.split("/");
16
		String[] ps = new String[split.length];
17
		for (int i = 0 ; i < split.length ; i++) {
18
			if (split[i].length() > 0) {
19
				ps[i] = URLEncoder.encode(split[i]);
20
			} else {
21
				ps[i] = split[i];
22
			}
23
		}
24
		buffer.append(StringUtils.join(ps, "/"));
25
		return buffer.toString();
26
	}
27
	
28
	public static URL encodeURL(URL url) throws MalformedURLException {
29
		return new URL(encodeURL(url.toString()));
30
	}
31
}
0 32

  
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/editors/imports/sections/CommandsSection.java (revision 3397)
131 131
		if (this.section != null && !section.isDisposed()) {
132 132
			CorpusCommandPreferences concPrefs = project.getCommandPreferences("concordance");
133 133
			concPrefs.set("context_limits_type", "list");
134
			concPrefs.set("context_limits", structLimitsText.getText());
134 135
			
135 136
			concPrefs.set("view_reference_pattern", 
136 137
					ReferencePattern.referenceToString(
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 3397)
527 527
			}
528 528
			
529 529
			this.setDirty(this.dirty);
530
			
531 530
		}
532 531
		catch (Throwable e) {
533 532
			Log.severe(TXMCoreMessages.bind("TXMEditor.createPartControl(): can not create the editor for result {0}.", this.getResult())); //$NON-NLS-1$
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/p2/plugins/TXMUpdateHandler.java (revision 3397)
91 91
		// -configuration is set
92 92
		try {
93 93
			Log.info("Looking for TXM updates...");
94
			
94 95
			ProvisioningUI pui = ProvisioningUI.getDefaultUI();
95 96
			
96 97
			String profileId = pui.getProfileId();
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/commands/OpenBrowser.java (revision 3397)
29 29

  
30 30
import java.io.File;
31 31
import java.net.URL;
32
import java.net.URLEncoder;
33 32

  
34 33
import org.eclipse.core.commands.AbstractHandler;
35 34
import org.eclipse.core.commands.ExecutionEvent;
......
49 48
import org.txm.rcp.editors.TXMBrowserEditor;
50 49
import org.txm.rcp.messages.TXMUIMessages;
51 50
import org.txm.rcp.swt.dialog.LastOpened;
51
import org.txm.rcp.utils.URLUtils;
52 52
import org.txm.utils.logger.Log;
53 53

  
54 54
// TODO: Auto-generated Javadoc
......
185 185
				url = localfile.toURI().toURL();
186 186
			} else {
187 187
				url = new URL(filepath);
188
				
189
				url = URLUtils.encodeURL(url);
188 190
			}
189 191
			
190
			String s = url.toString();
191
			int begin = s.indexOf(":/");
192
			String start = s.substring(0, begin);
193
			String end = URLEncoder.encode(s.substring(begin+2));
194 192
			
195
			WebBrowserEditorInput editorInput = new WebBrowserEditorInput(new URL(start+":/"+end), BrowserViewer.BUTTON_BAR | BrowserViewer.LOCATION_BAR);
196 193
			
194
			WebBrowserEditorInput editorInput = new WebBrowserEditorInput(url, BrowserViewer.BUTTON_BAR | BrowserViewer.LOCATION_BAR);
195
			
197 196
			IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
198 197
			IWorkbenchPage page = window.getActivePage();
199 198
			
TXM/trunk/org.txm.utils/src/org/txm/utils/logger/Log.java (revision 3397)
59 59
	protected static FileHandler fh;
60 60

  
61 61
	public static int MAX_LINE_LENGTH = 1000;
62
	
62

  
63 63
	/**
64 64
	 * The CONSOLE flags indicates if messages with level < INFO are printed in
65 65
	 * console
......
224 224
	 * @param message
225 225
	 */
226 226
	public static void severe(String message) {
227
		
227

  
228 228
		if (message.length()> MAX_LINE_LENGTH) { // cut if too long
229 229
			message = message.substring(0, MAX_LINE_LENGTH) + "[...]";
230
			}
231
message = message.replace("\n", "⏎");
232
		
230
		}
231
		message = message.replace("\n", "⏎");
233 232

  
233

  
234 234
		if (Level.SEVERE.intValue() >= txm.getLevel().intValue()) {
235 235
			System.out.println(message);
236 236

  
......
293 293
	 * @param message
294 294
	 */
295 295
	public static void warning(String message) {
296
		
296

  
297 297
		if (message.length()> MAX_LINE_LENGTH) { // cut if too long
298 298
			message = message.substring(0, MAX_LINE_LENGTH) + "[...]";
299
			}
300
message = message.replace("\n", "⏎");
301
		
302
		
299
		}
300
		message = message.replace("\n", "⏎");
301

  
302

  
303 303
		if (Level.WARNING.intValue() >= txm.getLevel().intValue()) {
304 304
			System.out.println(message);
305 305
			// System.out.print("AT: ");
......
336 336
	public static void info(String message) {
337 337
		info(message, true);
338 338
	}
339
	
339

  
340 340
	/**
341 341
	 * Log an info message
342 342
	 * 
......
345 345
	 *            where to print the message
346 346
	 */
347 347
	public static void info(String message, boolean newline) {
348
		
348

  
349 349
		if (message.length()> MAX_LINE_LENGTH) { // cut if too long
350 350
			message = message.substring(0, MAX_LINE_LENGTH) + "[...]";
351
			}
352
message = message.replace("\n", "⏎");
353
		
354
		
351
		}
352
		message = message.replace("\n", "⏎");
353

  
354

  
355 355
		if (Level.INFO.intValue() >= txm.getLevel().intValue()) {
356 356
			if (newline) System.out.println(message);
357 357
			else  System.out.print(message);
......
403 403
	public static void fine(String message) {
404 404
		fine(message, true);
405 405
	}
406
	
406

  
407 407
	/**
408 408
	 * Log an info message
409 409
	 * 
TXM/trunk/org.txm.concordance.core/src/org/txm/concordance/core/functions/Concordance.java (revision 3397)
51 51
import org.txm.core.preferences.TXMPreferences;
52 52
import org.txm.core.results.Parameter;
53 53
import org.txm.core.results.TXMParameters;
54
import org.txm.core.results.TXMResult;
55 54
import org.txm.objects.Match;
56 55
import org.txm.searchengine.core.IQuery;
57 56
import org.txm.searchengine.core.QueryBasedTXMResult;
......
260 259
			String refPropertyNames = this.getStringParameterValue(ConcordancePreferences.VIEW_REFERENCE_PATTERN);
261 260
			String refPropertyNames2 = this.getCorpus().getProject().getCommandPreferences("concordance").get(ConcordancePreferences.VIEW_REFERENCE_PATTERN);
262 261
			if (refPropertyNames2 != null && refPropertyNames2.length() > 0) {
263
				ReferencePattern ref = ReferencePattern.stringToReferencePattern(this.getCorpus(), refPropertyNames);
262
				ReferencePattern ref = ReferencePattern.stringToReferencePattern(this.getCorpus(), refPropertyNames2);
264 263
				if (ref.getProperties().size() > 0) { // ensure the ref properties is well set
265 264
					refPropertyNames = refPropertyNames2;
266 265
				}
......
597 596
		if (to >= nLines) to = nLines - 1;
598 597
		
599 598
		List<? extends Match> matches = queryResult.getMatches(from, to);
600
//		boolean hasTarget = false;
601
//		for (Match m : matches) {
602
//			if (m.getTarget() >= 0) {
603
//				hasTarget = true;
604
//				break;
605
//			}
606
//		}
599
		//		boolean hasTarget = false;
600
		//		for (Match m : matches) {
601
		//			if (m.getTarget() >= 0) {
602
		//				hasTarget = true;
603
		//				break;
604
		//			}
605
		//		}
607 606
		
608 607
		// System.out.println("cqllimit="+cql_limit);
609 608
		// System.out.println("CQLLimitStarts="+CQLLimitStarts);
610 609
		if (pLimitCQL != null && CQLLimitStarts == null) { // initialize text limits
611 610
			try {
612
				Log.fine("Get CQL limit for query=" + pLimitCQL);
613
				CQLLimitStarts = this.getCorpus().getStartLimits(pLimitCQL);
614
				if (CQLLimitStarts.length > 0 && CQLLimitStarts[0] != 0) {
615
					int[] tmp = new int[CQLLimitStarts.length + 1];
616
					System.arraycopy(CQLLimitStarts, 0, tmp, 1, CQLLimitStarts.length);
617
					CQLLimitStarts = tmp;
618
				}
611
//				CorpusCommandPreferences prefs = getProject().getCommandPreferences("concordance");
612
//				if (prefs != null && "list".equals(prefs.get("context_limits_type"))) {
613
//					String str = prefs.get("context_limits");
614
//					TreeSet<Integer> positions = new TreeSet<Integer>();
615
//						String[] ss = str.split(",");
616
//						
617
//						for (String s : ss) {
618
//							int[] tmp = this.getCorpus().getStartLimits("<" + s + "> []");
619
//							for (int i = 0 ; i < tmp.length ; i++) positions.add(tmp[i]);
620
//							tmp = this.getCorpus().getStartLimits("[] </" + s + ">");
621
//							for (int i = 0 ; i < tmp.length ; i++) positions.add(tmp[i]);
622
//						}
623
//						
624
//						CQLLimitStarts = new int[positions.size()];
625
//						int i = 0;
626
//						for (int p : positions) {
627
//							CQLLimitStarts[i] = p;
628
//							i++;
629
//						}
630
//				} else {
631
					Log.fine("Get CQL limit for query=" + pLimitCQL);
632
					CQLLimitStarts = this.getCorpus().getStartLimits(pLimitCQL);
633
					if (CQLLimitStarts.length > 0 && CQLLimitStarts[0] != 0) {
634
						int[] tmp = new int[CQLLimitStarts.length + 1];
635
						System.arraycopy(CQLLimitStarts, 0, tmp, 1, CQLLimitStarts.length);
636
						CQLLimitStarts = tmp;
637
					}
638
//				}
619 639
			}
620 640
			catch (Exception e) {
621 641
				org.txm.utils.logger.Log.printStackTrace(e);
622 642
				Log.severe(NLS.bind(ConcordanceCoreMessages.failedToGetTextsLimitsColonP0, e));
623 643
			}
644
			
624 645
		}
625 646
		
626 647
		int currentCQLLimit = 0;
......
662 683
					currentKeywordPos = match.getStart();
663 684
					currentKeywordEndPos = match.getEnd();
664 685
					
665
//					if (hasTarget) {
666
//						if (Concordance.TARGET_SELECT.equals(pTargetStrategy)) {
667
//							currentKeywordPos = match.getTarget();
668
//							currentKeywordEndPos = match.getTarget();
669
//						} else if (Concordance.TARGET_KEEPLEFT.equals(pTargetStrategy)) {
670
//							currentKeywordPos = match.getStart();
671
//							currentKeywordEndPos = match.getTarget();
672
//						} else if (Concordance.TARGET_KEEPRIGHT.equals(pTargetStrategy)) {
673
//							currentKeywordPos = match.getTarget();
674
//							currentKeywordEndPos = match.getEnd();
675
//						} else if (Concordance.TARGET_SHOW.equals(pTargetStrategy)) {
676
//							currentKeywordPos = match.getStart();
677
//							currentKeywordEndPos = match.getEnd();
678
//						}
679
//					}
686
					//					if (hasTarget) {
687
					//						if (Concordance.TARGET_SELECT.equals(pTargetStrategy)) {
688
					//							currentKeywordPos = match.getTarget();
689
					//							currentKeywordEndPos = match.getTarget();
690
					//						} else if (Concordance.TARGET_KEEPLEFT.equals(pTargetStrategy)) {
691
					//							currentKeywordPos = match.getStart();
692
					//							currentKeywordEndPos = match.getTarget();
693
					//						} else if (Concordance.TARGET_KEEPRIGHT.equals(pTargetStrategy)) {
694
					//							currentKeywordPos = match.getTarget();
695
					//							currentKeywordEndPos = match.getEnd();
696
					//						} else if (Concordance.TARGET_SHOW.equals(pTargetStrategy)) {
697
					//							currentKeywordPos = match.getStart();
698
					//							currentKeywordEndPos = match.getEnd();
699
					//						}
700
					//					}
680 701
					
681 702
					if (CQLLimitStarts != null && currentCQLLimit < CQLLimitStarts.length) {
682 703
						while (currentCQLLimit < CQLLimitStarts.length && CQLLimitStarts[currentCQLLimit] <= currentKeywordPos) { // find the match's text
......
707 728
					// TARGET POSITION
708 729
					
709 730
					
710
//					if (Concordance.TARGET_SELECT.equals(pTargetStrategy) || Concordance.TARGET_KEEPLEFT.equals(pTargetStrategy) || Concordance.TARGET_KEEPRIGHT.equals(pTargetStrategy)) {
711
//						targetPositions.add(match.getTarget());
712
//					} else if (Concordance.TARGET_SHOW.equals(pTargetStrategy)) {
713
						targetPositions.add(match.getTarget());
714
//					}
731
					//					if (Concordance.TARGET_SELECT.equals(pTargetStrategy) || Concordance.TARGET_KEEPLEFT.equals(pTargetStrategy) || Concordance.TARGET_KEEPRIGHT.equals(pTargetStrategy)) {
732
					//						targetPositions.add(match.getTarget());
733
					//					} else if (Concordance.TARGET_SHOW.equals(pTargetStrategy)) {
734
					targetPositions.add(match.getTarget());
735
					//					}
715 736
					
716 737
					// check if the end of keyword pass a text limit
717 738
					currentKeywordPos = currentKeywordEndPos;
TXM/trunk/org.txm.backtomedia.rcp/src/org/txm/backtomedia/commands/function/OpenMediaPlayer.java (revision 3397)
28 28
package org.txm.backtomedia.commands.function;
29 29

  
30 30
import java.io.File;
31
import java.io.UnsupportedEncodingException;
32 31
import java.net.MalformedURLException;
33
import java.net.URLEncoder;
34 32

  
35 33
import org.eclipse.core.commands.AbstractHandler;
36 34
import org.eclipse.core.commands.ExecutionEvent;
37 35
import org.eclipse.core.commands.ExecutionException;
38
import org.eclipse.jface.dialogs.InputDialog;
39
import org.eclipse.jface.util.IPropertyChangeListener;
40
import org.eclipse.jface.util.PropertyChangeEvent;
41 36
import org.eclipse.jface.viewers.IStructuredSelection;
42
import org.eclipse.swt.SWT;
43
import org.eclipse.swt.events.SelectionEvent;
44
import org.eclipse.swt.events.SelectionListener;
45
import org.eclipse.swt.widgets.Button;
46
import org.eclipse.swt.widgets.Composite;
47
import org.eclipse.swt.widgets.Control;
48
import org.eclipse.swt.widgets.FileDialog;
49 37
import org.eclipse.swt.widgets.Shell;
50 38
import org.eclipse.ui.IEditorPart;
51 39
import org.eclipse.ui.IWorkbenchPage;
TXM/trunk/org.txm.groovy.core/src/java/org/txm/groovy/core/GroovyScriptedImportEngine.java (revision 3397)
26 26
import org.txm.objects.Workspace;
27 27
import org.txm.searchengine.cqp.CQPSearchEngine;
28 28
import org.txm.tokenizer.TokenizerClasses;
29
import org.txm.utils.DeleteDir;
29 30
import org.txm.utils.ExecTimer;
30 31
import org.txm.utils.logger.Log;
31 32

  
......
85 86
					TXMResult child = project.getChildren().get(0);
86 87
					child.delete();
87 88
				}
89
				
90
				// clear files
91
				for (File f : project.getProjectDirectory().listFiles()) {
92
					if (".settings".equals(f.getName())) continue;
93
					if (".project".equals(f.getName())) continue;
94
					if (f.isDirectory()) {
95
						DeleteDir.deleteDirectory(f);
96
					} else {
97
						f.delete();
98
					}
99
				}
88 100
				// System.out.println("TXM FILES: " + Arrays.asList(new File(project.getProjectDirectory(), "txm/" + project.getName()).list()));
89 101
			}
90 102
			
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZImporter.groovy (revision 3397)
111 111
		
112 112
		//prepare metadata if any
113 113
		File allMetadataFile = Metadatas.findMetadataFile(inputDirectory);
114
		println "ALLMETADATAFILE="+allMetadataFile
114 115
		if (allMetadataFile.exists()) {
115 116
			File copy = new File(binDir, allMetadataFile.getName())
116 117
			if (!FileCopy.copy(allMetadataFile, copy)) {
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/scripts/filters/Tokeniser/OneTagPerLine.groovy (revision 3397)
33 33
import javax.xml.stream.*;
34 34
import java.net.URL;
35 35
import org.txm.importer.scripts.filters.*;
36
import java.net.URLEncoder;
37 36

  
38 37
// TODO: Auto-generated Javadoc
39 38
/**
......
226 225
									}
227 226
								//replace & by &amp; ; < by &lt; ; insecable space by space
228 227
								chars.append(parser.getText().substring(start).replace("\t", " ").replace("&","&amp;").replace("<","&lt;").replace(" "," ").trim()+ " ");
229
								//String text = URLEncoder.encode(parser.getText().substring(start))
230
								//output.write(text);
231 228
							}
232 229
							break;
233 230
					}
TXM/trunk/org.txm.groovy.core/src/groovy/org/txm/macro/prototypes/cqp/edition/XTZEditionBuilderMacro.groovy (revision 3397)
1
package org.txm.macroproto.edition
2

  
3
// STANDARD DECLARATIONS
4

  
5
import org.kohsuke.args4j.*
6

  
7
import groovy.transform.Field
8

  
9
import org.txm.rcp.swt.widget.parameters.*
10
import org.txm.macro.edition.BuildFacsEditions;
11
import org.txm.macro.edition.RemoveTag;
12
import org.txm.objects.*
13
import org.txm.searchengine.cqp.corpus.*;
14
import org.w3c.dom.*
15
import org.txm.utils.xml.DomUtils
16
import org.txm.Toolbox
17

  
18
import org.w3c.dom.Document;
19
import org.xml.sax.SAXException;
20
import org.txm.rcp.commands.*
21

  
22
import javax.xml.parsers.*;
23
import javax.xml.transform.*;
24
import javax.xml.transform.dom.DOMSource;
25
import javax.xml.transform.stream.StreamResult;
26

  
27
println "Corpus view selection is: "+corpusViewSelection
28
if (!(corpusViewSelection instanceof MainCorpus)) {
29
	println "This marcro works with a MainCorpus selection. Aborting"
30
	return;
31
}
32
def corpus = corpusViewSelection
33
debug = false
34
def editionName = corpus.getDefaultEdition()
35

  
36
// PARAMETERS
37
@Field @Option(name="wordsPerPage", usage="Number of words per page", widget="Integer", required=true, def="500")
38
int wordsPerPage
39
if (!ParametersDialog.open(this)) return;
40
// END OF PARAMETERS
41

  
42
File binDirectory = corpus.getProject().getProjectDirectory()
43
File txmDirectory = new File(binDirectory, "txm/"+corpus.getID().toUpperCase())
44

  
45
File HTMLDirectory = new File(binDirectory, "HTML")
46
File newEditionDirectory = new File(HTMLDirectory, corpus.getID().toUpperCase()+"/"+editionName)
47

  
48
BaseParameters parameters = corpus.getProject().params
49

  
50
if (!HTMLDirectory.exists()) {
51
	println "ERROR: can't find this corpus 'HTML' directory: $HTMLDirectory. Aborting"
52
	return false;
53
}
54

  
55
File workDirectory = txmDirectory
56
if (!workDirectory.exists()) {
57
	println "XML-TXM directory ($txmDirectory) not found. Using XML tokenized directory instead: "+tokenizedDirectory
58
	workDirectory = tokenizedDirectory
59
}
60
if (!workDirectory.exists()) {
61
	println "XML tokenized directory not found: "+tokenizedDirectory
62
	println "Aborting."
63
	return false
64
}
65

  
66
println "Work directory=$workDirectory"
67

  
68
//0- clean previous edition if any : html files, import.xml
69
if (newEditionDirectory.exists()) {
70
	println "** Old version of $editionName edition found."
71
	println " removing the 'edition' reference from the corpus configuration."
72
	File tempParam = new File(binDirectory, "import.xml.cpy")
73
	RemoveTag rt = new RemoveTag(
74
			parameters.root.getOwnerDocument(), // will be updated
75
			null, // don't create a new import.xml
76
			"//edition[@name='$editionName']"
77
			)
78
	println " delete $newEditionDirectory"
79
	newEditionDirectory.deleteDir()
80
	
81
	printDOM(parameters.root.getOwnerDocument())
82
}
83

  
84
//2- fix import.xml
85
println "** Updating corpus configuration..."
86
// for edition list
87
def corpusElem = parameters.getCorpusElement()
88
parameters.addEditionDefinition(corpusElem, editionName, "groovy", "FacsEditionBuilderMacro");
89

  
90
//1- create HTML files
91
println "** Building new edition HTML files..."
92

  
93
println " Creating edition $editionName directory: $newEditionDirectory"
94
newEditionDirectory.mkdir()
95
for (def xmlFile : workDirectory.listFiles()) {
96
	if (xmlFile.isHidden() || xmlFile.isDirectory()) continue // ignore
97
	String txtname = xmlFile.getName()
98
	int idx = txtname.lastIndexOf(".")
99
	if (idx > 0) txtname = txtname.substring(0,idx)
100

  
101
	println " Build HTML pages of text=$txtname"
102
	BuildFacsEditions builder = new BuildFacsEditions(xmlFile, newEditionDirectory, parameters.name, txtname, wordsPerPage);
103
	def newPages = builder.process()
104
	if (newPages == null || newPages.size() == 0) {
105
		println "WARNING: no edition files created with $xmlFile"
106
	} 
107
		
108
	println " Build edition references in corpus configuration"
109
	
110
	Element textElem = corpus.getText(txtname).getSelfElement()
111
	Element editionElem = parameters.addEdition(textElem, editionName, newEditionDirectory.getAbsolutePath(), "html");
112
	//println "$textElem $editionElem"
113
	for (def pagedef : newPages) {
114
		parameters.addPage(editionElem, pagedef[0], pagedef[1]);
115
	}
116
}
117

  
118
	printDOM(parameters.root.getOwnerDocument())
119

  
120
//3- Save and reload the corpus
121
println " Saving corpus configuration..."
122
File paramFile = new File(binDirectory, "import.xml");
123
DomUtils.save(parameters.root.getOwnerDocument(), paramFile);
124

  
125

  
126
//4- Reload Corpora
127
Toolbox.restart();
128
monitor.syncExec(new Runnable() {
129
			public void run() {
130
				println "RELOAD VIEWS"
131
				RestartTXM.reloadViews();
132
				println "RELOAD VIEWS2"
133
			}
134
		});
135

  
136
//5- Done
137
println "New edition created. Be sure to copy images files in $newEditionDirectory"
138

  
139
printDOM(parameters.root.getOwnerDocument())
140

  
141
def printDOM(def doc) {
142
	if (!debug) return;
143
	try {
144
		// Création de la source DOM
145
		Source source = new DOMSource(doc);
146
		
147
		// Création du fichier de sortie
148
		StreamResult resultat = new StreamResult(new PrintWriter(System.out));
149
		
150
		// Configuration du transformer
151
		TransformerFactory fabrique = new net.sf.saxon.TransformerFactoryImpl();
152
		Transformer transformer = fabrique.newTransformer();
153
		transformer.setOutputProperty(OutputKeys.METHOD, "xml"); //$NON-NLS-1$
154
		transformer.setOutputProperty(OutputKeys.INDENT, "yes");  //$NON-NLS-1$
155
		transformer.setOutputProperty(OutputKeys.ENCODING, "UTF-8");  //$NON-NLS-1$
156
		
157
		// Transformation
158
		transformer.transform(source, resultat);
159
		// writer.close();
160
		return true;
161
	} catch (Exception e) {
162
		e.printStackTrace();
163
		return false;
164
	}
165
}
TXM/trunk/org.txm.edition.rcp/src/org/txm/edition/rcp/messages/messages.properties (revision 3397)
52 52

  
53 53
noEditionFound = Edition not found
54 54

  
55
noEditionFoundForTextEqualsP0AndEditionEqualsP1 = No ''{1}'' edition found for text {0}
55
noEditionFoundForTextEqualsP0AndEditionEqualsP1 = No ''{0}'' edition found for text ''{1}''.
56 56

  
57 57
noEditionToOpen = No edition available.
58 58

  
59
noEditionWithNameEqualsP0AvailableForTextEqualsP1 = No "{1}" edition found for text {0}.
59
noEditionWithNameEqualsP0AvailableForTextEqualsP1 = No ''{0}'' edition found for text ''{1}''.
60 60

  
61 61
openingDefaultEditionsColonP0 = Opening [{0}] edition...
62 62

  
TXM/trunk/org.txm.edition.rcp/src/org/txm/edition/rcp/messages/messages_fr.properties (revision 3397)
52 52

  
53 53
noEditionFound = Édition introuvable 
54 54

  
55
noEditionFoundForTextEqualsP0AndEditionEqualsP1 = Aucune édition ''{1}'' trouvée pour le texte ''{0}''
55
noEditionFoundForTextEqualsP0AndEditionEqualsP1 = Aucune édition ''{0}'' trouvée pour le texte ''{1}''.
56 56

  
57 57
noEditionToOpen = Pas d'édition disponible.
58 58

  
59
noEditionWithNameEqualsP0AvailableForTextEqualsP1 = Aucune édition "{1}" trouvée pour le texte {0}.
59
noEditionWithNameEqualsP0AvailableForTextEqualsP1 = Aucune édition ''{0}'' trouvée pour le texte ''{1}''.
60 60

  
61 61
openingDefaultEditionsColonP0 = Ouverture de l'édition [{0}]...
62 62

  
TXM/trunk/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java (revision 3397)
2 2

  
3 3
import java.io.File;
4 4
import java.net.URL;
5
import java.net.URLEncoder;
6 5
import java.util.ArrayList;
7 6
import java.util.Arrays;
8 7
import java.util.Collection;
......
44 43
import org.txm.rcp.StatusLine;
45 44
import org.txm.rcp.editors.CommandLink;
46 45
import org.txm.rcp.utils.IOClipboard;
46
import org.txm.rcp.utils.URLUtils;
47 47
import org.txm.utils.io.IOUtils;
48 48
import org.txm.utils.logger.Log;
49 49

  
......
55 55
	// private List<String> lineids;
56 56
	/** The edition. */
57 57
	Text currentText;
58
	
58 59
	String editionName;
60
	
59 61
	Edition currentEdition;
62
	
60 63
	Page currentPage;
61 64
	
62 65
	protected SynopticEditionEditor synopticEditionEditor;
......
122 125
			// "elt.style.paddingTop=\"1px\";" + //$NON-NLS-1$
123 126
			// "elt.style.paddingBottom=\"1px\";" + //$NON-NLS-1$
124 127
			"} catch (e) { };"; //$NON-NLS-1$
125
	
128
			
126 129
	public static final String highlightscriptRuleFast = "sheet.insertRule(\"#%s {background-color:rgba(%s,%s,%s,%s);}\", 0);"; //$NON-NLS-1$
127 130
	
128 131
	public static final String colorscriptRuleFast = "sheet.insertRule(\"#%s {color:rgba(%s,%s,%s,%s);}\", 0);"; //$NON-NLS-1$
......
259 262
	private ArrayList<ProgressListener> beforeHighlighListeners;
260 263
	
261 264
	public ArrayList<ProgressListener> getBeforeHighlighListeners() {
265
		
262 266
		return beforeHighlighListeners;
263 267
	}
264 268
	
265 269
	private ArrayList<ProgressListener> afterHighlighListeners;
266 270
	
267 271
	public ArrayList<ProgressListener> getAfterHighlighListeners() {
272
		
268 273
		return beforeHighlighListeners;
269 274
	}
270 275
	
271 276
	public Object evaluate(String code) {
277
		
272 278
		if (Log.getLevel().intValue() <= Level.FINEST.intValue()) System.out.println(code);
273 279
		try {
274 280
			if (getBrowser() == null) return null;
275 281
			return getBrowser().evaluate(code);
276
		} catch(Exception e) {
282
		}
283
		catch (Exception e) {
277 284
			String error = e.getMessage();
278
			Log.severe("Browser evaluate error: "+e);
285
			Log.severe("Browser evaluate error: " + e);
279 286
			Log.printStackTrace(e);
280 287
		}
281 288
		return null;
282 289
	}
283 290
	
284 291
	public boolean execute(String code) {
292
		
285 293
		if (Log.getLevel().intValue() <= Level.FINEST.intValue()) System.out.println(code);
286 294
		try {
287 295
			return getBrowser().execute(code);
288
		} catch(Exception e) {
296
		}
297
		catch (Exception e) {
289 298
			String error = e.getMessage();
290
			Log.severe("Browser execute error: "+e);
299
			Log.severe("Browser execute error: " + e);
291 300
			Log.printStackTrace(e);
292 301
		}
293 302
		return false;
294 303
	}
295 304
	
296 305
	public EditionPanel(SynopticEditionEditor synopticEditionEditor, Composite parent, int style, String editionName) {
306
		
297 307
		super(parent, style);
298 308
		this.synopticEditionEditor = synopticEditionEditor;
299 309
		this.editionName = editionName;
300
		//		this.currentEdition = edition;
301
		//		this.currentText = currentEdition.getText();
310
		// this.currentEdition = edition;
311
		// this.currentText = currentEdition.getText();
302 312
		
303 313
		File functionsFile = null;
304 314
		try {
......
323 333
			
324 334
			@Override
325 335
			public synchronized void completed(ProgressEvent event) {
326
				Object o = getBrowser().evaluate("return typeof "+CommandLink.FCT+";");
336
				
337
				Object o = getBrowser().evaluate("return typeof " + CommandLink.FCT + ";");
327 338
				if ("undefined".equals(o)) {
328 339
					new CommandLink(synopticEditionEditor, getBrowser());
329 340
				}
330
				o = getBrowser().evaluate("return typeof "+EditionLink.FCT+";");
341
				o = getBrowser().evaluate("return typeof " + EditionLink.FCT + ";");
331 342
				if ("undefined".equals(o)) {
332 343
					new EditionLink(synopticEditionEditor, getBrowser());
333 344
				}
334 345
				
335
				
336 346
				Object rez = evaluate("return typeof sheet;"); //$NON-NLS-1$
337 347
				if ("undefined".equals(rez)) { //$NON-NLS-1$
338 348
					Object loadResult = evaluate(functions);
......
421 431
							// s = String.format(highlightscriptRule, wordid, composite.r, composite.g, composite.b, composite.a);
422 432
							s = "try { document.getElementById(\"" + wordid + "\").style.backgroundColor=\"rgba(" + composite.r + "," + composite.g + "," + composite.b + "," + composite.a + ")\";" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ //$NON-NLS-6$
423 433
									+
424
									// "elt.style.paddingLeft=\"3px\";" + //$NON-NLS-1$
425
									// "elt.style.paddingRight=\"3px\";" + //$NON-NLS-1$
426
									// "elt.style.paddingTop=\"1px\";" + //$NON-NLS-1$
427
									// "elt.style.paddingBottom=\"1px\";" + //$NON-NLS-1$
434
							// "elt.style.paddingLeft=\"3px\";" + //$NON-NLS-1$
435
							// "elt.style.paddingRight=\"3px\";" + //$NON-NLS-1$
436
							// "elt.style.paddingTop=\"1px\";" + //$NON-NLS-1$
437
							// "elt.style.paddingBottom=\"1px\";" + //$NON-NLS-1$
428 438
									"} catch (e) { };"; //$NON-NLS-1$
429 439
						}
430 440
						else {
......
505 515
						// s = String.format(highlightscriptRule, wordid, composite.r, composite.g, composite.b, composite.a);
506 516
						s = "try { document.getElementById(\"" + wordid + "\").style.fontWeight=\"" + fontWeightPerWordIDS.get(wordid) + "\";" //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
507 517
								+
508
								// "elt.style.paddingLeft=\"3px\";" + //$NON-NLS-1$
509
								// "elt.style.paddingRight=\"3px\";" + //$NON-NLS-1$
510
								// "elt.style.paddingTop=\"1px\";" + //$NON-NLS-1$
511
								// "elt.style.paddingBottom=\"1px\";" + //$NON-NLS-1$
518
						// "elt.style.paddingLeft=\"3px\";" + //$NON-NLS-1$
519
						// "elt.style.paddingRight=\"3px\";" + //$NON-NLS-1$
520
						// "elt.style.paddingTop=\"1px\";" + //$NON-NLS-1$
521
						// "elt.style.paddingBottom=\"1px\";" + //$NON-NLS-1$
512 522
								"} catch (e) { };"; //$NON-NLS-1$
513 523
						// s = String.format(highlightscriptRule, wordid, composite.r, composite.g, composite.b, composite.a);
514 524
						// s = "try { var elt = document.getElementById(\"" + wordid + "\");" + //$NON-NLS-1$ //$NON-NLS-2$
......
590 600
			
591 601
			@Override
592 602
			public void mouseDoubleClick(MouseEvent e) {
603
				
593 604
				if (debug) Log.finest("DOUBLE CLICK"); //$NON-NLS-1$
594 605
				dblClick = true;
595 606
			}
596 607
			
597 608
			@Override
598 609
			public void mouseDown(MouseEvent e) {
610
				
599 611
				if (debug) Log.finest("MOUSE DOWN"); //$NON-NLS-1$
600 612
				dblClick = false;
601 613
				t = e.time;
......
605 617
			
606 618
			@Override
607 619
			public void mouseUp(MouseEvent e) {
620
				
608 621
				if (dblClick) { // doucle click raised by mouseDoubleClick
609 622
					dblClick = false;
610 623
					return; // stop right now ! :-o
......
639 652
			
640 653
			@Override
641 654
			public void keyReleased(KeyEvent e) {
655
				
642 656
				if (debug) Log.finest(" KEY RELEASED: " + e); //$NON-NLS-1$
643 657
			}
644 658
			
645 659
			@Override
646 660
			public void keyPressed(KeyEvent e) {
661
				
647 662
				if (debug) Log.finest(" KEY PRESSED: " + e); //$NON-NLS-1$
648 663
				if (e.keyCode == 'f' && (e.stateMask & SWT.CTRL) != 0) {
649 664
					synopticEditionEditor.getSearchEditionToolbar().openSearch(getTextSelection());
......
661 676
	 */
662 677
	@Override
663 678
	public Browser getBrowser() {
679
		
664 680
		return super.getBrowser();
665 681
	}
666 682
	
......
668 684
	 * Bypass BrowserViewer restriction on the getBrowser method
669 685
	 */
670 686
	public String getDOM() {
687
		
671 688
		return "";// execute("return document.innerHTML"; //$NON-NLS-1$
672 689
	}
673 690
	
674 691
	public ISelectionProvider getSelectionProvider() {
692
		
675 693
		return selProvider;
676 694
	}
677 695
	
678 696
	public void setHighlightWordsById(RGBA color, HashSet<String> wordids) {
697
		
679 698
		for (String wordid : wordids) {
680 699
			if (this.highlightedColorPerWordIDS.get(wordid) != null) {
681 700
				removeHighlightWordsById(color, wordid);
......
687 706
	}
688 707
	
689 708
	public void addHighlightWordsById(RGBA color, String wordid) {
709
		
690 710
		if (!this.highlightedColorPerWordIDS.containsKey(wordid)) {
691 711
			this.highlightedColorPerWordIDS.put(wordid, new ArrayList<RGBA>());
692 712
		}
......
697 717
	 * Can be called to refresh the page word styles but only when the page is loaded
698 718
	 */
699 719
	public void updateWordStyles() {
720
		
700 721
		progressListener.completed(null);
701 722
	}
702 723
	
703 724
	public void addHighlightWordsById(RGBA color, Collection<String> wordids) {
725
		
704 726
		for (String wordid : wordids) {
705 727
			addHighlightWordsById(color, wordid);
706 728
		}
707 729
	}
708 730
	
709 731
	public void removeHighlightWordsById(RGBA color, Collection<String> wordids) {
732
		
710 733
		// System.out.println("Call removeHighlightWordsById: "+wordids+" color="+color);
711 734
		StringBuffer buffer = new StringBuffer();
712 735
		for (String wordid : wordids) {
......
720 743
	}
721 744
	
722 745
	public void removeHighlightWordsById(RGBA color, String wordid) {
746
		
723 747
		if (highlightedColorPerWordIDS.get(wordid) == null) return; // nothing to do
724 748
		
725 749
		// System.out.println("remove color="+color+" from id="+wordid);
......
738 762
	 */
739 763
	public boolean backToText(Text text, String line_wordid) {
740 764
		
741
		//String name = currentEdition.getName();
765
		// String name = currentEdition.getName();
742 766
		Edition edition = text.getEdition(editionName);
743 767
		
744 768
		if (edition == null) {
......
768 792
	 * First page.
769 793
	 */
770 794
	public void firstPage() {
795
		
796
		if (currentEdition == null) return;
797
		
771 798
		// System.out.println(Messages.TxmBrowser_1+currentPage);
772 799
		currentPage = currentEdition.getFirstPage();
773 800
		currentText = currentEdition.getText();
......
783 810
	
784 811
	@Override
785 812
	public void setURL(String url) {
813
		
786 814
		if (!this.browser.isDisposed()) {
787
			int begin = url.indexOf(":/");
788
			String start = url.substring(0, begin);
789
			String end = URLEncoder.encode(url.substring(begin+2));
790
			super.setURL(start+":/"+end);
815
			super.setURL(URLUtils.encodeURL(url));
791 816
		}
792 817
	}
793 818
	
......
796 821
	 */
797 822
	public void lastPage() {
798 823
		// System.out.println(Messages.TxmBrowser_2+currentPage);
824
		if (currentEdition == null) return;
799 825
		
800 826
		if (currentPage != null && currentPage.getFile().equals(currentEdition.getLastPage().getFile())) {
801 827
			return;
......
809 835
	 * Previous page.
810 836
	 */
811 837
	public void previousPage() {
838
		
839
		if (currentEdition == null) return;
840
		
812 841
		// System.out.println(Messages.TxmBrowser_3+currentPage);
813 842
		if (currentPage != null) {
814 843
			Page previous = currentEdition.getPreviousPage(currentPage);
......
834 863
	 * Next page.
835 864
	 */
836 865
	public void nextPage() {
866
		
867
		if (currentEdition == null) return;
868
		
837 869
		// System.out.println(Messages.TxmBrowser_4+currentPage);
838 870
		if (currentPage != null) {
839 871
			Page next = currentEdition.getNextPage(currentPage);
......
854 886
	
855 887
	
856 888
	public void firstText() {
889
		
857 890
		// Text current = this.currentPage.getEdition().getText();
858 891
		Project project = currentText.getProject();
859 892
		String id;
......
888 921
	 * Next text.
889 922
	 */
890 923
	public void lastText() {
924
		
891 925
		// Text current = this.currentPage.getEdition().getText();
892 926
		Project project = currentText.getProject();
893 927
		String id;
......
981 1015
	 * Next text.
982 1016
	 */
983 1017
	public void nextText() {
1018
		
984 1019
		// Text current = this.currentPage.getEdition().getText();
985 1020
		Project project = currentText.getProject();
986 1021
		String id;
......
1027 1062
	
1028 1063
	
1029 1064
	public void setText(Text text, boolean refresh) {
1030
		//String editionName = currentEdition.getName();
1065
		
1066
		// String editionName = currentEdition.getName();
1031 1067
		Edition tmp = text.getEdition(this.editionName);
1032 1068
		if (tmp == null) {
1033 1069
			System.out.println(EditionUIMessages.bind(EditionUIMessages.noEditionWithNameEqualsP0AvailableForTextEqualsP1, this.editionName, text.getName()));
......
1055 1091
	 * @return the current page
1056 1092
	 */
1057 1093
	public Page getCurrentPage() {
1094
		
1058 1095
		return currentPage;
1059 1096
	}
1060 1097
	
......
1064 1101
	 * @return the current page
1065 1102
	 */
1066 1103
	public Text getCurrentText() {
1104
		
1067 1105
		return currentText;
1068 1106
	}
1069 1107
	
......
1073 1111
	 * @return the string
1074 1112
	 */
1075 1113
	public String makePageLabel() {
1114
		
1076 1115
		return currentPage.getName() + " / " + currentPage.getEdition().getNumPages(); //$NON-NLS-1$
1077 1116
	}
1078 1117
	
......
1082 1121
	 * @param page the page
1083 1122
	 */
1084 1123
	public void showPage(Page page) {
1124
		
1125
		if (currentEdition == null) return;
1085 1126
		// System.out.println("SHOW PAGE "+page);
1086 1127
		currentEdition = page.getEdition();
1087 1128
		currentText = currentEdition.getText();
......
1093 1134
	 * Reload the browser with the currentPage URL
1094 1135
	 */
1095 1136
	public void reloadPage() {
1137
		
1096 1138
		this.setURL(currentPage.toURL());
1097 1139
	}
1098 1140
	
......
1123 1165
			"return html"; //$NON-NLS-1$
1124 1166
	
1125 1167
	public String getTextSelectionDOM() {
1168
		
1126 1169
		String t = ((String) evaluate(SCRIPT01));
1127 1170
		Log.finest("HTML text selection=" + t);
1128 1171
		return t;
......
1168 1211
				+ "\n}" //$NON-NLS-1$
1169 1212
				// +"alert('result='+all)"
1170 1213
				+ "\nreturn all;"; //$NON-NLS-1$
1171
		
1214
				
1172 1215
		// System.out.println(functions);
1173 1216
		// System.out.println(SCRIPT02_getspans);
1174 1217
		
......
1197 1240
	}
1198 1241
	
1199 1242
	public String getTextSelection() {
1243
		
1200 1244
		// System.out.println("DOM="+getTextSelectionDOM());
1201 1245
		String dom = getTextSelectionDOM();
1202 1246
		if (dom == null) return "";
......
1211 1255
	
1212 1256
	@Override
1213 1257
	public ISelection getSelection() {
1258
		
1214 1259
		return new SynopticTextSelection(this);
1215 1260
	}
1216 1261
	
......
1226 1271
		String str;
1227 1272
		
1228 1273
		public SynopticTextSelection(EditionPanel panel) {
1274
			
1229 1275
			this.str = panel.getTextSelection();
1230 1276
		}
1231 1277
		
1232 1278
		@Override
1233 1279
		public boolean isEmpty() {
1280
			
1234 1281
			return str != null && str.length() > 0;
1235 1282
		}
1236 1283
		
1237 1284
		public String getTextSelection() {
1285
			
1238 1286
			return str;
1239 1287
		}
1240 1288
	}
1241 1289
	
1242 1290
	public Edition getEdition() {
1291
		
1243 1292
		return currentEdition;
1244 1293
	}
1245 1294
	
1246 1295
	public MenuManager getMenuManager() {
1296
		
1247 1297
		return menuManager;
1248 1298
	}
1249 1299
	
1250 1300
	public void initMenu() {
1301
		
1251 1302
		// create a new menu
1252 1303
		menuManager = new MenuManager();
1253 1304
		
......
1257 1308
			
1258 1309
			@Override
1259 1310
			public void menuShown(MenuEvent e) {
1311
				
1260 1312
				Menu menu = menuManager.getMenu();
1261 1313
				if (menu == null) return;
1262 1314
				new MenuItem(menu, SWT.SEPARATOR);
......
1267 1319
					
1268 1320
					@Override
1269 1321
					public void widgetSelected(SelectionEvent e) {
1322
						
1270 1323
						String text = EditionPanel.this.getTextSelection();
1271 1324
						synopticEditionEditor.getSearchEditionToolbar().openSearch(text);
1272 1325
					}
......
1281 1334
					
1282 1335
					@Override
1283 1336
					public void widgetSelected(SelectionEvent e) {
1337
						
1284 1338
						String text = EditionPanel.this.getTextSelection();
1285 1339
						if (text != null && text.length() > 0) {
1286 1340
							IOClipboard.write(text);
......
1299 1353
					
1300 1354
					@Override
1301 1355
					public void widgetSelected(SelectionEvent e) {
1356
						
1302 1357
						EditionPanel.this.getBrowser().refresh();
1303 1358
					}
1304 1359
					
......
1311 1366
					
1312 1367
					@Override
1313 1368
					public void widgetSelected(SelectionEvent e) {
1369
						
1314 1370
						EditionPanel.this.getBrowser().back();
1315 1371
					}
1316 1372
					
......
1323 1379
					
1324 1380
					@Override
1325 1381
					public void widgetSelected(SelectionEvent e) {
1382
						
1326 1383
						EditionPanel.this.getBrowser().forward();
1327 1384
					}
1328 1385
					
......
1356 1413
	}
1357 1414
	
1358 1415
	public void initSelectionProvider() {
1416
		
1359 1417
		selProvider = new ISelectionProvider() {
1360 1418
			
1361 1419
			@Override
......
1366 1424
			
1367 1425
			@Override
1368 1426
			public ISelection getSelection() {
1427
				
1369 1428
				ITextSelection sel = new ITextSelection() {
1370 1429
					
1371 1430
					@Override
1372 1431
					public boolean isEmpty() {
1432
						
1373 1433
						return EditionPanel.this.getTextSelection().length() == 0;
1374 1434
					}
1375 1435
					
1376 1436
					@Override
1377 1437
					public String getText() {
1438
						
1378 1439
						return EditionPanel.this.getTextSelection();
1379 1440
					}
1380 1441
					
1381 1442
					@Override
1382 1443
					public int getStartLine() {
1444
						
1383 1445
						return 0;
1384 1446
					}
1385 1447
					
1386 1448
					@Override
1387 1449
					public int getOffset() {
1450
						
1388 1451
						return 0;
1389 1452
					}
1390 1453
					
1391 1454
					@Override
1392 1455
					public int getLength() {
1456
						
1393 1457
						return 0;
1394 1458
					}
1395 1459
					
1396 1460
					@Override
1397 1461
					public int getEndLine() {
1462
						
1398 1463
						return 0;
1399 1464
					}
1400 1465
				};
......
1409 1474
	
1410 1475
	
1411 1476
	public void goToPage(String text, String name) {
1477
		
1412 1478
		if (text != null) {
1413 1479
			Text newText = this.synopticEditionEditor.getCorpus().getProject().getText(text);
1414 1480
			if (newText == null) {
......
1431 1497
	}
1432 1498
	
1433 1499
	public void setFocusedWordID(String focusid) {
1500
		
1434 1501
		this.focusedWordID = focusid;
1435 1502
	}
1436 1503
	
1437 1504
	public void setHighlightedArea(HashSet<int[]> positions) {
1505
		
1438 1506
		Log.finer("Highlight area: not implemented");
1439 1507
	}
1440 1508
	
1441 1509
	public void expandSelectionTo(String[] ids) {
1510
		
1442 1511
		// expand selection
1443 1512
		if (ids == null) return;
1444 1513
		if (ids.length == 0) return;
......
1468 1537
				+ "sel.addRange(range);\n" //$NON-NLS-1$
1469 1538
				+ "\n" //$NON-NLS-1$
1470 1539
				+ "return null;"; //$NON-NLS-1$
1471
		
1540
				
1472 1541
		// System.out.println("Eval...\n"+SCRIPT02_expand);
1473 1542
		evaluate(SCRIPT02_expand);
1474 1543
		return;
1475 1544
	}
1476 1545
	
1477 1546
	public void addFontWeightWordsById(String weight, List<String> wordids) {
1547
		
1478 1548
		for (String wordid : wordids) {
1479 1549
			addFontWeightWordsById(weight, wordid);
1480 1550
		}
1481 1551
	}
1482 1552
	
1483 1553
	public void addFontWeightWordsById(String weight, String wordid) {
1554
		
1484 1555
		this.fontWeightPerWordIDS.put(wordid, weight);
1485 1556
	}
1486 1557
	
1487 1558
	public void removeFontWeightWordsById(String wordid) {
1559
		
1488 1560
		this.fontWeightPerWordIDS.remove(wordid);
1489 1561
	}
1490 1562
	
1491 1563
	public void removeFontWeightWordsById(List<String> wordids) {
1564
		
1492 1565
		for (String wordid : wordids) {
1493 1566
			removeFontWeightWordsById(wordid);
1494 1567
		}
TXM/trunk/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java (revision 3397)
131 131
	public Text getResult() {
132 132
		
133 133
		for (EditionPanel panel : editionPanels.values()) {
134
			return panel.getCurrentText();
134
			if (panel.getCurrentText() != null) {
135
				return panel.getCurrentText();
136
			}
135 137
		}
136 138
		
137 139
		if (textIdToOpen != null) {

Formats disponibles : Unified diff