Révision 2632

tmp/org.txm.core/src/java/org/txm/core/engines/ImportEngine.java (revision 2632)
4 4
import org.eclipse.core.runtime.IStatus;
5 5
import org.txm.core.results.TXMResult;
6 6
import org.txm.objects.Project;
7
import org.txm.utils.TXMProgressMonitor;
8 7

  
9 8
public abstract class ImportEngine implements Engine {
10 9
	
tmp/org.txm.core/src/java/org/txm/objects/Project.java (revision 2632)
184 184
		this.hasBeenComputedOnce = true;
185 185
		this.setVisible(false);
186 186
		
187
		initRCPStuffs(new TXMProgressMonitor());
187
		initRCPStuffs(new LogMonitor());
188
		
188 189
		if (isOpen()) {
189 190
			this.autoSaveParametersFromAnnotations();
190 191
			this.saveParameters();
......
192 193
		}
193 194
	}
194 195
	
196
	
195 197
	/**
198
	 * Instantiates a new existing project from persistence.
199
	 * This project will not be builded, main corpus, texts, editions, etc. will be restored from persistence.
200
	 * 
201
	 * @param nodePath
202
	 * @throws CoreException
203
	 */
204
	public Project(String parametersNodePath) throws CoreException {
205
		super(parametersNodePath);
206
		
207
		this.needToBuild = false;
208
		this.dirty = false;
209
		this.hasBeenComputedOnce = true;
210
		this.setVisible(false);
211
		
212
		initRCPStuffs(new LogMonitor());
213
		
214
		//
215
		// this.setPath(project.getPath() + getName());
216
		// params = parameters;
217
		// setSelfElement(params.root);
218
		// this.project = project;
219
		// //load();
220
		// this.userName = params.name;
221
		// if (!userName.equals(userName.toUpperCase())) {
222
		// System.out.println("Warning in Base.init: binary corpus name contains lower case letters: "+this.userName);
223
		// }
224
		//
225
		// this.scope = new BasePreferenceScope(this);
226
		
227
		// reloading existing results
228
		this.loadResults(null);
229
	}
230
	
231
	/**
196 232
	 * Instantiates a new project that needs to build its main corpus, texts, editions, etc..
197 233
	 * 
198 234
	 * @param workspace
......
211 247
		if (rcpProject != null && !rcpProject.isOpen()) {
212 248
			try {
213 249
				
214
				TXMProgressMonitor subMonitor = new TXMProgressMonitor(monitor);
215
				subMonitor.setTask("Openning project");
250
				monitor.beginTask("Openning project", 100);
216 251
				
217 252
				
218 253
				rcpProject.open(monitor);
219 254
				
220
				initRCPStuffs(subMonitor);
255
				initRCPStuffs(monitor);
221 256
				
222
				subMonitor.setTask("loading results");
257
				monitor.subTask("Loading results");
223 258
				
224 259
				this.loadResults(null);
225 260
				
......
236 271
					}
237 272
				}
238 273
				
239
				subMonitor.setTask("");
274
				monitor.setTaskName("");
240 275
			}
241 276
			catch (CoreException e) {
242 277
				e.printStackTrace();
......
285 320
		return version;
286 321
	}
287 322
	
288
	/**
289
	 * Instantiates a new existing project from persistence.
290
	 * This project will not be builded, main corpus, texts, editions, etc. will be restored from persistence.
291
	 * 
292
	 * @param nodePath
293
	 * @throws CoreException
294
	 */
295
	public Project(String parametersNodePath) throws CoreException {
296
		super(parametersNodePath);
297
		
298
		this.needToBuild = false;
299
		this.dirty = false;
300
		this.hasBeenComputedOnce = true;
301
		this.setVisible(false);
302
		
303
		initRCPStuffs(new TXMProgressMonitor());
304
		
305
		//
306
		// this.setPath(project.getPath() + getName());
307
		// params = parameters;
308
		// setSelfElement(params.root);
309
		// this.project = project;
310
		// //load();
311
		// this.userName = params.name;
312
		// if (!userName.equals(userName.toUpperCase())) {
313
		// System.out.println("Warning in Base.init: binary corpus name contains lower case letters: "+this.userName);
314
		// }
315
		//
316
		// this.scope = new BasePreferenceScope(this);
317
		
318
		// reloading existing results
319
		this.loadResults(null);
320
	}
321 323
	
324
	
322 325
	@Override
323 326
	public boolean isInternalPersistable() {
324 327
		return true;
......
387 390
				return true;
388 391
			}
389 392
			
390
			SubMonitor subMonitor = SubMonitor.convert(new LogMonitor(), "computing " + this, 100);
391
			
392 393
			Log.finest("RUNNING IMPORT MODULE WITH NAME = " + getImportModuleName());
393 394
			
394
			boolean state = engine.build(this, subMonitor).isOK();
395
			boolean state = engine.build(this, monitor.internalGetSubMonitor()).isOK();
395 396
			if (state == true) {
396 397
				this.needToBuild = false;
397 398
				// This step could be done only if the compiler step if done and only if it modifying/deleting the corpus builds
......
422 423
	 * 
423 424
	 * @throws CoreException
424 425
	 */
425
	private void initRCPStuffs(TXMProgressMonitor monitor) throws CoreException {
426
	private void initRCPStuffs(IProgressMonitor monitor) throws CoreException {
426 427
		IWorkspace rcpWorkspace = ResourcesPlugin.getWorkspace();
427 428
		if (this.rcpProject == null) {
428 429
			String n = this.getName();
......
447 448
		}
448 449
	}
449 450
	
450
	private void createRCPProject(TXMProgressMonitor monitor) throws CoreException {
451
	private void createRCPProject(IProgressMonitor monitor) throws CoreException {
451 452
		
452 453
		IProjectDescription description = ResourcesPlugin.getWorkspace().newProjectDescription(rcpProject.getName());
453 454
		IFolder folder = Workspace.getInstance().corporaProject.getFolder(rcpProject.getName());
......
455 456
		description.setLocation(folder.getLocation());
456 457
		description.setNatureIds(new String[] { TXMCORPUSNATURE });
457 458
		
458
		// SubMonitor subMonitor = monitor.createNewMonitor(100);
459
		IProgressMonitor subMonitor = new LogMonitor();
460 459
		
461 460
		
462
		rcpProject.create(description, subMonitor);
463
		rcpProject.open(subMonitor);
461
		rcpProject.create(description, monitor);
462
		rcpProject.open(monitor);
464 463
		// TODO might fail if corpus source directory changed
465 464
		IFolder srcFolder = rcpProject.getFolder("src");
466 465
		if (pSrcDirectory != null && !pSrcDirectory.getName().isEmpty()) {
467 466
			IPath path = new Path(pSrcDirectory.getAbsolutePath());
468 467
			if (!srcFolder.exists()) {
469
				srcFolder.createLink(path, IResource.ALLOW_MISSING_LOCAL, subMonitor);
468
				srcFolder.createLink(path, IResource.ALLOW_MISSING_LOCAL, monitor);
470 469
			}
471 470
		}
472 471
	}
tmp/org.txm.core/src/java/org/txm/utils/TXMProgressMonitor.java (revision 2632)
108 108
		return new TXMProgressMonitor(this.monitor.split(totalWork));
109 109
	}
110 110
	
111
	
112
	/**
113
	 * Returns the instance of the internal {@link SubMonitor}.
114
	 * Using this {@link SubMonitor} may leads to redefine the main task.
115
	 * 
116
	 * @return the instance of the internal {@link SubMonitor}
117
	 */
118
	public SubMonitor internalGetSubMonitor() {
119
		return this.monitor;
120
	}
121
	
111 122
}
tmp/org.txm.core/src/java/org/txm/utils/LogMonitor.java (revision 2632)
6 6
import org.txm.utils.logger.Log;
7 7

  
8 8
/**
9
 * A silent monitor only loggin INFO level messages
9
 * A silent monitor that logs in console FINE level messages only.
10 10
 * 
11 11
 * @author mdecorde
12 12
 *

Formats disponibles : Unified diff