Révision 3251

tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationExtension.java (revision 3251)
11 11
import org.eclipse.core.runtime.IStatus;
12 12
import org.eclipse.core.runtime.Platform;
13 13
import org.eclipse.core.runtime.Status;
14
import org.eclipse.jface.dialogs.MessageDialog;
14 15
import org.eclipse.swt.SWT;
15 16
import org.eclipse.swt.events.SelectionEvent;
16 17
import org.eclipse.swt.events.SelectionListener;
......
32 33
import org.txm.utils.logger.Log;
33 34

  
34 35
public class AnnotationExtension extends TXMEditorExtension<TXMResult> {
35

  
36
	
36 37
	/** The annotation area. */
37 38
	protected ArrayList<AnnotationArea> annotationAreas = new ArrayList<>();
38

  
39
	
39 40
	private Group controlArea;
40

  
41
	
41 42
	private SelectionListener defaultListener;
42

  
43
	
43 44
	private ToolItem saveButton;
44

  
45
	
45 46
	public static final String GROUP_NAME = "Annotation";
46

  
47
	
47 48
	@Override
48 49
	public String getName() {
49 50
		return GROUP_NAME;
50 51
	}
51

  
52
	
52 53
	/**
53 54
	 * use this to enable/disable the button
54 55
	 * 
......
57 58
	public ToolItem getSaveButton() {
58 59
		return saveButton;
59 60
	}
60

  
61
	
61 62
	/**
62 63
	 * install the annotation start button and dropdown list
63 64
	 */
64 65
	@Override
65 66
	public void notifyEndOfCreatePartControl() throws Exception {
66

  
67
		
67 68
		IConfigurationElement[] config = Platform.getExtensionRegistry().getConfigurationElementsFor(AnnotationArea.class.getName());
68 69
		Arrays.sort(config, new Comparator<IConfigurationElement>() {
69

  
70
			
70 71
			@Override
71 72
			public int compare(IConfigurationElement o1, IConfigurationElement o2) {
72 73
				return o1.getAttribute("position").compareTo(o2.getAttribute("position"));
73 74
			}
74 75
		});
75

  
76
		
76 77
		ArrayList<String> modes = new ArrayList<>();
77 78
		ArrayList<SelectionListener> listeners = new ArrayList<>();
78 79
		for (final IConfigurationElement celement : config) {
79 80
			try {
80 81
				Object o = celement.createExecutableExtension("class"); //$NON-NLS-1$
81 82
				AnnotationArea aa = (AnnotationArea) o;
82

  
83
				
83 84
				if (!aa.getAnnotatedTXMResultClass().equals(editor.getResult().getClass())) {
84 85
					continue;
85 86
				}
86 87
				Log.finer("Installing AnnotationExtension: " + aa.getName());
87 88
				modes.add(aa.getName()); // get the annotation name
88

  
89
				
89 90
				listeners.add(new SelectionListener() { // create alistener to instantiate a new AnnotationArea
90

  
91
					
91 92
					@Override
92 93
					public void widgetSelected(SelectionEvent e) {
93 94
						try {
......
99 100
							e1.printStackTrace();
100 101
						}
101 102
					}
102

  
103
					
103 104
					@Override
104 105
					public void widgetDefaultSelected(SelectionEvent e) {}
105 106
				});
......
108 109
				exx.printStackTrace();
109 110
			}
110 111
		}
111

  
112
		
112 113
		if (modes.size() == 0) {
113 114
			return; // no need to show the buttons
114 115
		}
115

  
116
		
116 117
		SelectionListener openCloseSelectionListener = new SelectionListener() {
117

  
118
			
118 119
			@Override
119 120
			public void widgetSelected(SelectionEvent e) {
120 121
				// if (editor.getTopToolbar().isVisible(GROUP_NAME)) {
......
125 126
				// else {
126 127
				// annotationAreas.clear();
127 128
				// }
128

  
129
				
129 130
				if (annotationAreas.size() == 0) { // if no annotation mode is opened, opens the default mode
130 131
					openDefaultAnnotationMode(e);
131 132
				}
132 133
			}
133

  
134
			
134 135
			@Override
135 136
			public void widgetDefaultSelected(SelectionEvent e) {}
136 137
		};
137

  
138
		
138 139
		defaultListener = listeners.get(0);
139 140
		String defaultMode = modes.get(0);
140 141
		controlArea = editor.getTopToolbar().installAlternativesGroup(GROUP_NAME, AnnotationUIMessages.annotateWordProperty,
......
142 143
				"platform:/plugin/org.txm.rcp/icons/functions/pencil_close.png", false,
143 144
				openCloseSelectionListener, modes, listeners);
144 145
		controlArea.setLayout(new GridLayout(1, true));
145

  
146
		
146 147
		saveButton = new ToolItem(editor.getTopToolbar(), SWT.PUSH);
147
		saveButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL_SAVE));
148
		saveButton.setText("Save annotations");
149
		//saveButton.setImage(IImageKeys.getImage(IImageKeys.PENCIL_SAVE));
148 150
		saveButton.addSelectionListener(new SelectionListener() {
149

  
151
			
150 152
			@Override
151 153
			public void widgetSelected(SelectionEvent e) {
152 154
				try {
......
157 159
					e1.printStackTrace();
158 160
				}
159 161
			}
160

  
162
			
161 163
			@Override
162 164
			public void widgetDefaultSelected(SelectionEvent e) {}
163 165
		});
164 166
		saveButton.setEnabled(false);
165 167
	}
166

  
168
	
167 169
	public void closeAreasPanel() {
168 170
		editor.getTopToolbar().setVisible(GROUP_NAME, false);
169 171
		editor.getTopToolbar().getOpenCloseButton().setSelection(false);
170 172
		saveButton.setEnabled(false);
171 173
	}
172

  
174
	
173 175
	public void openAnnotationMode(AnnotationArea aa, int position) throws Exception {
174 176
		// AnnotationArea aa = (AnnotationArea)o;
175 177
		if (!aa.allowMultipleAnnotations()) {
......
181 183
			removed.addAll(closeAllAreas(aa.getClass()));
182 184
			annotationAreas.removeAll(removed);
183 185
		}
184

  
186
		
185 187
		// System.out.println("Starting "+aa.getName());
186

  
188
		
187 189
		aa.install(editor, AnnotationExtension.this, controlArea, position);
188

  
190
		
189 191
		editor.getTopToolbar().setVisible(GROUP_NAME, true);
190 192
		annotationAreas.add(aa);
191 193
		editor.refresh(false); // refresh the concordance display
192 194
	}
193

  
195
	
194 196
	/**
195 197
	 * 
196 198
	 * @param areaToAvoid
......
208 210
		}
209 211
		return removed;
210 212
	}
211

  
213
	
212 214
	public void closeArea(AnnotationArea area, boolean closeExtensionIfEmpty) {
213 215
		if (area != null && !area.getAnnotationArea().isDisposed()) {
214 216
			area.getAnnotationArea().dispose();
215 217
		}
216 218
		area._close();
217

  
219
		
218 220
		this.annotationAreas.remove(area);
219 221
		if (this.annotationAreas.size() == 0 && closeExtensionIfEmpty) {
220 222
			this.closeAreasPanel();
221 223
		}
222 224
	}
223

  
225
	
224 226
	protected void openDefaultAnnotationMode(SelectionEvent e) {
225 227
		defaultListener.widgetSelected(e);
226 228
	}
227

  
229
	
228 230
	@Override
229 231
	public void notifyStartOfCompute() throws Exception {
230 232
		for (AnnotationArea aa : annotationAreas) {
231 233
			aa.notifyStartOfCompute();
232 234
		}
233 235
	}
234

  
236
	
235 237
	@Override
236 238
	public void notifyEndOfCompute() throws Exception {
237 239
		for (AnnotationArea aa : annotationAreas) {
238 240
			aa.notifyEndOfCompute();
239 241
		}
240 242
	}
241

  
242

  
243
	
244
	
243 245
	public boolean isAnnotationEnable() {
244 246
		return annotationAreas != null;
245 247
	}
246

  
248
	
247 249
	@Override
248 250
	public void notifyEndOfRefresh() throws Exception {
249 251
		for (AnnotationArea aa : annotationAreas) {
250 252
			aa.notifyEndOfRefresh();
251 253
		}
252 254
	}
253

  
255
	
254 256
	@Override
255 257
	public void notifyStartOfCreatePartControl() throws Exception {
256 258
		for (AnnotationArea aa : annotationAreas) {
257 259
			aa.notifyStartOfCreatePartControl();
258 260
		}
259 261
	}
260

  
262
	
261 263
	@Override
262 264
	public void notifyStartOfRefresh() throws Exception {
263 265
		for (AnnotationArea aa : annotationAreas) {
264 266
			aa.notifyStartOfRefresh();
265 267
		}
266 268
	}
267

  
269
	
268 270
	@Override
269 271
	public boolean isDirty() throws Exception {
270 272
		boolean dirty = false;
......
273 275
		}
274 276
		return dirty;
275 277
	}
276

  
278
	
277 279
	@Override
278 280
	public boolean isSaveOnCloseNeeded() throws Exception {
279 281
		return true;
280 282
	}
281

  
283
	
282 284
	@Override
283 285
	public void notifyDoSave() throws Exception {
284

  
286
		
285 287
		//		if (needToUpdateIndexes) {
286 288
		JobHandler job = new JobHandler("Updating corpus indexes and editions", true) {
287

  
289
			
288 290
			@Override
289 291
			protected IStatus run(IProgressMonitor monitor) {
290

  
292
				
291 293
				this.runInit(monitor);
292

  
294
				
293 295
				try {
294 296
					monitor.setTaskName("Updating corpus XML-TXM files");
295

  
297
					
296 298
					Log.info("Saving annotations...");
297 299
					boolean needToUpdateIndexes = false;
298 300
					// System.out.println("Saving annotations...");
......
311 313
						if (corpus != null && UpdateCorpus.update(corpus) != null) {
312 314
							monitor.worked(50);
313 315
							this.syncExec(new Runnable() {
314

  
316
								
315 317
								@Override
316 318
								public void run() {
317 319
									Log.info("Done.");
......
331 333
						}
332 334
					} else {
333 335
						this.syncExec(new Runnable() {
334

  
336
							
335 337
							@Override
336 338
							public void run() {
337 339
								Log.info("Done.");
......
351 353
		job.schedule();
352 354
		//		}
353 355
	}
354

  
356
	
355 357
	@Override
356 358
	public void notifyDispose() throws Exception {
359
		
360
		//FIXME MD: I have to do this because Eclipse is not asking for editor saves before exiting the app - BUG
361
		try {
362
			boolean annotationsDirty = false;
363
			for (AnnotationArea aa : annotationAreas) {
364
				annotationsDirty = annotationsDirty || aa.isDirty();
365
			}
366
			if (annotationsDirty) {
367
				boolean doSave = MessageDialog.openQuestion(this.editor.getShell(), "Annotations not saved", "Do you want to save the annotations before closing the editor?");
368
				if (doSave) {
369
					notifyDoSave();
370
				}
371
			}
372
		} catch(Exception e) {
373
			e.printStackTrace();
374
		}
375
		
357 376
		for (AnnotationArea aa : annotationAreas) {
358 377
			aa._close();
359 378
		}
360 379
	}
361

  
380
	
362 381
	public void layout() {
363 382
		if (!controlArea.isDisposed()) {
364 383
			editor.layout(true);
365 384
		}
366 385
	}
367

  
386
	
368 387
	public int getNumberOfAnnotationArea() {
369 388
		return annotationAreas.size();
370 389
	}
371

  
390
	
372 391
	@Override
373 392
	public Set<Class<? extends TXMResult>> getTXMResultValidClasses() {
374 393
		HashSet<Class<? extends TXMResult>> h = new HashSet<>();
......
376 395
		h.add(Text.class);
377 396
		return h;
378 397
	}
379

  
380

  
398
	
399
	
381 400
}
tmp/org.txm.properties.core/src/org/txm/properties/core/preferences/PropertiesPreferences.java (revision 3251)
26 26
		super.initializeDefaultPreferences();
27 27
		Preferences preferences = DefaultScope.INSTANCE.getNode(getPreferencesNodeQualifier());
28 28
		
29
		preferences.putInt(MAX_PROPERTIES_TO_DISPLAY, 100);
29
		preferences.putInt(MAX_PROPERTIES_TO_DISPLAY, 10);
30 30
		
31 31
	}
32 32
	
tmp/org.txm.properties.core/src/org/txm/properties/core/functions/CorpusPropertiesComputer.java (revision 3251)
1 1
package org.txm.properties.core.functions;
2 2

  
3
import java.io.IOException;
3 4
import java.text.NumberFormat;
4 5
import java.util.ArrayList;
5 6
import java.util.Arrays;
6 7
import java.util.Collections;
8
import java.util.Comparator;
7 9
import java.util.HashMap;
8 10
import java.util.LinkedHashMap;
9 11
import java.util.LinkedHashSet;
......
16 18
import org.txm.objects.Project;
17 19
import org.txm.properties.core.messages.PropertiesCoreMessages;
18 20
import org.txm.searchengine.cqp.AbstractCqiClient;
21
import org.txm.searchengine.cqp.CQPSearchEngine;
19 22
import org.txm.searchengine.cqp.clientExceptions.CqiClientException;
20 23
import org.txm.searchengine.cqp.corpus.CQPCorpus;
21 24
import org.txm.searchengine.cqp.corpus.CorpusManager;
22 25
import org.txm.searchengine.cqp.corpus.MainCorpus;
23 26
import org.txm.searchengine.cqp.corpus.Property;
27
import org.txm.searchengine.cqp.corpus.QueryResult;
24 28
import org.txm.searchengine.cqp.corpus.StructuralUnit;
25 29
import org.txm.searchengine.cqp.corpus.StructuralUnitProperty;
26 30
import org.txm.searchengine.cqp.corpus.WordProperty;
31
import org.txm.searchengine.cqp.corpus.query.CQLQuery;
27 32
import org.txm.searchengine.cqp.corpus.query.Match;
33
import org.txm.searchengine.cqp.serverException.CqiServerError;
28 34
import org.txm.utils.TXMProgressMonitor;
29 35
import org.txm.utils.logger.Log;
30 36

  
......
209 215
				}
210 216
			}
211 217
		}
218
		
219
		HashMap<String, org.txm.utils.Tuple<Integer>> firstPositionOfStructures = new HashMap<>();
220
		for (String su : internalArchitecture) {
221
			try {
222
				QueryResult r = result.query(new CQLQuery("<"+su+">[]+ </"+su+"> cut 1"), "tmp", false);
223
				firstPositionOfStructures.put(su, new org.txm.utils.Tuple<Integer>(r.getStarts()[0], r.getEnds()[0]));
224
			}
225
			catch (Exception e) {
226
				e.printStackTrace();
227
				firstPositionOfStructures.put(su, new org.txm.utils.Tuple<Integer>(Integer.MAX_VALUE, 0));
228
			}
229
		}
230
		System.out.println(firstPositionOfStructures);
231
		internalArchitecture.sort(new Comparator<String>() {
232

  
233
			@Override
234
			public int compare(String arg0, String arg1) {
235
				
236
				int r = firstPositionOfStructures.get(arg0).a - firstPositionOfStructures.get(arg1).a;
237
				if (r == 0) {
238
					return -(firstPositionOfStructures.get(arg0).b - firstPositionOfStructures.get(arg1).b);
239
				}
240
				return r;
241
			}
242
		});
212 243
	}
213 244
	
214 245
	/**
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationWriter.java (revision 3251)
48 48
			Log.severe(NLS.bind("** Error: no knowledge repository found in {0} corpus.", corpus));
49 49
			throw new IllegalArgumentException("No kr in " + corpus);
50 50
		}
51
		String t = krnames.get(0);
52
		defaultKR = KRAnnotationEngine.getKnowledgeRepository(corpus, t);
51
		String firtsKRName = krnames.get(0);
52
		defaultKR = KRAnnotationEngine.getKnowledgeRepository(corpus, firtsKRName);
53 53
		if (defaultKR == null) {
54 54
			Log.severe(NLS.bind("** Error: no knowledge repository {0} found in {0} corpus.", defaultKR, corpus));
55 55
			throw new IllegalArgumentException("No kr " + defaultKR + " in " + corpus);
56 56
		}
57
		types = defaultKR.getAllAnnotationTypes();
58 57
		
58
		types = new ArrayList<AnnotationType>();
59
		for (AnnotationType type : defaultKR.getAllAnnotationTypes()) {
60
			if (type.getEffect().equals(AnnotationEffect.SEGMENT)) {
61
				types.add(type);
62
			}
63
		}
59 64
	}
60 65
	
61 66
	/**
tmp/org.txm.groovy.core/src/groovy/org/txm/scripts/importer/xtz/XTZImporter.groovy (revision 3251)
235 235
			cpb.tick()
236 236
			
237 237
			for (File inputFile : filesToProcess) {
238
				File outputFile = File.createTempFile("tmp", inputFile.getName(),inputFile.getParentFile());
238
				File outputFile = new File(inputFile.getParentFile(), "tmp"+inputFile.getName());
239 239
				println "$inputFile, 'text', $wordTag, $milestone, $outputFile"
240 240
				MileStoneProjection msp = new MileStoneProjection(inputFile, "text", wordTag, milestone)
241 241
				if (!msp.process(outputFile)) {
242
					println "Fail to encode $milestone in $inputFile"
242
					println "** Fail to encode $milestone in $inputFile"
243 243
					return false
244 244
				} else {
245 245
					if (inputFile.delete()) {
246
						FileCopy.copy(outputFile, inputFile)
247
						//outputFile.renameTo(inputFile)
246
						if (!FileCopy.copy(outputFile, inputFile)) {
247
							println "** Fail to copy $outputFile to ${inputFile}."
248
							return false
249
						}
250
						if (!outputFile.delete()) {
251
							println "** Fail to delete $outputFile temporary file."
252
							return false
253
						}
248 254
					} else {
249 255
						println "Fail to encode $milestone in ${inputFile}: could not replace the file with the $outputFile file."
250 256
						return false
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/EditionPanel.java (revision 3251)
54 54
	// private List<String> lineids;
55 55
	/** The edition. */
56 56
	Text currentText;
57
	
57
	String editionName;
58 58
	Edition currentEdition;
59
	
60 59
	Page currentPage;
61 60
	
62 61
	protected SynopticEditionEditor synopticEditionEditor;
......
278 277
		return getBrowser().execute(code);
279 278
	}
280 279
	
281
	public EditionPanel(SynopticEditionEditor synopticEditionEditor, Composite parent, int style, Edition edition) {
280
	public EditionPanel(SynopticEditionEditor synopticEditionEditor, Composite parent, int style, String editionName) {
282 281
		super(parent, style);
283 282
		this.synopticEditionEditor = synopticEditionEditor;
284
		this.currentEdition = edition;
285
		this.currentText = currentEdition.getText();
283
		this.editionName = editionName;
284
//		this.currentEdition = edition;
285
//		this.currentText = currentEdition.getText();
286 286
		
287 287
		File functionsFile = null;
288 288
		try {
......
291 291
			URL r = FileLocator.resolve(fileURL);
292 292
			Log.fine("Load JS functions from: " + r);
293 293
			functions = IOUtils.getText(r, "UTF-8"); //$NON-NLS-1$
294
			
295 294
		}
296 295
		catch (Exception e) {
297 296
			Log.severe(EditionUIMessages.bind(EditionUIMessages.error_while_reading, functionsFile, e.getLocalizedMessage()));
......
714 713
	 */
715 714
	public boolean backToText(Text text, String line_wordid) {
716 715
		
717
		String name = currentEdition.getName();
718
		Edition edition = text.getEdition(name);
716
		//String name = currentEdition.getName();
717
		Edition edition = text.getEdition(editionName);
719 718
		
720 719
		if (edition == null) {
721
			String s = EditionUIMessages.bind(EditionUIMessages.noEditionFoundForTextEqualsP0AndEditionEqualsP1, text, name);
722
			System.out.println(s);
720
			String s = EditionUIMessages.bind(EditionUIMessages.noEditionFoundForTextEqualsP0AndEditionEqualsP1, text, editionName);
721
			Log.warning(s);
723 722
			StatusLine.setMessage(s);
724 723
			Log.severe(s);
725 724
		}
......
731 730
			else {
732 731
				openedPage = edition.getFirstPage();
733 732
			}
734
			if (openedPage == null || !openedPage.equals(currentPage)) {
733
			if (currentPage == null || !openedPage.equals(currentPage)) {
735 734
				this.showPage(openedPage);
736 735
				return true;
737 736
			}
......
1000 999
	
1001 1000
	
1002 1001
	public void setText(Text text, boolean refresh) {
1003
		String editionName = currentEdition.getName();
1004
		Edition tmp = text.getEdition(editionName);
1002
		//String editionName = currentEdition.getName();
1003
		Edition tmp = text.getEdition(this.editionName);
1005 1004
		if (tmp == null) {
1006
			System.out.println(EditionUIMessages.bind(EditionUIMessages.noEditionWithNameEqualsP0AvailableForTextEqualsP1, editionName, text.getName()));
1005
			System.out.println(EditionUIMessages.bind(EditionUIMessages.noEditionWithNameEqualsP0AvailableForTextEqualsP1, this.editionName, text.getName()));
1007 1006
			return;
1008 1007
		}
1009 1008
		
1010 1009
		currentEdition = tmp;
1011
		currentPage = currentEdition.getFirstPage();
1010
		
1012 1011
		currentText = text;
1013
		if (currentPage == null) {
1014
			StatusLine.setMessage("No text next"); //$NON-NLS-1$
1015
			return;
1016
		}
1017 1012
		
1018 1013
		if (refresh) {
1014
			currentPage = currentEdition.getFirstPage();
1015
			if (currentPage == null) {
1016
				StatusLine.setMessage("No text next"); //$NON-NLS-1$
1017
				return;
1018
			}
1019 1019
			reloadPage();
1020 1020
		}
1021 1021
		// page_label.setText(makePageLabel());
......
1377 1377
	
1378 1378
	
1379 1379
	
1380
	public void goToPage(String name) {
1380
	public void goToPage(String text, String name) {
1381
		Text newText = this.synopticEditionEditor.getCorpus().getProject().getText(text);
1382
		if (newText == null) {
1383
			return;
1384
		}
1385
		if (!newText.equals(currentText)) {
1386
			setText(newText, false);
1387
		}
1381 1388
		
1389
		
1382 1390
		Page next = currentEdition.getPageForName(name);
1383 1391
		// System.out.println(Messages.TxmBrowser_4+currentPage);
1384 1392
		if (next != null) {
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditionEditor.java (revision 3251)
28 28
package org.txm.edition.rcp.editors;
29 29

  
30 30
import java.util.ArrayList;
31
import java.util.Arrays;
31 32
import java.util.Collection;
32
import java.util.HashMap;
33 33
import java.util.HashSet;
34 34
import java.util.LinkedHashMap;
35 35
import java.util.List;
36 36

  
37 37
import org.apache.commons.lang.StringUtils;
38
import org.eclipse.core.commands.Command;
39
import org.eclipse.core.commands.IParameter;
40
import org.eclipse.core.commands.Parameterization;
41
import org.eclipse.core.commands.ParameterizedCommand;
42
import org.eclipse.core.commands.common.NotDefinedException;
43 38
import org.eclipse.jface.bindings.keys.KeyStroke;
44 39
import org.eclipse.jface.fieldassist.TXMAutoCompleteField;
45 40
import org.eclipse.jface.fieldassist.TextContentAdapter;
......
66 61
import org.eclipse.ui.IEditorInput;
67 62
import org.eclipse.ui.IEditorPart;
68 63
import org.eclipse.ui.IEditorSite;
69
import org.eclipse.ui.IWorkbenchWindow;
70 64
import org.eclipse.ui.PartInitException;
71
import org.eclipse.ui.PlatformUI;
72
import org.eclipse.ui.commands.ICommandService;
73
import org.eclipse.ui.handlers.IHandlerService;
74
import org.txm.core.messages.TXMCoreMessages;
65
import org.txm.edition.rcp.handlers.BackToText;
75 66
import org.txm.edition.rcp.messages.EditionUIMessages;
76 67
import org.txm.objects.Edition;
77
import org.txm.objects.Match;
78 68
import org.txm.objects.Page;
79 69
import org.txm.objects.Project;
80 70
import org.txm.objects.Text;
......
106 96
	GLComposite editionsArea;
107 97
	
108 98
	private List<String> editionNames;
99
	private String textIdToOpen, pageIdToOpen, wordIdToOpen;
109 100
	
110 101
	private CQPCorpus corpus;
111 102
	
112
	private Text text;
103
	//private Text text;
113 104
	
114 105
	private Button editionsChooser;
115 106
	
......
135 126
	// TODO finish editor conversion
136 127
	@Override
137 128
	public Text getResult() {
129
		
138 130
		for (EditionPanel panel : editionPanels.values()) {
139 131
			return panel.getCurrentText();
140 132
		}
141
		return text;
133
		if (textIdToOpen != null) return this.getCorpus().getProject().getText(textIdToOpen);
134
		return this.getCorpus().getProject().getFirstText();
142 135
	}
143 136
	
144 137
	public SearchEditionToolbar getSearchEditionToolbar() {
......
278 271
	 * Last page.
279 272
	 */
280 273
	public void lastPage() {
281
		for (EditionPanel panel : editionPanels.values())
274
		for (EditionPanel panel : editionPanels.values()) {
282 275
			panel.lastPage();
276
		}
283 277
		updatePageLabel();
284 278
	}
285 279
	
......
287 281
	 * Previous page.
288 282
	 */
289 283
	public void previousPage() {
290
		for (EditionPanel panel : editionPanels.values())
284
		for (EditionPanel panel : editionPanels.values()) {
291 285
			panel.previousPage();
286
		}
292 287
		updatePageLabel();
293 288
	}
294 289
	
......
296 291
	 * Next page.
297 292
	 */
298 293
	public void nextPage() {
299
		for (EditionPanel panel : editionPanels.values())
294
		for (EditionPanel panel : editionPanels.values()) {
300 295
			panel.nextPage();
296
		}
301 297
		updatePageLabel();
302 298
	}
303 299
	
304 300
	/**
305 301
	 * Direct access to a page with a name.
306 302
	 */
307
	public void goToPage(String name) {
303
	public void goToPage(String textId, String name) {
304
		
308 305
		for (EditionPanel panel : editionPanels.values()) {
309
			panel.goToPage(name);
306
			panel.goToPage(textId, name);
310 307
		}
311 308
		updatePageLabel();
312
		
313 309
	}
314 310
	
315 311
	/**
316 312
	 * Direct access to a text with a name.
317 313
	 */
318
	public void goToText(String id) {
319
		try {
320
			String[] texts = corpus.getCorpusTextIdsList();
321
			for (String text_id : texts) {
322
				if (text_id.equals(id)) {
323
					Text text = project.getText(text_id);
324
					if (text != null) {
325
						setText(text, true);
326
						return;
327
					}
328
				}
329
			}
314
	public void goToText(String textId) {
315
		Text newText = this.project.getText(textId);
316
		if (newText == null) {
317
			Log.warning("** Error: not text found with ID="+textId);
318
			return;
319
		} else {
320
			setText(newText, true);
330 321
		}
331
		catch (Exception e) {
332
			e.printStackTrace();
333
		}
334
		
335
		Log.info(NLS.bind("No {0} text found.", id));
336 322
	}
337 323
	
338 324
	/**
......
456 442
							}
457 443
							
458 444
							editionsChooser.setText(StringUtils.join(editionNames, " | ")); //$NON-NLS-1$
459
							openEditions(text, editionNames);
445
							openEditions(editionNames, null, null, null);
460 446
							firstPage();
461 447
						}
462 448
					}
......
685 671
			@Override
686 672
			public void keyReleased(KeyEvent e) {
687 673
				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
688
					goToPage(page_text.getText());
674
					goToPage(null, page_text.getText());
689 675
				}
690 676
			}
691 677
			
......
749 735
			for (Text t : project.getTexts()) {
750 736
				t.compute();
751 737
			}
752
			if (openEditions(text, editionNames)) {
738
			if (openEditions(editionNames, textIdToOpen, pageIdToOpen, wordIdToOpen)) {
753 739
				firstPage();
754 740
			}
755 741
		}
......
823 809
	 * @param corpus
824 810
	 * @param editionNames
825 811
	 */
826
	public boolean openEditions(Text text, List<String> editionNames) {
812
	public boolean openEditions(List<String> editionNames, String textId, String pageId, String wordId) {
827 813
		
828
		try {
829
			text.compute();
830
		}
831
		catch (Exception e) {
832
			System.out.println("Error: " + text.getName() + " is not ready to use");
833
			return false;
834
		}
835 814
		// remove previous EditionPanel
836 815
		for (EditionPanel panel : editionPanels.values()) {
837 816
			panel.dispose();
......
844 823
			String editionName = editionNames.get(i);
845 824
			// System.out.println("EDITION NAME: "+editionName);
846 825
			Composite container = editionsArea;// .getContainer(i);
847
			Edition edition = text.getEdition(editionName);
848
			if (edition != null) {
826
			if (corpus.getProject().hasEditionDefinition(editionName)) {
849 827
				try {
850
					EditionPanel panel = new EditionPanel(this, container, SWT.BORDER, edition);
828
					EditionPanel panel = new EditionPanel(this, container, SWT.BORDER, editionName);
851 829
					panel.initSelectionProvider();
852 830
					
853 831
					if (i == 0) { // TODO: how to manage multiple menumanager -> the text selection does not work only the first panel selection is used
......
867 845
			}
868 846
		}
869 847
		editionsArea.layout();
848
		
849
		Text text = null;
850
		if (textId != null) {
851
			text = this.corpus.getProject().getText(textId);
852
		} else {
853
			text = this.corpus.getProject().getFirstText();
854
		}
855
		
856
		if (text == null) {
857
			Log.warning("** Error: no text found with id="+textId);
858
			return false;
859
		}
860
		try {
861
			text.compute();
862
			setText(text,  false);
863
		}
864
		catch (Exception e) {
865
			System.out.println("Error: " + text.getName() + " is not ready to use");
866
			return false;
867
		}
868
		
869
		if (pageId != null) {
870
			this.goToPage(textId, pageId);
871
		}
872
		
873
		if (wordId != null) {
874
			if (pageId == null) {
875
				this.goToWord(textId, pageId);
876
			}
877
			this.addHighlightWordsById(BackToText.lightred, Arrays.asList(wordId));
878
			this.setFocusedWordID(wordId);
879
		}
870 880
		return true;
871 881
	}
872 882
	
883
	private boolean goToWord(String textId, String wordId) {
884
		
885
		Text text = this.corpus.getProject().getText(textId);
886
		if (text == null) {
887
			Log.warning("** Error: no text found with ID="+textId);
888
			return false;
889
		}
890
		
891
		return backToText(text, wordId);
892
	}
893
	
873 894
	// /**
874 895
	// *
875 896
	// * //TODO: add getDefaultEditions to Corpus object
......
905 926
		
906 927
		project = corpus.getProject();
907 928
		
908
		text = ((SynopticEditorInput) input).getText();
929
		//text = ((SynopticEditorInput) input).getText();
909 930
		editionNames = ((SynopticEditorInput) input).getEditions();
931
		textIdToOpen = ((SynopticEditorInput) input).getTextID();
932
		if (textIdToOpen == null) {
933
			textIdToOpen = corpus.getProject().getFirstText().getName();
934
		}
935
		pageIdToOpen = ((SynopticEditorInput) input).getPageID();
936
		wordIdToOpen = ((SynopticEditorInput) input).getWordId();
910 937
		
911 938
		super.init(site, input);
912 939
	}
......
922 949
	
923 950
	@Override
924 951
	public void _setFocus() {
952
		if (this.getEditionPanel(0) == null) return;
925 953
		this.getEditionPanel(0).setFocus();
926 954
	}
927 955
	
928
	public void backToText(Text text, String line_wordid) {
956
	public boolean backToText(Text text, String line_wordid) {
929 957
		try {
930 958
			text.compute();
959
			this.setText(text, false);
960
			
931 961
			for (EditionPanel p : editionPanels.values()) {
932 962
				p.backToText(text, line_wordid);
933 963
			}
934 964
			updatePageLabel();
935 965
			updateWordStyles();
936 966
			notifyExtensions("onBackToText"); //$NON-NLS-1$
967
			return true;
937 968
		}
938 969
		catch (Exception e) {
939 970
			e.printStackTrace();
971
			return false;
940 972
		}
941 973
	}
942 974
	
......
986 1018
	
987 1019
	/**
988 1020
	 * 
989
	 * @param text2 the Text to set
1021
	 * @param newText the Text to set
990 1022
	 * @param refresh if true set the first Text page
991 1023
	 */
992
	public void setText(Text text2, boolean refresh) {
1024
	public void setText(Text newText, boolean refresh) {
993 1025
		for (EditionPanel p : editionPanels.values()) {
994
			p.setText(text2, refresh);
1026
			p.setText(newText, refresh);
995 1027
		}
996
		updatePageLabel();
1028
		
1029
		if (refresh) {
1030
			updatePageLabel();
1031
		}
997 1032
	}
998 1033
	
999 1034
	public void setFocusedWordID(String focusid) {
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/editors/SynopticEditorInput.java (revision 3251)
3 3
import java.util.Arrays;
4 4
import java.util.List;
5 5

  
6
import org.eclipse.e4.ui.model.application.impl.ApplicationPackageImpl;
6 7
import org.eclipse.jface.resource.ImageDescriptor;
7 8
import org.eclipse.ui.IEditorInput;
8 9
import org.eclipse.ui.IPersistableElement;
......
20 21
	
21 22
	private List<String> editions;
22 23
	
24
	private String textId, pageId, wordId;
25
	
23 26
	/**
24 27
	 * Instantiates a new SynopticEditorInput
25 28
	 *
......
27 30
	 * @param text, the text to show
28 31
	 * @param editions, the editions to show
29 32
	 */
30
	public SynopticEditorInput(Text text, CQPCorpus corpus, List<String> editions) {
33
	public SynopticEditorInput(Text text, CQPCorpus corpus, List<String> editions, String textId, String pageId, String wordId) {
31 34
		super(text);
32 35
		
33 36
		this.corpus = corpus;
34 37
		this.editions = editions;
38
		this.textId = textId;
39
		this.pageId = pageId;
40
		this.wordId = wordId;
35 41
		
36 42
		// if (text == null) {
37 43
		// this.text = corpus.getProject().getFirstText();
......
100 106
		return corpus;
101 107
	}
102 108
	
109
	public String getTextID() {
110
		return textId;
111
	}
112
	
113
	public String getPageID() {
114
		return pageId;
115
	}
116
	
117
	public String getWordId() {
118
		return wordId;
119
	}
120
	
103 121
	public Text getText() {
104 122
		return getResult();
105 123
	}
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/BackToText.java (revision 3251)
238 238
				}
239 239
			}
240 240
			
241
			
242 241
			String projectid = ""; //$NON-NLS-1$
243 242
			try {
244 243
				textS = corpus.getStructuralUnit("text"); //$NON-NLS-1$
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/OpenEdition.java (revision 3251)
149 149
	 * @return the object
150 150
	 */
151 151
	public static SynopticEditionEditor openEdition(CQPCorpus corpus, List<String> editions) {
152
		return openEdition(corpus, editions, null, null, null);
153
	}
154
	
155
	/**
156
	 * Open edition, but don't show a page
157
	 *
158
	 * @param corpus the corpus
159
	 * @return the object
160
	 */
161
	public static SynopticEditionEditor openEdition(CQPCorpus corpus, String[] editions, String textId) {
162
		return openEdition(corpus, Arrays.asList(editions), textId, null, null);
163
	}
164
	
165
	/**
166
	 * Open edition, but don't show a page
167
	 *
168
	 * @param corpus the corpus
169
	 * @param editions the editions to show
170
	 * @param textId the ID of the Text to show
171
	 * @param pageId the ID of the page to show. textId must be specified to work
172
	 * @param wordId the wordId of the word to focus&show. textId must be specified to work
173
	 * @return the SynopticEditionEditor (not shown yet)
174
	 */
175
	public static SynopticEditionEditor openEdition(CQPCorpus corpus, List<String> editions, String textId, String pageId, String wordId) {
152 176
		
153 177
		Log.fine("Opening edition of " + corpus); //$NON-NLS-1$
154 178
		try {
......
177 201
			IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
178 202
			IWorkbenchPage page = window.getActivePage();
179 203
			
180
			SynopticEditorInput editorInput = new SynopticEditorInput(text, corpus, editions);
204
			SynopticEditorInput editorInput = new SynopticEditorInput(text, corpus, editions, textId, pageId, wordId);
181 205
			SynopticEditionEditor editor = (SynopticEditionEditor) page.openEditor(editorInput, SynopticEditionEditor.ID, true);
182 206
			
183 207
			return editor;
tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/commands/OpenDemocratTools.java (revision 3251)
42 42
			// close Element View if opened
43 43
			if (view == null) {
44 44
				view = (MacroExplorer) page.showView(MacroExplorer.ID);
45
				page.activate(view);
45 46
			}
46 47

  
47 48
			if (view == null) {
tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/preferences/URSPreferencePage.java (revision 3251)
1 1
package org.txm.annotation.urs.preferences;
2 2

  
3 3
import org.eclipse.jface.preference.BooleanFieldEditor;
4
import org.eclipse.jface.preference.IntegerFieldEditor;
4 5
import org.eclipse.jface.preference.RadioGroupFieldEditor;
5 6
import org.eclipse.ui.IWorkbench;
6 7
import org.eclipse.ui.IWorkbenchPreferencePage;
7 8
import org.eclipse.ui.preferences.ScopedPreferenceStore;
8 9
import org.txm.annotation.urs.Messages;
9
import org.txm.rcp.Application;
10 10
import org.txm.rcp.preferences.TXMPreferencePage;
11
import org.txm.rcp.preferences.TXMPreferenceStore;
11 12

  
12
public class URSPreferencePage extends TXMPreferencePage
13
		implements IWorkbenchPreferencePage {
13
public class URSPreferencePage extends TXMPreferencePage implements IWorkbenchPreferencePage {
14 14
	
15 15
	private BooleanFieldEditor analec_limit_scheme_field;
16 16
	
17 17
	private BooleanFieldEditor prefix_autocompletion_field;
18 18
	
19
	private IntegerFieldEditor save_timer_field;
20
	
19 21
	// public static final String SELECTED_UNIT_COLOR = "selected_unit_color";
20 22
	// private ColorFieldEditor selected_unit_color;
21 23
	// public static final String HIGHLIGHTED_UNIT_COLOR = "hightlighted_unit_color";
......
27 29
	
28 30
	private RadioGroupFieldEditor color_palette;
29 31
	
30
	public URSPreferencePage() {
31
		super();
32
		
33
		preferences = new ScopedPreferenceStore(org.eclipse.core.runtime.preferences.InstanceScope.INSTANCE,
34
				Application.PLUGIN_ID);
35
		setPreferenceStore(preferences);
36
	}
37
	
38 32
	/**
39 33
	 * Creates the field editors. Field editors are abstractions of the common
40 34
	 * GUI blocks needed to manipulate various types of preferences. Each field
......
52 46
				getFieldEditorParent());
53 47
		addField(prefix_autocompletion_field);
54 48
		
49
		save_timer_field = new IntegerFieldEditor(
50
				URSPreferences.SAVE_TIMER, "Save timer duration (0 desactivate the timer)",
51
				getFieldEditorParent());
52
		addField(save_timer_field);
53
		
55 54
		// hightlighted_unit_color = new ColorFieldEditor(
56 55
		// HIGHLIGHTED_UNIT_COLOR, "Highlighted units background color",
57 56
		// getFieldEditorParent());
......
66 65
		String[][] values = { { "green", "green" }, { "yellow", "yellow" } }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
67 66
		color_palette = new RadioGroupFieldEditor(COLOR_PALETTE, Messages.AnalecPreferencePage_9, 2, values, getFieldEditorParent());
68 67
		addField(color_palette);
69
		
70
		preferences = new ScopedPreferenceStore(org.eclipse.core.runtime.preferences.InstanceScope.INSTANCE,
71
				Application.PLUGIN_ID);
72
		setPreferenceStore(preferences);
73
		setTitle("URS"); //$NON-NLS-1$
74 68
	}
75 69
	
76 70
	@Override
77
	public void init(IWorkbench workbench) {}
71
	public void init(IWorkbench workbench) {
72
		this.setPreferenceStore(new TXMPreferenceStore(URSPreferences.getInstance().getPreferencesNodeQualifier()));
73
		this.setTitle("URS");
74
		//this.setImageDescriptor(IndexAdapterFactory.ICON);
75
	}
78 76
}
tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/preferences/URSPreferences.java (revision 3251)
14 14
	public static final String COLOR_PALETTE = "color_palette";
15 15
	public static final String PREFIX_AUTOCOMPLETION = "prefix_autocompletion"; //$NON-NLS-1$
16 16
	public static final String ANALEC_LIMIT_CORRECTION_SCHEME = "urs_limit_correction_scheme"; //$NON-NLS-1$
17
	public static final String SAVE_TIMER = "save_timer_duration"; //$NON-NLS-1$
17 18

  
18 19
	
19 20
	@Override
......
24 25
		preferences.put(COLOR_PALETTE, "green");
25 26
		preferences.putBoolean(ANALEC_LIMIT_CORRECTION_SCHEME, false);
26 27
		preferences.putBoolean(PREFIX_AUTOCOMPLETION, false);
28
		preferences.putInt(SAVE_TIMER, 5);
27 29
	}
28 30
	
29 31
	/**
tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/UnitToolbar.java (revision 3251)
156 156
		typeCombo = new Combo(annotationArea, SWT.NONE | SWT.READ_ONLY);
157 157
		typeCombo.setToolTipText(Messages.UnitToolbar_7);
158 158
		GridData gdata = new GridData(GridData.CENTER, GridData.CENTER, false, false);
159
		gdata.minimumWidth = 100;
159
		gdata.minimumWidth = 150;
160 160
		//gdata.widthHint = 100;
161
		typeCombo.setSize(150, SWT.DEFAULT);
161 162
		typeCombo.setLayoutData(gdata);
162 163
		typeCombo.addSelectionListener(new SelectionListener() {
163 164
			
......
283 284
		
284 285
		ElementPropertiesView.openView();
285 286
		editor.updateWordStyles();
286
		
287
		annotationArea.layout();
287 288
		return true;
288 289
	}
289 290
	
......
435 436
						editor.updateWordStyles();
436 437
					}
437 438
					else { // a word have been clicked
438
						testIfAwordSpanIsSelected(ids);
439
						panel.expandSelectionTo(ids);
439
						//testIfAwordSpanIsSelected(ids);
440
						//panel.expandSelectionTo(ids);
440 441
					}
441 442
				}
442 443
				catch (Exception ex) {
......
787 788
			// System.out.println("firstWordTextId="+firstWordTextId);
788 789
			// System.out.println("newText="+newText+" e="+e);
789 790
			Edition newEdition = newText.getEdition(e.getName()); // get the edition of the new text
790
			Page p = newEdition.getPageForWordId(firstWordId); // find out the page containing the word
791
			Page newPage = newEdition.getPageForWordId(firstWordId); // find out the page containing the word
791 792
			// System.out.println("page="+p+" current page="+panel.getCurrentPage());
792 793
			
793 794
			previousSelectedUnitIDS = Arrays.asList(ids);
......
799 800
			}
800 801
			Page cp = panel.getCurrentPage();
801 802
			// System.out.println("Word page= "+p+" current="+panel.getCurrentPage());
802
			if (!panel.getCurrentText().equals(newText)) { // text changed
803
				// System.out.println("TEXT CHANGED");
804
				editor.setText(newText, false); // don't refresh right now
805
				editor.goToPage(p.getName());
803
			if (!cp.equals(newPage) || !panel.getCurrentText().equals(newText)) { // do we need to change page ?
804
				editor.goToPage(newText.getName(), newPage.getName());
806 805
			}
807
			else if (!cp.equals(p)) { // do we need to change page ?
808
				editor.goToPage(p.getName());
809
			}
810 806
			else { // just reload the page to highlight words
811 807
				// System.out.println("NO CHANGE");
812 808
			}
......
1105 1101
			return true;
1106 1102
		}
1107 1103
		
1104
		if (navigationField.getSelectionIndex() != 0) { // is the navigationField already at 0 ?
1105
			navigationField.setSelectionIndex(0);
1106
		}
1108 1107
		
1109
		navigationField.setSelectionIndex(0);
1110
		
1111 1108
		return false;
1112 1109
	}
1113 1110
	
tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/SchemaToolbar.java (revision 3251)
555 555
			Project corpus = e.getText().getProject();
556 556
			Text newText = corpus.getText(firstWordTextId); // get the new text
557 557
			Edition newEdition = newText.getEdition(e.getName()); // get the edition of the new text
558
			Page p = newEdition.getPageForWordId(firstWordId); // find out the page containing the word
558
			Page newPage = newEdition.getPageForWordId(firstWordId); // find out the page containing the word
559 559

  
560 560
			previousSelectedUniteIDS = Arrays.asList(ids);
561 561
//			System.out.println("HU: "+previousSelectedUniteIDS);
......
564 564
			
565 565
			if (previousSelectedUniteIDS.size() > 0)	editor.setFocusedWordID(previousSelectedUniteIDS.get(0));
566 566
			//System.out.println("Word page= "+p+" current="+panel.getCurrentPage());
567
			if (panel.getCurrentText() != newText) { // text changed
568
				//System.out.println("TEXT CHANGED");
569
				editor.setText(newText, false); // don't refresh right now
570
			} else if (panel.getCurrentPage() != p) { // do we need to change page ?
571
				//System.out.println("PAGE CHANGED");
572
				editor.goToPage(p.getName());
573
			} else { // just reload the page to highlight words
567
			if (panel.getCurrentPage() != newPage || panel.getCurrentText() != newText) { // do we need to change page ?
568
				//System.out.println("PAGE&TEXT CHANGED");
569
				editor.goToPage(newText.getName(), newPage.getName());
570
			} else  { // just reload the page to highlight words
574 571
				//editor.updateWordStyles();
575 572
			}
576 573
			
tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/toolbar/URSAnnotationToolbar.java (revision 3251)
1 1
package org.txm.annotation.urs.toolbar;
2 2

  
3 3
import java.util.List;
4
import java.util.Timer;
5
import java.util.TimerTask;
4 6

  
5 7
import org.apache.commons.lang.StringUtils;
6 8
import org.eclipse.swt.SWT;
......
16 18
import org.txm.annotation.rcp.editor.AnnotationArea;
17 19
import org.txm.annotation.rcp.editor.AnnotationExtension;
18 20
import org.txm.annotation.urs.URSCorpora;
21
import org.txm.annotation.urs.preferences.URSPreferences;
19 22
import org.txm.annotation.urs.view.ElementPropertiesView;
20 23
import org.txm.annotation.urs.view.ElementSearchView;
21 24
import org.txm.core.results.TXMResult;
......
59 62
	
60 63
	protected Corpus analecCorpus;
61 64
	
65
	protected Timer saveTimer;
66
	
62 67
	protected Vue vue;
63 68
	
64 69
	protected MainCorpus maincorpus;
......
68 73
	protected ToolItem button;
69 74
	
70 75
	private Button closeButton;
76

  
77
	private TimerTask saveTask;
71 78
	
72 79
	public URSAnnotationToolbar() {}
73 80
	
......
87 94
	
88 95
	@Override
89 96
	public boolean save() {
90
		// System.out.println();
97
		if (!analecCorpus.isModifie()) return false;
98
		
91 99
		Log.info("Saving URS annotation...");
92 100
		if (URSCorpora.saveCorpus(analecCorpus)) {
93 101
			Log.info("Done: URS annotations saved.");
......
107 115
		analecCorpus = URSCorpora.getCorpus(maincorpus);
108 116
		vue = URSCorpora.getVue(maincorpus);
109 117
		
118
		if (URSPreferences.getInstance().getInt(URSPreferences.SAVE_TIMER) > 0) {
119
			saveTimer = new Timer(true);
120
			
121
			Log.info("URS auto-save timer is activated (set to "+URSPreferences.getInstance().getInt(URSPreferences.SAVE_TIMER)+" minutes).");
122
			
123
			saveTask = new TimerTask() {
124
				
125
				@Override
126
				public void run() {
127
					
128
					Log.fine("URS auto-saving... ", false);
129
					if (save()) {
130
						Log.fine("Annotations saved.");
131
						editor.getParent().getDisplay().syncExec(new Runnable() {
132
							
133
							@Override
134
							public void run() {
135
								editor.fireIsDirty();
136
							}
137
						});
138
						
139
					} else {
140
						//Log.info("Annotations were already saved.");
141
					}
142
					
143
				}
144
			};
145
			
146
			saveTimer.scheduleAtFixedRate(saveTask, URSPreferences.getInstance().getInt(URSPreferences.SAVE_TIMER) * 60L * 1000L, URSPreferences.getInstance().getInt(URSPreferences.SAVE_TIMER) * 60L * 1000L);
147
		}
110 148
		annotationArea = new GLComposite(parent, SWT.NONE, "Unit annotation");
111 149
		annotationArea.getLayout().horizontalSpacing = 1;
112 150
		
......
316 354
		}
317 355
		if (annotationArea != null && annotationArea.isDisposed()) annotationArea.dispose();
318 356
		
357
		if (saveTimer != null) {
358
			saveTimer.cancel();
359
		}
360
		
319 361
		ElementPropertiesView.closeView();
320 362
		ElementSearchView.closeView();
321 363
		analecCorpus.removeEventListener(corpusListener);
tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/view/PropertyField.java (revision 3251)
62 62
					first = false;
63 63
					return;
64 64
				}
65
				
66
				t.setBackground(new Color(t.getDisplay(),255,0,0));
65
				if (!t.getText().equals(view.getAnalecVue().getValeurChamp(view.element, t.getToolTipText()))) {
66
					t.setBackground(new Color(t.getDisplay(),255,0,0));
67
				} else {
68
					t.setBackground(null);
69
				}
67 70
			}
68 71
		});
69 72
		t.addSelectionListener(new SelectionListener() {
......
84 87
			public void keyReleased(KeyEvent e) {
85 88
				if (!(e.widget instanceof Combo)) return;
86 89
				if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
90
					view.saveFieldValue(PropertyField.this);
91
					
92
				} else if (e.keyCode == SWT.ESC) {
87 93
					//								System.out.println("w:"+e.widget+" key pressed2.");
88 94
					
89
					view.saveFieldValue(PropertyField.this);
90
					
95
					t.setText(view.getAnalecVue().getValeurChamp(view.element, t.getToolTipText()));
91 96
				}
92
				//							else if (e.keyCode == SWT.DEL) {
93
				//								String value =((Combo) e.widget).getText();
94
				//								System.out.println("DEL prop="+textWidgets.get(e.widget)+" value="+value);
95
				//							}
96 97
			}
97 98
			
98 99
			@Override
......
147 148
		
148 149
		return t.getText();
149 150
	}
151

  
152
	public void setTextBackground(Color color) {
153
		
154
		t.setBackground(color);
155
	}
150 156
	
151 157
}
tmp/org.txm.analec.rcp/src/org/txm/annotation/urs/view/ElementSearchView.java (revision 3251)
9 9
import java.util.LinkedHashSet;
10 10
import java.util.List;
11 11

  
12
import org.eclipse.e4.ui.model.application.ui.basic.MPart;
12 13
import org.eclipse.e4.ui.workbench.modeling.EModelService;
13 14
import org.eclipse.jface.bindings.keys.KeyStroke;
14 15
import org.eclipse.jface.fieldassist.ComboContentAdapter;
......
30 31
import org.eclipse.swt.widgets.Label;
31 32
import org.eclipse.swt.widgets.Text;
32 33
import org.eclipse.ui.IEditorPart;
34
import org.eclipse.ui.IViewPart;
35
import org.eclipse.ui.IViewReference;
33 36
import org.eclipse.ui.IWorkbenchPage;
34 37
import org.eclipse.ui.PartInitException;
35 38
import org.eclipse.ui.PlatformUI;
......
143 146
	private Concordance concordance;
144 147
	
145 148
	public static void closeView() {
146
		try {
147 149
			IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
148 150
			ElementSearchView view = (ElementSearchView) page.findView(ElementSearchView.ID);
149 151
			
150 152
			// close Element View if opened
151 153
			if (view != null) {
152
				view = (ElementSearchView) page.showView(ElementSearchView.ID);
153 154
				page.hideView(view);
154 155
			}
155 156
			
156 157
			return;
157
		}
158
		catch (PartInitException e1) {
159
			System.out.println("Part initialisation error: " + e1.getLocalizedMessage());
160
			Log.printStackTrace(e1);
161
		}
162
		return;
163 158
	}
164 159
	
165 160
	public static ElementSearchView openView() {
......
174 169
			}
175 170
			if (view == null) {
176 171
				System.out.println("Error ElementPropertiesView view not found: " + ElementSearchView.ID);
172
				return null;
177 173
			}
174
			view.getSite().getPage().activate(view);
178 175
			return view;
179 176
		}
180 177
		catch (PartInitException e1) {
......
262 259
			
263 260
			@Override
264 261
			public void widgetSelected(SelectionEvent e) {
262
				
263
				splitViewIfNecessary();
265 264
				int current = Integer.parseInt(text.getText());
266 265
				current--;
267 266
				if (current < 1) current = 1;
......
406 405
		updateCurrentLabel();
407 406
	}
408 407
	
408
	protected void splitViewIfNecessary() {
409
		
410
//		for (IViewReference ref : ElementSearchView.this.getSite().getPage().getViewReferences()) {
411
//			System.out.println("ref="+ref+" id="+ref.getId());
412
//			if (ref.getId().equals(ElementPropertiesView.class.getName())) {
413
//				IWorkbenchPage p = ref.getView(true).getSite().getPage();
414
//				MPart mp1 = ref.getView(true).getSite().getService(MPart.class);
415
//				MPart mp2 = this.getSite().getService(MPart.class);
416
//				SWTEditorsUtils.addPart(mp1, mp2, EModelService.RIGHT_OF, 0.5f);
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff