Revision 763

tmp/org.txm.rcp/src/main/java/org/txm/rcp/views/corpora/CorporaView.java (revision 763)
47 47
import org.eclipse.jface.viewers.TreeViewer;
48 48
import org.eclipse.jface.viewers.Viewer;
49 49
import org.eclipse.jface.viewers.ViewerFilter;
50
import org.eclipse.jface.viewers.ViewerSorter;
50 51
import org.eclipse.swt.SWT;
51 52
import org.eclipse.swt.events.KeyAdapter;
52 53
import org.eclipse.swt.events.KeyEvent;
......
82 83
import org.txm.rcp.messages.TXMUIMessages;
83 84
import org.txm.rcp.utils.JobHandler;
84 85
import org.txm.searchengine.cqp.corpus.Corpus;
86
import org.txm.searchengine.cqp.corpus.Partition;
87
import org.txm.searchengine.cqp.corpus.Subcorpus;
85 88
import org.txm.utils.logger.Log;
86 89
//import org.txm.functions.queryindex.QueryIndex;
87 90
//import org.txm.rcp.editors.input.QueryIndexEditorInput;
......
204 207
		treeViewer.setLabelProvider(
205 208
				new DecoratingLabelProvider(new TXMResultLabelProvider(),
206 209
						PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()));
210
		
211
		// for now the sorter is used to sort the Corpus, Subcorpus and partition objects
212
		treeViewer.setSorter(new ViewerSorter() {
213
		    public int category(Object element) {
214
		    	if (element instanceof Subcorpus) return 2; // must do it before the Corpus test
215
		    	else if (element instanceof Corpus) return 0;
216
		        else if (element instanceof Partition) return 1;
217
		        else return 3;
218
		    }
219
		    
220
		    public int compare(Viewer viewer, Object e1, Object e2) {
221
		    	
222
		    	int cat1 = category(e1);
223
		        int cat2 = category(e2);
207 224

  
225
		        if (cat1 != cat2) {
226
					return cat1 - cat2;
227
				}
228
		    	
229
		    	if (e1 instanceof TXMResult && e2 instanceof TXMResult) {
230
		    		return TXMResult.compare((TXMResult)e1, (TXMResult)e2);
231
		    	} else {
232
		    		return super.compare(viewer, e1, e2);
233
		    	}
234
		    }
235
		});
236
		
208 237
		if (Toolbox.isInitialized()) {
209 238
			Workspace w = null;
210 239
			while (w == null) {
tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorporaDirectory.java (revision 763)
132 132
							// copy files in the new current corpora directory
133 133
							File destDir = new File(corporaDirectory, corpusDirectory.getName());
134 134
							if (destDir.exists()) {
135
								System.out.println("Le répertoire "+destDir+" existe déjà. Chargement du corpus du répertoire "+corpusDirectory+" ignoré.");
135
								System.out.println("Le répertoire "+destDir+" existe déjà. Chargement du corpus de répertoire "+corpusDirectory.getName()+" ignoré.");
136 136
								continue;
137 137
							}
138 138

  
......
142 142
						} else if (corpusDirectory.getName().endsWith(".txm")) {
143 143
							// corpusDirectory is a TXM archive
144 144
							String basedirname = Zip.getRoot(corpusDirectory); 
145
							File destDir = new File(corporaDirectory, basedirname);
146
							if (destDir.exists()) {
147
								System.out.println("Le répertoire "+destDir+" existe déjà. Chargement du corpus "+corpusDirectory.getName()+" ignoré.");
148
								continue;
149
							}
145 150
							Zip.decompress(corpusDirectory.getAbsolutePath(), corporaDirectory.getAbsolutePath(), false, this);
146
							corpusDirectory = new File(corporaDirectory, basedirname);
151
							corpusDirectory = destDir;
147 152
						} else {
148 153
							continue; // not a corpus
149 154
						}
......
162 167

  
163 168
					this.acquireSemaphore();
164 169
					org.txm.Toolbox.restartWorkspace(monitor);
165
					Toolbox.getEngineManager(EngineType.SEARCH).restartEngines();
170
					Toolbox.getEngineManager(EngineType.SEARCH).startEngines(monitor);
166 171
					this.releaseSemaphore();
167 172

  
168 173

  
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 763)
61 61
public abstract class TXMResult implements Cloneable, IProgressMonitor, Comparable<TXMResult> {
62 62

  
63 63

  
64
	public static final DateFormat ID_TIME_FORMAT = new SimpleDateFormat("YYYYMMdd");
64
	public static final DateFormat ID_TIME_FORMAT = new SimpleDateFormat("YYYYMMdd-HHmmssSSS");
65 65
	public static final Pattern FILE_NAME_PATTERN = Pattern.compile("[^a-zA-Z0-9\\.-]+"); //$NON-NLS-1$
66 66
	public static final String UNDERSCORE = "_";
67 67

  
......
226 226
	protected void createUUID() {
227 227
		// FIXME: see if it's useful to put the class name or not, should be better to save it in the .prefs
228 228
		//this.uniqueID = this.getClass().getName() + '@' + ID_TIME_FORMAT.format(new Date(System.currentTimeMillis())) + "_" + UUID.randomUUID();
229
		this.uniqueID = "txm_res_" + ID_TIME_FORMAT.format(new Date(System.currentTimeMillis())) + "_" + UUID.randomUUID();
229
		this.uniqueID = ID_TIME_FORMAT.format(new Date(System.currentTimeMillis())) + "_" + UUID.randomUUID();
230 230
	}
231 231

  
232 232
	/**
......
1731 1731
		return Integer.compare(this.weight, o.weight);
1732 1732
	}
1733 1733

  
1734
	
1734
	public static int compare(TXMResult e1, TXMResult e2) {
1735
		if (e1 == null && e2 == null) return 0;
1736
		if (e1 == null) return 1;
1737
		
1738
		return e1.getUUID().compareTo(e2.getUUID());
1739
	}
1735 1740
}

Also available in: Unified diff