Révision 2710

tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/UpdateCorpus.java (revision 2710)
1 1
package org.txm.rcp.commands.workspace;
2 2

  
3
import java.io.File;
4
import java.io.FileFilter;
5

  
3 6
import org.eclipse.core.commands.AbstractHandler;
4 7
import org.eclipse.core.commands.ExecutionEvent;
5 8
import org.eclipse.core.commands.ExecutionException;
......
20 23
import org.txm.rcp.utils.JobHandler;
21 24
import org.txm.rcp.views.corpora.CorporaView;
22 25
import org.txm.searchengine.cqp.corpus.MainCorpus;
26
import org.txm.utils.logger.Log;
23 27

  
24 28
public class UpdateCorpus extends AbstractHandler {
25 29
	
......
75 79
			});
76 80
		}
77 81
		
82
		File txmDir = new File(project.getProjectDirectory(), "txm");
83
		if (!txmDir.exists()) {
84
			Log.warning(NLS.bind("Error: Can't update the corpus: no 'txm' directory found: {0}", txmDir.getAbsolutePath()));
85
			return null;
86
		}
87
		
88
		File txmCorpusDirectory = new File(txmDir, corpus.getID());
89
		if (!txmCorpusDirectory.exists()) {
90
			Log.warning(NLS.bind("Error: Can't update the corpus: no 'txm/{0}' directory found: {1}", corpus.getID(), txmCorpusDirectory.getAbsolutePath()));
91
			return null;
92
		}
93
		
94
		if (txmCorpusDirectory.listFiles(new FileFilter() {
95
			
96
			@Override
97
			public boolean accept(File arg0) {
98
				return arg0.isFile() && arg0.getName().endsWith(".xml");
99
			}
100
		}).length == 0) {
101
			Log.warning(NLS.bind("Error: Can't update the corpus: no XML files found in {0}", txmCorpusDirectory.getAbsolutePath()));
102
			return null;
103
		}
104
		
78 105
		project.setDirty(false);// false=dont propagate dirty
79 106
		project.setNeedToBuild();
80 107
		project.setDoMultiThread(false); // too soon

Formats disponibles : Unified diff