Revision 1611

tmp/org.txm.rcp/src/main/java/org/txm/rcp/utils/SWTEditorsUtils.java (revision 1611)
84 84
				for (IEditorReference reference : page.getEditorReferences()) {
85 85
					IEditorPart tmpEditor = reference.getEditor(false);
86 86

  
87
					if(result == null || tmpEditor instanceof TXMEditor && ((TXMEditor)tmpEditor).getResult() == result)	{
87
					if(tmpEditor instanceof TXMEditor && ((TXMEditor)tmpEditor).getResult() == result)	{
88 88
						editors.add((TXMEditor) tmpEditor);
89 89
					}
90 90
					else if(tmpEditor instanceof TXMMultiPageEditor)	{
......
97 97
								}
98 98
							}
99 99
						}
100

  
101 100
					}
102 101
				}
103

  
104 102
			}
105 103
		}
106 104

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/UpdateCorpus.java (revision 1611)
3 3
import org.eclipse.core.commands.AbstractHandler;
4 4
import org.eclipse.core.commands.ExecutionEvent;
5 5
import org.eclipse.core.commands.ExecutionException;
6
import org.eclipse.core.runtime.IProgressMonitor;
7
import org.eclipse.core.runtime.IStatus;
8
import org.eclipse.core.runtime.Status;
6 9
import org.eclipse.jface.viewers.ISelection;
7 10
import org.eclipse.jface.viewers.IStructuredSelection;
8 11
import org.eclipse.swt.widgets.Display;
......
35 38
	
36 39
	public static JobHandler update(final MainCorpus corpus) {
37 40
		
38
		Project project = corpus.getProject();
41
		final Project project = corpus.getProject();
39 42
		if (project == null)  return null;
40 43
		
41 44
		if (!project.getImportModuleName().matches("xtz|txt|hyperbase|cnr|alceste|xml")) {
42 45
			System.out.println("Can't update a corpus not imported with the XTZ import module.");
43 46
			return null;
44 47
		}
48
		
49
		Display.getDefault().syncExec(new Runnable() {
50
			@Override
51
			public void run() {CloseEditorsUsing.corpus(corpus);}
52
		});
53
		
45 54
		project.setDirty();
46 55
		project.setNeedToBuild();
47 56
		project.setDoMultiThread(false); //too soon
48 57
		project.setDoUpdate(true);
58
		project.setImportModuleName("xtz");
49 59
		
50
//		String txmhome = Toolbox.getTxmHomePath();
51
//		File scriptDir = new File(txmhome, "scripts/groovy/user/org/txm/scripts/importer/xtz");
52
//		File script = new File(scriptDir, "xtzLoader.groovy");
53
		System.out.println("Updating corpus "+corpus+" using "+project);
54
		JobHandler ret = ExecuteImportScript.executeScript(project);
55
		Display.getDefault().syncExec(new Runnable() {
60
		JobHandler job = new JobHandler("Updating corpus "+corpus+" using "+project) {
61
			
56 62
			@Override
57
			public void run() {CloseEditorsUsing.corpus(corpus);}
58
		});
59
		return ret;
63
			protected IStatus run(IProgressMonitor monitor) {
64
				if (project.compute(monitor)) {
65
					return Status.OK_STATUS;
66
				} else {
67
					return Status.CANCEL_STATUS;
68
				}
69
			}
70
		};
71
		
72
		job.schedule();
73
		
74
////		String txmhome = Toolbox.getTxmHomePath();
75
////		File scriptDir = new File(txmhome, "scripts/groovy/user/org/txm/scripts/importer/xtz");
76
////		File script = new File(scriptDir, "xtzLoader.groovy");
77
//		System.out.println();
78
//		JobHandler ret = ExecuteImportScript.executeScript(project);
79
//		
80
		return job;
60 81
	}
61 82
}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorporaDirectory.java (revision 1611)
36 36
import org.eclipse.core.runtime.IProgressMonitor;
37 37
import org.eclipse.core.runtime.IStatus;
38 38
import org.eclipse.core.runtime.Status;
39
import org.eclipse.osgi.util.NLS;
39 40
import org.eclipse.swt.SWT;
40 41
import org.eclipse.swt.widgets.DirectoryDialog;
41 42
import org.eclipse.swt.widgets.Shell;
......
138 139
						for (Project newProject2 : newProjects) {
139 140
							newProject2.compute();
140 141
						}
141
						System.out.println(newProjects.size()+" corpus loaded.");
142
						System.out.println(NLS.bind(TXMUIMessages.P0CorpusLoaded, newProjects.size()));
142 143
						RestartTXM.reloadViews();
143 144
						System.err.println(TXMUIMessages.info_txmIsReady);
144 145
						StatusLine.setMessage(TXMUIMessages.info_txmIsReady);
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorToolBar.java (revision 1611)
164 164

  
165 165
	/**
166 166
	 * Creates a <code>GLComposite</code> in the toolbar subwidgets container.
167
	 * 
167 168
	 * @param groupTitle the composite uniq title in the toolbar 
168 169
	 * @return
169 170
	 */
......
272 273
		group.setVisible(false);
273 274

  
274 275
		// add finally a button to the toolbar to show/hide the Group
275
		final OpenCloseToolItem showParameters = new OpenCloseToolItem(this, groupTitle, openIconFilePath, closeIconFilePath, buttonToolTip);
276
		OpenCloseToolItem showParameters = new OpenCloseToolItem(this, groupTitle, openIconFilePath, closeIconFilePath, buttonToolTip);
276 277
		this.setVisible(group, showGroup); // default init
277 278

  
278 279
		showParameters.addSelectionListener(new SelectionListener() {
279 280

  
280 281
			@Override
281 282
			public void widgetSelected(SelectionEvent e) {
282
				setVisible(group, showParameters.getSelection());
283
				OpenCloseToolItem b = (OpenCloseToolItem) e.widget;
284
				setVisible(group, b.getSelection());
283 285
			}
284 286

  
285 287
			@Override
tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages.properties (revision 1611)
974 974

  
975 975
theP0CorpusWillBeCreatedFromTheP1Directory=The {0} corpus will be created from the {1} directory.
976 976

  
977
theP1P0CorpusWillBeReplaced=The {0} ({1}) corpus will be replaced.
977
theP1P0CorpusWillBeReplaced=The {0} ({1}) corpus will be replaced.
978

  
979
P0CorpusLoaded={0} corpus loaded.
tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/messages_fr.properties (revision 1611)
973 973
zoomInAmpoutColonMouseWheelORShiftPlusRightMousePlusDrag = \	Zoom +/- : Roulette OU Maj + Clic Droit + Glisser\n
974 974

  
975 975
zoomToSelectionColonCtrlPlusLeftMousePlusdrag = \	Zoomer sur la sélection : Ctrl + Clic Gauche + Glisser\n
976

  
977
P0CorpusLoaded={0} corpus chargées.
tmp/org.txm.rcp/src/main/java/org/txm/rcp/messages/TXMUIMessages.java (revision 1611)
7 7
public class TXMUIMessages extends NLS {
8 8
	
9 9
	private static final String BUNDLE_NAME = "org.txm.rcp.messages.messages"; //$NON-NLS-1$
10

  
11
	public static final String P0CorpusLoaded = null;
10 12
	
11 13
	public static String EMPTY; 
12 14
	public static String Explorer_4;
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/AnnotationWriter.java (revision 1611)
40 40

  
41 41
	public AnnotationWriter(MainCorpus corpus) throws BackingStoreException{
42 42
		this.corpus = corpus;
43
		defaultKR = KRAnnotationEngine.getKnowledgeRepository(corpus, KRAnnotationEngine.getKnowledgeRepositoryNames(corpus).get(0));
43
		List<String> krnames = KRAnnotationEngine.getKnowledgeRepositoryNames(corpus);
44
		if (krnames.size() == 0) {
45
			Log.severe(NLS.bind("** Error: no knowledge repository found in {0} corpus.", corpus));
46
			throw new IllegalArgumentException("No kr in "+corpus);
47
		}
48
		String t = krnames.get(0);
49
		defaultKR = KRAnnotationEngine.getKnowledgeRepository(corpus, t);
50
		if (defaultKR == null) {
51
			Log.severe(NLS.bind("** Error: no knowledge repository {0} found in {0} corpus.", defaultKR, corpus));
52
			throw new IllegalArgumentException("No kr "+defaultKR+" in "+corpus);
53
		}
44 54
		types = defaultKR.getAllAnnotationTypes();
45 55
		
46 56
	}
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/messages/KRAnnotationCoreMessages.java (revision 1611)
5 5

  
6 6

  
7 7
/**
8
 * KR annotation UI messages.
8
 * KR annotation Core messages.
9 9
 * 
10 10
 * @author mdecorde
11 11
 * @author sjacquot
......
13 13
 */
14 14
public class KRAnnotationCoreMessages extends NLS {
15 15

  
16
	private static final String BUNDLE_NAME = "org.txm.annotation.kr.rcp.messages.messages"; //$NON-NLS-1$
16
	private static final String BUNDLE_NAME = "org.txm.annotation.kr.core.messages.messages"; //$NON-NLS-1$
17 17
	
18 18
	public static String savingP0Annotations;
19 19

  
20
	public static Throwable annotationSuccesfullyWritten;
20
	public static String annotationSuccesfullyWritten;
21 21

  
22 22
	public static String savingAnnotations;
23 23

  
......
29 29
	}
30 30

  
31 31
	private KRAnnotationCoreMessages() {
32
		
32 33
	}
33
	
34
	
35 34
}
tmp/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/KRAnnotationEngine.java (revision 1611)
297 297
		if (corpus == null) return new ArrayList<String>();
298 298
		Project base = corpus.getProject();
299 299
		if (base == null) return new ArrayList<String>();
300
		
300 301
		String[] names;
301 302
		try {
302 303
			IEclipsePreferences node = base.getPreferencesScope().getNode("KnowledgeRepository");
......
441 442
	public String getDetails() {
442 443
		return "";
443 444
	}
445

  
446
	public static void registerKnowledgeRepositoryName(CQPCorpus corpus, String name) {
447
		if (corpus == null) return;
448
		Project project = corpus.getProject();
449
		if (project == null) return;
450
		try {
451
			IEclipsePreferences node = project.getPreferencesScope().getNode("KnowledgeRepository");
452
			if (!node.nodeExists(name)) {
453
				// create the "DEFAULT" KR configuration
454
				Preferences krconf = node.node(name);
455
				krconf.put("name", name);
456
			}
457
			
458
		} catch (BackingStoreException e) {
459
			e.printStackTrace();
460
		}
461
	}
462
	
463
	public static void unregisterKnowledgeRepositoryName(CQPCorpus corpus, String name) {
464
		if (corpus == null) return;
465
		Project project = corpus.getProject();
466
		if (project == null) return;
467
		try {
468
			IEclipsePreferences node = project.getPreferencesScope().getNode("KnowledgeRepository");
469
			if (node.nodeExists(name)) {
470
				Preferences krconf = node.node(name);
471
				krconf.removeNode();
472
			}
473
		} catch (BackingStoreException e) {
474
			e.printStackTrace();
475
		}
476
	}
444 477
}
tmp/org.txm.core/src/java/org/txm/objects/EditionDefinition.java (revision 1611)
1 1
package org.txm.objects;
2 2

  
3
import org.osgi.service.prefs.BackingStoreException;
3 4
import org.osgi.service.prefs.Preferences;
4 5
import org.txm.core.preferences.TBXPreferences;
5 6

  
......
15 16
	
16 17
	public EditionDefinition(Project project, String name) {
17 18
		this.node = project.getPreferencesScope().getNode(EditionDefinition.class.getSimpleName()).node(name);
19
		setName(name); //TODO use node.name() instead
20
		
18 21
	}
19 22

  
20 23
	public String getName() {
......
64 67
	public void setImagesDirectory(String images_directory) {
65 68
		node.put(TBXPreferences.EDITION_DEFINITION_IMAGES_DIRECTORY, images_directory);
66 69
	}
70
	
71
	public String toString() {
72
		StringBuffer buffer = new StringBuffer();
73
		try {
74
			for (String k : node.keys()) {
75
				buffer.append(k+"="+node.get(k, "")+"\t");
76
			}
77
		} catch (BackingStoreException e) {
78
			// TODO Auto-generated catch block
79
			e.printStackTrace();
80
		}
81
		return buffer.toString();
82
	}
67 83
}
tmp/org.txm.core/src/java/org/txm/objects/Project.java (revision 1611)
32 32
import java.io.IOException;
33 33
import java.lang.reflect.Constructor;
34 34
import java.util.ArrayList;
35
import java.util.Arrays;
35 36
import java.util.Date;
36 37
import java.util.HashMap;
37 38
import java.util.List;
38 39

  
39 40
import javax.xml.parsers.ParserConfigurationException;
40 41

  
42
import org.apache.commons.lang.StringUtils;
41 43
import org.eclipse.core.resources.IFolder;
42 44
import org.eclipse.core.resources.IProject;
43 45
import org.eclipse.core.resources.IResource;
......
76 78
 */
77 79
public class Project extends TXMResult {
78 80

  
79
	private ArrayList<String> pEditionNames = new ArrayList<String>();
81
	//private ArrayList<String> pEditionNames = new ArrayList<String>();
80 82
	private IProject rcpProject;
81 83

  
82 84
	private ProjectScope preferenceScope;
......
631 633
		return pDefaultEditionName;
632 634
	}
633 635

  
634
	public ArrayList<String> getEditionNames() {
635
		return pEditionNames;
636
	public List<String> getEditionNames() {
637
		IEclipsePreferences node = this.getPreferencesScope().getNode(EditionDefinition.class.getSimpleName());
638
		try {
639
			return Arrays.asList(node.childrenNames());
640
		} catch (BackingStoreException e) {
641
			Log.printStackTrace(e);
642
		}
643
		
644
		return new ArrayList<String>();
636 645
	}
637 646

  
638 647
	/**
......
826 835
		if (this.pSrcDirectory != null) {
827 836
			this.saveParameter(TBXPreferences.SOURCE, pSrcDirectory.getAbsolutePath());
828 837
		}
829

  
838
		
830 839
		return true;
831 840
	}
832 841

  
tmp/org.txm.core/src/java/org/txm/objects/CorpusBuild.java (revision 1611)
685 685
				Element edition = (Element)editionNodes.item(i);
686 686
				String name = edition.getAttribute(NAME);
687 687
				String built = edition.getAttribute("build_edition");
688
				String pbElement = edition.getAttribute("page_break_tag");
689
				int wpp = Integer.parseInt(edition.getAttribute("words_per_page"));
688 690
				//System.out.println("declare edition: "+name);
689 691
				//String corpus = edition.getAttribute("corpus");
690 692
				//				String mode = edition.getAttribute("mode");
691 693
				//				String script = edition.getAttribute("script");
692
				if (!this.getProject().getEditionNames().contains(name) && !"false".equals(built)) {
693
					this.getProject().getEditionNames().add(name);
694
				}
694
				
695
				EditionDefinition ed = this.getProject().getEditionDefinition(name);
696
				ed.setBuildEdition("true".equals(built));
697
				ed.setPageBreakTag(pbElement);
698
				ed.setWordsPerPage(wpp);
695 699
			}
696
			if (!this.getProject().getEditionNames().contains(this.getProject().getDefaultEdition()) && this.getProject().getEditionNames().size() > 0) {
697
				this.getProject().setDefaultEditionName(this.getProject().getEditionNames().get(0));
700
			
701
			List<String> editionNames = this.getProject().getEditionNames();
702
			if (!editionNames.contains(this.getProject().getDefaultEdition()) 
703
					&& editionNames.size() > 0) {
704
				this.getProject().setDefaultEditionName(editionNames.get(0));
698 705
			}
699 706
		}
700 707

  
tmp/org.txm.core/src/java/org/txm/objects/Workspace.java (revision 1611)
319 319
				File HTMLc = new File(HTMLs, corpusname);
320 320
				File REGISTRYc = new File(REGISTRY, corpusname.toLowerCase());
321 321
				File DATAc = new File(DATAs, corpusname);
322

  
322
				
323 323
				if (!(PARAMS.exists() && HTMLc.exists() && REGISTRYc.exists() && DATAc.exists())) {
324 324
					System.out.println(NLS.bind(TXMCoreMessages.errorColonSkippingTheLoadingOfTheP0Corpus, corpusname));
325 325
					System.out.println(NLS.bind(TXMCoreMessages.pARAMSColonP0, PARAMS));
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/SaveAnnotations.java (revision 1611)
17 17
import org.txm.annotation.kr.core.AnnotationManager;
18 18
import org.txm.annotation.kr.core.KRAnnotationEngine;
19 19
import org.txm.core.results.TXMResult;
20
import org.txm.rcp.TXMWindows;
20 21
import org.txm.rcp.commands.CloseEditorsUsing;
21 22
import org.txm.rcp.commands.workspace.UpdateCorpus;
22 23
import org.txm.rcp.editors.TXMEditor;
......
49 50
			e.printStackTrace();
50 51
			return null;
51 52
		}
53
		
54
		CorporaView.refresh();
52 55

  
53 56
		return corpus;
54 57
	}
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/KRAnnotation.java (revision 1611)
545 545
							// update editor corpus
546 546
							System.out.println("Fail to save annotations of the corpus."); //$NON-NLS-1$
547 547
						}
548
						
549
						CorporaView.refresh();
548 550
					}
549 551
				} catch(Exception ex) {
550 552
					ex.printStackTrace();
tmp/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/WordAnnotationToolbar.java (revision 1611)
389 389
			access.put("version", "0"); //$NON-NLS-1$ //$NON-NLS-2$
390 390
			currentKnowledgeRepository = KnowledgeRepositoryManager.createKnowledgeRepository(corpus.getMainCorpus().getName(), conf);
391 391
			KnowledgeRepositoryManager.registerKnowledgeRepository(currentKnowledgeRepository);
392
			//KRAnnotationEngine.registerKnowledgeRepositoryName(corpus, corpus.getMainCorpus().getName());
392 393
		}
393 394

  
394 395
		List<WordProperty> wordProperties = corpus.getProperties();
tmp/org.txm.annotation.rcp/src/org/txm/annotation/rcp/editor/AnnotationExtension.java (revision 1611)
137 137
				boolean saveSuccessful = true;
138 138
				boolean needToUpdateIndexes = false;
139 139
				//System.out.println("Saving annotations...");
140
				if (annotationAreas != null) {
140
				if (annotationAreas != null && annotationAreas.size() > 0) {
141 141
					for (AnnotationArea aa : annotationAreas) {
142 142
						saveSuccessful = saveSuccessful && aa.save();
143 143
						needToUpdateIndexes = needToUpdateIndexes || aa.needToUpdateIndexes();
144 144
					}
145
					CorporaView.refresh();
145 146
				}
146 147

  
147 148
				if (saveSuccessful && needToUpdateIndexes) {
......
169 170
					};
170 171
					job.schedule();
171 172
				}
172

  
173 173
			}
174 174

  
175 175
			@Override
tmp/org.txm.groovy.core/src/java/org/txm/groovy/core/GroovyScriptedImportEngine.java (revision 1611)
14 14
import org.txm.core.engines.Engine;
15 15
import org.txm.core.engines.EngineType;
16 16
import org.txm.core.engines.ScriptedImportEngine;
17
import org.txm.core.messages.TXMCoreMessages;
17 18
import org.txm.core.results.TXMResult;
18 19
import org.txm.groovy.core.messages.GroovyMessages;
19 20
import org.txm.objects.CorpusBuild;
......
147 148
					Log.info(GroovyMessages.restartingToolboxSearchengines);
148 149
					//Toolbox.restartWorkspace(null);
149 150
					Toolbox.getEngineManager(EngineType.SEARCH).restartEngines();
150

  
151
					Log.info(TXMCoreMessages.common_done);
152
					
151 153
//					DeleteDir.deleteDirectory(tempBinDirectory);
152 154

  
153 155
					//							IWorkspace workspace = ResourcesPlugin.getWorkspace();
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/OpenEdition.java (revision 1611)
92 92
				String[] editionsToOpen = getDefaultEditions(c);
93 93

  
94 94
				if (editionsToOpen.length == 0) { // the defaultEdition parameter is not set
95
					ArrayList<String> editionNames = c.getProject().getEditionNames();
95
					List<String> editionNames = c.getProject().getEditionNames();
96 96
					if (editionNames.size() > 0) { // use the first edition declared
97 97
						editionsToOpen = new String[1];
98 98
						editionsToOpen[0] = editionNames.get(0);
tmp/org.txm.edition.rcp/src/org/txm/edition/rcp/handlers/BackToText.java (revision 1611)
254 254
				String[] editionsToOpen = OpenEdition.getDefaultEditions(corpus);
255 255

  
256 256
				if (editionsToOpen.length == 0) { // the defaultEdition parameter is not set
257
					ArrayList<String> editionNames = corpus.getProject().getEditionNames();
257
					List<String> editionNames = corpus.getProject().getEditionNames();
258 258
					if (editionNames.size() > 0) { // use the first edition declared
259 259
						editionsToOpen = new String[1];
260 260
						editionsToOpen[0] = editionNames.get(0);

Also available in: Unified diff