Révision 1218
tmp/org.txm.core/src/java/org/txm/objects/Project.java (revision 1218) | ||
---|---|---|
84 | 84 |
* If true, the computing will build the main corpus, editions, texts, etc. |
85 | 85 |
*/ |
86 | 86 |
protected boolean needToBuild; |
87 |
|
|
88 | 87 |
|
88 |
|
|
89 | 89 |
@Parameter(key=TBXPreferences.CLEAN) |
90 | 90 |
private boolean pCleanAfterBuild; |
91 | 91 |
|
... | ... | |
186 | 186 |
this.setVisible(false); |
187 | 187 |
|
188 | 188 |
initRCPStuffs(); |
189 |
|
|
189 |
|
|
190 | 190 |
// FIXME: SJ: this code doesn't flush the other nodes (EditionsPreferences, Tokenizer, etc. see if it's a problem at this stage or not) |
191 | 191 |
this.autoSaveParametersFromAnnotations(); |
192 | 192 |
this.saveParameters(); |
... | ... | |
202 | 202 |
public Project(Workspace workspace, String name) throws Exception { |
203 | 203 |
this(workspace, name, true); |
204 | 204 |
} |
205 |
|
|
205 |
|
|
206 | 206 |
/** |
207 | 207 |
* Instantiates a new existing project from persistence. |
208 | 208 |
* This project will not be builded, main corpus, texts, editions, etc. will be restored from persistence. |
... | ... | |
218 | 218 |
this.dirty = false; |
219 | 219 |
this.hasBeenComputedOnce = true; |
220 | 220 |
this.setVisible(false); |
221 |
|
|
221 |
|
|
222 | 222 |
initRCPStuffs(); |
223 | 223 |
|
224 | 224 |
// |
... | ... | |
245 | 245 |
Log.severe("Project.canCompute(): can not compute with missing name."); |
246 | 246 |
return false; |
247 | 247 |
} |
248 |
|
|
248 |
|
|
249 | 249 |
if(this.needToBuild == true && (pSrcDirectory == null || pImportModuleName == null)) { |
250 | 250 |
Log.severe("Project.canCompute(): the project needs to build but source directory or import module name is missing."); |
251 | 251 |
return false; |
252 | 252 |
} |
253 | 253 |
return true; |
254 | 254 |
} |
255 |
|
|
255 |
|
|
256 | 256 |
/** |
257 | 257 |
* flag the project to be rebuild with the Import module |
258 | 258 |
*/ |
... | ... | |
266 | 266 |
|
267 | 267 |
// build the main corpus, texts, editions, etc. |
268 | 268 |
if(this.needToBuild) { |
269 |
|
|
269 |
|
|
270 | 270 |
// if (pImportXMLParameters != null) { |
271 | 271 |
// pImportXMLParameters.load(); |
272 | 272 |
// this._load(pImportXMLParameters.name); |
273 | 273 |
// // convert to new preferences persistence |
274 | 274 |
// } |
275 |
|
|
275 |
|
|
276 | 276 |
if (!rcpProject.getName().equals(userName)) { // project directory and project name must stay in sync |
277 | 277 |
IPath destination = new Path(this.getName()); |
278 | 278 |
if (destination.toFile().exists()) { |
... | ... | |
281 | 281 |
} |
282 | 282 |
rcpProject.move(destination, true, null); |
283 | 283 |
} |
284 |
|
|
284 |
|
|
285 | 285 |
ImportEngines engines = Toolbox.getImportEngines(); |
286 |
|
|
286 |
|
|
287 | 287 |
//File scriptfile = new File(Toolbox.getTxmHomePath(), "scripts/groovy/user/org/txm/scripts/importer/"+importName+"/"+importName+"Loader.groovy"); //$NON-NLS-1$ |
288 | 288 |
ImportEngine engine = engines.getEngine(getImportModuleName()); |
289 | 289 |
if (engine == null) { |
... | ... | |
296 | 296 |
// } |
297 | 297 |
// }; |
298 | 298 |
//Log.severe("Project._compute(): Import engine not found."); |
299 |
|
|
299 |
|
|
300 | 300 |
// no import set |
301 | 301 |
return true; |
302 | 302 |
} |
303 |
|
|
303 |
|
|
304 | 304 |
if (monitor == null || monitor.isCanceled()) { |
305 | 305 |
monitor = new LogMonitor("computing "+this); |
306 | 306 |
} |
307 |
|
|
307 |
|
|
308 | 308 |
Log.finest("RUNNING IMPORT MODULE WITH NAME = " + getImportModuleName()); |
309 |
|
|
309 |
|
|
310 | 310 |
// This step could be done only if the compiler step if done and only if it modifying/deleteing the corpus builds |
311 | 311 |
for (CorpusBuild corpus : getCorpusBuilds()) { |
312 | 312 |
if (corpus != null) { |
313 | 313 |
corpus.deleteChildren(null); // remove all Corpus results |
314 | 314 |
} |
315 | 315 |
} |
316 |
|
|
316 |
|
|
317 | 317 |
boolean state = engine.build(this, monitor).isOK(); |
318 | 318 |
if(state == true) { |
319 | 319 |
this.needToBuild = false; |
320 | 320 |
} |
321 | 321 |
return state; |
322 |
|
|
322 |
|
|
323 | 323 |
} |
324 | 324 |
// Nothing to do if the project does not need to build |
325 | 325 |
else { |
326 | 326 |
return true; |
327 | 327 |
} |
328 | 328 |
} |
329 |
|
|
329 |
|
|
330 | 330 |
/** |
331 | 331 |
* Initializes the RCP project and project scope. |
332 | 332 |
* |
... | ... | |
481 | 481 |
public boolean _load(BaseOldParameters params) throws Exception { |
482 | 482 |
params.load(); |
483 | 483 |
userName = params.name; |
484 |
|
|
485 |
// set the improt module name using the Loader script name |
|
486 |
this.pImportModuleName = params.scriptFile; |
|
487 |
if (this.pImportModuleName != null) { |
|
488 |
int idx = this.pImportModuleName.indexOf("Loader.groovy"); |
|
489 |
if (idx > 0) { |
|
490 |
this.pImportModuleName = this.pImportModuleName.substring(0, idx); |
|
491 |
idx = this.pImportModuleName.lastIndexOf("/"); |
|
492 |
if (idx > 0 && this.pImportModuleName.length() > idx) { |
|
493 |
this.pImportModuleName = this.pImportModuleName.substring(idx+1); |
|
494 |
} |
|
495 |
} |
|
496 |
} else { |
|
497 |
this.pImportModuleName = "xtz"; |
|
498 |
} |
|
499 |
|
|
500 |
this.pSrcDirectory = params.paramFile.getParentFile(); |
|
501 |
if (pSrcDirectory == null) { |
|
502 |
pSrcDirectory = new File(getProjectDirectory(), "src"); |
|
503 |
} |
|
504 |
|
|
484 | 505 |
File dir = new File(this.getWorkspace().getLocation(), userName); |
485 | 506 |
File paramFile = new File(dir, "import.xml"); |
486 | 507 |
if (!paramFile.exists()) return false; |
... | ... | |
747 | 768 |
|
748 | 769 |
if (binarydir.exists() && exportzip.getParentFile().exists()) { |
749 | 770 |
this.save(); |
750 |
|
|
771 |
|
|
751 | 772 |
try { |
752 | 773 |
Zip.compress(binarydir, exportzip, monitor); |
753 | 774 |
} catch (IOException e) { |
... | ... | |
898 | 919 |
e.printStackTrace(); |
899 | 920 |
} |
900 | 921 |
} |
901 |
|
|
922 |
|
|
902 | 923 |
Toolbox.notifyEngines(this, "clean"); |
903 | 924 |
//DeleteDir.deleteDirectory(getProjectDirectory()); |
904 | 925 |
} |
... | ... | |
1234 | 1255 |
try { |
1235 | 1256 |
ProjectScope scope = this.getPreferencesScope(); |
1236 | 1257 |
scope.getNode("").flush(); |
1237 |
|
|
1258 |
|
|
1238 | 1259 |
autoSaveParametersFromAnnotations(); |
1239 | 1260 |
saveParameters(); |
1240 |
|
|
1261 |
|
|
1241 | 1262 |
List<TXMResult> results = this.getDeepChildren(); |
1242 | 1263 |
for (int i = 0; i < results.size(); i++) { |
1243 | 1264 |
TXMResult r = results.get(i); |
... | ... | |
1247 | 1268 |
TXMPreferences.flush(r); |
1248 | 1269 |
} |
1249 | 1270 |
} |
1250 |
|
|
1271 |
|
|
1251 | 1272 |
Toolbox.notifyEngines(this, "save"); // save things before exporting or else |
1252 | 1273 |
} catch (Exception e) { |
1253 | 1274 |
e.printStackTrace(); |
... | ... | |
1259 | 1280 |
public IProject getRCPProject() { |
1260 | 1281 |
return rcpProject; |
1261 | 1282 |
} |
1262 |
|
|
1283 |
|
|
1263 | 1284 |
public String toString() { |
1264 | 1285 |
return this.userName+" "+this.rcpProject.getLocation(); |
1265 | 1286 |
} |
Formats disponibles : Unified diff