Révision 1414

tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/editors/ProgressionEditor.java (revision 1414)
182 182
			
183 183
			
184 184
			// Computing listeners
185
			ComputeSelectionListener computeSelectionListener = new ComputeSelectionListener(this);
185
			ComputeSelectionListener computeSelectionListener = new ComputeSelectionListener(this, true);
186 186
			ComputeKeyListener computeKeyListener = new ComputeKeyListener(this);
187 187
			
188 188
			
......
249 249
			cumulativeButton = new Button(paramPanel, SWT.RADIO);
250 250
			cumulativeButton.setText(ProgressionUIMessages.cumulative);
251 251
			// listeners
252
			cumulativeButton.addSelectionListener(new ComputeSelectionListener(this) {
252
			cumulativeButton.addSelectionListener(new ComputeSelectionListener(this, true) {
253 253
				@Override
254 254
				public void widgetSelected(SelectionEvent e) {
255 255
					bandeField.setEnabled(densityButton.getSelection());
......
261 261
			densityButton = new Button(paramPanel, SWT.RADIO);
262 262
			densityButton.setText(ProgressionUIMessages.density);
263 263
			// listener
264
			densityButton.addSelectionListener(new ComputeSelectionListener(this) {
264
			densityButton.addSelectionListener(new ComputeSelectionListener(this, true) {
265 265
				@Override
266 266
				public void widgetSelected(SelectionEvent e) {
267 267
					bandeField.setEnabled(densityButton.getSelection());
tmp/org.txm.partition.rcp/src/org/txm/partition/rcp/editors/PartitionDimensionsEditor.java (revision 1414)
38 38
		this.sortByPartSize.setImage(IImageKeys.getImage(this.getClass(), "icons/silk_sort_by_size.png")); //$NON-NLS-1$
39 39
		this.sortByPartSize.setToolTipText(PartitionUIMessages.sortByPartSize);
40 40
		
41
		this.sortByPartSize.addSelectionListener(new ComputeSelectionListener(this));
41
		this.sortByPartSize.addSelectionListener(new ComputeSelectionListener(this, true));
42 42
		
43 43
		
44 44
	}
tmp/org.txm.ahc.rcp/src/org/txm/ahc/rcp/editors/AHCChartEditor.java (revision 1414)
72 72

  
73 73
		
74 74
		// Computing listeners
75
		ComputeSelectionListener computeSelectionListener = new ComputeSelectionListener(this);
75
		ComputeSelectionListener computeSelectionListener = new ComputeSelectionListener(this, true);
76 76
		ComputeKeyListener computeKeyListener = new ComputeKeyListener(this);
77 77
		
78 78
		// Number of clusters
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditor.java (revision 1414)
311 311
	 */
312 312
	public void deactivateContext()	{
313 313
		IContextService contextService = (IContextService)getSite().getService(IContextService.class);
314
		contextService.deactivateContext(this.contextActivationToken);
314
		if(contextService != null)	{
315
			contextService.deactivateContext(this.contextActivationToken);
316
		}
315 317
	}
316 318
	
317 319
	/**
tmp/org.txm.rcp/src/main/java/org/txm/rcp/testers/CurrentEditorIsDirty.java (revision 1414)
32 32
		//System.err.println("Current editor is dirty: " + dirty);
33 33
		
34 34
		return dirty;
35
		
36
//		return true;
35 37
	}
36 38

  
37 39
}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/utils/SWTEditorsUtils.java (revision 1414)
17 17
import org.eclipse.ui.IWorkbenchWindow;
18 18
import org.eclipse.ui.PlatformUI;
19 19
import org.eclipse.ui.part.EditorPart;
20
import org.txm.core.results.TXMResult;
21
import org.txm.rcp.editors.TXMResultEditorInput;
20 22

  
21 23
/**
22 24
 * Utility class to manage EditorPart.
23 25
 * Methods that modify the UI are intended to be called in the UI thread.
26
 * 
24 27
 * @author sjacquot
25 28
 *
26 29
 */
27 30
public class SWTEditorsUtils {
28 31
	
32
	
29 33
	/**
34
	 * Gets an editor for the specified result if its opened.
35
	 * @param result
36
	 * @return the editor if its opened otherwise null
37
	 */
38
	public static IEditorPart getEditor(TXMResult result)	{
39

  
40
		IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
41
		IWorkbenchPage page = window.getActivePage();
42
//		IEditorReference[] editorsReferences = page.findEditors(editorInput, editorId, IWorkbenchPage.MATCH_INPUT | IWorkbenchPage.MATCH_ID);
43
//		if(editorsReferences.length > 0)	{
44
//			return editorsReferences[0].getEditor(false);
45
//		}
46
//		return null;
47

  
48
		return page.findEditor(new TXMResultEditorInput<TXMResult>(result));
49
	}
50
	
51
	/**
30 52
	 * Checks if the editor specified by its editor input is already open in the active page.
31 53
	 * @param editorInput
32 54
	 * @return
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 1414)
18 18
import org.eclipse.core.runtime.SafeRunner;
19 19
import org.eclipse.core.runtime.Status;
20 20
import org.eclipse.core.runtime.jobs.Job;
21
import org.eclipse.jface.action.IContributionItem;
21 22
import org.eclipse.jface.action.MenuManager;
23
import org.eclipse.jface.action.ToolBarManager;
22 24
import org.eclipse.jface.dialogs.MessageDialog;
23 25
import org.eclipse.jface.viewers.ISelectionProvider;
24 26
import org.eclipse.jface.viewers.IStructuredSelection;
......
530 532
	public void setDirty(boolean dirty) {
531 533
		this.dirty = dirty;
532 534
        
535
		// FIXME: old version
533 536
		//this.result.setDirty(dirty);
534 537
        
538
		ToolBarManager manager = new ToolBarManager(this.topToolBar);
539
		IContributionItem[] items = manager.getItems(); 
540

  
541
		
535 542
        firePropertyChange(IEditorPart.PROP_DIRTY);
536 543
        CorporaView.refreshObject(this.result);
537 544
    }
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/listeners/ComputeKeyListener.java (revision 1414)
8 8
import org.eclipse.swt.events.KeyListener;
9 9
import org.txm.core.results.TXMResult;
10 10
import org.txm.rcp.editors.TXMEditor;
11
import org.txm.rcp.preferences.RCPPreferences;
12 11

  
13 12
/**
14 13
 * Key listener that calls TXMEditor.compute() when the Enter key is pressed.
......
32 31
		if (e.keyCode == SWT.CR || e.keyCode == SWT.KEYPAD_CR) {
33 32
			this.editor.compute(true);
34 33
		}
35
		// if other key than Return is pressed then makes the editor and result dirty in manual-computing mode
36
		else if(!RCPPreferences.getInstance().getBoolean(RCPPreferences.AUTO_UPDATE_EDITOR))	{
37
			//this.editor.setDirty(true);
34
		// if other key than Return is pressed then makes the editor dirty
35
		else	{
36
			this.editor.setDirty(true);
38 37
		}
39 38
		// FIXME: update the result from the widget
40 39
		// purpose here is, for example, to enable the compute command button when a query is typed
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/listeners/BaseAbstractComputeListener.java (revision 1414)
22 22
	 */
23 23
	protected TXMEditor<? extends TXMResult> editor;
24 24
	
25
	
26
	/**
27
	 * Auto-computing mode.
28
	 */
29
	protected boolean autoCompute;
25 30

  
26 31
	/**
27 32
	 * 
28 33
	 * @param editor
34
	 * @param autoCompute
29 35
	 */
30
	public BaseAbstractComputeListener(TXMEditor<? extends TXMResult> editor) {
36
	public BaseAbstractComputeListener(TXMEditor<? extends TXMResult> editor, boolean autoCompute) {
31 37
		this.editor = editor;
38
		this.autoCompute = autoCompute;
32 39
	}
33 40

  
41
	/**
42
	 * 
43
	 * @param editor
44
	 */
45
	public BaseAbstractComputeListener(TXMEditor<? extends TXMResult> editor) {
46
		this(editor, false);
47
	}
34 48
	
49
	
35 50
	/**
36 51
	 * To skip programmatically setSelection() call. The event source Viewer must set the "ignore" option
37 52
	 * @param event
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/listeners/ComputeSelectionListener.java (revision 1414)
4 4
import org.eclipse.jface.viewers.SelectionChangedEvent;
5 5
import org.eclipse.swt.events.SelectionEvent;
6 6
import org.eclipse.swt.events.SelectionListener;
7
import org.eclipse.swt.widgets.Combo;
8 7
import org.eclipse.swt.widgets.Spinner;
9 8
import org.txm.core.results.TXMResult;
10 9
import org.txm.rcp.editors.TXMEditor;
......
20 19
	/**
21 20
	 * 
22 21
	 * @param editor
22
	 * @param autoCompute
23 23
	 */
24
	public ComputeSelectionListener(TXMEditor<? extends TXMResult> editor, boolean autoCompute) {
25
		super(editor, autoCompute);
26
	}
27

  
28
	/**
29
	 * 
30
	 * @param editor
31
	 */
24 32
	public ComputeSelectionListener(TXMEditor<? extends TXMResult> editor) {
25 33
		super(editor);
26 34
	}
......
30 38
		// tests for QueryWidget computing from history
31 39
//		System.err.println("ComputeSelectionListener.widgetSelected() " + ((Combo)e.getSource()).getText());
32 40
		// this method is called on a Spinner even when a key is pressed, that's not what we want, so this test breaks the behavior
33
		if(RCPPreferences.getInstance().getBoolean(RCPPreferences.AUTO_UPDATE_EDITOR) && (!(e.getSource() instanceof Spinner) || e.stateMask != 0))	{
41
		if((this.autoCompute || RCPPreferences.getInstance().getBoolean(RCPPreferences.AUTO_UPDATE_EDITOR)) && (!(e.getSource() instanceof Spinner) || e.stateMask != 0))	{
34 42
			this.editor.compute(true);
35 43
		}
36 44
		else	{
......
57 65
		// FIXME: SJ: dirty tests
58 66
		// to skip programmatically setSelection() calls on some widgets or if auto-compute preference is false
59 67
		if(!mustIgnoreEvent(event)) {
60
			if(RCPPreferences.getInstance().getBoolean(RCPPreferences.AUTO_UPDATE_EDITOR))	{
68
			if((this.autoCompute || RCPPreferences.getInstance().getBoolean(RCPPreferences.AUTO_UPDATE_EDITOR)))	{
61 69
				this.editor.compute(true);
62 70
			}
63 71
			else	{
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/structures/StructuralUnitsComboViewer.java (revision 1414)
52 52
		}
53 53
		
54 54
		// Listeners
55
		if(autoCompute)	{
56
			this.addSelectionChangedListener(new ComputeSelectionListener(editor));
57
		}
55
		//if(autoCompute)	{
56
			this.addSelectionChangedListener(new ComputeSelectionListener(editor, autoCompute));
57
		//}
58 58

  
59 59
	}
60 60

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/structures/PropertiesComboViewer.java (revision 1414)
48 48
		this.updateFromList(properties, selectedProperty);
49 49

  
50 50
		// Listener
51
		if(autoCompute)	{
52
			this.addSelectionChangedListener(new ComputeSelectionListener(editor));
53
		}
51
		//if(autoCompute)	{
52
			this.addSelectionChangedListener(new ComputeSelectionListener(editor, autoCompute));
53
		//}
54 54

  
55 55
	}
56 56

  
tmp/org.txm.rcp/src/main/java/org/txm/rcp/swt/widget/structures/StructuralUnitPropertiesComboViewer.java (revision 1414)
37 37
		this.updateFromStructuralUnit(su, selectedSUP);
38 38
		
39 39
		// Listener
40
		if(autoCompute)	{
41
			this.addSelectionChangedListener(new ComputeSelectionListener(editor));
42
		}
40
		//if(autoCompute)	{
41
			this.addSelectionChangedListener(new ComputeSelectionListener(editor, autoCompute));
42
		//}
43 43

  
44 44
		
45 45
	}
tmp/org.txm.rcp/src/main/java/org/txm/rcp/adapters/TXMResultAdapter.java (revision 1414)
8 8
import org.eclipse.swt.graphics.FontData;
9 9
import org.eclipse.swt.graphics.RGB;
10 10
import org.eclipse.swt.widgets.Display;
11
import org.eclipse.ui.IEditorPart;
11 12
import org.eclipse.ui.model.WorkbenchAdapter;
12 13
import org.txm.core.preferences.TBXPreferences;
13 14
import org.txm.core.results.TXMResult;
15
import org.txm.rcp.editors.TXMEditor;
14 16
import org.txm.rcp.handlers.BaseAbstractHandler;
15 17
import org.txm.rcp.utils.SWTEditorsUtils;
16 18

  
......
40 42
		// FIXME: SJ: dirty tests
41 43
		String label = ((TXMResult) result).getCurrentName();
42 44

  
43
		if(((TXMResult) result).isDirty() && ((TXMResult) result).hasBeenComputedOnce())	{
45
		IEditorPart editor = SWTEditorsUtils.getEditor((TXMResult) result);
46

  
47
		if(editor != null && editor.isDirty())	{
44 48
			label += " *";
45 49
		}
50
		
51
		
52
//		if(((TXMResult) result).isDirty() && ((TXMResult) result).hasBeenComputedOnce())	{
53
//			label += " *";
54
//		}
46 55
		return label;
47 56
	}
48 57

  
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesSelectionEditor.java (revision 1414)
43 43
		
44 44
		
45 45
		// Computing listeners
46
		ComputeSelectionListener computeSelectionListener = new ComputeSelectionListener(this);
46
		ComputeSelectionListener computeSelectionListener = new ComputeSelectionListener(this, true);
47 47
		ComputeKeyListener computeKeyListener = new ComputeKeyListener(this);
48 48

  
49 49
		
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAFactorialMapChartEditor.java (revision 1414)
126 126
			// Extend the chart editor tool bar
127 127
			new ToolItem(this.chartToolBar, SWT.SEPARATOR);
128 128

  
129
			ComputeSelectionListener computeSelectionListener = new ComputeSelectionListener(this, true); 
129 130
			
130 131
			// Show/hide columns
131 132
			showIndividuals = new ToolItem(this.chartToolBar, SWT.CHECK);
......
133 134
			//showColumns.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_LABEL);
134 135
			showIndividuals.setToolTipText(CAUIMessages.showhideTheColumnPoints);
135 136
			showIndividuals.setImage(IImageKeys.getImage(CAFactorialMapChartEditor.class, "icons/show_columns.png")); //$NON-NLS-1$
136
			showIndividuals.addSelectionListener(new ComputeSelectionListener(this));
137
			showIndividuals.addSelectionListener(computeSelectionListener);
137 138

  
138 139
			// Show/hide rows
139 140
			showVariables = new ToolItem(this.chartToolBar, SWT.CHECK);
......
141 142
			//this.showRows.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_LABEL);
142 143
			showVariables.setToolTipText(CAUIMessages.showhideTheRowPoints);
143 144
			showVariables.setImage(IImageKeys.getImage(CAFactorialMapChartEditor.class, "icons/show_rows.png")); //$NON-NLS-1$
144
			showVariables.addSelectionListener(new ComputeSelectionListener(this));
145
			showVariables.addSelectionListener(computeSelectionListener);
145 146

  
146 147
			
147 148
			// Show/hide point shapes
......
150 151
			//showPointShapes.setText(CAUIMessages.SHOW_HIDE_POINT_SHAPES);
151 152
			showPointShapes.setToolTipText(CAUIMessages.showhidePointShapes);
152 153
			showPointShapes.setImage(IImageKeys.getImage(CAFactorialMapChartEditor.class, "icons/show_point_shapes.png")); //$NON-NLS-1$
153
			showPointShapes.addSelectionListener(new ComputeSelectionListener(this));
154
			showPointShapes.addSelectionListener(computeSelectionListener);
154 155

  
155 156
			
156 157
			// Factors plane selection

Formats disponibles : Unified diff