Révision 1154
tmp/org.txm.ca.core/src/org/txm/ca/core/functions/CA.java (revision 1154) | ||
---|---|---|
43 | 43 |
import org.txm.core.results.Parameter; |
44 | 44 |
import org.txm.core.results.TXMParameters; |
45 | 45 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
46 |
import org.txm.searchengine.cqp.corpus.Property; |
|
46 | 47 |
import org.txm.statsengine.core.StatException; |
47 | 48 |
import org.txm.utils.logger.Log; |
48 | 49 |
|
... | ... | |
964 | 965 |
} |
965 | 966 |
|
966 | 967 |
|
968 |
/** |
|
969 |
* Gets the unit property. |
|
970 |
* @return the unitProperty |
|
971 |
*/ |
|
972 |
public Property getUnitProperty() { |
|
973 |
return this.getLexicalTable().getProperty(); |
|
974 |
} |
|
975 |
|
|
976 |
|
|
967 | 977 |
} |
tmp/org.txm.ca.core/src/org/txm/ca/core/chartsengine/jfreechart/themes/highcharts/chartcreators/JFCCAChartCreator.java (revision 1154) | ||
---|---|---|
87 | 87 |
|
88 | 88 |
|
89 | 89 |
// recreate the dataset if the unit property has changed |
90 |
// if(ca.getLexicalTable().hasParameterChanged(TXMPreferences.UNIT_PROPERTY)) {
|
|
91 |
// try {
|
|
92 |
// chart.getXYPlot().setDataset(new CAXYDataset(ca));
|
|
93 |
// }
|
|
94 |
// catch (Exception e) {
|
|
95 |
// // TODO Auto-generated catch block
|
|
96 |
// e.printStackTrace();
|
|
97 |
// }
|
|
98 |
// }
|
|
90 |
if(ca.getLexicalTable().hasParameterChanged(TXMPreferences.UNIT_PROPERTY, true)) {
|
|
91 |
try { |
|
92 |
chart.getXYPlot().setDataset(new CAXYDataset(ca)); |
|
93 |
} |
|
94 |
catch (Exception e) { |
|
95 |
// TODO Auto-generated catch block |
|
96 |
e.printStackTrace(); |
|
97 |
} |
|
98 |
} |
|
99 | 99 |
|
100 | 100 |
|
101 | 101 |
CAItemSelectionRenderer renderer = (CAItemSelectionRenderer) chart.getXYPlot().getRenderer(); |
tmp/org.txm.ahc.core/src/org/txm/ahc/core/functions/AHC.java (revision 1154) | ||
---|---|---|
195 | 195 |
this.target = this.ca.getSymbol(); |
196 | 196 |
|
197 | 197 |
// reset the number of clusters to default if columns or rows computing has changed |
198 |
if(this.lastParameters.get(AHCPreferences.COLUMNS_COMPUTING) != null && this.hasParameterChanged(AHCPreferences.COLUMNS_COMPUTING)) {
|
|
198 |
if(this.hasParameterChanged(AHCPreferences.COLUMNS_COMPUTING)) { |
|
199 | 199 |
this.numberOfClusters = AHCPreferences.getInstance().getInt(AHCPreferences.N_CLUSTERS); |
200 | 200 |
} |
201 | 201 |
|
tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAFactorialMapChartEditor.java (revision 1154) | ||
---|---|---|
5 | 5 |
import org.eclipse.swt.events.SelectionEvent; |
6 | 6 |
import org.eclipse.swt.events.SelectionListener; |
7 | 7 |
import org.eclipse.swt.widgets.Combo; |
8 |
import org.eclipse.swt.widgets.Composite;
|
|
8 |
import org.eclipse.swt.widgets.Label;
|
|
9 | 9 |
import org.eclipse.swt.widgets.ToolItem; |
10 | 10 |
import org.txm.ca.core.functions.CA; |
11 | 11 |
import org.txm.ca.core.preferences.CAPreferences; |
12 | 12 |
import org.txm.ca.rcp.messages.CAUIMessages; |
13 | 13 |
import org.txm.chartsengine.rcp.editors.ChartEditor; |
14 | 14 |
import org.txm.chartsengine.rcp.editors.ChartEditorInput; |
15 |
import org.txm.core.messages.TXMCoreMessages; |
|
16 |
import org.txm.core.preferences.TXMPreferences; |
|
15 | 17 |
import org.txm.core.results.Parameter; |
16 | 18 |
import org.txm.rcp.IImageKeys; |
17 | 19 |
import org.txm.rcp.editors.listeners.ComputeSelectionListener; |
20 |
import org.txm.rcp.swt.GLComposite; |
|
21 |
import org.txm.rcp.swt.widget.structures.PropertiesComboViewer; |
|
22 |
import org.txm.searchengine.cqp.clientExceptions.CqiClientException; |
|
23 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
|
18 | 24 |
|
19 | 25 |
/** |
20 | 26 |
* Correspondence analysis factorial map chart editor. |
... | ... | |
58 | 64 |
protected ToolItem showPointShapes; |
59 | 65 |
|
60 | 66 |
|
67 |
/** |
|
68 |
* Unit property. |
|
69 |
*/ |
|
70 |
@Parameter(key=TXMPreferences.UNIT_PROPERTY) |
|
71 |
protected PropertiesComboViewer unitPropertyComboViewer; |
|
61 | 72 |
|
73 |
|
|
74 |
|
|
75 |
|
|
62 | 76 |
/** |
63 | 77 |
* |
64 | 78 |
* @param chartEditorInput |
... | ... | |
71 | 85 |
@Override |
72 | 86 |
public void __createPartControl() { |
73 | 87 |
|
74 |
// Extend the chart editor tool bar |
|
75 |
new ToolItem(this.chartToolBar, SWT.SEPARATOR); |
|
76 |
|
|
77 | 88 |
|
78 |
// Show/hide columns |
|
79 |
showIndividuals = new ToolItem(this.chartToolBar, SWT.CHECK); |
|
80 |
// FIXME: keep this for offering an option "large icons" with text in buttons ? |
|
81 |
//showColumns.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_LABEL); |
|
82 |
showIndividuals.setToolTipText(CAUIMessages.CHART_TOOLBAR_BUTTON_SHOW_COLUMS_TOOLTIP); |
|
83 |
showIndividuals.setImage(IImageKeys.getImage(CAFactorialMapChartEditor.class, "icons/show_columns.png")); //$NON-NLS-1$ |
|
84 |
showIndividuals.addSelectionListener(new ComputeSelectionListener(this)); |
|
89 |
try { |
|
90 |
// Main parameters |
|
91 |
GLComposite mainParametersArea = this.getMainParametersComposite(); |
|
92 |
mainParametersArea.getLayout().numColumns = 2; |
|
93 |
|
|
94 |
// unit property |
|
95 |
new Label(mainParametersArea, SWT.NONE).setText(TXMCoreMessages.common_property); |
|
96 |
this.unitPropertyComboViewer = new PropertiesComboViewer(mainParametersArea, this, true, |
|
97 |
CQPCorpus.getFirstParentCorpus(this.getResult()).getOrderedProperties(), |
|
98 |
this.getResult().getUnitProperty(), false); |
|
85 | 99 |
|
86 |
// Show/hide rows |
|
87 |
showVariables = new ToolItem(this.chartToolBar, SWT.CHECK); |
|
88 |
// FIXME: keep this for offering an option "large icons" with text in buttons ? |
|
89 |
//this.showRows.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_LABEL); |
|
90 |
showVariables.setToolTipText(CAUIMessages.CHART_TOOLBAR_BUTTON_SHOW_ROWS_TOOLTIP); |
|
91 |
showVariables.setImage(IImageKeys.getImage(CAFactorialMapChartEditor.class, "icons/show_rows.png")); //$NON-NLS-1$ |
|
92 |
showVariables.addSelectionListener(new ComputeSelectionListener(this)); |
|
100 |
} |
|
101 |
catch (CqiClientException e) { |
|
102 |
// TODO Auto-generated catch block |
|
103 |
e.printStackTrace(); |
|
104 |
} |
|
93 | 105 |
|
94 |
|
|
95 |
// Show/hide point shapes |
|
96 |
showPointShapes = new ToolItem(this.chartToolBar, SWT.CHECK); |
|
97 |
// FIXME: keep this for offering an option "large icons" with text in buttons ? |
|
98 |
//showPointShapes.setText(CAUIMessages.SHOW_HIDE_POINT_SHAPES); |
|
99 |
showPointShapes.setToolTipText(CAUIMessages.CHART_TOOLBAR_BUTTON_SHOW_HIDE_POINT_SHAPES); |
|
100 |
showPointShapes.setImage(IImageKeys.getImage(CAFactorialMapChartEditor.class, "icons/show_point_shapes.png")); //$NON-NLS-1$ |
|
101 |
showPointShapes.addSelectionListener(new ComputeSelectionListener(this)); |
|
106 |
|
|
107 |
// Extend the chart editor tool bar |
|
108 |
new ToolItem(this.chartToolBar, SWT.SEPARATOR); |
|
102 | 109 |
|
103 |
|
|
104 |
// Factors plane selection |
|
105 |
CLabel factorsLabel = new CLabel(this.chartToolBar, SWT.CENTER); |
|
106 |
factorsLabel.setText(CAUIMessages.CHART_TOOLBAR_AXES_SELECTION_COMBO_BOX_LABEL); |
|
107 |
this.chartToolBar.addControl(factorsLabel); |
|
108 |
|
|
109 |
final Combo plansCombo = new Combo(this.chartToolBar, SWT.READ_ONLY); |
|
110 |
|
|
111 |
// Show/hide columns |
|
112 |
showIndividuals = new ToolItem(this.chartToolBar, SWT.CHECK); |
|
113 |
// FIXME: keep this for offering an option "large icons" with text in buttons ? |
|
114 |
//showColumns.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_COLUMS_LABEL); |
|
115 |
showIndividuals.setToolTipText(CAUIMessages.CHART_TOOLBAR_BUTTON_SHOW_COLUMS_TOOLTIP); |
|
116 |
showIndividuals.setImage(IImageKeys.getImage(CAFactorialMapChartEditor.class, "icons/show_columns.png")); //$NON-NLS-1$ |
|
117 |
showIndividuals.addSelectionListener(new ComputeSelectionListener(this)); |
|
110 | 118 |
|
111 |
// FIXME: commented because the infos panel is not ready to manage more axes |
|
119 |
// Show/hide rows |
|
120 |
showVariables = new ToolItem(this.chartToolBar, SWT.CHECK); |
|
121 |
// FIXME: keep this for offering an option "large icons" with text in buttons ? |
|
122 |
//this.showRows.setText(SWTComponentsProviderMessages.SWTChartsComponentProvider_CA_TOOLBAR_BUTTON_SHOW_ROWS_LABEL); |
|
123 |
showVariables.setToolTipText(CAUIMessages.CHART_TOOLBAR_BUTTON_SHOW_ROWS_TOOLTIP); |
|
124 |
showVariables.setImage(IImageKeys.getImage(CAFactorialMapChartEditor.class, "icons/show_rows.png")); //$NON-NLS-1$ |
|
125 |
showVariables.addSelectionListener(new ComputeSelectionListener(this)); |
|
126 |
|
|
127 |
|
|
128 |
// Show/hide point shapes |
|
129 |
showPointShapes = new ToolItem(this.chartToolBar, SWT.CHECK); |
|
130 |
// FIXME: keep this for offering an option "large icons" with text in buttons ? |
|
131 |
//showPointShapes.setText(CAUIMessages.SHOW_HIDE_POINT_SHAPES); |
|
132 |
showPointShapes.setToolTipText(CAUIMessages.CHART_TOOLBAR_BUTTON_SHOW_HIDE_POINT_SHAPES); |
|
133 |
showPointShapes.setImage(IImageKeys.getImage(CAFactorialMapChartEditor.class, "icons/show_point_shapes.png")); //$NON-NLS-1$ |
|
134 |
showPointShapes.addSelectionListener(new ComputeSelectionListener(this)); |
|
135 |
|
|
136 |
|
|
137 |
// Factors plane selection |
|
138 |
CLabel factorsLabel = new CLabel(this.chartToolBar, SWT.CENTER); |
|
139 |
factorsLabel.setText(CAUIMessages.CHART_TOOLBAR_AXES_SELECTION_COMBO_BOX_LABEL); |
|
140 |
this.chartToolBar.addControl(factorsLabel); |
|
141 |
|
|
142 |
final Combo plansCombo = new Combo(this.chartToolBar, SWT.READ_ONLY); |
|
143 |
|
|
144 |
// FIXME: commented because the infos panel is not ready to manage more axes |
|
112 | 145 |
// ArrayList<String> planes = null; |
113 | 146 |
// try { |
114 | 147 |
// int nbsv = ((CA) editorPart.getResultData()).getSingularValues().length; |
... | ... | |
127 | 160 |
// } |
128 | 161 |
// String [] items = planes.toArray(new String[planes.size()]); |
129 | 162 |
|
130 |
String items[] = { "(1,2)", "(1,3)", "(2,3)" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
163 |
String items[] = { "(1,2)", "(1,3)", "(2,3)" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
|
|
131 | 164 |
|
132 |
// TODO : commented because the infos panel is not ready to manage more axes |
|
133 |
// if(couples != null && couples.size() > 3) { |
|
134 |
// items = couples.toArray(new String[couples.size()]); |
|
135 |
//} |
|
165 |
// TODO : commented because the infos panel is not ready to manage more axes
|
|
166 |
// if(couples != null && couples.size() > 3) {
|
|
167 |
// items = couples.toArray(new String[couples.size()]);
|
|
168 |
//}
|
|
136 | 169 |
|
137 | 170 |
|
138 |
plansCombo.setItems(items); |
|
171 |
plansCombo.setItems(items);
|
|
139 | 172 |
|
140 |
// Preselect the plan from the CA data |
|
141 |
if(this.getIntParameterValue(CAPreferences.FIRST_DIMENSION) == 2) { |
|
142 |
plansCombo.select(2); |
|
143 |
} |
|
144 |
else if(this.getIntParameterValue(CAPreferences.SECOND_DIMENSION) == 3) { |
|
145 |
plansCombo.select(1); |
|
146 |
} |
|
147 |
else { |
|
148 |
plansCombo.select(0); |
|
149 |
} |
|
173 |
// Preselect the plan from the CA data
|
|
174 |
if(this.getIntParameterValue(CAPreferences.FIRST_DIMENSION) == 2) {
|
|
175 |
plansCombo.select(2);
|
|
176 |
}
|
|
177 |
else if(this.getIntParameterValue(CAPreferences.SECOND_DIMENSION) == 3) {
|
|
178 |
plansCombo.select(1);
|
|
179 |
}
|
|
180 |
else {
|
|
181 |
plansCombo.select(0);
|
|
182 |
}
|
|
150 | 183 |
|
151 | 184 |
|
152 |
this.chartToolBar.addControl(plansCombo); |
|
153 |
|
|
154 |
|
|
155 |
|
|
156 |
// Listeners |
|
157 |
SelectionListener listener = new SelectionListener() { |
|
185 |
this.chartToolBar.addControl(plansCombo); |
|
158 | 186 |
|
159 |
@Override |
|
160 |
public void widgetSelected(SelectionEvent e) { |
|
161 |
|
|
162 |
boolean resetView = false;
|
|
187 |
|
|
188 |
|
|
189 |
// Listeners |
|
190 |
SelectionListener listener = new SelectionListener() {
|
|
163 | 191 |
|
164 |
// Change factors
|
|
165 |
if(e.getSource() == plansCombo) {
|
|
192 |
@Override
|
|
193 |
public void widgetSelected(SelectionEvent e) {
|
|
166 | 194 |
|
167 |
Combo plans = (Combo) e.getSource(); |
|
195 |
boolean resetView = false; |
|
196 |
|
|
197 |
// Change factors |
|
198 |
if(e.getSource() == plansCombo) { |
|
168 | 199 |
|
169 |
int dimension1 = 1; |
|
170 |
int dimension2 = 2; |
|
200 |
Combo plans = (Combo) e.getSource(); |
|
171 | 201 |
|
172 |
String str = plans.getItem(plans.getSelectionIndex()); |
|
173 |
str = str.substring(1, str.length() -1); // remove ( and ) |
|
174 |
String[] split = str.split(","); // 2 items //$NON-NLS-1$ |
|
175 |
dimension1 = Integer.parseInt(split[0]); |
|
176 |
dimension2 = Integer.parseInt(split[1]); |
|
202 |
int dimension1 = 1; |
|
203 |
int dimension2 = 2; |
|
177 | 204 |
|
178 |
getResult().setFirstDimension(dimension1); |
|
179 |
getResult().setSecondDimension(dimension2); |
|
205 |
String str = plans.getItem(plans.getSelectionIndex()); |
|
206 |
str = str.substring(1, str.length() -1); // remove ( and ) |
|
207 |
String[] split = str.split(","); // 2 items //$NON-NLS-1$ |
|
208 |
dimension1 = Integer.parseInt(split[0]); |
|
209 |
dimension2 = Integer.parseInt(split[1]); |
|
180 | 210 |
|
181 |
resetView = true; |
|
211 |
getResult().setFirstDimension(dimension1); |
|
212 |
getResult().setSecondDimension(dimension2); |
|
213 |
|
|
214 |
resetView = true; |
|
215 |
} |
|
216 |
getResult().setChartDirty(); |
|
217 |
getResult().setNeedsToResetView(resetView); |
|
218 |
compute(true); |
|
219 |
// synchronize the part names |
|
220 |
((CAEditor)getParentMultiPagesEditor()).setName(getResult().getName()); |
|
221 |
forceFocus(); |
|
182 | 222 |
} |
183 |
getResult().setChartDirty(); |
|
184 |
getResult().setNeedsToResetView(resetView); |
|
185 |
compute(true); |
|
186 |
// synchronize the part names |
|
187 |
((CAEditor)getParentMultiPagesEditor()).setName(getResult().getName()); |
|
188 |
forceFocus(); |
|
189 |
} |
|
223 |
|
|
224 |
@Override |
|
225 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
226 |
// TODO Auto-generated method stub |
|
227 |
} |
|
228 |
}; |
|
190 | 229 |
|
191 |
@Override |
|
192 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
193 |
// TODO Auto-generated method stub |
|
194 |
} |
|
195 |
}; |
|
196 |
|
|
197 |
|
|
198 |
plansCombo.addSelectionListener(listener); |
|
230 |
|
|
231 |
plansCombo.addSelectionListener(listener); |
|
199 | 232 |
|
200 | 233 |
} |
201 | 234 |
|
tmp/org.txm.specificities.core/src/org/txm/specificities/core/functions/Specificities.java (revision 1154) | ||
---|---|---|
757 | 757 |
* @return the unitProperty |
758 | 758 |
*/ |
759 | 759 |
public Property getUnitProperty() { |
760 |
return getLexicalTable().getProperty(); |
|
760 |
return this.getLexicalTable().getProperty();
|
|
761 | 761 |
} |
762 | 762 |
|
763 | 763 |
@Override |
tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/results/ChartResult.java (revision 1154) | ||
---|---|---|
186 | 186 |
return true; |
187 | 187 |
} |
188 | 188 |
|
189 |
HashMap<String, Object> lastParameters = this.lastParameters; |
|
190 |
if(this.parametersHistory.size() > 1) { |
|
191 |
lastParameters = this.parametersHistory.get(this.parametersHistory.size() - 2); |
|
192 |
} |
|
193 |
|
|
194 |
return this.hasParameterChanged(key, lastParameters); |
|
189 |
return super.hasParameterChanged(key); |
|
195 | 190 |
} |
196 | 191 |
|
197 | 192 |
/** |
... | ... | |
255 | 250 |
// also before the call of this.updateLastParameters() to be able to check if a computing parameter has changed in the chart creators |
256 | 251 |
chartCreator.updateChart(this); |
257 | 252 |
|
258 |
this.updateLastParameters(); |
|
259 | 253 |
this.updateLastRenderingParameters(); |
260 | 254 |
|
261 |
|
|
262 | 255 |
this.needsToClearItemsSelection = false; |
263 | 256 |
this.needsToResetView = false; |
264 | 257 |
|
... | ... | |
288 | 281 |
* @throws Exception |
289 | 282 |
*/ |
290 | 283 |
protected void updateLastRenderingParameters() throws Exception { |
291 |
this.updateLastParameters(Parameter.RENDERING); |
|
284 |
this.updateLastParameters(Parameter.RENDERING, true);
|
|
292 | 285 |
} |
293 | 286 |
|
294 | 287 |
/** |
... | ... | |
325 | 318 |
} |
326 | 319 |
|
327 | 320 |
f.setAccessible(true); // not to set accessible to test the field values |
328 |
Object previousValue = this.lastParameters.get(name); |
|
321 |
|
|
322 |
// FIXME: old version |
|
323 |
//Object previousValue = this.lastParameters.get(name); |
|
324 |
// FIXME: new version with stack |
|
325 |
Object previousValue = this.getLastParametersFromHistory().get(name); |
|
326 |
|
|
327 |
|
|
329 | 328 |
Object newValue = f.get(this); |
330 | 329 |
this.updateChartDirty(previousValue, newValue); |
331 | 330 |
if (this.chartDirty) { |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 1154) | ||
---|---|---|
634 | 634 |
autoUpdateResultFromEditorParameters(); // auto updating result from Parameter annotations in result <=> editor |
635 | 635 |
|
636 | 636 |
// Stores the last parameters before the computing to later auto-update the Widgets only if some parameters have changed |
637 |
setLastComputingParameters(TXMEditor.this.getResult().getLastParameters()); |
|
637 |
setLastComputingParameters(TXMEditor.this.getResult().getLastParametersFromHistory());
|
|
638 | 638 |
} |
639 | 639 |
} |
640 | 640 |
}); |
tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesEditor.java (revision 1154) | ||
---|---|---|
41 | 41 |
import org.eclipse.swt.widgets.TableColumn; |
42 | 42 |
import org.txm.Toolbox; |
43 | 43 |
import org.txm.core.messages.TXMCoreMessages; |
44 |
import org.txm.core.preferences.TXMPreferences; |
|
44 | 45 |
import org.txm.core.results.Parameter; |
45 | 46 |
import org.txm.rcp.editors.TXMEditor; |
46 | 47 |
import org.txm.rcp.editors.TableKeyListener; |
... | ... | |
82 | 83 |
/** |
83 | 84 |
* Unit property. |
84 | 85 |
*/ |
85 |
@Parameter(key=SpecificitiesPreferences.UNIT_PROPERTY)
|
|
86 |
@Parameter(key=TXMPreferences.UNIT_PROPERTY)
|
|
86 | 87 |
protected PropertiesComboViewer unitPropertyComboViewer; |
87 | 88 |
|
88 | 89 |
/** |
tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1154) | ||
---|---|---|
144 | 144 |
/** |
145 | 145 |
* To keep track of the parameters used for the last computing and to determine if the result is dirty. |
146 | 146 |
*/ |
147 |
protected HashMap<String, Object> lastParameters = new HashMap<String, Object>(); |
|
147 |
//protected HashMap<String, Object> lastParameters = new HashMap<String, Object>();
|
|
148 | 148 |
|
149 | 149 |
// FIXME: SJ: actually only used by the chart results. Purpose here is that the chart creators need to know if a computing parameter has changed to recreate or not some entity. |
150 | 150 |
// The problem is since the result is already computing, the parameters are already updated and the method hasParameterChanged() will always return false. Using this stack fix the problem. |
... | ... | |
204 | 204 |
} |
205 | 205 |
else { |
206 | 206 |
try { |
207 |
this.uniqueID = parametersNodePath.substring(parametersNodePath.lastIndexOf("/") + 1); |
|
207 |
this.uniqueID = parametersNodePath.substring(parametersNodePath.lastIndexOf("/") + 1); //$NON-NLS-1$
|
|
208 | 208 |
} |
209 | 209 |
// FIXME: essentially for the UUID "ROOT" defined in the Workspace class, see if we can do in another way |
210 | 210 |
catch (Exception e) { |
... | ... | |
277 | 277 |
} |
278 | 278 |
|
279 | 279 |
try { |
280 |
this.parametersHistory.add(new HashMap<String, Object>()); |
|
280 | 281 |
this.updateLastParameters(); |
281 | 282 |
} |
282 | 283 |
catch (Exception e) { |
... | ... | |
411 | 412 |
* @throws Exception |
412 | 413 |
*/ |
413 | 414 |
protected void updateLastParameters(int parameterType) throws Exception { |
415 |
this.updateLastParameters(parameterType, false); |
|
416 |
} |
|
414 | 417 |
|
415 |
// FIXME: SJ store in the history stack |
|
416 |
HashMap<String, Object> lastParametersHistory = new HashMap<>(); |
|
418 |
|
|
419 |
/** |
|
420 |
* Stores the parameters of the specified type used for last computing. |
|
421 |
* @param parameterType |
|
422 |
* @param appendToLastParameters |
|
423 |
* @throws Exception |
|
424 |
*/ |
|
425 |
protected void updateLastParameters(int parameterType, boolean appendToLastParameters) throws Exception { |
|
426 |
|
|
427 |
// FIXME: SJ: store in the history stack |
|
428 |
HashMap<String, Object> lastParameters; |
|
417 | 429 |
|
430 |
if(appendToLastParameters) { |
|
431 |
lastParameters = this.getLastParametersFromHistory(); |
|
432 |
} |
|
433 |
else { |
|
434 |
lastParameters = new HashMap<>(); |
|
435 |
} |
|
436 |
|
|
418 | 437 |
List<Field> fields = this.getAllFields(); |
419 | 438 |
|
420 | 439 |
for (Field f : fields) { |
... | ... | |
432 | 451 |
} |
433 | 452 |
|
434 | 453 |
f.setAccessible(true); |
435 |
this.lastParameters.put(name, f.get(this)); |
|
436 |
|
|
437 |
lastParametersHistory.put(name, f.get(this)); |
|
454 |
lastParameters.put(name, f.get(this)); |
|
438 | 455 |
} |
439 | 456 |
|
440 |
this.parametersHistory.add(lastParametersHistory); |
|
457 |
if(!appendToLastParameters) { |
|
458 |
this.parametersHistory.add(lastParameters); |
|
459 |
} |
|
460 |
|
|
461 |
// truncate the stack to the max count |
|
462 |
// FIXME: store this in a TBX preference |
|
463 |
if(this.parametersHistory.size() > 5) { |
|
464 |
this.parametersHistory.remove(0); |
|
465 |
this.parametersHistory.remove(0); |
|
466 |
this.parametersHistory.remove(0); |
|
467 |
} |
|
468 |
|
|
441 | 469 |
} |
442 |
|
|
443 |
|
|
470 |
|
|
444 | 471 |
/** |
445 | 472 |
* Stores the last parameters used for computing. |
446 | 473 |
* @throws Exception |
... | ... | |
473 | 500 |
} |
474 | 501 |
|
475 | 502 |
f.setAccessible(true); |
476 |
this.lastParameters.remove(name); |
|
503 |
//this.lastParameters.remove(name); |
|
504 |
this.getLastParametersFromHistory().remove(name); |
|
477 | 505 |
} |
478 | 506 |
|
479 | 507 |
} |
... | ... | |
489 | 517 |
} |
490 | 518 |
|
491 | 519 |
|
492 |
public HashMap<String, Object> getLastParameters() { |
|
493 |
return lastParameters; |
|
520 |
// public HashMap<String, Object> getLastParameters() { |
|
521 |
// return lastParameters; |
|
522 |
// } |
|
523 |
// |
|
524 |
|
|
525 |
/** |
|
526 |
* Checks if a parameter value has changed since the n-2 computing. |
|
527 |
* This method permits to know, for example, if a parent that has already been computed was dirty before its computing, |
|
528 |
* then a child can adjust or not its computing, regarding to the parent state. |
|
529 |
* @param key |
|
530 |
* @param older |
|
531 |
* @return |
|
532 |
*/ |
|
533 |
public boolean hasParameterChanged(String key, boolean older) { |
|
534 |
return this.hasParameterChanged(key, this.parametersHistory.get(this.parametersHistory.size() - 2)); |
|
494 | 535 |
} |
495 | 536 |
|
496 |
|
|
497 |
|
|
498 |
|
|
499 | 537 |
/** |
500 | 538 |
* Checks if a parameter value has changed since last computing. |
501 | 539 |
* @param key |
... | ... | |
503 | 541 |
* @return |
504 | 542 |
*/ |
505 | 543 |
public boolean hasParameterChanged(String key) { |
506 |
return this.hasParameterChanged(key, this.lastParameters);
|
|
544 |
return this.hasParameterChanged(key, this.getLastParametersFromHistory());
|
|
507 | 545 |
} |
508 | 546 |
|
509 | 547 |
/** |
... | ... | |
653 | 691 |
*/ |
654 | 692 |
public final boolean isDirtyFromHistory() throws Exception { |
655 | 693 |
|
656 |
//if (hasBeenComputedOnce) return false; // can't be dirty from history if the result has never been computed |
|
657 |
|
|
658 | 694 |
Class clazz = this.getClass(); |
659 | 695 |
|
660 | 696 |
Field[] fields = clazz.getDeclaredFields(); |
... | ... | |
677 | 713 |
} |
678 | 714 |
|
679 | 715 |
f.setAccessible(true); // to be able to test the field values |
680 |
Object previousValue = this.lastParameters.get(name); |
|
716 |
|
|
717 |
|
|
718 |
// FIXME: old version |
|
719 |
//Object previousValue = this.lastParameters.get(name); |
|
720 |
// FIXME: new version with stack |
|
721 |
Object previousValue = this.getLastParametersFromHistory().get(name); |
|
722 |
|
|
723 |
|
|
681 | 724 |
Object newValue = f.get(this); |
682 | 725 |
|
683 | 726 |
// FIXME: debug |
... | ... | |
691 | 734 |
return this.dirty; |
692 | 735 |
} |
693 | 736 |
|
737 |
|
|
738 |
public HashMap<String, Object> getLastParametersFromHistory() { |
|
739 |
return this.parametersHistory.get(this.parametersHistory.size() - 1); |
|
740 |
} |
|
741 |
|
|
694 | 742 |
/** |
695 |
* Gets the dirty states.
|
|
743 |
* Gets the dirty state. |
|
696 | 744 |
* |
697 | 745 |
* @return |
698 | 746 |
*/ |
... | ... | |
701 | 749 |
} |
702 | 750 |
|
703 | 751 |
/** |
704 |
* Marks the result as dirty so editors or others will know the TXMResult |
|
705 |
* needs to be recomputed.
|
|
752 |
* Marks the result as dirty so editors or others will know the TXMResult needs to be recomputed.
|
|
753 |
* This method is also recursively called on all the children branch to mark them as dirty.
|
|
706 | 754 |
*/ |
707 | 755 |
public void setDirty() { |
708 | 756 |
this.dirty = true; |
tmp/org.txm.core/src/java/org/txm/core/results/TXMParameters.java (revision 1154) | ||
---|---|---|
29 | 29 |
super(); |
30 | 30 |
} |
31 | 31 |
|
32 |
//FIXME: use super.toString()? -> MD: nope super.toString() don't break lines |
|
32 |
//FIXME: SJ: use super.toString()? -> MD: nope super.toString() don't break lines
|
|
33 | 33 |
public void dump() { |
34 | 34 |
Set<String> keys = this.keySet(); |
35 | 35 |
Iterator<String> it = keys.iterator(); |
Formats disponibles : Unified diff