74 |
74 |
* @author sjacquot
|
75 |
75 |
*/
|
76 |
76 |
public class CAEditor extends TXMMultiPageEditor<CA> {
|
77 |
|
|
78 |
|
|
|
77 |
|
|
78 |
|
79 |
79 |
/**
|
80 |
80 |
* The CA.
|
81 |
81 |
*/
|
82 |
82 |
private CA ca;
|
83 |
|
|
84 |
|
|
|
83 |
|
|
84 |
|
85 |
85 |
@Override
|
86 |
86 |
protected void createPages() {
|
87 |
|
|
|
87 |
|
88 |
88 |
// Tabs titles
|
89 |
|
this.names = Arrays.asList(new String[] {CAUIMessages.factPlan, CACoreMessages.rows, CACoreMessages.columns, CAUIMessages.eigenvaluesBarChat, CAUIMessages.eigenvalues});
|
90 |
|
|
|
89 |
this.names = Arrays.asList(new String[] { CAUIMessages.factPlan, CACoreMessages.rows, CACoreMessages.columns, CAUIMessages.eigenvaluesBarChat, CAUIMessages.eigenvalues });
|
|
90 |
|
91 |
91 |
Composite container = this.getContainer();
|
92 |
92 |
final Composite parentContainer = container.getParent();
|
93 |
|
|
|
93 |
|
94 |
94 |
parentContainer.setLayout(new FormLayout());// change layout
|
95 |
95 |
final Sash sash = new Sash(parentContainer, SWT.VERTICAL);
|
96 |
|
|
|
96 |
|
97 |
97 |
Composite mainEditorComposite = new Composite(parentContainer, SWT.NONE);
|
98 |
|
|
|
98 |
|
99 |
99 |
FormData containerData = new FormData();
|
100 |
100 |
containerData.left = new FormAttachment(sash, 0);
|
101 |
101 |
containerData.right = new FormAttachment(100, 0);
|
102 |
102 |
containerData.top = new FormAttachment(0, 0);
|
103 |
103 |
containerData.bottom = new FormAttachment(100, 0);
|
104 |
104 |
container.setLayoutData(containerData);// set new layout data
|
105 |
|
|
|
105 |
|
106 |
106 |
final FormData sashData = new FormData();
|
107 |
107 |
sashData.left = new FormAttachment(70, 0);
|
108 |
108 |
sashData.top = new FormAttachment(0, 0);
|
109 |
109 |
sashData.bottom = new FormAttachment(100, 0);
|
110 |
110 |
sash.setLayoutData(sashData);
|
111 |
111 |
sash.addListener(SWT.Selection, new Listener() {
|
|
112 |
|
112 |
113 |
@Override
|
113 |
114 |
public void handleEvent(Event e) {
|
114 |
115 |
Rectangle sashRect = sash.getBounds();
|
... | ... | |
121 |
122 |
}
|
122 |
123 |
}
|
123 |
124 |
});
|
124 |
|
|
|
125 |
|
125 |
126 |
FormData CAFactorialMapChartFormData = new FormData();
|
126 |
127 |
CAFactorialMapChartFormData.left = new FormAttachment(0, 0);
|
127 |
128 |
CAFactorialMapChartFormData.right = new FormAttachment(sash, 0);
|
... | ... | |
129 |
130 |
CAFactorialMapChartFormData.bottom = new FormAttachment(100, 0);
|
130 |
131 |
mainEditorComposite.setLayoutData(CAFactorialMapChartFormData);// set new layout data
|
131 |
132 |
mainEditorComposite.setLayout(new FillLayout());
|
132 |
|
|
133 |
|
|
134 |
|
editors = new ArrayList<EditorPart>();
|
135 |
|
inputs = new ArrayList<IEditorInput>();
|
136 |
|
|
|
133 |
|
|
134 |
|
|
135 |
editors = new ArrayList<>();
|
|
136 |
inputs = new ArrayList<>();
|
|
137 |
|
137 |
138 |
this.ca = ((TXMResultEditorInput<CA>) this.getEditorInput()).getResult();
|
138 |
|
|
|
139 |
|
139 |
140 |
// Initialize the editor parts and editor inputs
|
140 |
141 |
this.initCAFactorialMapEditor();
|
141 |
142 |
this.initRowsTableEditor();
|
142 |
143 |
this.initColumnsTableEditor();
|
143 |
144 |
this.initCAEigenvaluesBarChartEditor();
|
144 |
145 |
this.initCAEigenvaluesTableEditor();
|
145 |
|
|
146 |
|
|
|
146 |
|
|
147 |
|
147 |
148 |
if (editors.size() != inputs.size()) {
|
148 |
149 |
throw new IllegalArgumentException(NLS.bind(TXMUIMessages.theNumberOfEditorsP0AndNumberOfInputsP1MustBeEqual, editors.size(), inputs.size()));
|
149 |
150 |
}
|
150 |
|
|
|
151 |
|
151 |
152 |
// put first editor in the left panel and set it as "main" editor
|
152 |
153 |
try {
|
153 |
|
|
154 |
|
final CAFactorialMapChartEditor caFactorialMapEditorPart = (CAFactorialMapChartEditor) editors.get(0);
|
|
154 |
|
|
155 |
final CAFactorialMapChartEditor caFactorialMapEditorPart = (CAFactorialMapChartEditor) editors.get(0);
|
155 |
156 |
this.mainEditor = caFactorialMapEditorPart;
|
156 |
|
|
|
157 |
|
157 |
158 |
IEditorSite site = this.createSite(caFactorialMapEditorPart);
|
158 |
159 |
// call init first so that if an exception is thrown, we have created no new widgets
|
159 |
160 |
caFactorialMapEditorPart.init(site, caFactorialMapEditorPart.getEditorInput());
|
160 |
|
|
|
161 |
|
161 |
162 |
// Set the parent multi pages editor of the CA factorial map editor to activate it from the child editor
|
162 |
163 |
caFactorialMapEditorPart.setParentMultiPagesEditor(this);
|
163 |
|
|
|
164 |
|
164 |
165 |
caFactorialMapEditorPart.createPartControl(mainEditorComposite);
|
165 |
|
|
|
166 |
|
166 |
167 |
caFactorialMapEditorPart.addPropertyListener(new IPropertyListener() {
|
|
168 |
|
167 |
169 |
@Override
|
168 |
170 |
public void propertyChanged(Object source, int propertyId) {
|
169 |
171 |
handlePropertyChange(propertyId);
|
170 |
172 |
}
|
171 |
173 |
});
|
172 |
|
|
|
174 |
|
173 |
175 |
// add the other editors
|
174 |
176 |
for (int i = 1; i < editors.size(); i++) {
|
175 |
177 |
int editorIndex = this.addPage(editors.get(i), inputs.get(i)); // NOTE: the method addPage() calls the createPartControl() method of the editors
|
176 |
178 |
this.setPageText(editorIndex, this.names.get(i));
|
177 |
179 |
}
|
178 |
|
|
|
180 |
|
179 |
181 |
caFactorialMapEditorPart.compute(false);
|
180 |
|
|
|
182 |
// this.getEigenvaluesBarChartEditor().compute(false);
|
|
183 |
|
181 |
184 |
}
|
182 |
185 |
catch (Exception e1) {
|
183 |
186 |
Log.printStackTrace(e1);
|
184 |
187 |
Log.severe(NLS.bind(CAUIMessages.errorWhileOpeningCAEditorColonP0, e1));
|
185 |
188 |
return;
|
186 |
189 |
}
|
187 |
|
|
|
190 |
|
188 |
191 |
// Selection changed listener to highlight CA chart points from table lines selection
|
189 |
192 |
ISelectionChangedListener selectionChangedListener = new ISelectionChangedListener() {
|
190 |
|
|
|
193 |
|
191 |
194 |
@Override
|
192 |
195 |
public void selectionChanged(SelectionChangedEvent e) {
|
193 |
196 |
// Highlight points from table lines
|
194 |
|
Table table = (Table) ((TableViewer) e.getSource()).getTable();
|
|
197 |
Table table = ((TableViewer) e.getSource()).getTable();
|
195 |
198 |
String[] selectedLabels = new String[table.getSelectionCount()];
|
196 |
199 |
TableItem[] selection = table.getSelection();
|
197 |
|
|
198 |
|
for (int i = 0; i < selection.length; i++) {
|
|
200 |
|
|
201 |
for (int i = 0; i < selection.length; i++) {
|
199 |
202 |
selectedLabels[i] = selection[i].getText();
|
200 |
203 |
}
|
201 |
|
|
|
204 |
|
202 |
205 |
CAFactorialMapChartEditor chartEditor = (CAFactorialMapChartEditor) editors.get(0);
|
203 |
|
((CAChartCreator) chartEditor.getResult().getChartCreator()).updateChartCAFactorialMapHighlightPoints(chartEditor.getChart(), (e.getSource() == getRowsInfosEditor().getViewer()), selectedLabels);
|
204 |
|
|
|
206 |
((CAChartCreator) chartEditor.getResult().getChartCreator()).updateChartCAFactorialMapHighlightPoints(chartEditor.getChart(), (e.getSource() == getRowsInfosEditor().getViewer()),
|
|
207 |
selectedLabels);
|
|
208 |
|
205 |
209 |
// SJ: fix a Linux focus bug with MultiPageEditorPart
|
206 |
|
// if(OSDetector.isFamilyUnix()) {
|
207 |
|
// table.getParent().setFocus();
|
208 |
|
// }
|
209 |
|
|
210 |
|
|
|
210 |
// if(OSDetector.isFamilyUnix()) {
|
|
211 |
// table.getParent().setFocus();
|
|
212 |
// }
|
|
213 |
|
|
214 |
|
211 |
215 |
}
|
212 |
216 |
};
|
213 |
|
|
|
217 |
|
214 |
218 |
// Add selection listener to rows table to link editor with factorial map chart
|
215 |
219 |
this.getRowsInfosEditor().getViewer().addSelectionChangedListener(selectionChangedListener);
|
216 |
220 |
// Add selection listener to cols table to link editor with factorial map chart
|
217 |
221 |
this.getColsInfosEditor().getViewer().addSelectionChangedListener(selectionChangedListener);
|
218 |
|
|
|
222 |
|
219 |
223 |
// Selection listeners to change chart items selection order from table sorting
|
220 |
224 |
SelectionListener selectionListener = new SelectionListener() {
|
221 |
|
|
|
225 |
|
222 |
226 |
@Override
|
223 |
227 |
public void widgetSelected(SelectionEvent e) {
|
224 |
228 |
// Change chart items selection order
|
225 |
|
CAFactorialMapChartEditor chartEditor = (CAFactorialMapChartEditor) editors.get(0);
|
226 |
|
((CAChartCreator) chartEditor.getResult().getChartCreator()).updateChartCAFactorialMapSetLabelItemsSelectionOrder(chartEditor.getChart(), getRowsInfosEditor().getOrdererLabels(), getColsInfosEditor().getOrdererLabels());
|
|
229 |
CAFactorialMapChartEditor chartEditor = (CAFactorialMapChartEditor) editors.get(0);
|
|
230 |
((CAChartCreator) chartEditor.getResult().getChartCreator()).updateChartCAFactorialMapSetLabelItemsSelectionOrder(chartEditor.getChart(), getRowsInfosEditor().getOrdererLabels(),
|
|
231 |
getColsInfosEditor().getOrdererLabels());
|
227 |
232 |
}
|
228 |
|
|
|
233 |
|
229 |
234 |
@Override
|
230 |
235 |
public void widgetDefaultSelected(SelectionEvent e) {
|
231 |
236 |
// TODO Auto-generated method stub
|
232 |
|
|
|
237 |
|
233 |
238 |
}
|
234 |
239 |
};
|
235 |
240 |
// Add listener to column to link chart items selection order with table sorting order
|
236 |
|
for(int i = 0; i < this.getRowsInfosEditor().getViewer().getTable().getColumnCount(); i++) {
|
|
241 |
for (int i = 0; i < this.getRowsInfosEditor().getViewer().getTable().getColumnCount(); i++) {
|
237 |
242 |
this.getRowsInfosEditor().getViewer().getTable().getColumn(i).addSelectionListener(selectionListener);
|
238 |
243 |
}
|
239 |
244 |
// Add listener to column to link chart items selection order with table sorting order
|
240 |
|
for(int i = 0; i < this.getColsInfosEditor().getViewer().getTable().getColumnCount(); i++) {
|
|
245 |
for (int i = 0; i < this.getColsInfosEditor().getViewer().getTable().getColumnCount(); i++) {
|
241 |
246 |
this.getColsInfosEditor().getViewer().getTable().getColumn(i).addSelectionListener(selectionListener);
|
242 |
247 |
}
|
243 |
|
|
244 |
|
|
245 |
|
|
|
248 |
|
|
249 |
|
|
250 |
|
246 |
251 |
// Sets the parent multi pages editor of the singular values barplot to activate it from the child editor
|
247 |
|
((ChartEditor)editors.get(3)).setParentMultiPagesEditor(this);
|
248 |
|
|
249 |
|
|
|
252 |
((ChartEditor) editors.get(3)).setParentMultiPagesEditor(this);
|
|
253 |
|
|
254 |
|
250 |
255 |
// set the eigenvalues chart visible by default
|
251 |
|
if(LAST_EDITOR_USED == 0) {
|
|
256 |
if (LAST_EDITOR_USED == 0) {
|
252 |
257 |
LAST_EDITOR_USED = 3;
|
253 |
258 |
}
|
254 |
259 |
this.setActivePage(LAST_EDITOR_USED);
|
255 |
|
|
|
260 |
|
256 |
261 |
this.setPartName(this.getEditorInput().getName());
|
257 |
262 |
}
|
258 |
|
|
|
263 |
|
259 |
264 |
/**
|
260 |
265 |
* Initializes CA factorial map editor.
|
261 |
266 |
*/
|
262 |
|
public void initCAFactorialMapEditor() {
|
|
267 |
public void initCAFactorialMapEditor() {
|
263 |
268 |
ChartEditor caFactorialMapEditorPart = new CAFactorialMapChartEditor(new ChartEditorInput<CA>(this.ca));
|
264 |
269 |
editors.add(caFactorialMapEditorPart);
|
265 |
270 |
inputs.add(caFactorialMapEditorPart.getEditorInput());
|
266 |
271 |
}
|
267 |
|
|
|
272 |
|
268 |
273 |
/**
|
269 |
274 |
* Initializes CA Eigenvalues bar chart editor.
|
270 |
275 |
*/
|
271 |
|
public void initCAEigenvaluesBarChartEditor() {
|
|
276 |
public void initCAEigenvaluesBarChartEditor() {
|
272 |
277 |
Eigenvalues eigenvalues = (Eigenvalues) ca.getFirstChild(Eigenvalues.class);
|
273 |
278 |
EigenvaluesChartEditor editor = new EigenvaluesChartEditor(new ChartEditorInput<Eigenvalues>(eigenvalues));
|
274 |
279 |
editors.add(editor);
|
275 |
280 |
inputs.add(editor.getEditorInput());
|
276 |
281 |
}
|
277 |
|
|
|
282 |
|
278 |
283 |
/**
|
279 |
284 |
* Initializes CA Eigenvalues table editor.
|
280 |
285 |
*/
|
281 |
|
public void initCAEigenvaluesTableEditor() {
|
282 |
|
EigenvaluesTableEditor editor = new EigenvaluesTableEditor(ca);
|
|
286 |
public void initCAEigenvaluesTableEditor() {
|
|
287 |
EigenvaluesTableEditor editor = new EigenvaluesTableEditor(ca);
|
283 |
288 |
editors.add(editor);
|
284 |
289 |
inputs.add(editor.getEditorInput());
|
285 |
290 |
}
|
286 |
|
|
|
291 |
|
287 |
292 |
/**
|
288 |
293 |
* Initializes rows data table editor.
|
289 |
294 |
*/
|
290 |
|
public void initRowsTableEditor() {
|
|
295 |
public void initRowsTableEditor() {
|
291 |
296 |
ColsRowsInfosEditor editor = new ColsRowsInfosEditor(ca, CAUIMessages.rowsInfos) {
|
292 |
|
|
|
297 |
|
293 |
298 |
@Override
|
294 |
299 |
public String[] getTableTitles() {
|
295 |
300 |
return ca.getRowInfosTitles();
|
296 |
301 |
}
|
297 |
|
|
|
302 |
|
298 |
303 |
@Override
|
299 |
304 |
public Object getTableInput() {
|
300 |
305 |
return ca.getRowInfos();
|
301 |
306 |
}
|
302 |
307 |
};
|
303 |
|
|
|
308 |
|
304 |
309 |
editors.add(editor);
|
305 |
310 |
inputs.add(editor.getEditorInput());
|
306 |
|
|
|
311 |
|
307 |
312 |
}
|
308 |
|
|
|
313 |
|
309 |
314 |
/**
|
310 |
315 |
* Initializes columns data table editor.
|
311 |
316 |
*/
|
312 |
|
public void initColumnsTableEditor() {
|
313 |
|
|
|
317 |
public void initColumnsTableEditor() {
|
|
318 |
|
314 |
319 |
ColsRowsInfosEditor editor = new ColsRowsInfosEditor(ca, CAUIMessages.colsInfos) {
|
315 |
|
|
|
320 |
|
316 |
321 |
@Override
|
317 |
322 |
public String[] getTableTitles() {
|
318 |
323 |
return ca.getColInfosTitles();
|
319 |
324 |
}
|
320 |
|
|
|
325 |
|
321 |
326 |
@Override
|
322 |
327 |
public Object getTableInput() {
|
323 |
328 |
return ca.getColInfos();
|
324 |
329 |
}
|
325 |
330 |
};
|
326 |
|
|
|
331 |
|
327 |
332 |
editors.add(editor);
|
328 |
333 |
inputs.add(editor.getEditorInput());
|
329 |
334 |
}
|
330 |
|
|
331 |
|
|
332 |
|
|
|
335 |
|
|
336 |
|
|
337 |
|
333 |
338 |
/**
|
334 |
339 |
* Gets the CA.
|
335 |
340 |
*
|
... | ... | |
338 |
343 |
public CA getCA() {
|
339 |
344 |
return this.ca;
|
340 |
345 |
}
|
341 |
|
|
|
346 |
|
342 |
347 |
/**
|
|
348 |
* Gets the factorial map chart editor.
|
|
349 |
*
|
|
350 |
* @return the factorial map chart editor
|
|
351 |
*/
|
|
352 |
public ChartEditor getChartEditor() {
|
|
353 |
return (ChartEditor) this.editors.get(0);
|
|
354 |
}
|
|
355 |
|
|
356 |
|
|
357 |
/**
|
343 |
358 |
* Gets the rows information editor.
|
|
359 |
*
|
344 |
360 |
* @return the rows information editor
|
345 |
361 |
*/
|
346 |
|
public ColsRowsInfosEditor getRowsInfosEditor() {
|
|
362 |
public ColsRowsInfosEditor getRowsInfosEditor() {
|
347 |
363 |
return (ColsRowsInfosEditor) this.editors.get(1);
|
348 |
364 |
}
|
349 |
|
|
|
365 |
|
350 |
366 |
/**
|
351 |
367 |
* Gets the columns information editor.
|
|
368 |
*
|
352 |
369 |
* @return the columns information editor
|
353 |
370 |
*/
|
354 |
|
public ColsRowsInfosEditor getColsInfosEditor() {
|
|
371 |
public ColsRowsInfosEditor getColsInfosEditor() {
|
355 |
372 |
return (ColsRowsInfosEditor) this.editors.get(2);
|
356 |
373 |
}
|
357 |
|
|
|
374 |
|
358 |
375 |
/**
|
359 |
|
* Gets the factorial map chart editor.
|
360 |
|
* @return the factorial map chart editor
|
|
376 |
* Gets the Eigenvalues chart editor.
|
|
377 |
*
|
|
378 |
* @return the Eigenvalues chart editor
|
361 |
379 |
*/
|
362 |
|
public ChartEditor getChartEditor() {
|
363 |
|
return (ChartEditor) this.editors.get(0);
|
|
380 |
public ChartEditor getEigenvaluesBarChartEditor() {
|
|
381 |
return (ChartEditor) this.editors.get(3);
|
364 |
382 |
}
|
365 |
|
|
|
383 |
|
|
384 |
|
366 |
385 |
@Override
|
367 |
|
public void setFocus() {
|
|
386 |
public void setFocus() {
|
368 |
387 |
super.setFocus();
|
369 |
388 |
// Give the focus to the CA factorial map ChartEditor instead of the parent MultiPageEditorPart
|
370 |
|
//editors.get(0).setFocus();
|
|
389 |
// editors.get(0).setFocus();
|
371 |
390 |
// FIXME: the problem here is that we need to give the focus to the singular values chart editor when clicking in it
|
372 |
|
// System.err.println("CaEditor.setFocus(): " + this.getActivePage());
|
373 |
|
// editors.get(4).setFocus();
|
|
391 |
// System.err.println("CaEditor.setFocus(): " + this.getActivePage());
|
|
392 |
// editors.get(4).setFocus();
|
374 |
393 |
}
|
375 |
|
|
376 |
|
// @Override
|
|
394 |
|
|
395 |
// @Override
|
377 |
396 |
public CA getResult() {
|
378 |
397 |
return ca;
|
379 |
398 |
}
|
380 |
|
|
381 |
|
//
|
382 |
|
//
|
383 |
|
// @Override
|
384 |
|
// public void close() {
|
385 |
|
// close(false);
|
386 |
|
// }
|
387 |
|
//
|
388 |
|
// @Override
|
389 |
|
// public void close(final boolean deleteResult) {
|
390 |
|
// final EditorPart self = this;
|
391 |
|
// this.getSite().getShell().getDisplay().syncExec(new Runnable() {
|
392 |
|
// @Override
|
393 |
|
// public void run() {
|
394 |
|
// getSite().getPage().closeEditor(self, false);
|
395 |
|
// if(deleteResult) {
|
396 |
|
// try {
|
397 |
|
// getResult().delete();
|
398 |
|
// }
|
399 |
|
// catch(Exception e) {
|
400 |
|
//
|
401 |
|
// }
|
402 |
|
// }
|
403 |
|
// }
|
404 |
|
// });
|
405 |
|
// }
|
406 |
|
//
|
407 |
|
// @Override
|
408 |
|
// public void setLocked(boolean locked) {
|
409 |
|
// }
|
410 |
|
//
|
411 |
|
// @Override
|
412 |
|
// public JobHandler compute(boolean update) {
|
413 |
|
// // TODO Auto-generated method stub
|
414 |
|
// return null;
|
415 |
|
// }
|
416 |
|
//
|
417 |
|
// @Override
|
418 |
|
// public void refresh(boolean update) throws Exception {
|
419 |
|
// // TODO Auto-generated method stub
|
420 |
|
//
|
421 |
|
// }
|
422 |
|
}
|
|
399 |
|
|
400 |
//
|
|
401 |
//
|
|
402 |
// @Override
|
|
403 |
// public void close() {
|
|
404 |
// close(false);
|
|
405 |
// }
|
|
406 |
//
|
|
407 |
// @Override
|
|
408 |
// public void close(final boolean deleteResult) {
|
|
409 |
// final EditorPart self = this;
|
|
410 |
// this.getSite().getShell().getDisplay().syncExec(new Runnable() {
|
|
411 |
// @Override
|
|
412 |
// public void run() {
|
|
413 |
// getSite().getPage().closeEditor(self, false);
|
|
414 |
// if(deleteResult) {
|
|
415 |
// try {
|
|
416 |
// getResult().delete();
|
|
417 |
// }
|
|
418 |
// catch(Exception e) {
|
|
419 |
//
|
|
420 |
// }
|
|
421 |
// }
|
|
422 |
// }
|
|
423 |
// });
|
|
424 |
// }
|
|
425 |
//
|
|
426 |
// @Override
|
|
427 |
// public void setLocked(boolean locked) {
|
|
428 |
// }
|
|
429 |
//
|
|
430 |
// @Override
|
|
431 |
// public JobHandler compute(boolean update) {
|
|
432 |
// // TODO Auto-generated method stub
|
|
433 |
// return null;
|
|
434 |
// }
|
|
435 |
//
|
|
436 |
// @Override
|
|
437 |
// public void refresh(boolean update) throws Exception {
|
|
438 |
// // TODO Auto-generated method stub
|
|
439 |
//
|
|
440 |
// }
|
|
441 |
}
|