Révision 779

tmp/org.txm.lexicaltable.rcp/src/org/txm/lexicaltable/rcp/editors/LexicalTableEditor.java (revision 779)
130 130
//	@Parameter(key=LexicalTablePreferences.V_MAX)
131 131
	protected Spinner vMax;
132 132

  
133
	private Label infoLine;
133 134

  
135

  
134 136
	
135 137
	
136 138
	
......
387 389
			// Register the context menu
388 390
			TXMEditor.initContextMenu(this.viewer.getTable(), this.getSite(), this.viewer); // $NON-NLS-1$
389 391

  
392
			infoLine = new Label(getBottomToolbar().getParent(), SWT.NONE);
390 393
		}
391 394
		catch (CqiClientException e) {
392 395
			// TODO Auto-generated catch block
......
409 412
		}
410 413
	}
411 414

  
415
	public void setContentDescription(String desc) {
416
		infoLine.setText(desc);
417
		infoLine.update();
418
		infoLine.getParent().layout();
419
	}
420
	
412 421
	/**
413 422
	 * Refreshes the description area.
414 423
	 */
tmp/org.txm.concordance.rcp/src/org/txm/concordance/rcp/editors/ConcordanceEditor.java (revision 779)
960 960
		queryWidget.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
961 961
		queryWidget.addKeyListener(new ComputeKeyListener(this));
962 962

  
963
		// hide the parameters panel
963 964
		getTopToolbar().setVisible(TXMEditor.COMPUTING_PARAMETERS_GROUP_ID, false); // the settings are not necessary to compute the concordance
964 965
		
965 966
		// | Properties: word/pos [Edit] |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 779)
78 78
	public final static String TOP_TOOLBAR_ID = "TXMEditorTopToolBar"; //$NON-NLS-1$
79 79
	public final static String BOTTOM_TOOLBAR_ID = "TXMEditorBottomToolBar"; //$NON-NLS-1$
80 80
	public final static String COMPUTING_PARAMETERS_GROUP_ID = "Parameters";
81
	
81

  
82 82
	/**
83 83
	 * The editor main tool bar, positioned at the top of the editor.
84 84
	 */
......
116 116
	 */
117 117
	protected Composite bottomToolBarContainer;
118 118

  
119
	
119

  
120 120
	/**
121 121
	 * To keep track of the parameters used for the last computing and updates only the widgets if a parameter has changed. 
122 122
	 */
......
128 128
	private GLComposite bottomSubWidgetsComposite;
129 129
	private GLComposite minimalParametersComposite;
130 130
	private GLComposite firstLineComposite;
131
	
131
	private boolean createPartControlDoneSucessfully = true; // for now... muahahaha
132 132

  
133
	
134
	
133

  
134

  
135

  
135 136
	@Override
136 137
	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
137 138
		this.setSite(site);
......
149 150
	public GLComposite getMinimalParametersComposite() {
150 151
		return minimalParametersComposite;
151 152
	}
152
	
153

  
153 154
	/**
154 155
	 * Creates the default toolbar (empty) and default result area (empty).
155 156
	 * 
......
167 168
			this.firstLineComposite = new GLComposite(parent, SWT.NONE);
168 169
			this.firstLineComposite.getLayout().numColumns = 2;
169 170
			this.firstLineComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
170
			
171

  
171 172
			this.minimalParametersComposite = new GLComposite(firstLineComposite, SWT.NONE);
172 173
			this.minimalParametersComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
173 174
			this.minimalParametersComposite.getLayout().horizontalSpacing = 5;
174 175

  
175
			
176

  
176 177
			// create the top tool bar
177 178
			this.topToolBarContainer = new Composite(firstLineComposite, SWT.NONE);
178 179
			this.topToolBarContainer.setLayoutData(new GridData(GridData.FILL, GridData.FILL, false, false));
......
186 187
			if (parent.getLayout() instanceof GridLayout)	{
187 188
				this.parametersGroupsComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
188 189
			}
189
			
190

  
190 191
			this.topToolBar = new TXMEditorToolBar(this, this.topToolBarContainer, this.parametersGroupsComposite, SWT.FLAT | SWT.RIGHT, TOP_TOOLBAR_ID);
191 192
			// FIXME: debug tests for see why there is an empty area at bottom of the toolbar
192 193
			//this.topToolBar.setBackground(parent.getDisplay().getSystemColor(SWT.COLOR_RED));
193
			
194

  
194 195
			// computing parameters components
195 196
			boolean showComputingParameters = false;
196 197
			// only show the area if the result can not compute and is dirty
......
206 207
			// display main area
207 208
			this.resultArea = new Composite(parent, SWT.NONE);
208 209
			this.resultArea.setLayoutData(new GridData(GridData.FILL_BOTH));
209
			
210

  
210 211
			// create the bottom tool bar
211 212
			this.bottomToolBarContainer = new Composite(parent, SWT.NONE);
212 213
			this.bottomToolBarContainer.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
213 214
			rl = new RowLayout(SWT.HORIZONTAL);
214 215
			rl.marginTop = rl.marginHeight = rl.marginWidth = rl.marginBottom = 0;
215
			rl.center = true;
216
			//rl.center = true;
217
			//rl.justify = true;
216 218
			this.bottomToolBarContainer.setLayout(rl);
217
			
219

  
218 220
			this.bottomSubWidgetsComposite = new GLComposite(parent, SWT.NONE);
219 221
			if (parent.getLayout() instanceof GridLayout)	{
220 222
				this.bottomSubWidgetsComposite.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false));
221 223
			}
222
			
224

  
223 225
			this.bottomToolBar = new TXMEditorToolBar(this, this.bottomToolBarContainer, this.bottomSubWidgetsComposite, SWT.FLAT, "bottom");
224
			
226

  
225 227
			this._createPartControl(parent); // child editor create its parameters and display widgets
226
			
227
			
228

  
229

  
228 230
			// remove empty toolbar
229 231
			//TODO SJ: Hack? MD: yeah -> need to find a way to not display the bottom toolbar on Windows instead
230 232
			if (this.bottomToolBar.getItems().length == 0) {
231 233
				this.bottomToolBar.dispose();
232 234
			}
233
			
234
			// uninstall parameers group if not used
235

  
236
			// remove empty toolbar
237
			//TODO SJ: Hack? MD: yeah -> need to find a way to not display the bottom toolbar on Windows instead
238
			if (this.topToolBar.getItems().length == 0) {
239
				this.topToolBar.dispose();
240
			}
241

  
242
			// uninstall parameters group if not used
235 243
			if (computingParametersGroup.getChildren().length == 0) {
236 244
				this.topToolBar.unInstallGroup(COMPUTING_PARAMETERS_GROUP_ID);
237 245
			}
238 246
		}
239
		catch(Exception e) {
247
		catch(Throwable e) {
240 248
			System.err.println("TXMEditor.createPartControl(): can not create the editor.");
241 249
			e.printStackTrace();
250
			createPartControlDoneSucessfully  = false;
242 251
		}
243 252
	}
244 253

  
245 254
	/**
246
	 * Subclasses manual creation.
255
	 * Subclasses manual creation method called after TXMEditor.createPartControl is called.
256
	 * 
257
	 * Use this method to set your own widgets in the minimal parameters area, the top toolbar, parameters group, the result area and the bottom toolbar
247 258
	 * @param parent
248 259
	 */
249 260
	public abstract void _createPartControl(Composite parent);
250
	
261

  
251 262
	/**
252 263
	 * Use this method to add widget next to the default Top toolbar
253 264
	 * 
......
346 357
		// TODO Auto-generated method stub
347 358
	}
348 359

  
360
	@SuppressWarnings("unchecked")
349 361
	@Override
350 362
	public TXMResultEditorInput<T> getEditorInput() {
351
		return (TXMResultEditorInput) super.getEditorInput();
363
		return (TXMResultEditorInput<T>) super.getEditorInput();
352 364
	}
353 365

  
354 366
	/**
......
428 440
	 */
429 441
	public JobHandler compute(final boolean update)	{
430 442

  
431
		
443

  
432 444
		StatusLine.setMessage("Computing " + this.getResult().getName());
433 445

  
434 446
		JobHandler job = new JobHandler("Computing " + this.getResult().getName()) {
......
451 463
								// FIXME: DEbug
452 464
								System.err.println("TXMEditor.compute(): auto updating result from editor.");
453 465
								autoUpdateResultFromEditorParameters(); // auto updating result from Parameter annotations in result <=> editor
454
								
466

  
455 467
								// Stores the last parameters before the computing to later auto-update the Widgets only if some parameters have changed 
456 468
								setLastComputingParameters(TXMEditor.this.getResult().getLastParameters());
457 469
							}
......
461 473

  
462 474
					// computing result
463 475
					monitor.beginTask("Computing", 100);
464
					
476

  
465 477
					if (!TXMEditor.this.getResult().compute(monitor)) {
466 478
						Log.info("TXMEditor.compute(): computing failed.");
467 479
					}
......
470 482

  
471 483
					// FIXME: old version
472 484
					// opening an editor if not exists
473
//					if (currentEditor == null && editorId != null)	{
474
//						this.syncExec(new Runnable() {
475
//							@Override
476
//							public void run() {
477
//								try {
478
//
479
//									Log.info("TXMEditor.compute(): opening editor with id: " + editorId);
480
//
481
//									IWorkbenchWindow window = TXMWindows.getActiveWindow();
482
//									IWorkbenchPage page = window.getActivePage();
483
//									currentEditor = (TXMEditor) page.openEditor(editorInput, editorId, true, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID);
484
//								}
485
//								catch (Exception e) {
486
//									System.err.println("TXMEditor.compute(): could not open editor: " + e.getLocalizedMessage());
487
//									Log.printStackTrace(e);
488
//								}
489
//							}
490
//						});
491
//					}
485
					//					if (currentEditor == null && editorId != null)	{
486
					//						this.syncExec(new Runnable() {
487
					//							@Override
488
					//							public void run() {
489
					//								try {
490
					//
491
					//									Log.info("TXMEditor.compute(): opening editor with id: " + editorId);
492
					//
493
					//									IWorkbenchWindow window = TXMWindows.getActiveWindow();
494
					//									IWorkbenchPage page = window.getActivePage();
495
					//									currentEditor = (TXMEditor) page.openEditor(editorInput, editorId, true, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID);
496
					//								}
497
					//								catch (Exception e) {
498
					//									System.err.println("TXMEditor.compute(): could not open editor: " + e.getLocalizedMessage());
499
					//									Log.printStackTrace(e);
500
					//								}
501
					//							}
502
					//						});
503
					//					}
492 504

  
493 505
					// refreshing the UI
494 506
					this.syncExec(new Runnable() {
......
497 509
							refresh(update);
498 510
						}
499 511
					});
500
					
501
					
502
					
512

  
513

  
514

  
503 515
				}
504 516
				// for user direct canceling
505 517
				catch (ThreadDeath td) {
......
561 573
		}
562 574
		return editor;
563 575
	}
564
	
565
	
576

  
577

  
566 578
	/**
567 579
	 * Synchronizes the editor with the result and refreshes the corpus view.
568 580
	 * Also fires a dirty property change.
569 581
	 * @param update
570 582
	 */
571 583
	public final void refresh(boolean update)	{
584
		if (!createPartControlDoneSucessfully) return; // no refresh
585

  
572 586
		// FIXME: result should never be null?
573 587
		if (this.getResult() != null) {
574
			
588

  
575 589
			this.setPartName(this.getResult().getName());
576 590
			this.firePropertyChange(TXMEditor.PROP_DIRTY);
577
			
591

  
578 592
			//MD commented 'if (!update) {...}'
579 593
			// SJ need to check all works, it also was dedicated to not refresh the Editor from result after a computing, it's not needed since the computing has been done
580 594
			// from fields themselves
581 595
			//if (!update) {
582
				// FIXME: debug
583
				System.err.println("TXMEditor.refresh(): auto updating editor from result.");
584
				this.autoUpdateEditorFieldsFromResult(update); // auto update from Parameter annotations
585
	
586
				// FIXME: debug
587
				System.err.println("TXMEditor.refresh(): updating subclass editor (" + getClass().getSimpleName() + ") from result.");
588
				this.updateEditorFromResult(update); // subclasses manual settings
596
			// FIXME: debug
597
			System.err.println("TXMEditor.refresh(): auto updating editor from result.");
598
			this.autoUpdateEditorFieldsFromResult(update); // auto update from Parameter annotations
599

  
600
			// FIXME: debug
601
			System.err.println("TXMEditor.refresh(): updating subclass editor (" + getClass().getSimpleName() + ") from result.");
602
			this.updateEditorFromResult(update); // subclasses manual settings
589 603
			//}
590
				
604

  
591 605
			// Hide the computing parameter area if the editor wasn't open and the result is computed
592 606
			if (!update) {
593 607
				if (!this.getResult().isDirty() && !this.topToolBar.isDisposed()) {
594 608
					this.topToolBar.setComputingParametersVisible(false);
595 609
				}
596 610
			}
597
				
611

  
598 612
			topToolBar.redraw();
599 613
			CorporaView.refreshObject(this);
600 614
			TXMResultDebugView.refreshView();
......
708 722
				else	{
709 723
					f.set(this, value);
710 724
				}
711
				
725

  
712 726
				// FIXME: debug
713 727
				if(object != null)	{
714 728
					String message = "TXMEditor.autoUpdateEditorFieldsFromResult(): setting editor parameter " + parameter.key() + " = " + value;
715 729
					if(value != null) {
716
						 message += " (" + value.getClass() + " to object " + object + ")";
730
						message += " (" + value.getClass() + " to object " + object + ")";
717 731
					}
718 732
					System.err.println(message);
719 733
				}
720
				
734

  
721 735
				// FIXME: need to extend this list of managed Widgets
722 736
			}
723 737
			catch (Exception e) {
......
725 739
				e.printStackTrace();
726 740
			}
727 741
		}
728
		
742

  
729 743
		// FIXME: Updating the compute button enabled/disabled state
730 744
		// the code below doesn't work as expected for text fields (as query field or other)
731
//		try {
732
//			this.topToolBar.getItem(0).setEnabled(this.getResult().canCompute());
733
//		}
734
//		catch (Exception e) {
735
//			// TODO Auto-generated catch block
736
//			e.printStackTrace();
737
//		}
745
		//		try {
746
		//			this.topToolBar.getItem(0).setEnabled(this.getResult().canCompute());
747
		//		}
748
		//		catch (Exception e) {
749
		//			// TODO Auto-generated catch block
750
		//			e.printStackTrace();
751
		//		}
738 752
	}
739 753

  
740 754

  
......
772 786
					value = ((Button)object).getSelection(); 
773 787
				}
774 788
				else if(object instanceof Viewer)	{
775
					
789

  
776 790
					IStructuredSelection selection = ((IStructuredSelection)((Viewer)object).getSelection());
777
					
791

  
778 792
					// Multi-selection
779 793
					if(SWT.MULTI == (((Viewer)object).getControl().getStyle() & SWT.MULTI))	{
780 794
						value = selection.toList();
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditorToolBar.java (revision 779)
13 13
import org.eclipse.swt.widgets.Button;
14 14
import org.eclipse.swt.widgets.Composite;
15 15
import org.eclipse.swt.widgets.Control;
16
import org.eclipse.swt.widgets.Event;
16 17
import org.eclipse.swt.widgets.Group;
18
import org.eclipse.swt.widgets.Listener;
17 19
import org.eclipse.swt.widgets.ToolBar;
18 20
import org.eclipse.swt.widgets.ToolItem;
19 21
import org.eclipse.ui.menus.IMenuService;
......
133 135
	/**
134 136
	 * Adds the specified control to this toolbar.
135 137
	 * Convenience method to add non-ToolItem controls to the toolbar using the SWT.SEPARATOR trick, plus packing and setting the right width.
138
	 * 
139
	 * Warning: the item size is not synchronized with the control size
136 140
	 * @param control
137 141
	 */
138
	public void addControl(Control control)	{
139
		ToolItem itemSeparator = new ToolItem(this, SWT.SEPARATOR);
142
	public void addControl(final Control control)	{
143
		final ToolItem itemSeparator = new ToolItem(this, SWT.SEPARATOR);
140 144
		control.pack();
141 145
		itemSeparator.setWidth(control.getBounds().width);
142
		itemSeparator.setControl(control);	
146
		itemSeparator.setControl(control);
147
		control.addListener(SWT.RESIZE, new Listener() {
148
			
149
			@Override
150
			public void handleEvent(Event event) {
151
				itemSeparator.setWidth(control.getBounds().width);
152
			}
153
		});
143 154
	}
144 155

  
145 156
	/**

Formats disponibles : Unified diff