Révision 1453

tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RWorkspace.java (revision 1453)
401 401
	}
402 402

  
403 403
	/**
404
	 * Plot.
405
	 *
406
	 * @param file the file
407
	 * @param expr the expr
408
	 * @throws REXPMismatchException the rEXP mismatch exception
409
	 * @throws StatException the stat exception
410
	 */
411
	public void plot(File file, String expr)throws REXPMismatchException,
412
	StatException {
413
		plot(file, expr, "svg");
414
	}
415
	/**
416
	 * Plot.
417
	 *
418
	 * @param file the file
419
	 * @param expr the expr
420
	 * @param device the device (svg, png, jpeg, ...)
421
	 * @throws REXPMismatchException the rEXP mismatch exception
422
	 * @throws StatException the stat exception
423
	 */
424
	public void plot(File file, String expr, String devicename)throws REXPMismatchException,
425
	StatException
426
	{
427
		try {
428
			file.createNewFile();
429
		} catch (IOException e1) {
430
			org.txm.utils.logger.Log.printStackTrace(e1);
431
			return;
432
		}
433
		if (!file.canWrite()) {
434
			System.out.println(NLS.bind("{0} cannot be written.", file)); //$NON-NLS-1$
435
		}
436
		
437
		String name;
438
		if (OSDetector.isFamilyWindows()) { //$NON-NLS-1$ //$NON-NLS-2$
439
			try {
440
				name = file.getCanonicalPath().replaceAll("/", "\\");
441
			} catch (IOException e) {
442
				throw new StatException(e);
443
			}
444
		} else {
445
			name = file.getAbsolutePath();
446
		}
447

  
448
		if (devicename.equals("devSVG")) voidEval("library(RSvgDevice);");
449

  
450
		// FIXME : test for window dimensions so the large plots can be entirely displayed. Need to pass width and height to RWorkspace.plot() so
451
		// RChartsEngine will be able to dynamically compute the width from the number of bars in a barplot for example.
452
		//REXP xp = eval("try("+devicename+"(\"" + name + "\", width=20, height=10))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
453

  
454
		REXP xp = eval("try("+devicename+"(\"" + name + "\"))"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
455

  
456
		if (xp.isString() && xp.asString() != null) { // if there's a string
457
			// then we have a
458
			// problem, R sent an
459
			// error
460
			// System.out.println("Can't open svg graphics device:\n"+xp.asString());
461
			// this is analogous to 'warnings', but for us it's sufficient to
462
			// get just the 1st warning
463
			REXP w = eval("if (exists(\"last.warning\") && length(last.warning)>0) names(last.warning)[1] else 0"); //$NON-NLS-1$
464
			// if (w.asString()!=null) System.out.println(w.asString());
465
			throw new StatException(w.asString());
466
		}
467

  
468
		// ok, so the device should be fine - let's plot
469
		voidEval(expr);
470
		voidEval("dev.off()"); //$NON-NLS-1$
471
	}
472
	
473
	/**
404 474
	 * Prints the last safe eval expr.
405 475
	 */
406 476
	public static void printLastSafeEvalExpr() {
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationManager.java (revision 1453)
43 43
		return cqpManager;
44 44
	}
45 45
	
46
	public boolean saveAnnotations() throws Exception{
46
	public boolean saveAnnotations(IProgressMonitor monitor) throws Exception {
47
		
47 48
		List<Annotation> annots = tempManager.getAnnotations();
48 49
		if (annots.isEmpty()) {
49 50
			System.out.println("No annotation to save. Aborting.");
50 51
			dirty = false;
51 52
			return true;
52 53
		}
54
		
55
		if (monitor != null) {
56
			monitor.beginTask("Saving annotations", annots.size());
57
			monitor.setTaskName("writing annotations in XML-TXM files");
58
		}
53 59

  
54 60
		AnnotationWriter writer = new AnnotationWriter(corpus);
55
		if (writer.writeAnnotations(annots)) {
61
		if (writer.writeAnnotations(annots, monitor)) {
56 62
			Log.info("Annotations succesfully written. Deleting temporary annotations...");
57 63
			tempManager.deleteAnnotations();
58 64
			dirty = false;
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationWriter.java (revision 1453)
11 11
import javax.xml.stream.XMLStreamException;
12 12

  
13 13
import org.apache.commons.lang.StringUtils;
14
import org.eclipse.core.runtime.IProgressMonitor;
14 15
import org.osgi.service.prefs.BackingStoreException;
15 16
import org.txm.Toolbox;
16 17
import org.txm.annotation.kr.core.repository.AnnotationEffect;
......
127 128
	/**
128 129
	 * 
129 130
	 * @param allCorpusAnnotations ordered annotations
131
	 * @param monitor 
130 132
	 * @return
131 133
	 * @throws IOException
132 134
	 * @throws CqiServerError
......
135 137
	 * @throws XMLStreamException 
136 138
	 * @throws BackingStoreException 
137 139
	 */
138
	public boolean writeAnnotations(List<Annotation> allCorpusAnnotations) throws IOException, CqiServerError, CqiClientException, InvalidCqpIdException, XMLStreamException, BackingStoreException{
140
	public boolean writeAnnotations(List<Annotation> allCorpusAnnotations, IProgressMonitor monitor) throws IOException, CqiServerError, CqiClientException, InvalidCqpIdException, XMLStreamException, BackingStoreException{
139 141
		//MainCorpus corpus = CorpusManager.getCorpusManager().getCorpus(c.getName());
140 142
		System.out.println("Saving "+allCorpusAnnotations.size()+"annotations...");
141 143

  
......
221 223
						tmpXMLTXMDirectory, previousXMLTXMDirectory)) {
222 224
					System.out.println("Error while writing annotations of text "+currentXMLFile);
223 225
					return false;
226
				} else {
227
					if (monitor != null) {
228
						monitor.worked(allSegmentAnnotations.size()+allTokenAnnotations.size());
229
					}
224 230
				}
225 231
			}
226 232
			currentText++;
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationInjector.java (revision 1453)
187 187
			currentTokenAnnotations.clear(); // current word annotations to write, may be empty
188 188
			Annotation a = null;
189 189
			
190
			if (tokenAnnotations.size() > 0) {
191
				a = tokenAnnotations.get(0);
190
			ArrayList<Annotation> toRemove = new ArrayList<>();
191
			for (Annotation annot : tokenAnnotations) {
192
				a = annot;
192 193
				//System.out.println("for p="+position_counter+" next token annot="+a);
193 194
				
194 195
				if (a.getStart() <= position_counter && position_counter <= a.getEnd()) {
195 196
					// write the annotation
196 197
					currentTokenAnnotations.put(a.getType(), a);
197
					if (a.getEnd() == position_counter) // its the last word that needs to write this annotation
198
						tokenAnnotations.remove(0);
198
					if (a.getEnd() == position_counter) { // its the last word that needs to write this annotation
199
						toRemove.add(annot);
200
					}
199 201
				}
200 202
			}
203
			tokenAnnotations.removeAll(toRemove);
201 204

  
202 205
			super.processStartElement(); // write the tag
203 206
		
......
766 769

  
767 770
	public static void main(String[] args) {
768 771
		try {
769
		File xmlFile = new File("/home/mdecorde/TXM/corpora/TDM80J/txm/TDM80J/tdm80j.xml");
770
		File outfile = new File("/home/mdecorde/TXM/corpora/TDM80J/txm/TDM80J/tdm80j-annot.xml");
772
		File xmlFile = new File("/home/mdecorde/TXM-0.8.0-dev/corpora/XMLLINEBREAK/txm/XMLLINEBREAK/test.xml");
773
		File outfile = new File("/home/mdecorde/TXM-0.8.0-dev/corpora/XMLLINEBREAK/txm/XMLLINEBREAK/test-out.xml");
771 774

  
772 775
		ArrayList<Annotation> segmentAnnotations = new ArrayList<Annotation>();
773
		int starts[] = { 5, 50, 104, 185, 235, 434, 517, 784, 949 };
774
		int ends[] = { 6, 51, 105, 186, 236, 435, 518, 785, 950 };
775
		for (int i = 0; i < starts.length; i++) {
776
			segmentAnnotations.add(new Annotation("Actr", "Philou", starts[i], ends[i]));
777
		}
776
//		int starts[] = { 3, 6 };
777
//		int ends[] = { 5, 8 };
778
//		for (int i = 0; i < starts.length; i++) {
779
//			segmentAnnotations.add(new Annotation("UN", "un", starts[i], ends[i]));
780
//			segmentAnnotations.add(new Annotation("DEUX", "deux", starts[i], ends[i]));
781
//		}
778 782

  
779 783
		ArrayList<Annotation> tokenAnnotations = new ArrayList<Annotation>();
780
		int positions[] = { 1, 32, 79, 224, 358, 428, 889, 1247, 1253, 1346 };
781
		for (int p : positions) tokenAnnotations.add(new Annotation("frlemma", "de", p, p+5));
784
		int positions[] = { 1, 2 };
785
		int n = 1;
786
		for (int p : positions) {
787
			tokenAnnotations.add(new Annotation("frlemma", ""+(n++), p, p));
788
			tokenAnnotations.add(new Annotation("frpos", ""+(n++), p, p));
789
		}
782 790
		
783 791
		AnnotationInjector ai;
784 792
		
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/CQPAnnotationManager.java (revision 1453)
214 214
			int p = positions[i++];
215 215
			annotations.add(new Annotation(type.getId(), str, p, p));
216 216
		}
217
		Log.info("TOKEN ANNOTATION CQP VALUES: "+annotations);
217
		//Log.info("TOKEN ANNOTATION CQP VALUES: "+annotations);
218 218
		return annotations;
219 219
	}
220 220
	
......
319 319
			}
320 320
		}
321 321

  
322
		Log.info("SEGMENT ANNOTATION CQP VALUES: "+annotations);
322
		//Log.info("SEGMENT ANNOTATION CQP VALUES: "+annotations);
323 323
		return annotations;
324 324
	}
325 325

  
......
351 351
		int[] struc = CQPSearchEngine.getCqiClient().cpos2Struc(sup.getQualifiedName(), cpos);
352 352

  
353 353
		if (struc[0] >= 0) {
354
			System.out.println("struct for positions "+start+"-"+end+" -> "+struc[0]+"-"+struc[1]);
354
			//System.out.println("struct for positions "+start+"-"+end+" -> "+struc[0]+"-"+struc[1]);
355 355
			if (struc[0] == struc[1]) { // même structure
356 356
				String[] struc_str = CQPSearchEngine.getCqiClient().struc2Str(sup.getQualifiedName(), struc);
357 357
				return struc_str[0];
tmp/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java (revision 1453)
6 6
import java.io.ObjectInputStream;
7 7
import java.io.ObjectOutputStream;
8 8
import java.io.Serializable;
9
import java.text.ParseException;
9 10
import java.util.ArrayList;
10 11
import java.util.Arrays;
11 12
import java.util.Collections;
13
import java.util.Date;
12 14
import java.util.HashMap;
13 15
import java.util.Map;
14 16

  
......
21 23
import org.osgi.framework.FrameworkUtil;
22 24
import org.osgi.service.prefs.BackingStoreException;
23 25
import org.osgi.service.prefs.Preferences;
26
import org.txm.Toolbox;
24 27
import org.txm.core.results.TXMParameters;
25 28
import org.txm.core.results.TXMResult;
26 29
import org.txm.utils.logger.Log;
......
172 175
	protected String commandPreferencesNodeQualifier;
173 176
	
174 177
	/**
175
	 * Instances map.
178
	 * TXMPreferences instances map 
176 179
	 */
177 180
	protected static Map<Class<? extends TXMPreferences>, TXMPreferences> instances = new HashMap<>();
178 181

  
......
589 592

  
590 593
		//System.out.println("--- TXMPreferences.getString() node path = " + nodePath);
591 594
		
592
		
595
		//FIXME defaultValue is always replaced even if set
593 596
		defaultValue = DefaultScope.INSTANCE.getNode(nodePath).get(key, defaultValue);
594 597
		return preferencesRootNode.node(nodePath).get(key, defaultValue);
595 598
	}
596 599

  
600
	/**
601
	 * Looks for the value of the specified <code>key</code> in preference nodes.
602
	 * Returns the value of the local result node if exists.
603
	 * Otherwise try to get it from the specified node qualifier if exists.
604
	 * Otherwise try to get it from the specified alternative node qualifiers defined in the list <code>TXMPreferences.alternativeNodesQualifiers</code>.
605
	 * Returns defaultValue if no value has been found for the specified key.
606
	 * @param nodePath
607
	 * @param result
608
	 * @param key
609
	 * @return
610
	 */
611
	public static Date getDate(String key, TXMResult result, String nodePath, Date defaultValue) {
597 612

  
613
//		if(result instanceof Project)	{
614
//			//TXMPreferences.dump();
615
//			return preferencesService.getRootNode().node(result.getParametersNodePath()).get(key, defaultValue);
616
//		}
617

  
618
		
619
//		if(result != null && result.getProject() != null && result.getProject().getPreferencesScope().getNode(result.getUUID()) != null)	{
620
//			return result.getProject().getPreferencesScope().getNode(result.getUUID()).get(key, defaultValue);
621
//		}
622

  
623
		nodePath = findNodePath(nodePath, result, key);
624

  
625
		//System.out.println("--- TXMPreferences.getString() node path = " + nodePath);
626
		
627
		Date v = null;
628
		try {
629
			v = TXMResult.ID_TIME_FORMAT.parse(DefaultScope.INSTANCE.getNode(nodePath).get(key, null));
630
		} catch (Exception e) { }
631
		if (v != null) {
632
			defaultValue = v;
633
		}
634
		v = null;
635
		try {
636
			v = TXMResult.ID_TIME_FORMAT.parse(preferencesRootNode.node(nodePath).get(key, null));
637
		} catch (Exception e) { }
638
		
639
		if (v != null) {
640
			return defaultValue;
641
		} else {
642
			return v;
643
		}
644
	}
645

  
598 646
	/**
599 647
	 * Looks for the value of the specified <code>key</code> in preference nodes.
600 648
	 * Returns the value of the local result node if exists.
......
609 657
	public static String getString(String key, TXMResult result, String nodePath)	{
610 658
		return getString(key, result, nodePath, ""); //$NON-NLS-1$
611 659
	}
660
	
661
	/**
662
	 * Looks for the value of the specified <code>key</code> in preference nodes.
663
	 * Returns the value of the local result node if exists.
664
	 * Otherwise try to get it from the specified node qualifier if exists.
665
	 * Otherwise try to get it from the specified alternative node qualifiers defined in the list <code>TXMPreferences.alternativeNodesQualifiers</code>.
666
	 * Returns a 0 time <code>Date</code> if no value has been found for the specified key.
667
	 * @param nodePath
668
	 * @param result
669
	 * @param key
670
	 * @return
671
	 */
672
	public static Date getDate(String key, TXMResult result, String nodePath)	{
673
		return getDate(key, result, nodePath, new Date(0)); //$NON-NLS-1$
674
	}
612 675

  
613 676

  
614 677
	/**
......
1595 1658
		cloneNode(srcResult.getParametersNodePath(), dstResult.getParametersNodePath());
1596 1659
	}
1597 1660

  
1661
	public Date getDate(String key) {
1662
//		if (this.pCreationDate != null) {
1663
//			this.saveParameter(TBXPreferences.CREATE_DATE, Toolbox.dateformat.format(this.pCreationDate));
1664
//		}
1665
//
1666
//		if (this.pLastUpdateDate != null) {
1667
//			this.saveParameter(TBXPreferences.UPDATE_DATE, Toolbox.dateformat.format(this.pLastUpdateDate));
1668
//		}
1669
//		String date = this.getStringParameterValue(TBXPreferences.CREATE_DATE);
1670
//		if (date !=null && date.length() > 0) {
1671
//			this.pCreationDate = Toolbox.dateformat.parse(date);
1672
//		} else {
1673
//			this.pCreationDate = new Date(0);
1674
//		}
1675
		String date = this.getString(key);
1676
		if (date !=null && date.length() > 0) {
1677
			try {
1678
				return TXMResult.ID_TIME_FORMAT.parse(date);
1679
			} catch (ParseException e) {
1680
				e.printStackTrace();
1681
			}
1682
		}
1683
		
1684
		return new Date(0);
1685
	}
1598 1686

  
1687
	
1688
	public void setDate(String key, Date date) {
1689
		this.put(key, TXMResult.ID_TIME_FORMAT.format(date));
1690
	}
1599 1691

  
1600 1692
	//FIXME: this code is dedicated to dynamically retrieve the static field PREFERENCES_NODE of the runtime subclass and use it super class to avoid to pass it to all methods.
1601 1693
	// eg. to use ProgressionPreferences.getBoolean("test") instead of TXMPreferences.getBoolean(ProgressionPreferences.PREFERENCES_NODE, "test")
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1453)
7 7
import java.text.SimpleDateFormat;
8 8
import java.util.ArrayList;
9 9
import java.util.Arrays;
10
import java.util.Calendar;
10 11
import java.util.Date;
11 12
import java.util.HashMap;
12 13
import java.util.List;
......
172 173
	@Parameter(key=TXMPreferences.LAZY_NAME, type=Parameter.INTERNAL)
173 174
	private String lazyName;
174 175

  
176
	/**
177
	 * Last compute date.
178
	 */
179
	@Parameter(key=TBXPreferences.UPDATE_DATE, type=Parameter.INTERNAL)
180
	private Date pLastUpdateDate;
175 181

  
182
	/**
183
	 * Creation date.
184
	 */
185
	@Parameter(key=TBXPreferences.CREATE_DATE, type=Parameter.INTERNAL)
186
	private Date pCreationDate;
176 187

  
188

  
177 189
	/**
178 190
	 * Creates a new TXMResult, child of the specified parent.
179 191
	 * @param parent
......
182 194
		this(null, parent);
183 195
	}
184 196

  
197
	public Date getComputeDate() {
198
		return this.pLastUpdateDate;
199
	}
200

  
201
	public Date getCreationDate() {
202
		return this.pCreationDate;
203
	}
204
	
185 205
	/**
186 206
	 * Creates a new TXMResult with no parent.
187 207
	 * If a local node exist with the parent_uuid, the parent will be retrieved and this result will be added to it. 
......
212 232
			} else {
213 233
				parametersNodePath = "";
214 234
			}
235
			
236
			// no parametersNodePath -> new result
215 237
			this.parametersNodePath = parametersNodePath + createUUID() + "_" + this.getClass().getSimpleName(); //$NON-NLS-1$;
238
			try {
239
				this.saveParameter(TBXPreferences.CREATE_DATE, ID_TIME_FORMAT.format(Calendar.getInstance().getTime()));
240
			} catch (Exception e) {
241
				// TODO Auto-generated catch block
242
				e.printStackTrace();
243
			}
216 244
		}
217 245
		else	{
218 246
			this.parametersNodePath = parametersNodePath;
......
228 256
		this.commandPreferencesNodePath = FrameworkUtil.getBundle(getClass()).getSymbolicName(); //$NON-NLS-1$
229 257
		Log.finest("TXMResult.TXMResult(): command preferences node path: " + this.commandPreferencesNodePath + "."); //$NON-NLS-1$ //$NON-NLS-2$
230 258

  
231

  
232 259
		this.visible = true;
233 260
		this.dirty = true;
234 261
		this.internalPersistable = false;
235 262
		this.userPersistable = TBXPreferences.getInstance().getBoolean(TBXPreferences.AUTO_PERSISTENCE_ENABLED);
236 263

  
237

  
238 264
		// retrieving parent from UUID
239 265
		String parentNodePath = this.getStringParameterValue(TXMPreferences.PARENT_PARAMETERS_NODE_PATH);
240 266

  
......
869 895
	public String getStringParameterValue(String key) {
870 896
		return TXMPreferences.getString(key, this, this.commandPreferencesNodePath);
871 897
	}
898
	
899
	/**
900
	 * Gets the value of the specified key in parameters, local result node or
901
	 * default preferences nodes.
902
	 * 
903
	 * @param key
904
	 * @return
905
	 */
906
	public Date getDateParameterValue(String key) {
907
		return TXMPreferences.getDate(key, this, this.commandPreferencesNodePath);
908
	}
872 909

  
873 910

  
874 911
	/**
......
982 1019
				} catch (Exception e) {
983 1020
					e.printStackTrace();
984 1021
				}
1022
			} else if (f.getType().isAssignableFrom(Date.class)) {
1023
				f.setAccessible(true); // set accessible to test the field values
1024
				try {
1025
					Object value = f.get(this);
1026
					if (value != null) {
1027
						this.saveParameter(key, TXMResult.ID_TIME_FORMAT.format((Date)value));
1028
					}
1029
				} catch (Exception e) {
1030
					e.printStackTrace();
1031
				}
985 1032
			}
986 1033
		}
987 1034
		return true;
......
1082 1129
				else if (f.getType().isAssignableFrom(boolean.class) || f.getType().isAssignableFrom(Boolean.class)) {
1083 1130
					value = this.getBooleanParameterValue(key);
1084 1131
				}
1132
				else if (f.getType().isAssignableFrom(Date.class)) {
1133
					value = this.getDateParameterValue(key);
1134
				}
1085 1135
				// FIXME: test to automate other type creation as Property => problem here is that org.txm.core doesn't know the plug-in org.txm.searchengine.cqp.core
1086 1136
				// could be done using reflection. Get the field runtime class, then get and call the constructor
1087 1137
				//				else if (f.getType().isAssignableFrom(Property.class)) {
......
2037 2087

  
2038 2088
				// store last used parameters
2039 2089
//				this.updateLastParameters();
2040

  
2090
				if (this.hasBeenComputedOnce// don't update the compute date if the object has been lazy loaded
2091
						|| pLastUpdateDate == null) { // set the update date if never computed once
2092
					pLastUpdateDate = Calendar.getInstance().getTime(); // update this internal parameter before saving parameters
2093
				}
2041 2094
				
2042 2095
				if (!this.autoSaveParametersFromAnnotations()) {
2043 2096
					Log.severe("TXMResult.compute(): " + this.getClass().getSimpleName() + ": failed to save parameters from annotations for " + this.getName() + ".");
......
2053 2106

  
2054 2107
				this.dirty = false; // the computing was successful, the result is no more dirty
2055 2108
				this.hasBeenComputedOnce = true;
2109
				
2056 2110
				if (altered) {
2057 2111
					System.out.println(NLS.bind("Warning {0} modifications have been lost.", this.getSimpleName()));
2058 2112
				}
2059 2113
				this.altered = false;
2114
				
2060 2115
				Log.finest("TXMResult.compute(): " + this.getClass().getSimpleName() + ": computing of result type " + this.getClass() + " done.");
2061 2116

  
2062 2117
				// set the children as dirty since the result has changed
tmp/org.txm.core/src/java/org/txm/objects/Project.java (revision 1453)
158 158
	private boolean pAnnotate;
159 159

  
160 160
	/**
161
	 * Last update date.
162
	 */
163
	@Parameter(key=TBXPreferences.UPDATE_DATE)
164
	private Date pLastUpdateDate;
165

  
166
	/**
167
	 * Creation date.
168
	 */
169
	@Parameter(key=TBXPreferences.CREATE_DATE)
170
	private Date pCreationDate;
171

  
172
	/**
173 161
	 * Instantiates a new project and define if it needs to build its main corpus, texts, editions, etc..
174 162
	 * 
175 163
	 * @param workspace
......
834 822
			}
835 823
		}
836 824

  
837
		if (this.pCreationDate != null) {
838
			this.saveParameter(TBXPreferences.CREATE_DATE, Toolbox.dateformat.format(this.pCreationDate));
839
		}
840

  
841
		if (this.pLastUpdateDate != null) {
842
			this.saveParameter(TBXPreferences.UPDATE_DATE, Toolbox.dateformat.format(this.pLastUpdateDate));
843
		}
844

  
845 825
		if (this.pSrcDirectory != null) {
846 826
			this.saveParameter(TBXPreferences.SOURCE, pSrcDirectory.getAbsolutePath());
847 827
		}
......
857 837
			this.pSrcDirectory = new File(path);
858 838
		}
859 839

  
860
		String date = this.getStringParameterValue(TBXPreferences.CREATE_DATE);
861
		if (date !=null && date.length() > 0) {
862
			this.pCreationDate = Toolbox.dateformat.parse(date);
863
		} else {
864
			this.pCreationDate = new Date(0);
865
		}
866
		date = this.getStringParameterValue(TBXPreferences.UPDATE_DATE);
867
		if (date !=null && date.length() > 0) {
868
			this.pLastUpdateDate = Toolbox.dateformat.parse(date);
869
		} else {
870
			this.pLastUpdateDate = new Date(0);
871
		}
872 840
		String linksString = this.getStringParameterValue(TBXPreferences.LINKS);
873 841
		if (linksString != null && !linksString.isEmpty()) {
874 842
			String split[] = linksString.split("\t");
......
1135 1103
		this.pImportModuleName = name;
1136 1104
	}
1137 1105

  
1138
	public Date getLastUpdateDate() {
1139
		return this.pLastUpdateDate;
1140
	}
1141

  
1142
	public Date getCreationDate() {
1143
		return this.pCreationDate;
1144
	}
1145

  
1146 1106
	public boolean hasEditionDefinition(String name) {
1147 1107
		try {
1148 1108
			return getPreferencesScope().getNode("EditionDefinition").nodeExists(name);
tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/corpus/MainCorpus.java (revision 1453)
447 447
		return textids;
448 448
	}
449 449
	
450
	/**
451
	 * 
452
	 * @return the text_id values of the CQP corpus ordered by position
453
	 * @throws CqiClientException
454
	 * @throws IOException
455
	 * @throws CqiServerError
456
	 */
450 457
	public String[] getCorpusTextIdsList() throws CqiClientException, IOException, CqiServerError {
451 458
		
452 459
		int nbtext = getNbTexts();
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/KRAnnotation.java (revision 1453)
206 206

  
207 207
		List<KnowledgeRepository> krs = InitializeKnowledgeRepository.get(corpus.getMainCorpus());
208 208
		typesList.clear();
209
		Log.warning("Corpus KRs: "+krs); //$NON-NLS-1$
209
		Log.info("Corpus KRs: "+krs); //$NON-NLS-1$
210 210

  
211 211
		for (KnowledgeRepository kr : krs) {
212 212
			if (kr == null) continue;
213 213

  
214 214
			currentKnowledgeRepository = kr;
215
			Log.warning(" KR: "+kr); //$NON-NLS-1$
215
			Log.info(" KR: "+kr); //$NON-NLS-1$
216 216
			List<AnnotationType> krtypes = kr.getAllAnnotationTypes();
217 217

  
218 218
			typesList.addAll(krtypes);
219 219

  
220
			Log.warning(NLS.bind(KRAnnotationUIMessages.availableAnnotationTypesColonP0, typesList));
220
			Log.info(NLS.bind(KRAnnotationUIMessages.availableAnnotationTypesColonP0, typesList));
221 221
			break;
222 222
		}
223 223

  
......
777 777
			return;
778 778
		}
779 779

  
780
		Log.info("AFFECT "+value_to_add+" to SELECTION="+matches); //$NON-NLS-1$ //$NON-NLS-1$
780
		//Log.info("AFFECT "+value_to_add+" to SELECTION="+matches); //$NON-NLS-1$ //$NON-NLS-1$
781 781

  
782 782
		// finally we can 'try' to create the annotations \o/
783 783
		try {
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/SaveAnnotations.java (revision 1453)
1 1
package org.txm.annotation.kr.rcp.commands;
2 2

  
3
import java.util.ArrayList;
4

  
3 5
import org.eclipse.core.commands.AbstractHandler;
4 6
import org.eclipse.core.commands.ExecutionEvent;
5 7
import org.eclipse.core.commands.ExecutionException;
......
14 16
import org.eclipse.ui.handlers.HandlerUtil;
15 17
import org.txm.annotation.kr.core.AnnotationManager;
16 18
import org.txm.annotation.kr.core.KRAnnotationEngine;
19
import org.txm.core.results.TXMResult;
17 20
import org.txm.rcp.commands.CloseEditorsUsing;
18 21
import org.txm.rcp.commands.workspace.UpdateCorpus;
22
import org.txm.rcp.editors.TXMEditor;
19 23
import org.txm.rcp.messages.TXMUIMessages;
20 24
import org.txm.rcp.utils.JobHandler;
25
import org.txm.rcp.utils.SWTEditorsUtils;
21 26
import org.txm.rcp.views.corpora.CorporaView;
22 27
import org.txm.searchengine.cqp.corpus.MainCorpus;
23 28
import org.txm.utils.logger.Log;
......
73 78
			protected IStatus run(IProgressMonitor monitor) {
74 79
				this.runInit(monitor);
75 80
				try {
76
					monitor.beginTask("Saving annotations", 100);
77

  
78
					monitor.setTaskName("writing annotations in XML-TXM files");
79
					boolean rez = am.saveAnnotations();
81
					
82
					ArrayList<TXMEditor> editors = SWTEditorsUtils.getEditors() ;
83
					monitor.beginTask("Closing editors", editors.size());
84
					for (TXMEditor editor : editors) {
85
						TXMResult result = editor.getResult();
86
						if (corpus.equals(result.getFirstParent(MainCorpus.class))) {
87
							editor.close();
88
						}
89
						monitor.worked(1);
90
					}
91
					
92
					boolean rez = am.saveAnnotations(monitor);
80 93
					monitor.worked(30);
81 94

  
82 95
					if (rez) {
tmp/org.txm.rcp/plugin.xml (revision 1453)
223 223
            class="org.txm.rcp.editors.SVGGraphicEditor"
224 224
            default="false"
225 225
            id="org.txm.rcp.editors.SVGGraphicEditor"
226
            name="%editor.name"/>
226
            name="SVG"/>
227 227
      <editor
228 228
            class="org.txm.rcp.editors.TXMMultiPageEditor"
229 229
            default="false"
tmp/org.txm.rcp/META-INF/MANIFEST.MF (revision 1453)
103 103
 org.txm.rcp.commands.queryview,
104 104
 org.txm.rcp.commands.tests,
105 105
 org.txm.rcp.commands.workspace,
106
 org.txm.rcp.corpuswizard,
106 107
 org.txm.rcp.editors,
107 108
 org.txm.rcp.editors.adaptableDataStructure,
108 109
 org.txm.rcp.editors.imports,
......
142 143
 swing2swt.layout
143 144
Bundle-Vendor: %Bundle-Vendor
144 145
Bundle-ActivationPolicy: lazy
145
Bundle-ClassPath: bin/,.,lib/commons-cli-1.2.jar,lib/commons-lang-2.4.
146
 jar,lib/junit-4.5.jar,lib/log4j-1.2.12.jar,swing2swt.jar
146
Bundle-ClassPath: .,
147
 lib/commons-cli-1.2.jar,
148
 lib/commons-lang-2.4.jar,
149
 lib/junit-4.5.jar,
150
 lib/log4j-1.2.12.jar,
151
 swing2swt.jar
147 152
Bundle-Version: 0.8.0.qualifier
148 153
Bundle-Name: %Bundle-Name
149 154
Bundle-ManifestVersion: 2
tmp/org.txm.rcp/src/main/java/org/txm/rcp/corpuswizard/ImportWizard.java (revision 1453)
57 57
						continue;
58 58
					}
59 59
					
60
					if (project != null && p.getLastUpdateDate().compareTo(project.getLastUpdateDate()) > 0) {
60
					if (project != null && p.getComputeDate().compareTo(project.getComputeDate()) > 0) {
61 61
						project = p;
62 62
					} else {
63 63
						project = p;
tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/debug/TXMResultDebugView.java (revision 1453)
109 109
		buffer.append("User name: " + this.currentResult.getUserName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
110 110
		buffer.append("Lazy name: " + this.currentResult.getLazyName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
111 111
		buffer.append("Name: " + this.currentResult.getName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
112
		buffer.append("Creation date: " + this.currentResult.getCreationDate() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
113
		buffer.append("Compute date: " + this.currentResult.getComputeDate() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
112 114
		buffer.append("Valid filename: " + this.currentResult.getValidFileName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
113 115
		buffer.append("Empty name: " + this.currentResult.getEmptyName() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
114 116
		buffer.append("toString(): " + this.currentResult.toString() + "\n"); //$NON-NLS-1$ //$NON-NLS-2$
tmp/org.txm.rcp/src/main/java/org/txm/rcp/utils/SWTEditorsUtils.java (revision 1453)
46 46
		
47 47
		return page.findEditor(new TXMResultEditorInput<TXMResult>(result));
48 48
	}
49
	
50
	
49

  
50
	/**
51
	 * return all opened editors of every parts of every windows
52
	 */
53
	public static ArrayList<TXMEditor> getEditors() {
54
		return getEditors(null);
55
	}
56

  
51 57
	public static ArrayList<TXMEditor> getEditors(TXMResult result)	{
52
		
58

  
53 59
		ArrayList<TXMEditor> editors = new ArrayList<TXMEditor>();
54
		
55
		for (IEditorReference reference : PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getEditorReferences()) {
56
			IEditorPart tmpEditor = reference.getEditor(false);
57
	
58
			if(tmpEditor instanceof TXMEditor && ((TXMEditor)tmpEditor).getResult() == result)	{
59
				editors.add((TXMEditor) tmpEditor);
60
			}
61
			else if(tmpEditor instanceof TXMMultiPageEditor)	{
62
				TXMMultiPageEditor txmMultipageEditor = ((TXMMultiPageEditor)tmpEditor);
63
				for (int i = 0; i < txmMultipageEditor.getEditors().size(); i++) {
64
					if(txmMultipageEditor.getEditors().get(i) instanceof TXMEditor)	{
65
						TXMEditor txmEditor = ((TXMEditor)txmMultipageEditor.getEditors().get(i));
66
						if(txmEditor.getResult() == result)	{
67
							editors.add(txmEditor);
60

  
61
		IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows();
62
		for (IWorkbenchWindow window : windows) {
63
			IWorkbenchPage[] pages = window.getPages();
64
			for (IWorkbenchPage page : pages) {
65
				for (IEditorReference reference : page.getEditorReferences()) {
66
					IEditorPart tmpEditor = reference.getEditor(false);
67

  
68
					if(result == null || tmpEditor instanceof TXMEditor && ((TXMEditor)tmpEditor).getResult() == result)	{
69
						editors.add((TXMEditor) tmpEditor);
70
					}
71
					else if(tmpEditor instanceof TXMMultiPageEditor)	{
72
						TXMMultiPageEditor txmMultipageEditor = ((TXMMultiPageEditor)tmpEditor);
73
						for (int i = 0; i < txmMultipageEditor.getEditors().size(); i++) {
74
							if(txmMultipageEditor.getEditors().get(i) instanceof TXMEditor)	{
75
								TXMEditor txmEditor = ((TXMEditor)txmMultipageEditor.getEditors().get(i));
76
								if(txmEditor.getResult() == result)	{
77
									editors.add(txmEditor);
78
								}
79
							}
68 80
						}
81

  
69 82
					}
70 83
				}
71 84
				
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/OpenSVGGraph.java (revision 1453)
42 42
import org.eclipse.ui.PlatformUI;
43 43
import org.eclipse.ui.handlers.HandlerUtil;
44 44
import org.txm.rcp.editors.SVGGraphicEditor;
45
import org.txm.rcp.editors.TXMEditor;
45 46
import org.txm.rcp.editors.input.SVGGraphicEditorInput;
46 47
import org.txm.rcp.messages.TXMUIMessages;
47 48
import org.txm.rcp.swt.dialog.LastOpened;
......
98 99
	 */
99 100
	public static SVGGraphicEditor OpenSVGFile(String filepath, String name) {
100 101
		//System.out.println("SVGFile path : "+filepath); //$NON-NLS-1$
101
		IEditorInput editorInput = new SVGGraphicEditorInput(filepath, name);
102
		SVGGraphicEditorInput editorInput = new SVGGraphicEditorInput(filepath, name);
102 103
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
103 104
		//IWorkbenchWindow window = TXMWindows.getActiveWindow(); //.getActiveWorkbenchWindow()
104
		IWorkbenchPage page = window.getActivePage();
105
		SVGGraphicEditor editor = null;
106
		try {
107
			// System.out.println("open svg editor" );
108
			editor = (SVGGraphicEditor) page.openEditor(editorInput,
109
					SVGGraphicEditor.ID, true);
110
			editor.resetView();
111
			// System.out.println("open svg editor - DONE" );
112
		} catch (PartInitException e) {
113
			org.txm.rcp.utils.Logger.printStackTrace(e);
105

  
106
		// System.out.println("open svg editor" );
107
		TXMEditor editor = TXMEditor.openEditor(editorInput, SVGGraphicEditor.ID);
108
		if (editor !=null) {
109
			((SVGGraphicEditor)editor).resetView();
110
			return (SVGGraphicEditor)editor;
111
		} else {
112
			return null;
114 113
		}
115
		return editor;
116 114
	}
117 115
}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/input/SVGGraphicEditorInput.java (revision 1453)
32 32
import org.eclipse.jface.resource.ImageDescriptor;
33 33
import org.eclipse.ui.IEditorInput;
34 34
import org.eclipse.ui.IPersistableElement;
35
import org.txm.core.results.TXMResult;
35 36
import org.txm.rcp.editors.SVGGraphicable;
37
import org.txm.rcp.editors.TXMResultEditorInput;
36 38

  
37
// TODO: Auto-generated Javadoc
38 39
/**
39 40
 * The Class SpecificitiesResultEditorInput.
40 41
 * 
41
 * @author Sylvain Loiseau
42
 * @author Sylvain Loiseau,mdecorde
42 43
 */
43
public class SVGGraphicEditorInput implements IEditorInput, SVGGraphicable {
44
public class SVGGraphicEditorInput extends TXMResultEditorInput<TXMResult> implements IEditorInput, SVGGraphicable {
44 45

  
45 46
	/** The filename. */
46 47
	private String filename;
......
48 49
	/** The name. */
49 50
	private String name;
50 51

  
52
	public SVGGraphicEditorInput(TXMResult result) {
53
		super(null);
54
	}
55
	
56
	
57
	public SVGGraphicEditorInput() {
58
		super(null);
59
	}
60
	
51 61
	/**
52 62
	 * Instantiates a new sVG graphic editor input.
53 63
	 *
......
55 65
	 * @param name the name
56 66
	 */
57 67
	public SVGGraphicEditorInput(String filename, String name) {
58
		super();
68
		super(null);
59 69
		this.filename = filename;
60 70
		this.name = name;
61 71
	}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 1453)
877 877
	 * @param editorId
878 878
	 * @return
879 879
	 */
880
	public static TXMEditor openEditor(TXMResultEditorInput editorInput, String editorId)	{
881
		TXMEditor editor = null;
880
	@SuppressWarnings("unchecked")
881
	public static TXMEditor<? extends TXMResult> openEditor(TXMResultEditorInput<? extends TXMResult> editorInput, String editorId)	{
882
		TXMEditor<? extends TXMResult> editor = null;
882 883
		IWorkbenchWindow window = TXMWindows.getActiveWindow();
883 884
		IWorkbenchPage page = window.getActivePage();
884 885
		try {
885 886
			boolean wasAlreadyOpened = SWTEditorsUtils.isOpenEditor(editorInput, editorId);
886 887
			// opening the editor
887
			editor = (TXMEditor) page.openEditor(editorInput, editorId, true, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID);
888
			IEditorPart e = page.openEditor(editorInput, editorId, true, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID);
889
			if (e instanceof TXMEditor) {
890
				editor = (TXMEditor<? extends TXMResult>) e;
891
			} else {
892
				return null;
893
			}
894
			
888 895
			// computing the result only if the editor wasn't already opened
889 896
			if (!wasAlreadyOpened)	{
890 897
				editor.compute(false);
tmp/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchAdvisor.java (revision 1453)
34 34
import java.net.URL;
35 35
import java.util.ArrayList;
36 36
import java.util.Arrays;
37
import java.util.Date;
37 38
import java.util.logging.Handler;
38 39
import java.util.logging.Level;
39 40
import java.util.logging.LogRecord;
......
328 329
		// build the properties given to the Toolbox
329 330
		String version =  Activator.getDefault().getBundle().getVersion().toString(); // "0.7.7.201412160925";
330 331
		version = version.replaceAll("(.\\..\\..)\\.(....)(..)(..)(..)(..)", "$1 ($2-$3-$4 $5h$6)"); //$NON-NLS-1$ //$NON-NLS-2$
331
		System.out.println(NLS.bind(TXMUIMessages.startingUpP0, version));
332

  
332
		System.out.print(NLS.bind(TXMUIMessages.startingUpP0, version));
333
		System.out.println(NLS.bind(" ({0})", new Date(Activator.getDefault().getBundle().getLastModified())));
333 334
	}
334 335

  
335 336
	private void setPreferencesConfiguration() {
tmp/org.txm.rcp/build.properties (revision 1453)
1 1
#Fri Jul 06 10:25:15 CEST 2018
2 2
output..=bin/
3
bin.includes=plugin.xml,META-INF/,.,splash.bmp,lib/,rcp.product,plugin_customization.ini,lib/commons-cli-1.2.jar,lib/commons-lang-2.4.jar,lib/junit-4.5.jar,lib/log4j-1.2.12.jar,installtreetagger_en.html,css/,p2.inf,bin/,OSGI-INF/,TXM.sh,icons/,OSGI-INF/l10n/bundle.properties
3
bin.includes = plugin.xml,\
4
               META-INF/,\
5
               .,\
6
               splash.bmp,\
7
               lib/,\
8
               rcp.product,\
9
               plugin_customization.ini,\
10
               lib/commons-cli-1.2.jar,\
11
               lib/commons-lang-2.4.jar,\
12
               lib/junit-4.5.jar,\
13
               lib/log4j-1.2.12.jar,\
14
               installtreetagger_en.html,\
15
               css/,\
16
               p2.inf,\
17
               OSGI-INF/,\
18
               TXM.sh,\
19
               icons/,\
20
               OSGI-INF/l10n/bundle.properties
4 21
source..=src/main/java/
5 22
bin.excludes = lib/batik/
6 23
qualifier=svn

Formats disponibles : Unified diff