Revision 919

tmp/org.txm.tmp.rcp/.classpath (revision 919)
1 1
<?xml version="1.0" encoding="UTF-8"?>
2 2
<classpath>
3 3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
5
		<accessrules>
6
			<accessrule kind="accessible" pattern="**"/>
7
		</accessrules>
8
	</classpathentry>
5 9
	<classpathentry kind="src" path="src"/>
6 10
	<classpathentry kind="output" path="bin"/>
7 11
</classpath>
tmp/org.txm.tmp.rcp/META-INF/MANIFEST.MF (revision 919)
3 3
Bundle-Name: TMP RCP
4 4
Bundle-SymbolicName: org.txm.tmp.rcp;singleton:=true
5 5
Bundle-Version: 1.0.0.qualifier
6
Require-Bundle: org.eclipse.core.runtime,
7
 org.eclipse.ui
6
Require-Bundle: org.eclipse.ui;visibility:=reexport
8 7
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
tmp/org.txm.core/src/java/org/txm/objects/Workspace.java (revision 919)
117 117
			for (String folder : createfolders) {
118 118
				new File(txmhomedir, folder).mkdir();
119 119
			}
120
			
120 121
			if (!xmlfile.exists()) {
121 122
				if (!writeEmptyWorkspaceFile(xmlfile)) {
122 123
					System.out.println("Error while creating workspace definition file: "+xmlfile);
tmp/org.txm.rcp/src/main/java/org/txm/rcp/ApplicationWorkbenchAdvisor.java (revision 919)
260 260

  
261 261
						// restore corpora if TXMHOME has been created
262 262
						if (txmHomeRestored) {
263
							createBackUpDirectory(monitor);
263
							//createBackUpDirectory(monitor);
264 264
							reloadCorporaFromBackUpDirectory(monitor);
265 265
							this.syncExec(new Runnable() {
266 266
								@Override
......
273 273
										// TODO Auto-generated catch block
274 274
										e.printStackTrace();
275 275
									}
276

  
277 276
								}
278 277
							});
279 278
						}
......
678 677
	 * internal variable to know if the txm home directory has been created
679 678
	 */
680 679
	private boolean txmHomeRestored;
680
	
681 681
	{
682 682
		Log.addHandler(severeDialobBoxHandler);
683 683
		severeDialobBoxHandler.setLevel(Level.SEVERE);
......
821 821
			Log.info(TXMUIMessages.ApplicationWorkbenchAdvisor_11);
822 822
			monitor.setTaskName(TXMUIMessages.ApplicationWorkbenchAdvisor_11);
823 823
			//File corporaDir = new File(txmhomedir.getAbsolutePath(), "corpora"); //$NON-NLS-1$
824
			corporaDir = new File(txmhomedir, "corpora"); //$NON-NLS-1$
824 825
			corporaDir.mkdir();
825 826

  
826 827
			File[] sampleCorpusFiles = sampleCorporaDirectory.listFiles(); //$NON-NLS-1$
......
866 867
		}
867 868

  
868 869
		// after loading sample corpora, restore older corpus
869
		if (backup.exists()) {
870
			System.out.print(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_53, backup));
871
			monitor.setTaskName(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_53, backup));
872

  
873
			File[] corpusDirs = backup.listFiles();
874

  
875
			if (corpusDirs != null) {
876

  
877
				for (File corpusDir : corpusDirs) { // fix corpus name lowercase letters
878
					if (!corpusDir.getName().equals(corpusDir.getName().toUpperCase())) {
879
						File upperCasedCorpusDir = new File(corpusDir.getParentFile(), corpusDir.getName().toUpperCase());
880
						if (!upperCasedCorpusDir.exists()) {
881
							corpusDir.renameTo(upperCasedCorpusDir);
882
						}
883
					}
884
				}
885
				corpusDirs = backup.listFiles();
886

  
887
				ArrayList<String> notMoved = new ArrayList<String>();
888
				ArrayList<File> broken = new ArrayList<File>();
889

  
890
				for (File corpusDir : corpusDirs) {
891
					if (!corpusDir.isDirectory()) continue; // ignore
892
					System.out.print("."); //$NON-NLS-1$
893
					File outdir = new File(corporaDir, corpusDir.getName());
894
					if (outdir.exists()) {
895
						//System.out.println("This setup provides a new version of the "+corpusDir.getName()+" sample corpus. Skipping the backup of "+corpusDir);
896
						notMoved.add(corpusDir.getName());
897
						continue;
898
					}
899

  
900
					try {
901
						Convert5To6 converter = new Convert5To6(corpusDir, outdir);
902
						if (converter.is5(true)) {
903
							if (!converter.start()) {
904
								System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_22+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_23);
905
								System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_54+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_55);
906
								System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_56);
907
								broken.add(corpusDir);
908
							} else {
909
								//System.out.println(Messages.ApplicationWorkbenchAdvisor_57+outdir);
910
								Base base = LoadBinaryCorpus.loadBinaryCorpus(outdir);
911
								basenames.add(base.getName());
912
							}
913
						} else {
914
							if (Convert5To6.is6(corpusDir)) {
915
								if (corpusDir.renameTo(outdir)) {
916
									Base base = LoadBinaryCorpus.loadBinaryCorpus(outdir);
917
									if (base == null) {
918
										System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_58+outdir);
919
										System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_59+corpusDir);
920
										outdir.renameTo(corpusDir);
921
										broken.add(corpusDir);
922
									} else {
923
										basenames.add(base.getName());
924
									}
925
								} else {
926
									System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_24+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_26+outdir);
927
									broken.add(corpusDir);
928
								}
929
							} else {
930
								System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_60+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_61);
931
								broken.add(corpusDir);
932
							}
933
						}
934
					} catch (Throwable e) {
935
						System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_59+corpusDir);
936
						System.out.println(TXMUIMessages.ERROR+e);
937
						outdir.renameTo(corpusDir);
938
					}
939
				}
940
				System.out.println();
941
				if (sampleCorpusLoaded.size() > 0) {
942
					if (sampleCorpusLoaded.size() == 1) {
943
						System.out.println(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_43_single, StringUtils.join(sampleCorpusLoaded, ", "))); //$NON-NLS-1$
944
					} else {
945
						System.out.println(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_43, StringUtils.join(sampleCorpusLoaded, ", "))); //$NON-NLS-1$
946
					}
947
				}
948

  
949
				if (broken.size() > 0) {
950
					errorbackup.mkdir();
951
					System.out.println(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_48, StringUtils.join(broken, ", "), errorbackup)); //$NON-NLS-1$
952
					for(File corpusDir : broken) {
953
						if (corpusDir.exists())
954
							corpusDir.renameTo(new File(errorbackup, corpusDir.getName()));
955
					}
956
				}
957
			}
958
		}
870
//		if (backup.exists()) {
871
//			System.out.print(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_53, backup));
872
//			monitor.setTaskName(NLS.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_53, backup));
873
//
874
//			File[] corpusDirs = backup.listFiles();
875
//
876
//			if (corpusDirs != null) {
877
//
878
//				for (File corpusDir : corpusDirs) { // fix corpus name lowercase letters
879
//					if (!corpusDir.getName().equals(corpusDir.getName().toUpperCase())) {
880
//						File upperCasedCorpusDir = new File(corpusDir.getParentFile(), corpusDir.getName().toUpperCase());
881
//						if (!upperCasedCorpusDir.exists()) {
882
//							corpusDir.renameTo(upperCasedCorpusDir);
883
//						}
884
//					}
885
//				}
886
//				corpusDirs = backup.listFiles();
887
//
888
//				ArrayList<String> notMoved = new ArrayList<String>();
889
//				ArrayList<File> broken = new ArrayList<File>();
890
//
891
//				for (File corpusDir : corpusDirs) {
892
//					if (!corpusDir.isDirectory()) continue; // ignore
893
//					System.out.print("."); //$NON-NLS-1$
894
//					File outdir = new File(corporaDir, corpusDir.getName());
895
//					if (outdir.exists()) {
896
//						//System.out.println("This setup provides a new version of the "+corpusDir.getName()+" sample corpus. Skipping the backup of "+corpusDir);
897
//						notMoved.add(corpusDir.getName());
898
//						continue;
899
//					}
900
//
901
//					try {
902
//						Convert5To6 converter = new Convert5To6(corpusDir, outdir);
903
//						if (converter.is5(true)) {
904
//							if (!converter.start()) {
905
//								System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_22+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_23);
906
//								System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_54+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_55);
907
//								System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_56);
908
//								broken.add(corpusDir);
909
//							} else {
910
//								//System.out.println(Messages.ApplicationWorkbenchAdvisor_57+outdir);
911
//								Base base = LoadBinaryCorpus.loadBinaryCorpus(outdir);
912
//								basenames.add(base.getName());
913
//							}
914
//						} else {
915
//							if (Convert5To6.is6(corpusDir)) {
916
//								if (corpusDir.renameTo(outdir)) {
917
//									Base base = LoadBinaryCorpus.loadBinaryCorpus(outdir);
918
//									if (base == null) {
919
//										System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_58+outdir);
920
//										System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_59+corpusDir);
921
//										outdir.renameTo(corpusDir);
922
//										broken.add(corpusDir);
923
//									} else {
924
//										basenames.add(base.getName());
925
//									}
926
//								} else {
927
//									System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_24+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_26+outdir);
928
//									broken.add(corpusDir);
929
//								}
930
//							} else {
931
//								System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_60+corpusDir+TXMUIMessages.ApplicationWorkbenchAdvisor_61);
932
//								broken.add(corpusDir);
933
//							}
934
//						}
935
//					} catch (Throwable e) {
936
//						System.out.println(TXMUIMessages.ApplicationWorkbenchAdvisor_59+corpusDir);
937
//						System.out.println(TXMUIMessages.ERROR+e);
938
//						outdir.renameTo(corpusDir);
939
//					}
940
//				}
941
//				System.out.println();
942
//				if (sampleCorpusLoaded.size() > 0) {
943
//					if (sampleCorpusLoaded.size() == 1) {
944
//						System.out.println(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_43_single, StringUtils.join(sampleCorpusLoaded, ", "))); //$NON-NLS-1$
945
//					} else {
946
//						System.out.println(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_43, StringUtils.join(sampleCorpusLoaded, ", "))); //$NON-NLS-1$
947
//					}
948
//				}
949
//
950
//				if (broken.size() > 0) {
951
//					errorbackup.mkdir();
952
//					System.out.println(TXMUIMessages.bind(TXMUIMessages.ApplicationWorkbenchAdvisor_48, StringUtils.join(broken, ", "), errorbackup)); //$NON-NLS-1$
953
//					for(File corpusDir : broken) {
954
//						if (corpusDir.exists())
955
//							corpusDir.renameTo(new File(errorbackup, corpusDir.getName()));
956
//					}
957
//				}
958
//			}
959
//		}
959 960
	}
960 961

  
961 962
	/**
tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/CorporaView.java (revision 919)
55 55
import org.eclipse.jface.viewers.TreeViewer;
56 56
import org.eclipse.jface.viewers.TreeViewerEditor;
57 57
import org.eclipse.jface.viewers.Viewer;
58
import org.eclipse.jface.viewers.ViewerComparator;
58 59
import org.eclipse.jface.viewers.ViewerSorter;
59 60
import org.eclipse.swt.SWT;
60 61
import org.eclipse.swt.events.KeyAdapter;
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteImportScript.java (revision 919)
332 332
		int idx = scriptPackage.indexOf("Loader");
333 333
		scriptPackage = "org/txm/importer/" + scriptPackage.substring(0, idx);
334 334
		
335
		return BundleUtils.replaceFilesIfNewer("org.txm.groovy.core", "src/groovy", scriptPackage, 
335
		return BundleUtils.replaceFilesIfNewer("org.txm.core", "src", scriptPackage, 
336 336
				script.getName(), script);
337 337
	}
338 338
}

Also available in: Unified diff