Revision 568

tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/handlers/ComputeProgression.java (revision 568)
74 74
		
75 75
		
76 76
		// Compute a new progression
77
		if(selection instanceof Corpus)	{
77
		if (selection instanceof Corpus)	{
78 78
			Corpus corpus = (Corpus) selection;
79 79

  
80 80
			if (!Progression.canRunProgression(corpus)) {
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/RCPCommandsAPI.java (revision 568)
45 45
				result = rcpcommand.clazz.newInstance();
46 46
				result.setParameters(parameters);
47 47

  
48
				TXMResultEditorInput editorInput = new TXMResultEditorInput(result);
49
				TXMEditorPart editor = TXMEditorPart.openEditor(editorInput, rcpcommand.editor_id);
50
				if (editor != null) {
51
					return editor;
52
				} else	{
53
					System.out.println("Failed to open editor: internal error during initialisation.");
54
					System.out.println("Failed to open editor with "+cmd+" command and "+parameters+" parameters.");
55
				}
56
			}
57
			catch(Exception e) {
48
				TXMEditorPart.openEditor(result, rcpcommand.editor_id);
49
//				if (editor != null) {
50
//					return editor;
51
//				} else	{
52
//					System.out.println("Failed to open editor: internal error during initialisation.");
53
//					System.out.println("Failed to open editor with "+cmd+" command and "+parameters+" parameters.");
54
//				}
55
			} catch(Exception e) {
58 56
				// TODO Auto-generated catch block
59 57
				e.printStackTrace();
60 58
			}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorPart.java (revision 568)
311 311
		return this.getEditorInput().getResult().getStringParameterValue(key);
312 312
	}
313 313

  
314
//// TODO commented for now ?	
315
//	/**
316
//	 * Computes the result stored in the specified editor input and opens an editor specified by its id.
317
//	 * @param editorInput
318
//	 * @param editorPartId
319
//	 * @return
320
//	 */
321
//	public static void openEditor(TXMResultEditorInput editorInput, String editorPartId)	{
322
//		compute(editorInput, editorPartId, false, null);
323
//	}
314 324
	
315 325
	/**
316
	 * Computes the result stored in the specified editor input and opens an editor specified by its id.
317
	 * @param editorInput
318
	 * @param editorPartId
319
	 * @return
320
	 */
321
	public static void openEditor(TXMResultEditorInput editorInput, String editorPartId)	{
322
		compute(editorInput, editorPartId, false, null);
323
	}
324
	
325
	/**
326 326
	 * Computes specified result stored, creates an editor input and opens an editor specified by its id.
327
	 * 
328
	 * Always creates an editor
329
	 * 
327 330
	 * @param result
328 331
	 * @param editorPartId
329 332
	 * @return
330 333
	 */
331 334
	public static void openEditor(TXMResult result, String editorPartId)	{
332
		openEditor(new TXMResultEditorInput(result), editorPartId);
335
		//openEditor(new TXMResultEditorInput(result), editorPartId);
336
		compute(new TXMResultEditorInput(result), editorPartId, false, null);
333 337
	}
334 338
	
335

  
336
	
339
	/**
340
	 * Computes the TXMResult If all necessary parameters are set AND refresh the editor UI
341
	 *  
342
	 * @param update transfered to the TXMResult.compute method
343
	 */
337 344
	public final void compute(boolean update) {
338
		compute(update, this);
345
		compute(this.getEditorInput(), null, update, this);
339 346
	}
340 347
	
341
	
342
	public static void compute(final boolean update, final TXMEditorPart editor)	{
343
		compute(editor.getEditorInput(), null, update, editor);
344
	}
345
	
346 348
	/**
349
	 * Internal method to mutualize compute editor creation
347 350
	 * 
348 351
	 * @param result
349 352
	 * @param update
......
352 355
	 * @param resetView
353 356
	 * @param clearChartItemsSelection
354 357
	 */
355
	public static void compute(final TXMResultEditorInput editorInput, final String editorId, final boolean update, final TXMEditorPart editor)	{
358
	protected static void compute(final TXMResultEditorInput editorInput, final String editorId, final boolean update, final TXMEditorPart editor)	{
356 359
		
357 360
		StatusLine.setMessage("Computing " + editorInput.getResult().getName());
358 361
		
......
370 373

  
371 374
		    		
372 375
		    		currentEditor = editor;
373
		    		
374
		    		// transfer editor parameters to result
375
//		    		if (currentEditor != null)	{
376
//		    			currentEditor.updateResultFromEditor();
377
//		    		}
378
		    		
379
		    		
376
			    		
380 377
		    		// computing result
381 378
					monitor.beginTask("Computing", 100);
382 379

  
383
					editorInput.getResult().compute(update, monitor);
380
					editorInput.getResult().compute(update, monitor); // always open the editor
384 381

  
385
//					if (!editorInput.getResult().compute(update, monitor))	{
386
//						return Status.CANCEL_STATUS;
387
//					}
388

  
389 382
					monitor.worked(50);
390 383
					
391 384
					// opening an editor if not exists
392
					if (currentEditor == null)	{
385
					if (currentEditor == null && editorId != null)	{
393 386
						this.syncExec(new Runnable() {
394 387
							@Override
395 388
							public void run() {
......
397 390
									
398 391
									Log.info("TXMEditorPart.compute(): opening editor with id " + editorId);
399 392
									
400
									IWorkbenchWindow window =TXMWindows.getActiveWindow();
393
									IWorkbenchWindow window = TXMWindows.getActiveWindow();
401 394
									IWorkbenchPage page = window.getActivePage();
402 395
									currentEditor = (TXMEditorPart) page.openEditor(editorInput, editorId, true, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID);
403 396
								} catch (Exception e) {
......
408 401
						});
409 402
					}
410 403
					
411
					
412 404
					// refreshing the UI
413 405
					if (currentEditor != null)	{
414 406
						this.syncExec(new Runnable() {
......
434 426
		    	}
435 427
				return Status.OK_STATUS;
436 428
		    }
437

  
438 429
		};
439 430
		job.setPriority(Job.DECORATE);
440 431
		job.setUser(false);
tmp/org.txm.referencer.rcp/src/org/txm/referencer/rcp/commands/ComputeReferencer.java (revision 568)
85 85
			return false;
86 86
		}
87 87
		
88
		TXMEditorPart.openEditor(new TXMResultEditorInput(referencer), ReferencerEditor.ID); //$NON-NLS-1$
88
		TXMEditorPart.openEditor(referencer, ReferencerEditor.ID); //$NON-NLS-1$
89 89
		return false;
90 90
	}
91 91
}

Also available in: Unified diff