Revision 709

tmp/org.txm.information.core/src/org/txm/information/core/functions/Information.java (revision 709)
69 69
public class Information extends TXMResult {
70 70
	// Base base;
71 71
	/** The corpus. */
72
	Corpus corpus;
72
	protected Corpus corpus;
73 73
	
74 74
	// Numbers
75 75
	/** The T. */
......
126 126
	/**
127 127
	 * The maximum number of word property values to display.
128 128
	 */
129
	@Parameter(key=InformationPreferences.MAX_VALUE)
129
	@Parameter(key=InformationPreferences.MAX_PROPERTIES_TO_DISPLAY)
130 130
	protected int maxPropertiesToDisplay;
131 131
	
132 132
	
......
153 153
		this.dirty = true;
154 154
	}
155 155
	
156

  
157
//	public boolean setParameters(TXMParameters parameters) {
158
//		try {
159
//			Integer max = null;
160
//			Object o = parameters.get(CQPPreferences.MAX_VALUE);
161
//			if (o instanceof Integer) max = (Integer)o;
162
//			else if (o instanceof String) max = Integer.parseInt(o.toString());
163
//			
164
//			this.setParameters(max);
165
//		} catch (Exception e) {
166
//			System.out.println("Error while setting parameters of Informations: "+e.getLocalizedMessage());
167
//			return false;
168
//		}
169
//		return true;
170
//	}
171 156
	
172 157
	/**
173 158
	 * Step general infos.
......
663 648

  
664 649
	@Override
665 650
	public boolean setParameters(TXMParameters parameters) {
666
		this.maxPropertiesToDisplay = parameters.getInteger(InformationPreferences.MAX_VALUE);
651
		this.maxPropertiesToDisplay = parameters.getInteger(InformationPreferences.MAX_PROPERTIES_TO_DISPLAY);
667 652
		return true;
668 653
	}
669 654

  
tmp/org.txm.information.core/src/org/txm/information/core/preferences/InformationPreferences.java (revision 709)
22 22
	/**
23 23
	 * The maximum number of word property values to display.
24 24
	 */
25
	public static final String MAX_VALUE = PREFERENCES_PREFIX + "max_properties_to_display"; //$NON-NLS-1$
25
	public static final String MAX_PROPERTIES_TO_DISPLAY = PREFERENCES_PREFIX + "max_properties_to_display"; //$NON-NLS-1$
26 26

  
27 27
	
28 28
	@Override
29 29
	public void initializeDefaultPreferences() {
30 30
		Preferences preferences = DefaultScope.INSTANCE.getNode(PREFERENCES_NODE);
31 31
		
32
		preferences.putInt(MAX_VALUE, 10);
32
		preferences.putInt(MAX_PROPERTIES_TO_DISPLAY, 10);
33 33
		
34 34
	}
35 35
	
tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditor.java (revision 709)
109 109
		this(SWTChartsComponentsProvider.getCurrent(), chartEditorInput);
110 110
	}
111 111
	
112

  
112
	/**
113
	 * Subclasses manual creation.
114
	 * @param parent
115
	 */
116
	public abstract void __createPartControl(Composite parent);
117
	
118
	
113 119
	@Override
114
	public final void __createPartControl(Composite parent) {
120
	public final void _createPartControl(Composite parent) {
115 121
		
116 122
		// Toolbar
117 123
		this.chartToolBar = new ChartEditorToolBar(this, this.getTopToolBarContainer(), SWT.FLAT | SWT.RIGHT);
......
154 160
		//this.refresh(false);
155 161
//
156 162
//		}
163
		
164
		 // subclasses manual creation
165
		this.__createPartControl(parent);
166
		
157 167
	}
158 168

  
159 169

  
......
194 204
		//return chartsComponentsProvider.openEditor(result);
195 205
	}
196 206

  
207

  
197 208
	@Override
198
	public void updateEditorFromResult(boolean update) {
199
		// nothing to do
209
	public void updateResultFromEditor() {
210
		// does nothing by default
200 211
	}
201 212
	
213
//	@Override
214
//	public void updateEditorFromResult(boolean update) {
215
//		// nothing to do
216
//	}
202 217
	
218
	/**
219
	 * Synchronizes the editor with the chart result. 
220
	 * Dedicated to dynamically change the editor components from the stored result.
221
	 */
222
	public abstract void updateEditorFromChart(boolean update);
223
	
224
//	@Override
225
//	public final void updateEditorFromResult(boolean update) { updateEditorFromChart(update);
226
	
227
	
228
	
203 229
	@Override
204
	protected final void __updateEditorFromResult(boolean update) {
230
	public final void updateEditorFromResult(boolean update) {
205 231
		
206 232
		
233
		this.updateEditorFromChart(update);
234
		
207 235
		// check that the charts engine used for the result matches the SWT components provider otherwise fin a suitable components provider
208 236
		if(this.getResult().getChartsEngine() != this.getSWTChartsComponentsProvider().getChartsEngine())	{
209 237
			this.getEditorInput().setSWTChartsComponentsProvider(SWTChartsComponentsProvider.getComponentsProvider(this.getResult().getChartsEngine()));
......
732 760
		return chartToolBar;
733 761
	}
734 762

  
735
	@Override
736
	public void updateResultFromEditor() {
737
		// does nothing by default
738
	}
739 763
	
740 764
	
741 765
	@Override
tmp/org.txm.textsbalance.rcp/src/org/txm/textsbalance/rcp/editors/TextsBalanceEditor.java (revision 709)
53 53
	
54 54
	
55 55
	@Override
56
	public void _createPartControl(Composite parent) {
56
	public void __createPartControl(Composite parent) {
57 57
		
58 58
		if (((TextsBalance)this.getResult()).getCorpus() == null) {
59 59
			System.out.println("Error: no corpus");
......
94 94
	}
95 95

  
96 96

  
97

  
98

  
99
	@Override
100
	public void updateEditorFromChart(boolean update) {
101
		// nothing to do
102
	}
103

  
104

  
97 105
}
tmp/org.txm.ahc.rcp/src/org/txm/ahc/rcp/editors/AHCChartEditor.java (revision 709)
66 66
	
67 67

  
68 68
	@Override
69
	public void _createPartControl(Composite parent) {
69
	public void __createPartControl(Composite parent) {
70 70

  
71 71
		// Extend the chart editor tool bar
72 72
		new ToolItem(this.chartToolBar, SWT.SEPARATOR);
......
109 109

  
110 110

  
111 111
	@Override
112
	public void updateEditorFromResult(boolean update) {
112
	public void updateEditorFromChart(boolean update) {
113 113
		
114 114
		// Update the maximum value of the number of clusters spinner according to the new CAH configuration 
115 115
		this.numberOfClusters.setMaximum(this.getResult().getMaxClustersCount());
tmp/org.txm.progression.rcp/src/org/txm/progression/rcp/editors/ProgressionEditor.java (revision 709)
125 125
	
126 126
	
127 127
	@Override
128
	public void _createPartControl(Composite parent) {
128
	public void __createPartControl(Composite parent) {
129 129

  
130 130

  
131 131
		// FIXME: tests to use Fields editor and ScopedPreferenceStore for command parameters
......
419 419

  
420 420

  
421 421
	@Override
422
	public void updateEditorFromResult(boolean update) {
422
	public void updateEditorFromChart(boolean update) {
423 423
		
424 424
		// create the queries fields
425 425
		if (queries == null) {
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/EigenvaluesChartEditor.java (revision 709)
26 26
	}
27 27

  
28 28
	@Override
29
	public void _createPartControl(Composite parent) {
30
		// TODO Auto-generated method stub
31
		
29
	public void __createPartControl(Composite parent) {
30
		// nothing to do
32 31
	}
33 32

  
33
	@Override
34
	public void updateEditorFromChart(boolean update) {
35
		// nothing to do
36
	}
37

  
34 38
}
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAFactorialMapChartEditor.java (revision 709)
69 69

  
70 70

  
71 71
	@Override
72
	public void _createPartControl(Composite parent) {
72
	public void __createPartControl(Composite parent) {
73 73

  
74 74
		// Extend the chart editor tool bar
75 75
		new ToolItem(this.chartToolBar, SWT.SEPARATOR);
......
200 200
	}
201 201

  
202 202

  
203
	@Override
204
	public void updateEditorFromChart(boolean update) {
205
		// nothing to do
206
	}
203 207

  
204 208

  
205 209

  
206

  
207 210
}
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesSelectionEditor.java (revision 709)
37 37

  
38 38
	
39 39
	@Override
40
	public void _createPartControl(Composite parent) {
40
	public void __createPartControl(Composite parent) {
41 41
		
42 42
		// Group bars by lines
43 43
		groupBarsByLines = new ToolItem(this.getToolBar(), SWT.CHECK);
......
56 56
		banality.addSelectionListener(new ComputeSelectionListener(this));
57 57
		
58 58
	}
59

  
60

  
61
	@Override
62
	public void updateEditorFromChart(boolean update) {
63
		// nothing to do
64
	}
59 65
	
60 66
}
tmp/org.txm.information.rcp/plugin.xml (revision 709)
49 49
               tooltip="%command.name">
50 50
            <visibleWhen
51 51
                  checkEnabled="false">
52
               <reference
53
                     definitionId="OneCorpusSelected">
54
               </reference>
52
               <or>
53
                  <reference
54
                        definitionId="OneCorpusSelected">
55
                  </reference>
56
               </or>
55 57
            </visibleWhen>
56 58
         </command>
57 59
      </menuContribution>
tmp/org.txm.information.rcp/src/org/txm/information/rcp/editors/InformationEditor.java (revision 709)
36 36
	/**
37 37
	 * The maximum number of word property values to display.
38 38
	 */
39
	@Parameter(key=InformationPreferences.MAX_VALUE)
39
	@Parameter(key=InformationPreferences.MAX_PROPERTIES_TO_DISPLAY)
40 40
	protected Spinner maxPropertiesToDisplay;
41 41

  
42 42

  
tmp/org.txm.information.rcp/src/org/txm/information/rcp/handlers/ComputeInformation.java (revision 709)
29 29

  
30 30
import org.eclipse.core.commands.ExecutionEvent;
31 31
import org.eclipse.core.commands.ExecutionException;
32
import org.eclipse.jface.viewers.IStructuredSelection;
33
import org.eclipse.swt.SWT;
34
import org.eclipse.ui.PartInitException;
35
import org.eclipse.ui.handlers.HandlerUtil;
36 32
import org.txm.information.core.functions.Information;
37 33
import org.txm.information.rcp.editors.InformationEditor;
38
import org.txm.information.rcp.messages.InformationUIMessages;
39 34
import org.txm.rcp.editors.TXMEditor;
40 35
import org.txm.rcp.handlers.BaseAbstractHandler;
41 36
import org.txm.rcp.views.corpora.CorporaView;
42
import org.txm.searchengine.cqp.CQPEngine;
43 37
import org.txm.searchengine.cqp.corpus.Corpus;
44
import org.txm.utils.logger.Log;
45 38

  
46 39
/**
47
 * Calls the function Information on a MainCorpus, a SubCorpus or a Partition.
40
 * Calls the function Information on a MainCorpus or a SubCorpus.
48 41
 * Displays basic statistics and gives some properties values. 
49 42
 * 
50 43
 * @author mdecorde
......
57 50
		CorporaView.addDoubleClickListener(Information.class, ComputeInformation.class);
58 51
	}
59 52
	
60
	/** The selection. */
61
	private IStructuredSelection selection;
62
	
63
	/** The response. */
64
	int response = SWT.YES;
65

  
66

  
67 53
	@Override
68 54
	public Object execute(ExecutionEvent event) throws ExecutionException {
69
		if (!CQPEngine.isInitialized()) {
70
			System.out.println("SearchEngine is not ready. Aborting.");
55

  
56
		if (!this.checkCorpusEngine())	{
71 57
			return false;
72 58
		}
73 59
		
74
		Object sel = HandlerUtil.getCurrentSelection(event);
75
		if (!(sel instanceof IStructuredSelection)) {
76
			Log.warning(InformationUIMessages.ComputeDiagnostic_0);
77
			return null;
78
		}
60
		Object selection = this.getSelection(event);
61
		Information information = null;
79 62
		
80
		selection = (IStructuredSelection) sel;
81
		Object s = selection.getFirstElement();
82
		Information diag = null;
83
		if (s instanceof Corpus) {
84
			diag = new Information((Corpus)s);
85
		} else if (s instanceof Information) {
86
			diag = (Information)s;
87
		} else {
88
			Log.severe("Selection not managed: " + s);
63
		// Creating from Corpus
64
		if (selection instanceof Corpus) {
65
			information = new Information((Corpus) selection);
89 66
		}
90
		try {
91
			open(diag);
92
		} catch (PartInitException e) {
93
			System.out.println("Error while opening editor: "+e.getLocalizedMessage());
94
			Log.printStackTrace(e);
67
		// Reopening from existing result
68
		else if(selection instanceof Information)	{
69
			information = (Information) selection;
95 70
		}
71
		// Error
72
		else	{
73
			return super.logCanNotCompute(selection);
74
		}
75
		
76
		TXMEditor.openEditor(information, InformationEditor.class.getName());
96 77
		return null;
97 78
	}
98
	
99
	public static void open(Information diag) throws PartInitException {
100
		TXMEditor.openEditor(diag, InformationEditor.class.getName());
101
	}
102 79
}
tmp/org.txm.information.rcp/src/org/txm/information/rcp/preferences/InformationPreferencePage.java (revision 709)
57 57
	public void createFieldEditors() {
58 58
		
59 59
		// The maximum number of word property values to display
60
		IntegerFieldEditor maxValue = new IntegerFieldEditor(InformationPreferences.MAX_VALUE, InformationUIMessages.DiagnosticPreferencePage_2, this.getFieldEditorParent());
60
		IntegerFieldEditor maxValue = new IntegerFieldEditor(InformationPreferences.MAX_PROPERTIES_TO_DISPLAY, InformationUIMessages.DiagnosticPreferencePage_2, this.getFieldEditorParent());
61 61
		maxValue.setValidRange(1, 9999);
62 62
		this.addField(maxValue);
63 63
	}
tmp/org.txm.rcp/plugin.xml (revision 709)
1357 1357
               </visibleWhen>
1358 1358
            </command>
1359 1359
            <command
1360
                  commandId="org.txm.rcp.commands.base.DeleteObject"
1360
                  commandId="org.txm.rcp.commands.base.DeleteObject?after=org.txm.information.rcp.handlers.ComputeInformation"
1361 1361
                  icon="icons/functions/Delete.png"
1362 1362
                  style="push"
1363 1363
                  tooltip="%command.tooltip.33">
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 709)
182 182
			
183 183
			this.bottomToolBar = new TXMEditorToolBar(this, this.bottomToolBarContainer, SWT.FLAT, "bottom");
184 184
			
185
			this.__createPartControl(parent); // essentially for the ChartEditor
185
			//this.__createPartControl(parent); // essentially for the ChartEditor
186 186
			this._createPartControl(parent); // child editor create its parameters and display widgets
187 187
			
188 188
			
......
202 202
		}
203 203
	}
204 204

  
205
	public abstract void _createPartControl(Composite parent);
206
	
207 205
	/**
208
	 * Dedicated to special internal inheritance, especially to the ChartEditor.
206
	 * Subclasses manual creation.
209 207
	 * @param parent
210 208
	 */
211
	protected  void __createPartControl(Composite parent)	{
212
		// nothing to do
213
	}
214

  
215
	/**
216
	 * Dedicated to special internal inheritance, especially to the ChartEditor.
217
	 * @param parent
218
	 */
219
	protected  void __updateEditorFromResult(boolean update)	{
220
		// nothing to do
221
	}
209
	public abstract void _createPartControl(Composite parent);
222 210
	
223
	
224 211

  
225 212
	public Composite getTopToolBarContainer() {
226 213
		return topToolBarContainer;
......
604 591
	
605 592
				// FIXME: debug
606 593
				System.err.println("TXMEditor.refresh(): manually updating editor from result.");
607
				this.updateEditorFromResult(update);  // subclasses manual settings
594
				this.updateEditorFromResult(update); // subclasses manual settings
608 595
			}
609 596
			
610
			this.__updateEditorFromResult(update); // essentially for ChartEditor
597
			//this.__updateEditorFromResult(update); // essentially for ChartEditor
611 598
			
612 599
			
613 600
			topToolBar.redraw();
tmp/org.txm.wordcloud.rcp/src/org/txm/wordcloud/rcp/editors/WordCloudEditor.java (revision 709)
38 38
	
39 39
	
40 40
	@Override
41
	public void _createPartControl(Composite parent) {
41
	public void __createPartControl(Composite parent) {
42 42

  
43 43
		// for group tests
44 44
		Composite parametersArea = this.getCommandParametersGroup();
......
72 72
		Log.info(WordCloudUIMessages.Log_WordCloud_ready + this.getResult());
73 73

  
74 74
	}
75

  
76

  
77

  
78
	@Override
79
	public void updateEditorFromChart(boolean update) {
80
		// Nothing to do
81
	}
75 82
	
76 83
}
tmp/org.txm.partition.rcp/src/org/txm/partition/rcp/editors/PartitionDimensionsEditor.java (revision 709)
13 13

  
14 14
/**
15 15
 * Partition dimensions chart editor.
16
 * 
16 17
 * @author sjacquot
17 18
 *
18 19
 */
......
29 30

  
30 31
	
31 32
	@Override
32
	public void _createPartControl(Composite parent) {
33
	public void __createPartControl(Composite parent) {
33 34

  
34 35
		// extend the tool bar
35 36
		new ToolItem(this.getToolBar(), SWT.SEPARATOR);
......
39 40
		
40 41
		this.sortByPartSize.addSelectionListener(new ComputeSelectionListener(this));
41 42
	}
43

  
44

  
45

  
46

  
47
	@Override
48
	public void updateEditorFromChart(boolean update) {
49
		// nothing to do
50
	}
42 51
	
43 52
	
44 53
}

Also available in: Unified diff