Révision 410
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/handlers/ComputeCAH.java (revision 410) | ||
---|---|---|
49 | 49 |
import org.txm.cah.core.preferences.CAHPreferences; |
50 | 50 |
import org.txm.cah.rcp.messages.CAHUIMessages; |
51 | 51 |
import org.txm.chartsengine.rcp.SWTChartsComponentsProvider; |
52 |
import org.txm.chartsengine.rcp.editors.ChartEditorInput; |
|
53 |
import org.txm.chartsengine.rcp.editors.ChartEditorPart; |
|
52 | 54 |
import org.txm.core.preferences.TXMPreferences; |
53 | 55 |
import org.txm.lexicaltable.core.functions.LexicalTable; |
54 | 56 |
import org.txm.lexicaltable.core.functions.LexicalTableFactory; |
... | ... | |
87 | 89 |
return null; |
88 | 90 |
} |
89 | 91 |
|
90 |
|
|
91 |
CAH cah = null; |
|
92 |
Object selection = this.getSelection(); |
|
93 |
ChartEditorInput editorInput = null; |
|
94 |
|
|
95 |
|
|
96 |
|
|
92 | 97 |
CA ca = null; |
93 |
LexicalTable lexicaltable = null; |
|
94 |
Partition partition = null; |
|
95 |
IStructuredSelection selection = (IStructuredSelection) HandlerUtil.getCurrentSelection(event); |
|
96 | 98 |
|
97 | 99 |
|
98 |
// Build the CA or not depending on the selection |
|
99 |
if (selection.getFirstElement() instanceof CAH) { |
|
100 |
cah = (CAH) selection.getFirstElement(); |
|
101 |
} else if (selection.getFirstElement() instanceof CA) { |
|
102 |
//System.out.println("Compute CAH with CA : "+((CA)selection.getFirstElement()).getName()); |
|
103 |
ca = (CA) selection.getFirstElement(); |
|
104 |
} else if (selection.getFirstElement() instanceof LexicalTable) { |
|
100 |
// reopening an existing result |
|
101 |
if (selection instanceof CAH) { |
|
102 |
editorInput = new ChartEditorInput((CAH) selection); |
|
103 |
} |
|
104 |
// creates from CA |
|
105 |
else if (selection instanceof CA) { |
|
106 |
ca = (CA) selection; |
|
107 |
} |
|
108 |
// creates from LexicalTable |
|
109 |
else if (selection instanceof LexicalTable) { |
|
105 | 110 |
//System.out.println("Compute CAH with LT : "+((LexicalTable)selection.getFirstElement()).getName()); |
106 |
lexicaltable = (LexicalTable) selection.getFirstElement();
|
|
111 |
LexicalTable lexicaltable = (LexicalTable) selection;
|
|
107 | 112 |
|
108 | 113 |
try { |
109 | 114 |
ca = new CA(lexicaltable); |
... | ... | |
117 | 122 |
// lexicaltable.getPartition().storeResult(ca); |
118 | 123 |
// else if (lexicaltable.getCorpus() != null) |
119 | 124 |
// lexicaltable.getCorpus().storeResult(ca); |
120 |
} else if (selection.getFirstElement() instanceof Partition) { |
|
125 |
} |
|
126 |
// creates from Partition |
|
127 |
else if (selection instanceof Partition) { |
|
121 | 128 |
//System.out.println("Compute CAH with Partition : "+((Partition)selection.getFirstElement()).getName()); |
122 |
partition = (Partition)selection.getFirstElement();
|
|
129 |
Partition partition = (Partition)selection;
|
|
123 | 130 |
try { |
124 | 131 |
String title = CAHUIMessages.bind(CAHUIMessages.ComputeCAH_0, partition.getName()); |
125 |
int vmax = TXMPreferences.getInt(CAPreferences.PREFERENCES_NODE, CAPreferences.V_MAX);
|
|
126 |
int fmin = TXMPreferences.getInt(CAPreferences.PREFERENCES_NODE, CAPreferences.F_MIN);
|
|
132 |
int vmax = TXMPreferences.getInt(CAPreferences.V_MAX, CAPreferences.PREFERENCES_NODE);
|
|
133 |
int fmin = TXMPreferences.getInt(CAPreferences.F_MIN, CAPreferences.PREFERENCES_NODE);
|
|
127 | 134 |
Shell shell = Display.getCurrent().getActiveShell(); |
128 | 135 |
LexicalTableDialog d = new LexicalTableDialog(shell, partition.getCorpus(), title); |
129 | 136 |
d.setFminAndVMax(fmin, vmax); |
... | ... | |
133 | 140 |
fmin = d.getFmin(); |
134 | 141 |
vmax = d.getMaxLines(); |
135 | 142 |
|
136 |
lexicaltable = LexicalTableFactory.getLexicalTable(partition, property, fmin); // use the CAPreferencePage Fmin |
|
143 |
LexicalTable lexicaltable = LexicalTableFactory.getLexicalTable(partition, property, fmin); // use the CAPreferencePage Fmin
|
|
137 | 144 |
lexicaltable.getData().cut(vmax); |
138 | 145 |
partition.addResult(lexicaltable); |
139 | 146 |
|
... | ... | |
150 | 157 |
} |
151 | 158 |
} |
152 | 159 |
|
153 |
// Use existent CAH (used when reopening an editor from a CAH result node) |
|
154 |
//FIXME: why we remove the result from the parent here? it shouldn't be necessary |
|
155 |
if (cah != null) { |
|
156 |
if (cah.getParent() != null) { |
|
157 |
cah.getParent().removeResult(cah); |
|
158 |
} |
|
159 |
} else { |
|
160 |
// if (ca == null) cah = new CAH(lexicaltable, computeColumns, method, metric, ncluster, display2D); |
|
161 |
// else |
|
162 |
cah = new CAH(ca, |
|
163 |
TXMPreferences.getBoolean(CAHPreferences.PREFERENCES_NODE, CAHPreferences.COLUMNS_COMPUTING), |
|
164 |
TXMPreferences.getString(CAHPreferences.PREFERENCES_NODE, CAHPreferences.METHOD), |
|
165 |
TXMPreferences.getString(CAHPreferences.PREFERENCES_NODE, CAHPreferences.METRIC), |
|
166 |
TXMPreferences.getInt(CAHPreferences.PREFERENCES_NODE, CAHPreferences.N_CLUSTERS) |
|
167 |
); |
|
160 |
if (ca != null) { |
|
161 |
editorInput = new ChartEditorInput( |
|
162 |
new CAH( |
|
163 |
ca, |
|
164 |
TXMPreferences.getBoolean(CAHPreferences.COLUMNS_COMPUTING, CAHPreferences.PREFERENCES_NODE), |
|
165 |
TXMPreferences.getString(CAHPreferences.METHOD, CAHPreferences.PREFERENCES_NODE), |
|
166 |
TXMPreferences.getString(CAHPreferences.METRIC, CAHPreferences.PREFERENCES_NODE), |
|
167 |
TXMPreferences.getInt(CAHPreferences.N_CLUSTERS, CAHPreferences.PREFERENCES_NODE) |
|
168 |
)); |
|
168 | 169 |
} |
169 |
|
|
170 |
//compute(cah, null); |
|
171 |
SWTChartsComponentsProvider.getCurrent().openEditor(cah, CAHPreferences.PREFERENCES_NODE); |
|
170 |
|
|
171 |
ChartEditorPart editor = SWTChartsComponentsProvider.getCurrent().openEditor(editorInput); |
|
172 | 172 |
|
173 |
// computes if not reopening a result |
|
174 |
if(!(selection instanceof CAH)) { |
|
175 |
editor.computeResult(false); |
|
176 |
} |
|
177 |
|
|
178 |
|
|
173 | 179 |
return null; |
174 | 180 |
} |
175 | 181 |
|
... | ... | |
179 | 185 |
/** |
180 | 186 |
* The Class CAHParamDialog. |
181 | 187 |
*/ |
188 |
// FIXME: not used? |
|
182 | 189 |
public class CAHParamDialog extends Dialog { |
183 | 190 |
|
184 | 191 |
//protected Combo methodsCombo; |
... | ... | |
246 | 253 |
nclusterSpinner = new Spinner(composite, SWT.BORDER); |
247 | 254 |
nclusterSpinner.setMinimum(2); |
248 | 255 |
nclusterSpinner.setIncrement(1); |
249 |
nclusterSpinner.setSelection(TXMPreferences.getInt(CAHPreferences.PREFERENCES_NODE, CAHPreferences.N_CLUSTERS));
|
|
256 |
nclusterSpinner.setSelection(TXMPreferences.getInt(CAHPreferences.N_CLUSTERS, CAHPreferences.PREFERENCES_NODE));
|
|
250 | 257 |
nclusterSpinner.setMaximum(50); |
251 | 258 |
|
252 | 259 |
// ROWS OR COLS |
tmp/org.txm.cah.rcp/src/org/txm/cah/rcp/editors/CAHChartEditor.java (revision 410) | ||
---|---|---|
19 | 19 |
import org.txm.chartsengine.rcp.editors.ChartEditorPart; |
20 | 20 |
import org.txm.chartsengine.rcp.messages.SWTComponentsProviderMessages; |
21 | 21 |
import org.txm.core.preferences.TXMPreferences; |
22 |
import org.txm.core.results.ITXMResult;
|
|
22 |
import org.txm.core.results.TXMResult; |
|
23 | 23 |
import org.txm.rcp.IImageKeys; |
24 | 24 |
import org.txm.rcp.JobsTimer; |
25 | 25 |
import org.txm.rcp.commands.editor.CustomizableEditor; |
... | ... | |
81 | 81 |
computeColumns.setImage(IImageKeys.getImage(CAHChartEditor.class, "icons/compute_columns.png")); //$NON-NLS-1$ |
82 | 82 |
// FIXME: keep this for offering an option "large icons" with text in buttons ? |
83 | 83 |
//computeColumns.setText(CAUIPMessages.ComputeClassification_5); |
84 |
computeColumns.setSelection(TXMPreferences.getBoolean(CAHPreferences.PREFERENCES_NODE, this.getResultData(), CAHPreferences.COLUMNS_COMPUTING));
|
|
84 |
computeColumns.setSelection(this.getBooleanParameterValue(CAHPreferences.COLUMNS_COMPUTING));
|
|
85 | 85 |
|
86 | 86 |
// Rows |
87 | 87 |
final ToolItem computeRows = new ToolItem(this.toolBar, SWT.RADIO); |
... | ... | |
89 | 89 |
computeRows.setImage(IImageKeys.getImage(CAHChartEditor.class, "icons/compute_rows.png")); //$NON-NLS-1$ |
90 | 90 |
// FIXME: keep this for offering an option "large icons" with text in buttons ? |
91 | 91 |
//computeRows.setText(CAUIPMessages.ComputeClassification_6); |
92 |
computeRows.setSelection(!TXMPreferences.getBoolean(CAHPreferences.PREFERENCES_NODE, this.getResultData(), CAHPreferences.COLUMNS_COMPUTING));
|
|
92 |
computeRows.setSelection(!this.getBooleanParameterValue(CAHPreferences.COLUMNS_COMPUTING));
|
|
93 | 93 |
|
94 | 94 |
|
95 | 95 |
// 2D/3D |
96 | 96 |
final Combo displayCombo = new Combo(this.toolBar, SWT.READ_ONLY); |
97 | 97 |
String items[] = { "2D", "3D" }; //$NON-NLS-1$ //$NON-NLS-2$ |
98 | 98 |
displayCombo.setItems(items); |
99 |
if(TXMPreferences.getBoolean(CAHPreferences.PREFERENCES_NODE, this.getResultData(), CAHPreferences.DISPLAY_2D)) {
|
|
99 |
if(this.getBooleanParameterValue(CAHPreferences.DISPLAY_2D)) {
|
|
100 | 100 |
displayCombo.select(0); |
101 | 101 |
} |
102 | 102 |
else { |
... | ... | |
118 | 118 |
// Numbers of clusters |
119 | 119 |
if(e.getSource() == numbersOfClusters) { |
120 | 120 |
|
121 |
TXMPreferences.putLocalInt(cah, CAHPreferences.N_CLUSTERS, ((Spinner)e.getSource()).getSelection()); |
|
122 | 121 |
cah.setNCluster(((Spinner)e.getSource()).getSelection()); |
123 | 122 |
} |
124 | 123 |
// Compute columns or rows |
... | ... | |
130 | 129 |
// return; |
131 | 130 |
// } |
132 | 131 |
|
133 |
|
|
134 |
TXMPreferences.putLocalBoolean(cah, CAHPreferences.COLUMNS_COMPUTING, computeColumns.getSelection()); |
|
135 | 132 |
cah.setColumnsComputing(computeColumns.getSelection()); |
136 | 133 |
|
137 | 134 |
// reset the number of clusters |
138 |
TXMPreferences.putLocalInt(cah, CAHPreferences.N_CLUSTERS, TXMPreferences.getInt(CAHPreferences.PREFERENCES_NODE, CAHPreferences.N_CLUSTERS)); |
|
139 |
cah.setNCluster(TXMPreferences.getInt(CAHPreferences.PREFERENCES_NODE, CAHPreferences.N_CLUSTERS)); |
|
135 |
cah.setNCluster(TXMPreferences.getInt(CAHPreferences.N_CLUSTERS, CAHPreferences.PREFERENCES_NODE)); |
|
140 | 136 |
|
141 | 137 |
updateNumbersOfClustersCurrentValue(); |
142 | 138 |
// Update the maximum value of the number of clusters spinner according to the new CAH configuration |
... | ... | |
182 | 178 |
try { |
183 | 179 |
|
184 | 180 |
this.acquireSemaphore(); |
185 |
getResultData().stepCompute();
|
|
181 |
getResultData().compute(this);
|
|
186 | 182 |
this.releaseSemaphore(); |
187 | 183 |
|
188 | 184 |
if(!update) { |
... | ... | |
197 | 193 |
updateNumbersOfClustersMaxValue(); |
198 | 194 |
updateNumbersOfClustersCurrentValue(); |
199 | 195 |
|
200 |
|
|
201 |
// Refresh UI |
|
202 |
CorporaView.refresh(); |
|
203 |
CorporaView.expand(getResultData().getParent()); |
|
204 | 196 |
QueriesView.refresh(); |
205 | 197 |
RVariablesView.refresh(); |
206 | 198 |
} |
... | ... | |
212 | 204 |
computeChart(update); |
213 | 205 |
|
214 | 206 |
} |
207 |
// for user direct canceling |
|
215 | 208 |
catch (ThreadDeath td) { |
216 | 209 |
return Status.CANCEL_STATUS; |
217 | 210 |
} |
... | ... | |
262 | 255 |
@Override |
263 | 256 |
public void setSource(Object source) { |
264 | 257 |
if (source instanceof CAH) |
265 |
getEditorInput().setResult((ITXMResult) source);
|
|
258 |
getEditorInput().setResult((TXMResult) source); |
|
266 | 259 |
} |
267 | 260 |
|
268 | 261 |
@Override |
Formats disponibles : Unified diff