Révision 3435

TXM/trunk/org.txm.annotation.kr.core/src/org/txm/annotation/kr/core/preferences/KRAnnotationPreferences.java (revision 3435)
13 13
	
14 14
	public static final String UPDATE_EDITION = "udpate_edition";
15 15
	
16
	public static final String UPDATE_INDEXES = "udpate_indexes";
16
	public static final String UPDATE = "udpate";
17 17
	
18 18
	public static final String PRESERVE_ANNOTATIONS = "reset_temporary_annotations_when leaving_txm";
19 19
	
......
36 36
		super.initializeDefaultPreferences();
37 37
		Preferences preferences = this.getDefaultPreferencesNode();
38 38
		preferences.putBoolean(UPDATE_EDITION, true);
39
		preferences.putBoolean(UPDATE_INDEXES, true);
39
		preferences.putBoolean(UPDATE, true);
40 40
		preferences.putBoolean(PRESERVE_ANNOTATIONS, false);
41 41
	}
42 42
}
TXM/trunk/org.txm.core/src/java/org/txm/Toolbox.java (revision 3435)
47 47
import org.apache.commons.lang.StringUtils;
48 48
import org.eclipse.core.internal.registry.osgi.OSGIUtils;
49 49
import org.eclipse.core.internal.resources.Project;
50
import org.eclipse.core.resources.IProject;
51
import org.eclipse.core.resources.IWorkspace;
52
import org.eclipse.core.resources.ResourcesPlugin;
50 53
import org.eclipse.core.runtime.CoreException;
51 54
import org.eclipse.core.runtime.IConfigurationElement;
52 55
import org.eclipse.core.runtime.IProgressMonitor;
......
70 73
import org.txm.utils.LogMonitor;
71 74
import org.txm.utils.OSDetector;
72 75
import org.txm.utils.io.FileCopy;
76
import org.txm.utils.io.IOUtils;
73 77
import org.txm.utils.logger.Log;
74 78

  
75 79
/**
......
829 833
	public static String getConfigurationDirectory() {
830 834
		return OSGIUtils.getDefault().getConfigurationLocation().getURL().toString().substring(5);
831 835
	}
836

  
837
	public static void writeStartupCorporaDiagnostics(File checkupResultFile) {
838
		
839
		Log.warning(NLS.bind("TXM was not correctly closed, see the report in the ''{0}'' file", checkupResultFile.getAbsolutePath()));
840
		
841
		StringBuilder builder = new StringBuilder();
842
		
843
		IWorkspace rcpWorkspace = ResourcesPlugin.getWorkspace();
844
		IProject corporaDirectory = rcpWorkspace.getRoot().getProject("corpora");
845
		
846
		if (!corporaDirectory.exists()) {
847
			builder.append("No 'corpora' not found in workspace.");
848
			return;
849
		}
850
		IProject projects[] = rcpWorkspace.getRoot().getProjects();
851
		
852
		for (IProject rcpProject : projects) {
853

  
854
			if (rcpProject.equals(corporaDirectory)) continue;
855
			
856
			String s1 = rcpProject.getLocationURI().toString();
857
			String s2 = corporaDirectory.getLocationURI().toString();
858
			
859
			if (!s1.startsWith(s2)) {
860
				builder.append("RCP Project: "+rcpProject.getName()+" not in the corpora.\n\n");
861
				continue;
862
			}
863
			
864
			org.txm.objects.Project project = Toolbox.workspace.getProject(rcpProject.getName().toUpperCase());
865
		
866
			if (project == null) {
867
				builder.append("Corpus Project: "+rcpProject.getName()+" not found.\n\n");
868
				continue;
869
			}
870
			
871
			File indexes = new File(project.getProjectDirectory(), "data/"+project.getName());
872
			if (indexes.exists()) {
873
				if (indexes.listFiles().length == 0) {
874
					builder.append(" no CQP data files in directory: "+indexes.getAbsolutePath());
875
					builder.append("\n");
876
				}
877
			} else {
878
				builder.append(" no CQP data directory: "+indexes.getAbsolutePath());
879
				builder.append("\n");
880
			}
881
			
882
			builder.append("Project: "+project.getName()+" at "+project.getProjectDirectory());
883
			builder.append("\n");
884
			builder.append(" creation: "+project.getCreationDate());
885
			builder.append("\n");
886
			builder.append(" update: "+project.getLastComputingDate());
887
			builder.append("\n");
888
			builder.append(" 'default' edition: "+project.getEditionDefinition("default"));
889
			builder.append("\n");
890
			builder.append(" 'facs' edition: "+project.getEditionDefinition("facs"));
891
			builder.append("\n");
892
			builder.append(" 'preferences': "+TXMPreferences.dumpToString(project.getParametersNodePath()));
893
			builder.append("\n");
894
			
895
			builder.append(" Results: ");
896
			builder.append("\n");
897
			for (TXMResult result : project.getDeepChildren()) {
898
				builder.append("  "+result.getName()+" ("+result.getResultType()+"): "+result.getSimpleDetails());
899
				builder.append("\n");
900
				builder.append("  'preferences': "+TXMPreferences.dumpToString(result.getParametersNodePath()));
901
				builder.append("\n");
902
			}
903
			builder.append("\n");
904
		}
905
		
906
		IOUtils.write(checkupResultFile, builder.toString());
907
		
908
	}
832 909
}
TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/edition/WordAnnotationToolbar.java (revision 3435)
925 925
	
926 926
	@Override
927 927
	public boolean needToUpdateIndexes() {
928
		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_INDEXES);
928
		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE);
929 929
	}
930 930
	
931 931
	@Override
TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/SimpleKRAnnotation.java (revision 3435)
801 801
	
802 802
	@Override
803 803
	public boolean needToUpdateIndexes() {
804
		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_INDEXES);
804
		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE);
805 805
	}
806 806
	
807 807
	@Override
TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/KRAnnotation.java (revision 3435)
1061 1061
	
1062 1062
	@Override
1063 1063
	public boolean needToUpdateIndexes() {
1064
		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_INDEXES);
1064
		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE);
1065 1065
	}
1066 1066
	
1067 1067
	@Override
TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/concordance/WordAnnotationToolbar.java (revision 3435)
1051 1051
	
1052 1052
	@Override
1053 1053
	public boolean needToUpdateIndexes() {
1054
		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_INDEXES);
1054
		return KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE);
1055 1055
	}
1056 1056
	
1057 1057
	@Override
TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/commands/SaveAnnotationsAndUpdateCorpus.java (revision 3435)
48 48
				return null;
49 49
			}
50 50
			
51
			
52
			
53 51
			if (job.getState() == Status.OK_STATUS.getCode()) {
54
				if (KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_INDEXES)) {
52
				if (KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE)) {
55 53
					
56 54
					JobHandler job2 = new JobHandler("Updating corpus editions and indexes", true) {
57 55
						
......
60 58
							this.runInit(monitor);
61 59
							
62 60
							try {
63
								monitor.setTaskName("Updating corpus indexes and editions");
61
								monitor.setTaskName("Updating corpus");
64 62
								if (corpus != null && UpdateCorpus.update(corpus, KRAnnotationPreferences.getInstance().getBoolean(KRAnnotationPreferences.UPDATE_EDITION)) != null) {
65 63
									monitor.worked(50);
66 64
									this.syncExec(new Runnable() {
TXM/trunk/org.txm.annotation.kr.rcp/src/org/txm/annotation/kr/rcp/preferences/KRAnnotationPreferencePage.java (revision 3435)
28 28
package org.txm.annotation.kr.rcp.preferences;
29 29

  
30 30
import org.eclipse.jface.preference.BooleanFieldEditor;
31
import org.eclipse.jface.preference.FieldEditor;
32
import org.eclipse.jface.util.PropertyChangeEvent;
31 33
import org.eclipse.swt.SWT;
32 34
import org.eclipse.swt.layout.GridData;
33 35
import org.eclipse.swt.layout.RowLayout;
......
52 54

  
53 55
public class KRAnnotationPreferencePage extends TXMPreferencePage {
54 56
	
57
	private BooleanFieldEditor updateEditionField;
58
	private BooleanFieldEditor updateCorpusField;
59
	private Group updateGroup;
60

  
55 61
	/**
56 62
	 * Instantiates the preference page.
57 63
	 */
......
68 74
	public void createFieldEditors() {
69 75
		this.addField(new BooleanFieldEditor(KRAnnotationPreferences.PRESERVE_ANNOTATIONS, "Preserve annotations between TXM sessions", this.getFieldEditorParent()));
70 76
		
71
		Group updateGroup = new Group(getFieldEditorParent(), SWT.NONE);
72
		updateGroup.setText("Saving annotations");
77
		updateCorpusField = new BooleanFieldEditor(KRAnnotationPreferences.UPDATE, "Update corpus after writing the annotations (warning the annotations won't be visible but saved in the XML-TXM files)" , this.getFieldEditorParent());
78
		this.addField(updateCorpusField);
79
		
80
		updateGroup = new Group(getFieldEditorParent(), SWT.NONE);
81
		updateGroup.setText("Update option");
73 82
		GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, true, false);
74 83
		gridData2.horizontalSpan = 3;
75 84
		gridData2.verticalIndent = 10;
......
78 87
		rlayout.marginHeight = 5;
79 88
		updateGroup.setLayout(rlayout);
80 89
		
81
		this.addField(new BooleanFieldEditor(KRAnnotationPreferences.UPDATE_EDITION, "Update editions" , updateGroup));
82
		this.addField(new BooleanFieldEditor(KRAnnotationPreferences.UPDATE_INDEXES, "Update CQP indexes (warning the annotations won't be visible but saved in the XML-TXM files)" , updateGroup));
90
		updateEditionField = new BooleanFieldEditor(KRAnnotationPreferences.UPDATE_EDITION, "Update editions" , updateGroup);
91
		this.addField(updateEditionField);
83 92
	}
84 93
	
94
	/* (non-Javadoc)
95
	 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
96
	 */
97
	@Override
98
	public void propertyChange(PropertyChangeEvent event) {
99
		if (((FieldEditor) event.getSource()).getPreferenceName().equals(KRAnnotationPreferences.UPDATE)) {
100
			updateEditionField.setEnabled(updateCorpusField.getBooleanValue(), updateGroup);
101
		}
102
	}
103
	
85 104
	/*
86
	 * (non-Javadoc)
87 105
	 * 
88 106
	 * @see
89 107
	 * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/handlers/files/EditFile.java (revision 3435)
95 95
			IFileStore fileOnLocalDisk = EFS.getLocalFileSystem().getStore(file.toURI());
96 96

  
97 97
			FileStoreEditorInput editorInput = new FileStoreEditorInput(fileOnLocalDisk);
98
			IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
98
			IWorkbenchWindow window = PlatformUI.getWorkbench().getWorkbenchWindows()[0];
99 99
			IWorkbenchPage page = window.getActivePage();
100 100

  
101 101
			String ID = null;
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchWindowAdvisor.java (revision 3435)
27 27
//
28 28
package org.txm.rcp;
29 29

  
30
import java.io.File;
30 31
import java.util.ArrayList;
31 32
import java.util.HashMap;
32 33
import java.util.Iterator;
33 34

  
34
import org.apache.commons.lang.StringUtils;
35 35
import org.eclipse.e4.ui.model.application.ui.SideValue;
36 36
import org.eclipse.e4.ui.model.application.ui.basic.MTrimBar;
37 37
import org.eclipse.e4.ui.model.application.ui.basic.MTrimElement;
......
209 209
				}
210 210
			}
211 211
			mess.append("\n\nContinue and lost the unsaved annotations ");
212
			return MessageDialog.openConfirm(this.getWindowConfigurer().getWindow().getShell(), "Some annotations are not saved", mess.toString());
213
		} else {
214
			return true;
212
			if(!MessageDialog.openConfirm(this.getWindowConfigurer().getWindow().getShell(), "Some annotations are not saved", mess.toString())) {
213
				return false;
214
			}
215 215
		}
216
		
217
		return true;
216 218
	}
217 219
}
TXM/trunk/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchAdvisor.java (revision 3435)
35 35
import java.net.URL;
36 36
import java.util.ArrayList;
37 37
import java.util.Arrays;
38
import java.util.Date;
38 39
import java.util.HashMap;
39 40
import java.util.List;
40 41
import java.util.logging.Handler;
......
143 144
	/**
144 145
	 * initialization code done after the splash screen.
145 146
	 *
146
	 * @param configurer the configurer
147
	 * @param configurer the RCP configurer
147 148
	 */
148 149
	@Override
149 150
	public void initialize(IWorkbenchConfigurer configurer) {
......
234 235
							return Status.CANCEL_STATUS;
235 236
						}
236 237
						
238
						// CREATE THE CLOSE CONTROL FILE
239
						if (new File("txm_was_not_closed_correctly.lock").exists()) { // the close control file was not deleted
240
							
241
							File checkupResultFile = new File("startup_diagnostic_"+Toolbox.dateformat.format(new Date())+".txt");
242
							Toolbox.writeStartupCorporaDiagnostics(checkupResultFile);
243
							this.syncExec(new Runnable() {
244
								@Override
245
								public void run() {
246
									org.txm.rcp.handlers.files.EditFile.openfile(checkupResultFile);
247
								}
248
							});
249
							
250
							new File("txm_was_not_closed_correctly.lock").delete();
251
						}
252
						new File("txm_was_not_closed_correctly.lock").createNewFile();
253
						
237 254
						Log.info(TXMUIMessages.info_txmIsReady);
238 255
						monitor.done();
239 256
					}
......
522 539
		Toolbox.shutdown();
523 540
		
524 541
		callStopScript();
542
		
543
		new File("txm_was_not_closed_correctly.lock").delete();
525 544
	}
526 545
	
527 546
	/**

Formats disponibles : Unified diff