Révision 1437
| tmp/org.txm.specificities.rcp/src/org/txm/specificities/rcp/editors/SpecificitiesEditor.java (revision 1437) | ||
|---|---|---|
| 153 | 153 |
|
| 154 | 154 |
// Result area |
| 155 | 155 |
GLComposite resultArea = this.getResultArea(); |
| 156 |
resultArea.getLayout().numColumns = 2; |
|
| 157 | 156 |
|
| 158 | 157 |
// create table viewer |
| 159 | 158 |
viewer = new TableViewer(resultArea, SWT.VIRTUAL | SWT.MULTI | SWT.FULL_SELECTION); |
| ... | ... | |
| 162 | 161 |
viewer.getTable().setHeaderVisible(true); |
| 163 | 162 |
viewer.setLabelProvider(new SpecificitiesTableLabelProvider()); |
| 164 | 163 |
viewer.setContentProvider(ArrayContentProvider.getInstance()); |
| 165 |
|
|
| 164 |
specificitesTable = viewer.getTable(); |
|
| 165 |
specificitesTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2)); |
|
| 166 |
|
|
| 166 | 167 |
// creates the viewer comparator |
| 167 | 168 |
this.viewerComparator = new SpecificitiesLinesViewerComparator(Toolbox.getCollator(this.getResult())); |
| 168 | 169 |
viewer.setComparator(this.viewerComparator); |
| 169 | 170 |
|
| 170 |
specificitesTable = viewer.getTable(); |
|
| 171 |
specificitesTable.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 2)); |
|
| 172 | 171 |
|
| 173 | 172 |
// create 1st column: Unit |
| 174 | 173 |
TableColumn unitColumn = new TableColumn(specificitesTable, SWT.NONE); |
| tmp/org.txm.ca.core/src/org/txm/ca/core/functions/CA.java (revision 1437) | ||
|---|---|---|
| 165 | 165 |
|
| 166 | 166 |
@Override |
| 167 | 167 |
protected boolean _compute() throws Exception {
|
| 168 |
|
|
| 169 |
|
|
| 170 |
Eigenvalues eigenvalues = (Eigenvalues) this.getFirstChild(Eigenvalues.class); |
|
| 171 |
if(eigenvalues == null) {
|
|
| 172 |
eigenvalues = new Eigenvalues(this); |
|
| 173 |
} |
|
| 174 |
|
|
| 175 |
|
|
| 168 | 176 |
try {
|
| 169 | 177 |
// clear cache |
| 170 | 178 |
this.colnames = null; |
| ... | ... | |
| 591 | 599 |
if (rowtitles == null) {
|
| 592 | 600 |
List<String> colnames = new ArrayList<String>(); |
| 593 | 601 |
colnames.add(TXMCoreMessages.common_rows); // entry |
| 594 |
colnames.add(" "); //$NON-NLS-1$
|
|
| 602 |
colnames.add(""); //$NON-NLS-1$
|
|
| 595 | 603 |
colnames.add(CACoreMessages.common_q12); // Q12 |
| 596 | 604 |
colnames.add(CACoreMessages.common_q13); // Q13 |
| 597 | 605 |
colnames.add(CACoreMessages.common_q23); // Q23 |
| tmp/org.txm.ca.core/src/org/txm/ca/core/chartsengine/jfreechart/themes/highcharts/chartcreators/JFCSingularValueChartCreator.java (revision 1437) | ||
|---|---|---|
| 5 | 5 |
import org.jfree.chart.axis.NumberAxis; |
| 6 | 6 |
import org.jfree.data.category.DefaultCategoryDataset; |
| 7 | 7 |
import org.jfree.data.general.DatasetUtilities; |
| 8 |
import org.jfree.data.xy.XYSeriesCollection; |
|
| 8 | 9 |
import org.txm.ca.core.chartsengine.jfreechart.themes.highcharts.renderers.CASingularValuesItemSelectionRenderer; |
| 9 | 10 |
import org.txm.ca.core.functions.CA; |
| 10 | 11 |
import org.txm.ca.core.functions.Eigenvalues; |
| ... | ... | |
| 32 | 33 |
|
| 33 | 34 |
JFreeChart chart = null; |
| 34 | 35 |
|
| 35 |
try {
|
|
| 36 |
// Creating the data set from the CA result
|
|
| 36 |
|
|
| 37 |
// Creates the empty dataset
|
|
| 37 | 38 |
DefaultCategoryDataset dataset = new DefaultCategoryDataset(); |
| 38 |
double[] singularValues = ca.getValeursPropres(); |
|
| 39 |
|
|
| 40 |
for(int i = 0; i < singularValues.length; i++) {
|
|
| 41 |
dataset.setValue(singularValues[i], CACoreMessages.eigenvalue, String.valueOf(i + 1)); |
|
| 42 |
} |
|
| 43 |
|
|
| 44 | 39 |
// Create the chart |
| 45 | 40 |
chart = this.getChartsEngine().createCategoryBarChart(dataset, CACoreMessages.eigenvalues, CACoreMessages.axis, CACoreMessages.eigenvalue, false, false, false); |
| 46 | 41 |
|
| ... | ... | |
| 48 | 43 |
chart.getCategoryPlot().setRenderer(new CASingularValuesItemSelectionRenderer(ca)); |
| 49 | 44 |
|
| 50 | 45 |
|
| 51 |
// Custom range axis for ticks drawing options |
|
| 52 |
chart.getCategoryPlot().setRangeAxis(new ExtendedNumberAxis((NumberAxis) chart.getCategoryPlot().getRangeAxis(), false, true, 0, DatasetUtilities.findMaximumRangeValue(chart.getCategoryPlot().getDataset()).doubleValue())); |
|
| 53 | 46 |
|
| 47 |
|
|
| 48 |
return chart; |
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
|
|
| 52 |
@Override |
|
| 53 |
public void updateChart(ChartResult result) {
|
|
| 54 |
|
|
| 55 |
CA ca = (CA) ((Eigenvalues) result).getCA(); |
|
| 56 |
JFreeChart chart = (JFreeChart) result.getChart(); |
|
| 57 |
|
|
| 58 |
|
|
| 59 |
// freeze rendering while computing |
|
| 60 |
chart.setNotify(false); |
|
| 61 |
|
|
| 62 |
// update the dataset |
|
| 63 |
try {
|
|
| 64 |
|
|
| 65 |
DefaultCategoryDataset dataset = (DefaultCategoryDataset) chart.getCategoryPlot().getDataset(); |
|
| 66 |
dataset.clear(); |
|
| 67 |
|
|
| 68 |
|
|
| 69 |
double[] singularValues = ca.getValeursPropres(); |
|
| 70 |
|
|
| 71 |
for(int i = 0; i < singularValues.length; i++) {
|
|
| 72 |
dataset.setValue(singularValues[i], CACoreMessages.eigenvalue, String.valueOf(i + 1)); |
|
| 73 |
} |
|
| 74 |
|
|
| 54 | 75 |
} |
| 55 | 76 |
catch(StatException e) {
|
| 56 | 77 |
Log.severe(NLS.bind(CACoreMessages.cantCreateBarChartOfTheCASingularValuesP0, e)); |
| 57 | 78 |
Log.printStackTrace(e); |
| 58 | 79 |
} |
| 59 | 80 |
|
| 60 |
return chart; |
|
| 81 |
// Custom range axis for ticks drawing options |
|
| 82 |
chart.getCategoryPlot().setRangeAxis(new ExtendedNumberAxis((NumberAxis) chart.getCategoryPlot().getRangeAxis(), false, true, 0, DatasetUtilities.findMaximumRangeValue(chart.getCategoryPlot().getDataset()).doubleValue())); |
|
| 83 |
|
|
| 84 |
|
|
| 85 |
super.updateChart(result); |
|
| 86 |
|
|
| 61 | 87 |
} |
| 62 |
|
|
| 63 | 88 |
|
| 89 |
|
|
| 64 | 90 |
@Override |
| 65 | 91 |
public Class getResultDataClass() {
|
| 66 | 92 |
return Eigenvalues.class; |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TXMEditor.java (revision 1437) | ||
|---|---|---|
| 144 | 144 |
/** |
| 145 | 145 |
* The SWT parent Composite. |
| 146 | 146 |
*/ |
| 147 |
protected Composite parent;
|
|
| 147 |
private Composite parent;
|
|
| 148 | 148 |
|
| 149 | 149 |
/** |
| 150 | 150 |
* contains the default bottom toolbars widget |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TableSorter.java (revision 1437) | ||
|---|---|---|
| 41 | 41 |
* @author sloiseau |
| 42 | 42 |
* |
| 43 | 43 |
*/ |
| 44 |
// FIXME: SJ: this class declares some column types but they are not used if tne sorting |
|
| 45 |
// may need to finalize this class or |
|
| 46 |
// also see the class: TableLinesViewerComparator and SpecificitiesLinesViewerComparator for a full implemented other way example |
|
| 47 |
@Deprecated |
|
| 44 | 48 |
public class TableSorter extends ViewerSorter {
|
| 45 | 49 |
|
| 46 | 50 |
/** The locale. */ |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/editors/TableLinesViewerComparator.java (revision 1437) | ||
|---|---|---|
| 4 | 4 |
package org.txm.rcp.editors; |
| 5 | 5 |
|
| 6 | 6 |
import java.text.Collator; |
| 7 |
import java.util.List; |
|
| 7 | 8 |
|
| 8 | 9 |
import org.eclipse.jface.viewers.TableViewer; |
| 10 |
import org.eclipse.jface.viewers.Viewer; |
|
| 9 | 11 |
import org.eclipse.jface.viewers.ViewerComparator; |
| 10 | 12 |
import org.eclipse.swt.SWT; |
| 11 | 13 |
import org.eclipse.swt.events.SelectionAdapter; |
| 12 | 14 |
import org.eclipse.swt.events.SelectionEvent; |
| 15 |
import org.eclipse.swt.widgets.Table; |
|
| 13 | 16 |
import org.eclipse.swt.widgets.TableColumn; |
| 14 | 17 |
|
| 15 | 18 |
/** |
| 16 | 19 |
* Base abstract viewer comparator for table lines sorting. |
| 20 |
* This comparator tries to determine the primitive type of the objects and compare according to it. |
|
| 21 |
* The method compare() is dedicated to be override by subclasses if more granularity is needed. |
|
| 22 |
* Subclasses can for example sort using the column index that is stored each time a sort is done. |
|
| 17 | 23 |
* |
| 18 | 24 |
* @author sjacquot |
| 19 | 25 |
* |
| 20 | 26 |
*/ |
| 21 |
public abstract class TableLinesViewerComparator extends ViewerComparator {
|
|
| 27 |
public class TableLinesViewerComparator extends ViewerComparator {
|
|
| 22 | 28 |
|
| 23 | 29 |
|
| 24 | 30 |
public static final int DESCENDING = 1; |
| ... | ... | |
| 38 | 44 |
*/ |
| 39 | 45 |
protected Collator collator; |
| 40 | 46 |
|
| 47 |
/** |
|
| 48 |
* If true all the viewer columns will be packed after a sort. |
|
| 49 |
*/ |
|
| 50 |
protected boolean autoPackColumns; |
|
| 41 | 51 |
|
| 42 | 52 |
/** |
| 43 | 53 |
* |
| 44 | 54 |
* @param collator |
| 45 | 55 |
*/ |
| 46 | 56 |
public TableLinesViewerComparator(Collator collator) {
|
| 57 |
this(collator, true); |
|
| 58 |
} |
|
| 59 |
|
|
| 60 |
/** |
|
| 61 |
* |
|
| 62 |
* @param collator |
|
| 63 |
* @param autoPackColumns |
|
| 64 |
*/ |
|
| 65 |
public TableLinesViewerComparator(Collator collator, boolean autoPackColumns) {
|
|
| 47 | 66 |
this.collator = collator; |
| 67 |
this.autoPackColumns = autoPackColumns; |
|
| 48 | 68 |
this.lastColumnIndex = 0; |
| 49 | 69 |
this.direction = 0; |
| 50 | 70 |
} |
| 51 | 71 |
|
| 52 | 72 |
|
| 73 |
@Override |
|
| 74 |
public int compare(Viewer viewer, Object e1, Object e2) {
|
|
| 75 |
|
|
| 76 |
int result = 0; |
|
| 77 |
|
|
| 78 |
if(e1 instanceof List) {
|
|
| 79 |
Object cell1 = ((List)e1).get(this.lastColumnIndex); |
|
| 80 |
Object cell2 = ((List)e2).get(this.lastColumnIndex); |
|
| 81 |
|
|
| 82 |
if (Integer.class.isInstance(cell1)) {
|
|
| 83 |
result = ((Integer)cell1).compareTo(((Integer)cell2)); |
|
| 84 |
} |
|
| 85 |
else if (Double.class.isInstance(cell1)) {
|
|
| 86 |
result = ((Double)cell1).compareTo(((Double)cell2)); |
|
| 87 |
} |
|
| 88 |
else if (Float.class.isInstance(cell1)) {
|
|
| 89 |
result = ((Float)cell1).compareTo(((Float)cell2)); |
|
| 90 |
} |
|
| 91 |
else if (Long.class.isInstance(cell1)) {
|
|
| 92 |
result = ((Long)cell1).compareTo(((Long)cell2)); |
|
| 93 |
} |
|
| 94 |
else if (String.class.isInstance(cell1)) {
|
|
| 95 |
result = this.collator.compare((String)cell1, (String)cell2); |
|
| 96 |
} |
|
| 97 |
else if (Boolean.class.isInstance(cell1)) {
|
|
| 98 |
result = ((Boolean)cell1).compareTo(((Boolean)cell2)); |
|
| 99 |
} |
|
| 100 |
} |
|
| 101 |
|
|
| 102 |
// reverse if needed |
|
| 103 |
if (this.direction == DESCENDING) {
|
|
| 104 |
result = -result; |
|
| 105 |
} |
|
| 106 |
return result; |
|
| 107 |
} |
|
| 108 |
|
|
| 109 |
|
|
| 53 | 110 |
/** |
| 54 | 111 |
* |
| 55 | 112 |
* @return |
| ... | ... | |
| 91 | 148 |
viewer.getTable().setSortDirection(getDirection()); |
| 92 | 149 |
viewer.getTable().setSortColumn(column); |
| 93 | 150 |
|
| 94 |
TXMEditor.packColumns(viewer); |
|
| 151 |
if(autoPackColumns) {
|
|
| 152 |
TXMEditor.packColumns(viewer); |
|
| 153 |
} |
|
| 154 |
else {
|
|
| 155 |
viewer.refresh(); |
|
| 156 |
} |
|
| 95 | 157 |
|
| 96 | 158 |
} |
| 97 | 159 |
}); |
| 98 | 160 |
} |
| 99 | 161 |
|
| 162 |
/** |
|
| 163 |
* Adds some selection adapters to all column between the specified indexes range to manage the lines sorting. |
|
| 164 |
* @param viewer |
|
| 165 |
* @param startingColIndex |
|
| 166 |
* @param endingColIndex |
|
| 167 |
*/ |
|
| 168 |
// FIXME: SJ: not used at this time but could be useful? |
|
| 169 |
public void addSelectionAdapters(final TableViewer viewer, int startingColIndex, int endingColIndex) {
|
|
| 170 |
|
|
| 171 |
Table table = viewer.getTable(); |
|
| 172 |
|
|
| 173 |
for (int i = startingColIndex; i < endingColIndex; i++) {
|
|
| 174 |
this.addSelectionAdapter(viewer, table.getColumn(i), i); |
|
| 175 |
} |
|
| 176 |
} |
|
| 177 |
|
|
| 178 |
/** |
|
| 179 |
* Adds some selection adapters to all column that have a non empty header label. |
|
| 180 |
* @param viewer |
|
| 181 |
*/ |
|
| 182 |
public void addSelectionAdapters(final TableViewer viewer) {
|
|
| 183 |
Table table = viewer.getTable(); |
|
| 184 |
for (int i = 0; i < table.getColumnCount(); i++) {
|
|
| 185 |
TableColumn column = table.getColumn(i); |
|
| 186 |
String test = column.getText(); |
|
| 187 |
if(!column.getText().isEmpty()) {
|
|
| 188 |
this.addSelectionAdapter(viewer, column, i); |
|
| 189 |
} |
|
| 190 |
} |
|
| 191 |
} |
|
| 192 |
|
|
| 100 | 193 |
|
| 101 | 194 |
/** |
| 102 | 195 |
* @param direction the direction to set |
| tmp/org.txm.core/src/java/org/txm/Toolbox.java (revision 1437) | ||
|---|---|---|
| 659 | 659 |
*/ |
| 660 | 660 |
public static Collator getCollator(TXMResult result) {
|
| 661 | 661 |
Locale locale = Locale.getDefault(); |
| 662 |
String lang = result.getStringParameterValue(TBXPreferences.LANG); //$NON-NLS-1$
|
|
| 662 |
String lang = result.getStringParameterValue(TBXPreferences.LANG); |
|
| 663 | 663 |
if (lang != null) {
|
| 664 | 664 |
locale = new Locale(lang); |
| 665 | 665 |
} |
| tmp/org.txm.core/src/java/org/txm/core/results/TXMResult.java (revision 1437) | ||
|---|---|---|
| 174 | 174 |
|
| 175 | 175 |
|
| 176 | 176 |
|
| 177 |
|
|
| 178 |
|
|
| 179 | 177 |
/** |
| 180 | 178 |
* Creates a new TXMResult, child of the specified parent. |
| 181 | 179 |
* @param parent |
| tmp/org.txm.chartsengine.rcp/src/org/txm/chartsengine/rcp/editors/ChartEditor.java (revision 1437) | ||
|---|---|---|
| 27 | 27 |
import org.txm.chartsengine.rcp.swt.ChartComposite; |
| 28 | 28 |
import org.txm.chartsengine.rcp.swt.ChartEditorToolBar; |
| 29 | 29 |
import org.txm.rcp.editors.TXMEditor; |
| 30 |
import org.txm.rcp.editors.TXMMultiPageEditor; |
|
| 30 | 31 |
import org.txm.utils.logger.Log; |
| 31 | 32 |
|
| 32 | 33 |
/** |
| ... | ... | |
| 73 | 74 |
/** |
| 74 | 75 |
* The multi pages editor which contains this editor if exists. |
| 75 | 76 |
*/ |
| 76 |
protected MultiPageEditorPart parentMultiPagesEditor = null;
|
|
| 77 |
protected TXMMultiPageEditor parentMultiPagesEditor = null;
|
|
| 77 | 78 |
|
| 78 | 79 |
/** |
| 79 | 80 |
* Token used to deactivate the context after it has been activated. |
| ... | ... | |
| 605 | 606 |
* Sets the specified multipages editor part as parent of this one. |
| 606 | 607 |
* @param parentMultiPagesEditor the parentMultiPagesEditor to set |
| 607 | 608 |
*/ |
| 608 |
public void setParentMultiPagesEditor(MultiPageEditorPart parentMultiPagesEditor) {
|
|
| 609 |
public void setParentMultiPagesEditor(TXMMultiPageEditor parentMultiPagesEditor) {
|
|
| 609 | 610 |
this.parentMultiPagesEditor = parentMultiPagesEditor; |
| 610 | 611 |
} |
| 611 | 612 |
|
| tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/SingularValuesEditor.java (revision 1437) | ||
|---|---|---|
| 1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
| 2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
| 3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
| 4 |
// Sophia Antipolis, University of Paris 3. |
|
| 5 |
// |
|
| 6 |
// The TXM platform is free software: you can redistribute it |
|
| 7 |
// and/or modify it under the terms of the GNU General Public |
|
| 8 |
// License as published by the Free Software Foundation, |
|
| 9 |
// either version 2 of the License, or (at your option) any |
|
| 10 |
// later version. |
|
| 11 |
// |
|
| 12 |
// The TXM platform is distributed in the hope that it will be |
|
| 13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
| 14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
| 15 |
// PURPOSE. See the GNU General Public License for more |
|
| 16 |
// details. |
|
| 17 |
// |
|
| 18 |
// You should have received a copy of the GNU General |
|
| 19 |
// Public License along with the TXM platform. If not, see |
|
| 20 |
// http://www.gnu.org/licenses. |
|
| 21 |
// |
|
| 22 |
// |
|
| 23 |
// |
|
| 24 |
// $LastChangedDate:$ |
|
| 25 |
// $LastChangedRevision:$ |
|
| 26 |
// $LastChangedBy:$ |
|
| 27 |
// |
|
| 28 |
package org.txm.ca.rcp.editors; |
|
| 29 |
|
|
| 30 |
import java.text.DecimalFormat; |
|
| 31 |
import java.util.ArrayList; |
|
| 32 |
import java.util.List; |
|
| 33 |
|
|
| 34 |
import org.eclipse.jface.action.MenuManager; |
|
| 35 |
import org.eclipse.jface.viewers.ArrayContentProvider; |
|
| 36 |
import org.eclipse.jface.viewers.IStructuredContentProvider; |
|
| 37 |
import org.eclipse.jface.viewers.ITableLabelProvider; |
|
| 38 |
import org.eclipse.jface.viewers.LabelProvider; |
|
| 39 |
import org.eclipse.jface.viewers.TableViewer; |
|
| 40 |
import org.eclipse.jface.viewers.TableViewerColumn; |
|
| 41 |
import org.eclipse.jface.viewers.Viewer; |
|
| 42 |
import org.eclipse.swt.SWT; |
|
| 43 |
import org.eclipse.swt.events.SelectionAdapter; |
|
| 44 |
import org.eclipse.swt.events.SelectionEvent; |
|
| 45 |
import org.eclipse.swt.graphics.Image; |
|
| 46 |
import org.eclipse.swt.layout.FillLayout; |
|
| 47 |
import org.eclipse.swt.widgets.Event; |
|
| 48 |
import org.eclipse.swt.widgets.Listener; |
|
| 49 |
import org.eclipse.swt.widgets.Menu; |
|
| 50 |
import org.eclipse.swt.widgets.Table; |
|
| 51 |
import org.eclipse.swt.widgets.TableItem; |
|
| 52 |
import org.txm.ca.core.functions.CA; |
|
| 53 |
import org.txm.ca.rcp.messages.CAUIMessages; |
|
| 54 |
import org.txm.core.results.TXMResult; |
|
| 55 |
import org.txm.rcp.StatusLine; |
|
| 56 |
import org.txm.rcp.editors.ITablableEditorInput; |
|
| 57 |
import org.txm.rcp.editors.TXMEditor; |
|
| 58 |
import org.txm.rcp.editors.TableKeyListener; |
|
| 59 |
import org.txm.rcp.editors.TableSorter; |
|
| 60 |
import org.txm.rcp.editors.input.AbstractTablableEditorInput; |
|
| 61 |
import org.txm.rcp.messages.TXMUIMessages; |
|
| 62 |
// TODO: Auto-generated Javadoc |
|
| 63 |
/** |
|
| 64 |
* show the singular values and compute some stats. |
|
| 65 |
* |
|
| 66 |
* @author mdecorde |
|
| 67 |
*/ |
|
| 68 |
public class SingularValuesEditor extends TXMEditor<CA> {
|
|
| 69 |
|
|
| 70 |
|
|
| 71 |
|
|
| 72 |
/** The ID. */ |
|
| 73 |
static public String ID = "org.txm.rcp.editors.TableEditor"; //$NON-NLS-1$ |
|
| 74 |
|
|
| 75 |
/** The viewer. */ |
|
| 76 |
private TableViewer viewer; |
|
| 77 |
|
|
| 78 |
/** The table input. */ |
|
| 79 |
//private ITablableEditorInput tableInput; |
|
| 80 |
|
|
| 81 |
/** The columns. */ |
|
| 82 |
List<TableViewerColumn> columns = new ArrayList<TableViewerColumn>(); |
|
| 83 |
|
|
| 84 |
/** The table sorter. */ |
|
| 85 |
private TableSorter tableSorter; |
|
| 86 |
|
|
| 87 |
|
|
| 88 |
|
|
| 89 |
/** |
|
| 90 |
* |
|
| 91 |
* @param result |
|
| 92 |
*/ |
|
| 93 |
public SingularValuesEditor(TXMResult result) {
|
|
| 94 |
super(result); |
|
| 95 |
|
|
| 96 |
// // Editor input |
|
| 97 |
// ITablableEditorInput table = new AbstractTablableEditorInput() {
|
|
| 98 |
// @Override |
|
| 99 |
// public String[] getColumnTitles() {
|
|
| 100 |
// return new String[] {
|
|
| 101 |
// CAUIMessages.CorrespondanceAnalysisEditorInput_4, |
|
| 102 |
// CAUIMessages.eigenvalue, |
|
| 103 |
// "%", CAUIMessages.CorrespondanceAnalysisEditorInput_11, "", ""}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
| 104 |
// } |
|
| 105 |
// |
|
| 106 |
// @Override |
|
| 107 |
// public String[] getColumnTypes() {
|
|
| 108 |
// return new String[] {
|
|
| 109 |
// TXMUIMessages.integer, |
|
| 110 |
// CAEditor.COL_TYPE, |
|
| 111 |
// CAEditor.COL_TYPE, |
|
| 112 |
// CAEditor.COL_TYPE, |
|
| 113 |
// CAEditor.COL_TYPE, |
|
| 114 |
// CAEditor.SEPARATOR}; |
|
| 115 |
// } |
|
| 116 |
// |
|
| 117 |
// @Override |
|
| 118 |
// public IStructuredContentProvider getContentProvider() {
|
|
| 119 |
// return new IStructuredContentProvider() {
|
|
| 120 |
// @Override |
|
| 121 |
// public Object[] getElements(Object inputElement) {
|
|
| 122 |
// CA ca = (CA) inputElement; |
|
| 123 |
// List<List<Object>> tabledata = ca.getSingularValuesInfos(); |
|
| 124 |
// return tabledata.toArray(); |
|
| 125 |
// } |
|
| 126 |
// |
|
| 127 |
// @Override |
|
| 128 |
// public void dispose() {
|
|
| 129 |
// // TODO Auto-generated method stub |
|
| 130 |
// } |
|
| 131 |
// |
|
| 132 |
// @Override |
|
| 133 |
// public void inputChanged(Viewer viewer, Object oldInput, |
|
| 134 |
// Object newInput) {
|
|
| 135 |
// // TODO Auto-generated method stub |
|
| 136 |
// } |
|
| 137 |
// }; |
|
| 138 |
// } |
|
| 139 |
// |
|
| 140 |
// @Override |
|
| 141 |
// public Object getInput() {
|
|
| 142 |
// return SingularValuesEditor.this.getResult(); |
|
| 143 |
// } |
|
| 144 |
// |
|
| 145 |
// @Override |
|
| 146 |
// public LabelProvider getLabelProvider() {
|
|
| 147 |
// return new CASingularValueLabelProvider(); |
|
| 148 |
// } |
|
| 149 |
// }; |
|
| 150 |
// |
|
| 151 |
|
|
| 152 |
} |
|
| 153 |
|
|
| 154 |
|
|
| 155 |
/** |
|
| 156 |
* The Class CASingularValueLabelProvider. |
|
| 157 |
*/ |
|
| 158 |
private class CASingularValueLabelProvider extends LabelProvider implements ITableLabelProvider {
|
|
| 159 |
|
|
| 160 |
/** |
|
| 161 |
* Percent values number format. |
|
| 162 |
*/ |
|
| 163 |
protected DecimalFormat percentValuesNumberFormat = new DecimalFormat(new String("0.00")); //$NON-NLS-1$
|
|
| 164 |
|
|
| 165 |
|
|
| 166 |
/* (non-Javadoc) |
|
| 167 |
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) |
|
| 168 |
*/ |
|
| 169 |
@Override |
|
| 170 |
public Image getColumnImage(Object element, int columnIndex) {
|
|
| 171 |
// TODO Auto-generated method stub |
|
| 172 |
return null; |
|
| 173 |
} |
|
| 174 |
|
|
| 175 |
/* (non-Javadoc) |
|
| 176 |
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) |
|
| 177 |
*/ |
|
| 178 |
@Override |
|
| 179 |
@SuppressWarnings("unchecked") //$NON-NLS-1$
|
|
| 180 |
public String getColumnText(Object element, int columnIndex) {
|
|
| 181 |
DecimalFormat f; |
|
| 182 |
Object o = ((List<Object>) element).get(columnIndex); |
|
| 183 |
switch (columnIndex) {
|
|
| 184 |
case 0: // factor |
|
| 185 |
return o.toString(); |
|
| 186 |
case 1: // eigenvalue |
|
| 187 |
if ((Double) o < 1) {
|
|
| 188 |
if ((Double) o < 0.0001) |
|
| 189 |
f = new DecimalFormat("0.0000E00"); //$NON-NLS-1$
|
|
| 190 |
else |
|
| 191 |
f = new DecimalFormat("0.0000"); //$NON-NLS-1$
|
|
| 192 |
} else {
|
|
| 193 |
f = new DecimalFormat("##########0.0000"); //$NON-NLS-1$
|
|
| 194 |
} |
|
| 195 |
// FIXME: printf syntax tests |
|
| 196 |
//return String.format("%.4f", o);
|
|
| 197 |
return f.format(o); |
|
| 198 |
case 2: // percent |
|
| 199 |
case 3: // cumul |
|
| 200 |
return percentValuesNumberFormat.format(o); |
|
| 201 |
default: |
|
| 202 |
return ""; //$NON-NLS-1$ |
|
| 203 |
} |
|
| 204 |
} |
|
| 205 |
} |
|
| 206 |
|
|
| 207 |
|
|
| 208 |
@Override |
|
| 209 |
public void _createPartControl() throws Exception {
|
|
| 210 |
|
|
| 211 |
this.parent.setLayout(new FillLayout()); |
|
| 212 |
|
|
| 213 |
//tableInput = (ITablableEditorInput) this.getEditorInput(); |
|
| 214 |
|
|
| 215 |
viewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION); |
|
| 216 |
viewer.getTable().addKeyListener(new TableKeyListener(viewer)); |
|
| 217 |
|
|
| 218 |
Table table = viewer.getTable(); |
|
| 219 |
table.setHeaderVisible(true); |
|
| 220 |
table.setLinesVisible(true); |
|
| 221 |
|
|
| 222 |
String[] titles = new String[] {
|
|
| 223 |
CAUIMessages.CorrespondanceAnalysisEditorInput_4, |
|
| 224 |
CAUIMessages.eigenvalue, |
|
| 225 |
"%", CAUIMessages.CorrespondanceAnalysisEditorInput_11, "", ""}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$; |
|
| 226 |
|
|
| 227 |
|
|
| 228 |
for (int i = 0; i < titles.length; i++) {
|
|
| 229 |
final int index = i; |
|
| 230 |
final TableViewerColumn column; |
|
| 231 |
|
|
| 232 |
int alignment = SWT.RIGHT; |
|
| 233 |
// Align the bar plot to the left |
|
| 234 |
if(i == 4) {
|
|
| 235 |
alignment = SWT.LEFT; |
|
| 236 |
} |
|
| 237 |
|
|
| 238 |
column = new TableViewerColumn(viewer, alignment); |
|
| 239 |
|
|
| 240 |
column.getColumn().setText(titles[i]); |
|
| 241 |
column.getColumn().setWidth(100); |
|
| 242 |
column.getColumn().setResizable(true); |
|
| 243 |
column.getColumn().setMoveable(true); |
|
| 244 |
columns.add(column); |
|
| 245 |
|
|
| 246 |
column.getColumn().addSelectionListener(new SelectionAdapter() {
|
|
| 247 |
@Override |
|
| 248 |
public void widgetSelected(SelectionEvent e) {
|
|
| 249 |
StatusLine.setMessage(TXMUIMessages.sortingColumn); |
|
| 250 |
tableSorter.setColumn(index); |
|
| 251 |
int dir = viewer.getTable().getSortDirection(); |
|
| 252 |
if (viewer.getTable().getSortColumn() == column.getColumn()) {
|
|
| 253 |
dir = dir == SWT.UP ? SWT.DOWN : SWT.UP; |
|
| 254 |
} else {
|
|
| 255 |
dir = SWT.DOWN; |
|
| 256 |
} |
|
| 257 |
viewer.getTable().setSortDirection(dir); |
|
| 258 |
viewer.getTable().setSortColumn(column.getColumn()); |
|
| 259 |
viewer.refresh(); |
|
| 260 |
StatusLine.setMessage(TXMUIMessages.sortDone); |
|
| 261 |
} |
|
| 262 |
}); |
|
| 263 |
} |
|
| 264 |
|
|
| 265 |
|
|
| 266 |
// To draw the bar plot column |
|
| 267 |
viewer.getTable().addListener(SWT.EraseItem, new Listener() {
|
|
| 268 |
public void handleEvent(Event event) {
|
|
| 269 |
|
|
| 270 |
if(event.index == 4) {
|
|
| 271 |
int itemIndex = viewer.getTable().indexOf((TableItem)event.item); |
|
| 272 |
double percent = Double.parseDouble(((ArrayList)viewer.getElementAt(itemIndex)).get(2).toString().replaceAll(",",".")); // comma replacement according to the locale //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 273 |
|
|
| 274 |
int maxPercentItemIndex = 0; |
|
| 275 |
double maxPercent = Double.parseDouble(viewer.getTable().getItem(0).getText(2).replaceAll(",",".")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 276 |
double tmpMaxPercent; |
|
| 277 |
|
|
| 278 |
// Get the max percent despite of the current row sorting |
|
| 279 |
for(int i = 0; i < viewer.getTable().getItemCount(); i++) {
|
|
| 280 |
tmpMaxPercent = Double.parseDouble(viewer.getTable().getItem(i).getText(2).replaceAll(",",".")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 281 |
if(tmpMaxPercent > maxPercent) {
|
|
| 282 |
maxPercent = tmpMaxPercent; |
|
| 283 |
maxPercentItemIndex = i; |
|
| 284 |
} |
|
| 285 |
} |
|
| 286 |
|
|
| 287 |
event.gc.setBackground(viewer.getTable().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); |
|
| 288 |
event.gc.fillRectangle(event.x, event.y, (int) (event.width * percent / Double.parseDouble(viewer.getTable().getItem(maxPercentItemIndex).getText(2).replaceAll(",","."))), event.height); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 289 |
} |
|
| 290 |
} |
|
| 291 |
}); |
|
| 292 |
|
|
| 293 |
|
|
| 294 |
|
|
| 295 |
|
|
| 296 |
|
|
| 297 |
//viewer.setContentProvider(tableInput.getContentProvider()); |
|
| 298 |
|
|
| 299 |
|
|
| 300 |
viewer.setContentProvider(ArrayContentProvider.getInstance()); |
|
| 301 |
// viewer.setContentProvider(new IStructuredContentProvider() {
|
|
| 302 |
// @Override |
|
| 303 |
// public Object[] getElements(Object inputElement) {
|
|
| 304 |
// return ((CA) inputElement).getSingularValuesInfos().toArray(); |
|
| 305 |
// } |
|
| 306 |
// |
|
| 307 |
// @Override |
|
| 308 |
// public void dispose() {
|
|
| 309 |
// // TODO Auto-generated method stub |
|
| 310 |
// } |
|
| 311 |
// |
|
| 312 |
// @Override |
|
| 313 |
// public void inputChanged(Viewer viewer, Object oldInput, |
|
| 314 |
// Object newInput) {
|
|
| 315 |
// // TODO Auto-generated method stub |
|
| 316 |
// } |
|
| 317 |
// } |
|
| 318 |
//); |
|
| 319 |
|
|
| 320 |
|
|
| 321 |
viewer.setLabelProvider(new CASingularValueLabelProvider()); |
|
| 322 |
|
|
| 323 |
|
|
| 324 |
|
|
| 325 |
|
|
| 326 |
tableSorter = new TableSorter(); |
|
| 327 |
|
|
| 328 |
//tableSorter.setColumnTypes(tableInput.getColumnTypes()); |
|
| 329 |
|
|
| 330 |
|
|
| 331 |
tableSorter.setColumnTypes(new String[] {
|
|
| 332 |
TXMUIMessages.integer, |
|
| 333 |
CAEditor.COL_TYPE, |
|
| 334 |
CAEditor.COL_TYPE, |
|
| 335 |
CAEditor.COL_TYPE, |
|
| 336 |
CAEditor.COL_TYPE, |
|
| 337 |
CAEditor.SEPARATOR}); |
|
| 338 |
|
|
| 339 |
|
|
| 340 |
viewer.setSorter(tableSorter); |
|
| 341 |
|
|
| 342 |
// Register the context menu |
|
| 343 |
TXMEditor.initContextMenu(this.viewer.getTable(), this.getSite(), this.viewer); |
|
| 344 |
|
|
| 345 |
// createContextMenu(viewer); |
|
| 346 |
|
|
| 347 |
tableSorter.setColumn(0); |
|
| 348 |
int dir = viewer.getTable().getSortDirection(); |
|
| 349 |
if (viewer.getTable().getSortColumn() == columns.get(0).getColumn()) {
|
|
| 350 |
dir = dir == SWT.UP ? SWT.DOWN : SWT.UP; |
|
| 351 |
} else {
|
|
| 352 |
dir = SWT.DOWN; |
|
| 353 |
} |
|
| 354 |
viewer.getTable().setSortDirection(dir); |
|
| 355 |
viewer.getTable().setSortColumn(columns.get(0).getColumn()); |
|
| 356 |
|
|
| 357 |
|
|
| 358 |
} |
|
| 359 |
|
|
| 360 |
|
|
| 361 |
@Override |
|
| 362 |
public void updateEditorFromResult(boolean update) throws Exception {
|
|
| 363 |
|
|
| 364 |
try {
|
|
| 365 |
this.viewer.setInput(((CA)this.getResult()).getSingularValuesInfos().toArray()); |
|
| 366 |
} |
|
| 367 |
catch (Exception e) {
|
|
| 368 |
// TODO Auto-generated catch block |
|
| 369 |
e.printStackTrace(); |
|
| 370 |
this.viewer.setInput(null); |
|
| 371 |
} |
|
| 372 |
|
|
| 373 |
this.viewer.refresh(); |
|
| 374 |
|
|
| 375 |
// Pack the columns except the bar plot column |
|
| 376 |
for(int i = 0; i < viewer.getTable().getColumnCount(); i++) {
|
|
| 377 |
if(i != 4) {
|
|
| 378 |
this.viewer.getTable().getColumn(i).pack(); |
|
| 379 |
} |
|
| 380 |
} |
|
| 381 |
} |
|
| 382 |
|
|
| 383 |
|
|
| 384 |
|
|
| 385 |
@Override |
|
| 386 |
public void setFocus() {
|
|
| 387 |
viewer.getControl().setFocus(); |
|
| 388 |
} |
|
| 389 |
|
|
| 390 |
|
|
| 391 |
@Override |
|
| 392 |
public void updateResultFromEditor() {
|
|
| 393 |
// TODO Auto-generated method stub |
|
| 394 |
|
|
| 395 |
} |
|
| 396 |
|
|
| 397 |
|
|
| 398 |
} |
|
| tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAFactorialMapChartEditor.java (revision 1437) | ||
|---|---|---|
| 1 | 1 |
package org.txm.ca.rcp.editors; |
| 2 | 2 |
|
| 3 |
import java.awt.Component; |
|
| 4 |
import java.awt.event.ComponentEvent; |
|
| 5 |
import java.awt.event.ComponentListener; |
|
| 6 |
|
|
| 7 | 3 |
import org.eclipse.swt.SWT; |
| 8 | 4 |
import org.eclipse.swt.custom.CLabel; |
| 9 | 5 |
import org.eclipse.swt.events.SelectionEvent; |
| ... | ... | |
| 21 | 17 |
import org.txm.core.preferences.TXMPreferences; |
| 22 | 18 |
import org.txm.core.results.Parameter; |
| 23 | 19 |
import org.txm.rcp.IImageKeys; |
| 20 |
import org.txm.rcp.editors.TXMEditor; |
|
| 24 | 21 |
import org.txm.rcp.editors.listeners.ComputeSelectionListener; |
| 25 | 22 |
import org.txm.rcp.swt.GLComposite; |
| 26 | 23 |
import org.txm.rcp.swt.widget.ThresholdsGroup; |
| ... | ... | |
| 256 | 253 |
|
| 257 | 254 |
@Override |
| 258 | 255 |
public void updateEditorFromChart(boolean update) {
|
| 256 |
|
|
| 257 |
// Updating complementary editors |
|
| 258 |
try {
|
|
| 259 |
// singular values |
|
| 260 |
((TXMEditor)this.parentMultiPagesEditor.getEditors().get(1)).refresh(update); |
|
| 261 |
// cols and rows |
|
| 262 |
((ColsRowsInfosEditor)this.parentMultiPagesEditor.getEditors().get(2)).refresh(update); |
|
| 263 |
((ColsRowsInfosEditor)this.parentMultiPagesEditor.getEditors().get(3)).refresh(update); |
|
| 264 |
// eigenvalues |
|
| 265 |
((EigenvaluesChartEditor)this.parentMultiPagesEditor.getEditors().get(4)).refresh(update); |
|
| 266 |
} |
|
| 267 |
catch (Exception e) {
|
|
| 268 |
// TODO Auto-generated catch block |
|
| 269 |
e.printStackTrace(); |
|
| 270 |
} |
|
| 271 |
|
|
| 272 |
|
|
| 259 | 273 |
// if(!update) {
|
| 260 | 274 |
// // Axis unit square ratio constraint |
| 261 | 275 |
// this.getComposite().getChartComponent().setSquareOffEnabled(true); |
| tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/ColsRowsInfosEditor.java (revision 1437) | ||
|---|---|---|
| 27 | 27 |
// |
| 28 | 28 |
package org.txm.ca.rcp.editors; |
| 29 | 29 |
|
| 30 |
import java.util.ArrayList; |
|
| 31 |
import java.util.List; |
|
| 32 |
|
|
| 30 | 33 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 31 | 34 |
import org.eclipse.jface.action.MenuManager; |
| 35 |
import org.eclipse.jface.viewers.ArrayContentProvider; |
|
| 36 |
import org.eclipse.jface.viewers.IStructuredContentProvider; |
|
| 37 |
import org.eclipse.jface.viewers.LabelProvider; |
|
| 32 | 38 |
import org.eclipse.jface.viewers.TableViewer; |
| 33 | 39 |
import org.eclipse.jface.viewers.TableViewerColumn; |
| 40 |
import org.eclipse.jface.viewers.Viewer; |
|
| 34 | 41 |
import org.eclipse.osgi.util.NLS; |
| 35 | 42 |
import org.eclipse.swt.SWT; |
| 36 | 43 |
import org.eclipse.swt.events.SelectionAdapter; |
| 37 | 44 |
import org.eclipse.swt.events.SelectionEvent; |
| 38 | 45 |
import org.eclipse.swt.layout.FillLayout; |
| 46 |
import org.eclipse.swt.layout.GridData; |
|
| 39 | 47 |
import org.eclipse.swt.widgets.Composite; |
| 40 | 48 |
import org.eclipse.swt.widgets.Menu; |
| 41 | 49 |
import org.eclipse.swt.widgets.Table; |
| ... | ... | |
| 44 | 52 |
import org.eclipse.ui.IEditorInput; |
| 45 | 53 |
import org.eclipse.ui.IEditorSite; |
| 46 | 54 |
import org.eclipse.ui.PartInitException; |
| 47 |
import org.eclipse.ui.part.EditorPart; |
|
| 55 |
import org.txm.Toolbox; |
|
| 56 |
import org.txm.ca.core.functions.CA; |
|
| 48 | 57 |
import org.txm.ca.rcp.messages.CAUIMessages; |
| 58 |
import org.txm.core.results.TXMResult; |
|
| 49 | 59 |
import org.txm.rcp.StatusLine; |
| 50 | 60 |
import org.txm.rcp.editors.ITablableEditorInput; |
| 61 |
import org.txm.rcp.editors.TXMEditor; |
|
| 51 | 62 |
import org.txm.rcp.editors.TableKeyListener; |
| 63 |
import org.txm.rcp.editors.TableLinesViewerComparator; |
|
| 52 | 64 |
import org.txm.rcp.editors.TableSorter; |
| 65 |
import org.txm.rcp.editors.input.AbstractTablableEditorInput; |
|
| 53 | 66 |
import org.txm.rcp.messages.TXMUIMessages; |
| 67 |
import org.txm.rcp.swt.GLComposite; |
|
| 54 | 68 |
// TODO: Auto-generated Javadoc |
| 55 | 69 |
/** |
| 56 | 70 |
* Used to display rows and cols informations such as contribution, inertia, |
| 57 | 71 |
* mass, coord... @ author mdecorde |
| 58 | 72 |
* |
| 59 | 73 |
*/ |
| 60 |
public class ColsRowsInfosEditor extends EditorPart {
|
|
| 74 |
public abstract class ColsRowsInfosEditor extends TXMEditor {
|
|
| 61 | 75 |
|
| 62 | 76 |
/** The ID. */ |
| 63 | 77 |
static public String ID = "org.txm.rcp.editors.ca.ColsrowsInfosEditor"; //$NON-NLS-1$ |
| ... | ... | |
| 65 | 79 |
/** The viewer. */ |
| 66 | 80 |
private TableViewer viewer; |
| 67 | 81 |
|
| 68 |
/** The i editor input. */ |
|
| 69 |
private IEditorInput iEditorInput; |
|
| 70 |
|
|
| 71 |
/** The table input. */ |
|
| 72 |
private ITablableEditorInput tableInput; |
|
| 73 | 82 |
|
| 74 |
/** The table sorter. */ |
|
| 75 |
private TableSorter tableSorter; |
|
| 76 |
|
|
| 77 |
/* (non-Javadoc) |
|
| 78 |
* @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor) |
|
| 83 |
/** |
|
| 84 |
* |
|
| 85 |
* @param result |
|
| 79 | 86 |
*/ |
| 80 |
@Override |
|
| 81 |
public void doSave(IProgressMonitor monitor) {
|
|
| 82 |
// TODO Auto-generated method stub |
|
| 87 |
public ColsRowsInfosEditor(TXMResult result) {
|
|
| 88 |
super(result); |
|
| 83 | 89 |
} |
| 84 | 90 |
|
| 85 |
/* (non-Javadoc) |
|
| 86 |
* @see org.eclipse.ui.part.EditorPart#doSaveAs() |
|
| 87 |
*/ |
|
| 91 |
|
|
| 88 | 92 |
@Override |
| 89 |
public void doSaveAs() {
|
|
| 90 |
// TODO Auto-generated method stub |
|
| 91 |
} |
|
| 92 |
|
|
| 93 |
/* (non-Javadoc) |
|
| 94 |
* @see org.eclipse.ui.part.EditorPart#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput) |
|
| 95 |
*/ |
|
| 96 |
@Override |
|
| 97 |
public void init(IEditorSite site, IEditorInput input) |
|
| 98 |
throws PartInitException {
|
|
| 99 |
setSite(site); |
|
| 100 |
setInput(input); |
|
| 101 |
this.iEditorInput = input; |
|
| 102 |
} |
|
| 103 |
|
|
| 104 |
/* (non-Javadoc) |
|
| 105 |
* @see org.eclipse.ui.part.EditorPart#isDirty() |
|
| 106 |
*/ |
|
| 107 |
@Override |
|
| 108 |
public boolean isDirty() {
|
|
| 109 |
// TODO Auto-generated method stub |
|
| 110 |
return false; |
|
| 111 |
} |
|
| 112 |
|
|
| 113 |
/* (non-Javadoc) |
|
| 114 |
* @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed() |
|
| 115 |
*/ |
|
| 116 |
@Override |
|
| 117 |
public boolean isSaveAsAllowed() {
|
|
| 118 |
// TODO Auto-generated method stub |
|
| 119 |
return false; |
|
| 120 |
} |
|
| 121 |
|
|
| 122 |
/* (non-Javadoc) |
|
| 123 |
* @see org.eclipse.ui.part.WorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite) |
|
| 124 |
*/ |
|
| 125 |
@Override |
|
| 126 |
public void createPartControl(Composite parent) {
|
|
| 127 |
parent.setLayout(new FillLayout()); |
|
| 128 |
|
|
| 129 |
if (!(iEditorInput instanceof ITablableEditorInput)) {
|
|
| 130 |
throw new IllegalArgumentException(CAUIMessages.wrongInput); |
|
| 131 |
} |
|
| 132 |
tableInput = (ITablableEditorInput) iEditorInput; |
|
| 133 |
viewer = new TableViewer(parent, SWT.H_SCROLL | SWT.V_SCROLL |
|
| 134 |
| SWT.MULTI | SWT.FULL_SELECTION); |
|
| 93 |
public void _createPartControl() {
|
|
| 94 |
|
|
| 95 |
CA ca = (CA) this.getResult(); |
|
| 96 |
|
|
| 97 |
GLComposite resultArea = this.getResultArea(); |
|
| 98 |
|
|
| 99 |
viewer = new TableViewer(resultArea, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION); |
|
| 100 |
viewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); |
|
| 101 |
|
|
| 102 |
|
|
| 135 | 103 |
viewer.getTable().addKeyListener(new TableKeyListener(viewer)); |
| 136 | 104 |
Table table = viewer.getTable(); |
| 137 | 105 |
table.setHeaderVisible(true); |
| 138 | 106 |
table.setLinesVisible(true); |
| 139 | 107 |
|
| 140 |
String[] titles = tableInput.getColumnTitles(); |
|
| 141 |
String[] types = tableInput.getColumnTypes(); |
|
| 108 |
String[] titles = this.getTableTitles(); |
|
| 109 |
|
|
| 110 |
List<String> coltypes = new ArrayList<String>(); |
|
| 111 |
coltypes.add(TXMUIMessages.integer); |
|
| 112 |
coltypes.add("");
|
|
| 113 |
coltypes.add(CAEditor.COL_TYPE); |
|
| 114 |
coltypes.add(CAEditor.COL_TYPE); |
|
| 115 |
coltypes.add(CAEditor.COL_TYPE); |
|
| 116 |
coltypes.add(CAEditor.COL_TYPE); |
|
| 117 |
coltypes.add(CAEditor.COL_TYPE); |
|
| 118 |
for (int c = 0; c < 3; c++)// seulement les 3 premiers axes |
|
| 119 |
{
|
|
| 120 |
coltypes.add(CAEditor.SEPARATOR); |
|
| 121 |
coltypes.add(CAEditor.COL_TYPE); |
|
| 122 |
coltypes.add(CAEditor.COL_TYPE); |
|
| 123 |
} |
|
| 124 |
coltypes.add(CAEditor.SEPARATOR); |
|
| 125 |
coltypes.add(CAEditor.COL_TYPE); |
|
| 126 |
coltypes.add(CAEditor.COL_TYPE); |
|
| 127 |
coltypes.add(CAEditor.COL_TYPE); |
|
| 128 |
coltypes.add(CAEditor.SEPARATOR); |
|
| 129 |
|
|
| 130 |
String[] types = coltypes.toArray(new String[] {});
|
|
| 131 |
|
|
| 132 |
|
|
| 142 | 133 |
for (int i = 0; i < titles.length; i++) {
|
| 143 | 134 |
final int index = i; |
| 144 | 135 |
final TableViewerColumn column; |
| 145 |
if (index == 0) |
|
| 136 |
if (index == 0) {
|
|
| 146 | 137 |
column = new TableViewerColumn(viewer, SWT.LEFT); |
| 147 |
else |
|
| 138 |
} |
|
| 139 |
else {
|
|
| 148 | 140 |
column = new TableViewerColumn(viewer, SWT.RIGHT); |
| 141 |
} |
|
| 149 | 142 |
column.getColumn().setText(titles[i]); |
| 150 |
if (types[i].equals("SEPARATOR")) //$NON-NLS-1$
|
|
| 151 |
column.getColumn().setResizable(false); |
|
| 152 |
else |
|
| 153 |
column.getColumn().setResizable(true); |
|
| 143 |
} |
|
| 154 | 144 |
|
| 155 |
// column.getColumn().setMoveable(true); |
|
| 145 |
viewer.setContentProvider(ArrayContentProvider.getInstance()); |
|
| 146 |
viewer.setLabelProvider(new ColRowInfosLabelProvider(this.getTableTitles())); |
|
| 147 |
|
|
| 148 |
// creates the viewer comparator |
|
| 149 |
TableLinesViewerComparator viewerComparator = new TableLinesViewerComparator(Toolbox.getCollator(this.getResult())); |
|
| 150 |
viewer.setComparator(viewerComparator); |
|
| 151 |
viewerComparator.addSelectionAdapters(viewer); |
|
| 152 |
|
|
| 153 |
this.setContentDescription(NLS.bind(CAUIMessages.infosColonP0, titles[0])); |
|
| 154 |
|
|
| 155 |
// Register the context menu |
|
| 156 |
TXMEditor.initContextMenu(this.viewer.getTable(), this.getSite(), this.viewer); |
|
| 156 | 157 |
|
| 157 |
column.getColumn().addSelectionListener(new SelectionAdapter() {
|
|
| 158 |
@Override |
|
| 159 |
public void widgetSelected(SelectionEvent e) {
|
|
| 160 |
StatusLine.setMessage(TXMUIMessages.sortingColumn ); |
|
| 161 |
tableSorter.setColumn(index); |
|
| 162 |
int dir = viewer.getTable().getSortDirection(); |
|
| 163 |
if (viewer.getTable().getSortColumn() == column.getColumn()) {
|
|
| 164 |
dir = dir == SWT.UP ? SWT.DOWN : SWT.UP; |
|
| 165 |
} else {
|
|
| 166 |
dir = SWT.DOWN; |
|
| 167 |
} |
|
| 168 |
viewer.getTable().setSortDirection(dir); |
|
| 169 |
viewer.getTable().setSortColumn(column.getColumn()); |
|
| 170 |
viewer.refresh(); |
|
| 171 |
StatusLine.setMessage(TXMUIMessages.sortDone); |
|
| 172 |
} |
|
| 173 |
}); |
|
| 174 |
} |
|
| 158 |
// createContextMenu(viewer); |
|
| 175 | 159 |
|
| 176 |
viewer.setContentProvider(tableInput.getContentProvider()); |
|
| 177 |
viewer.setLabelProvider(tableInput.getLabelProvider()); |
|
| 178 |
viewer.setInput(tableInput.getInput()); |
|
| 179 | 160 |
|
| 180 |
tableSorter = new TableSorter(); |
|
| 181 |
tableSorter.setColumnTypes(tableInput.getColumnTypes()); |
|
| 182 |
viewer.setSorter(tableSorter); |
|
| 183 |
|
|
| 184 |
this.setContentDescription(NLS.bind(CAUIMessages.infosColonP0, titles[0])); |
|
| 185 |
createContextMenu(viewer); |
|
| 186 |
viewer.refresh(); |
|
| 187 |
for (TableColumn col : viewer.getTable().getColumns()) |
|
| 188 |
col.pack(); |
|
| 161 |
|
|
| 189 | 162 |
} |
| 190 | 163 |
|
| 164 |
// /** |
|
| 165 |
// * Creates the context menu. |
|
| 166 |
// * |
|
| 167 |
// * @param tableViewer the table viewer |
|
| 168 |
// */ |
|
| 169 |
// private void createContextMenu(TableViewer tableViewer) {
|
|
| 170 |
// |
|
| 171 |
// MenuManager menuManager = new MenuManager(); |
|
| 172 |
// Menu menu = menuManager.createContextMenu(tableViewer.getTable()); |
|
| 173 |
// |
|
| 174 |
// // Set the MenuManager |
|
| 175 |
// tableViewer.getTable().setMenu(menu); |
|
| 176 |
// getSite().registerContextMenu(menuManager, tableViewer); |
|
| 177 |
// // Make the selection available |
|
| 178 |
// getSite().setSelectionProvider(tableViewer); |
|
| 179 |
// } |
|
| 180 |
|
|
| 191 | 181 |
/** |
| 182 |
* Gets the data to give to the viewer. |
|
| 183 |
* @return |
|
| 184 |
*/ |
|
| 185 |
public abstract Object getTableInput(); |
|
| 186 |
|
|
| 187 |
/** |
|
| 188 |
* Gets the titles that will be used as column labels. |
|
| 189 |
* @return |
|
| 190 |
*/ |
|
| 191 |
public abstract String[] getTableTitles(); |
|
| 192 |
|
|
| 193 |
|
|
| 194 |
@Override |
|
| 195 |
public void updateEditorFromResult(boolean update) throws Exception {
|
|
| 196 |
|
|
| 197 |
this.viewer.setInput(this.getTableInput()); |
|
| 198 |
|
|
| 199 |
// Pack the columns |
|
| 200 |
TXMEditor.packColumns(this.viewer); |
|
| 201 |
|
|
| 202 |
} |
|
| 203 |
|
|
| 204 |
|
|
| 205 |
/** |
|
| 192 | 206 |
* Gets the ordered labels according to the current table sort. |
| 193 | 207 |
* @return |
| 194 | 208 |
*/ |
| ... | ... | |
| 203 | 217 |
return labels; |
| 204 | 218 |
} |
| 205 | 219 |
|
| 206 |
/** |
|
| 207 |
* Creates the context menu. |
|
| 208 |
* |
|
| 209 |
* @param tableViewer the table viewer |
|
| 210 |
*/ |
|
| 211 |
private void createContextMenu(TableViewer tableViewer) {
|
|
| 212 | 220 |
|
| 213 |
MenuManager menuManager = new MenuManager(); |
|
| 214 |
Menu menu = menuManager.createContextMenu(tableViewer.getTable()); |
|
| 215 |
|
|
| 216 |
// Set the MenuManager |
|
| 217 |
tableViewer.getTable().setMenu(menu); |
|
| 218 |
getSite().registerContextMenu(menuManager, tableViewer); |
|
| 219 |
// Make the selection available |
|
| 220 |
getSite().setSelectionProvider(tableViewer); |
|
| 221 |
} |
|
| 222 |
|
|
| 223 | 221 |
/* (non-Javadoc) |
| 224 | 222 |
* @see org.eclipse.ui.part.WorkbenchPart#setFocus() |
| 225 | 223 |
*/ |
| ... | ... | |
| 234 | 232 |
public TableViewer getViewer() {
|
| 235 | 233 |
return viewer; |
| 236 | 234 |
} |
| 235 |
|
|
| 236 |
|
|
| 237 |
|
|
| 238 |
|
|
| 239 |
@Override |
|
| 240 |
public void updateResultFromEditor() {
|
|
| 241 |
// TODO Auto-generated method stub |
|
| 242 |
|
|
| 243 |
} |
|
| 244 |
|
|
| 245 |
|
|
| 246 |
|
|
| 237 | 247 |
} |
| tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/EigenvaluesTableEditor.java (revision 1437) | ||
|---|---|---|
| 1 |
// Copyright © 2010-2013 ENS de Lyon. |
|
| 2 |
// Copyright © 2007-2010 ENS de Lyon, CNRS, INRP, University of |
|
| 3 |
// Lyon 2, University of Franche-Comté, University of Nice |
|
| 4 |
// Sophia Antipolis, University of Paris 3. |
|
| 5 |
// |
|
| 6 |
// The TXM platform is free software: you can redistribute it |
|
| 7 |
// and/or modify it under the terms of the GNU General Public |
|
| 8 |
// License as published by the Free Software Foundation, |
|
| 9 |
// either version 2 of the License, or (at your option) any |
|
| 10 |
// later version. |
|
| 11 |
// |
|
| 12 |
// The TXM platform is distributed in the hope that it will be |
|
| 13 |
// useful, but WITHOUT ANY WARRANTY; without even the implied |
|
| 14 |
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
| 15 |
// PURPOSE. See the GNU General Public License for more |
|
| 16 |
// details. |
|
| 17 |
// |
|
| 18 |
// You should have received a copy of the GNU General |
|
| 19 |
// Public License along with the TXM platform. If not, see |
|
| 20 |
// http://www.gnu.org/licenses. |
|
| 21 |
// |
|
| 22 |
// |
|
| 23 |
// |
|
| 24 |
// $LastChangedDate:$ |
|
| 25 |
// $LastChangedRevision:$ |
|
| 26 |
// $LastChangedBy:$ |
|
| 27 |
// |
|
| 28 |
package org.txm.ca.rcp.editors; |
|
| 29 |
|
|
| 30 |
import java.text.DecimalFormat; |
|
| 31 |
import java.util.ArrayList; |
|
| 32 |
import java.util.List; |
|
| 33 |
|
|
| 34 |
import org.eclipse.jface.viewers.ArrayContentProvider; |
|
| 35 |
import org.eclipse.jface.viewers.ITableLabelProvider; |
|
| 36 |
import org.eclipse.jface.viewers.LabelProvider; |
|
| 37 |
import org.eclipse.jface.viewers.TableViewer; |
|
| 38 |
import org.eclipse.jface.viewers.TableViewerColumn; |
|
| 39 |
import org.eclipse.swt.SWT; |
|
| 40 |
import org.eclipse.swt.graphics.Image; |
|
| 41 |
import org.eclipse.swt.layout.GridData; |
|
| 42 |
import org.eclipse.swt.widgets.Event; |
|
| 43 |
import org.eclipse.swt.widgets.Listener; |
|
| 44 |
import org.eclipse.swt.widgets.TableItem; |
|
| 45 |
import org.txm.Toolbox; |
|
| 46 |
import org.txm.ca.core.functions.CA; |
|
| 47 |
import org.txm.ca.rcp.messages.CAUIMessages; |
|
| 48 |
import org.txm.core.results.TXMResult; |
|
| 49 |
import org.txm.rcp.editors.TXMEditor; |
|
| 50 |
import org.txm.rcp.editors.TableKeyListener; |
|
| 51 |
import org.txm.rcp.editors.TableLinesViewerComparator; |
|
| 52 |
import org.txm.rcp.swt.GLComposite; |
|
| 53 |
// TODO: Auto-generated Javadoc |
|
| 54 |
/** |
|
| 55 |
* show the singular values and compute some stats. |
|
| 56 |
* |
|
| 57 |
* @author mdecorde |
|
| 58 |
*/ |
|
| 59 |
public class EigenvaluesTableEditor extends TXMEditor<CA> {
|
|
| 60 |
|
|
| 61 |
|
|
| 62 |
|
|
| 63 |
/** The ID. */ |
|
| 64 |
static public String ID = "org.txm.rcp.editors.TableEditor"; //$NON-NLS-1$ |
|
| 65 |
|
|
| 66 |
/** The viewer. */ |
|
| 67 |
private TableViewer viewer; |
|
| 68 |
|
|
| 69 |
/** The table input. */ |
|
| 70 |
//private ITablableEditorInput tableInput; |
|
| 71 |
|
|
| 72 |
/** The columns. */ |
|
| 73 |
List<TableViewerColumn> columns = new ArrayList<TableViewerColumn>(); |
|
| 74 |
|
|
| 75 |
/** The table sorter. */ |
|
| 76 |
// private TableSorter tableSorter; |
|
| 77 |
|
|
| 78 |
|
|
| 79 |
|
|
| 80 |
/** |
|
| 81 |
* |
|
| 82 |
* @param result |
|
| 83 |
*/ |
|
| 84 |
public EigenvaluesTableEditor(TXMResult result) {
|
|
| 85 |
super(result); |
|
| 86 |
} |
|
| 87 |
|
|
| 88 |
|
|
| 89 |
@Override |
|
| 90 |
public void _createPartControl() throws Exception {
|
|
| 91 |
|
|
| 92 |
//this.parent.setLayout(new FillLayout()); |
|
| 93 |
|
|
| 94 |
//tableInput = (ITablableEditorInput) this.getEditorInput(); |
|
| 95 |
|
|
| 96 |
GLComposite resultArea = this.getResultArea(); |
|
| 97 |
|
|
| 98 |
viewer = new TableViewer(resultArea, SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI | SWT.FULL_SELECTION); |
|
| 99 |
|
|
| 100 |
viewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH)); |
|
| 101 |
|
|
| 102 |
|
|
| 103 |
viewer.getTable().addKeyListener(new TableKeyListener(viewer)); |
|
| 104 |
|
|
| 105 |
viewer.getTable().setHeaderVisible(true); |
|
| 106 |
viewer.getTable().setLinesVisible(true); |
|
| 107 |
|
|
| 108 |
String[] titles = new String[] {
|
|
| 109 |
CAUIMessages.CorrespondanceAnalysisEditorInput_4, |
|
| 110 |
CAUIMessages.eigenvalue, |
|
| 111 |
"%", CAUIMessages.CorrespondanceAnalysisEditorInput_11, "", ""}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$; |
|
| 112 |
|
|
| 113 |
|
|
| 114 |
for (int i = 0; i < titles.length; i++) {
|
|
| 115 |
final int index = i; |
|
| 116 |
final TableViewerColumn column; |
|
| 117 |
|
|
| 118 |
int alignment = SWT.RIGHT; |
|
| 119 |
// Align the bar plot to the left |
|
| 120 |
if(i == 4) {
|
|
| 121 |
alignment = SWT.LEFT; |
|
| 122 |
} |
|
| 123 |
|
|
| 124 |
column = new TableViewerColumn(viewer, alignment); |
|
| 125 |
|
|
| 126 |
column.getColumn().setText(titles[i]); |
|
| 127 |
column.getColumn().setWidth(100); |
|
| 128 |
column.getColumn().setResizable(true); |
|
| 129 |
column.getColumn().setMoveable(true); |
|
| 130 |
columns.add(column); |
|
| 131 |
|
|
| 132 |
// column.getColumn().addSelectionListener(new SelectionAdapter() {
|
|
| 133 |
// @Override |
|
| 134 |
// public void widgetSelected(SelectionEvent e) {
|
|
| 135 |
// StatusLine.setMessage(TXMUIMessages.sortingColumn); |
|
| 136 |
// tableSorter.setColumn(index); |
|
| 137 |
// int dir = viewer.getTable().getSortDirection(); |
|
| 138 |
// if (viewer.getTable().getSortColumn() == column.getColumn()) {
|
|
| 139 |
// dir = dir == SWT.UP ? SWT.DOWN : SWT.UP; |
|
| 140 |
// } else {
|
|
| 141 |
// dir = SWT.DOWN; |
|
| 142 |
// } |
|
| 143 |
// viewer.getTable().setSortDirection(dir); |
|
| 144 |
// viewer.getTable().setSortColumn(column.getColumn()); |
|
| 145 |
// viewer.refresh(); |
|
| 146 |
// StatusLine.setMessage(TXMUIMessages.sortDone); |
|
| 147 |
// } |
|
| 148 |
// }); |
|
| 149 |
} |
|
| 150 |
|
|
| 151 |
|
|
| 152 |
// To draw the bar plot column |
|
| 153 |
viewer.getTable().addListener(SWT.EraseItem, new Listener() {
|
|
| 154 |
public void handleEvent(Event event) {
|
|
| 155 |
|
|
| 156 |
if(event.index == 4) {
|
|
| 157 |
int itemIndex = viewer.getTable().indexOf((TableItem)event.item); |
|
| 158 |
double percent = Double.parseDouble(((ArrayList)viewer.getElementAt(itemIndex)).get(2).toString().replaceAll(",",".")); // comma replacement according to the locale //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 159 |
|
|
| 160 |
int maxPercentItemIndex = 0; |
|
| 161 |
double maxPercent = Double.parseDouble(viewer.getTable().getItem(0).getText(2).replaceAll(",",".")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 162 |
double tmpMaxPercent; |
|
| 163 |
|
|
| 164 |
// Get the max percent despite of the current row sorting |
|
| 165 |
for(int i = 0; i < viewer.getTable().getItemCount(); i++) {
|
|
| 166 |
tmpMaxPercent = Double.parseDouble(viewer.getTable().getItem(i).getText(2).replaceAll(",",".")); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 167 |
if(tmpMaxPercent > maxPercent) {
|
|
| 168 |
maxPercent = tmpMaxPercent; |
|
| 169 |
maxPercentItemIndex = i; |
|
| 170 |
} |
|
| 171 |
} |
|
| 172 |
|
|
| 173 |
event.gc.setBackground(viewer.getTable().getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY)); |
|
| 174 |
event.gc.fillRectangle(event.x, event.y, (int) (event.width * percent / Double.parseDouble(viewer.getTable().getItem(maxPercentItemIndex).getText(2).replaceAll(",","."))), event.height); //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 175 |
} |
|
| 176 |
} |
|
| 177 |
}); |
|
| 178 |
|
|
| 179 |
|
|
| 180 |
viewer.setContentProvider(ArrayContentProvider.getInstance()); |
|
| 181 |
viewer.setLabelProvider(new CASingularValueLabelProvider()); |
|
| 182 |
|
|
| 183 |
|
|
| 184 |
// creates the viewer comparator |
|
| 185 |
TableLinesViewerComparator viewerComparator = new TableLinesViewerComparator(Toolbox.getCollator(this.getResult()), false); |
|
| 186 |
viewer.setComparator(viewerComparator); |
|
| 187 |
viewerComparator.addSelectionAdapters(viewer); |
|
| 188 |
|
|
| 189 |
|
|
| 190 |
// tableSorter = new TableSorter(); |
|
| 191 |
// |
|
| 192 |
// tableSorter.setColumnTypes(new String[] {
|
|
| 193 |
// TXMUIMessages.integer, |
|
| 194 |
// CAEditor.COL_TYPE, |
|
| 195 |
// CAEditor.COL_TYPE, |
|
| 196 |
// CAEditor.COL_TYPE, |
|
| 197 |
// CAEditor.COL_TYPE, |
|
| 198 |
// CAEditor.SEPARATOR}); |
|
| 199 |
// |
|
| 200 |
// |
|
| 201 |
// viewer.setSorter(tableSorter); |
|
| 202 |
|
|
| 203 |
// tableSorter.setColumn(0); |
|
| 204 |
// int dir = viewer.getTable().getSortDirection(); |
|
| 205 |
// if (viewer.getTable().getSortColumn() == columns.get(0).getColumn()) {
|
|
| 206 |
// dir = dir == SWT.UP ? SWT.DOWN : SWT.UP; |
|
| 207 |
// } else {
|
|
| 208 |
// dir = SWT.DOWN; |
|
| 209 |
// } |
|
| 210 |
// viewer.getTable().setSortDirection(dir); |
|
| 211 |
// viewer.getTable().setSortColumn(columns.get(0).getColumn()); |
|
| 212 |
|
|
| 213 |
|
|
| 214 |
// Register the context menu |
|
| 215 |
TXMEditor.initContextMenu(this.viewer.getTable(), this.getSite(), this.viewer); |
|
| 216 |
|
|
| 217 |
// createContextMenu(viewer); |
|
| 218 |
|
|
| 219 |
|
|
| 220 |
|
|
| 221 |
} |
|
| 222 |
|
|
| 223 |
|
|
| 224 |
@Override |
|
| 225 |
public void updateEditorFromResult(boolean update) throws Exception {
|
|
| 226 |
|
|
| 227 |
try {
|
|
| 228 |
this.viewer.setInput(((CA)this.getResult()).getSingularValuesInfos().toArray()); |
|
| 229 |
} |
|
| 230 |
catch (Exception e) {
|
|
| 231 |
// TODO Auto-generated catch block |
|
| 232 |
//e.printStackTrace(); |
|
| 233 |
this.viewer.setInput(null); |
|
| 234 |
} |
|
| 235 |
|
|
| 236 |
|
|
| 237 |
// Pack the columns except the bar plot column |
|
| 238 |
for(int i = 0; i < viewer.getTable().getColumnCount(); i++) {
|
|
| 239 |
if(i != 4) {
|
|
| 240 |
this.viewer.getTable().getColumn(i).pack(); |
|
| 241 |
} |
|
| 242 |
} |
|
| 243 |
|
|
| 244 |
this.viewer.refresh(); |
|
| 245 |
|
|
| 246 |
// Pack the columns |
|
| 247 |
//TXMEditor.packColumns(viewer); |
|
| 248 |
|
|
| 249 |
} |
|
| 250 |
|
|
| 251 |
|
|
| 252 |
|
|
| 253 |
@Override |
|
| 254 |
public void setFocus() {
|
|
| 255 |
viewer.getControl().setFocus(); |
|
| 256 |
} |
|
| 257 |
|
|
| 258 |
|
|
| 259 |
@Override |
|
| 260 |
public void updateResultFromEditor() {
|
|
| 261 |
// TODO Auto-generated method stub |
|
| 262 |
|
|
| 263 |
} |
|
| 264 |
|
|
| 265 |
|
|
| 266 |
/** |
|
| 267 |
* The Class CASingularValueLabelProvider. |
|
| 268 |
*/ |
|
| 269 |
private class CASingularValueLabelProvider extends LabelProvider implements ITableLabelProvider {
|
|
| 270 |
|
|
| 271 |
/** |
|
| 272 |
* Percent values number format. |
|
| 273 |
*/ |
|
| 274 |
protected DecimalFormat percentValuesNumberFormat = new DecimalFormat(new String("0.00")); //$NON-NLS-1$
|
|
| 275 |
|
|
| 276 |
|
|
| 277 |
/* (non-Javadoc) |
|
| 278 |
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnImage(java.lang.Object, int) |
|
| 279 |
*/ |
|
| 280 |
@Override |
|
| 281 |
public Image getColumnImage(Object element, int columnIndex) {
|
|
| 282 |
// TODO Auto-generated method stub |
|
| 283 |
return null; |
|
| 284 |
} |
|
| 285 |
|
|
| 286 |
/* (non-Javadoc) |
|
| 287 |
* @see org.eclipse.jface.viewers.ITableLabelProvider#getColumnText(java.lang.Object, int) |
|
| 288 |
*/ |
|
| 289 |
@Override |
|
| 290 |
@SuppressWarnings("unchecked") //$NON-NLS-1$
|
|
| 291 |
public String getColumnText(Object element, int columnIndex) {
|
|
| 292 |
DecimalFormat f; |
|
| 293 |
Object o = ((List<Object>) element).get(columnIndex); |
|
| 294 |
switch (columnIndex) {
|
|
| 295 |
case 0: // factor |
|
| 296 |
return o.toString(); |
|
| 297 |
case 1: // eigenvalue |
|
| 298 |
if ((Double) o < 1) {
|
|
| 299 |
if ((Double) o < 0.0001) |
|
| 300 |
f = new DecimalFormat("0.0000E00"); //$NON-NLS-1$
|
|
| 301 |
else |
|
| 302 |
f = new DecimalFormat("0.0000"); //$NON-NLS-1$
|
|
| 303 |
} else {
|
|
| 304 |
f = new DecimalFormat("##########0.0000"); //$NON-NLS-1$
|
|
| 305 |
} |
|
| 306 |
// FIXME: printf syntax tests |
|
| 307 |
//return String.format("%.4f", o);
|
|
| 308 |
return f.format(o); |
|
| 309 |
case 2: // percent |
|
| 310 |
case 3: // cumul |
|
| 311 |
return percentValuesNumberFormat.format(o); |
|
| 312 |
default: |
|
| 313 |
return ""; //$NON-NLS-1$ |
|
| 314 |
} |
|
| 315 |
} |
|
| 316 |
} |
|
| 317 |
|
|
| 318 |
|
|
| 319 |
} |
|
| 0 | 320 | |
| tmp/org.txm.ca.rcp/src/org/txm/ca/rcp/editors/CAEditor.java (revision 1437) | ||
|---|---|---|
| 27 | 27 |
// |
| 28 | 28 |
package org.txm.ca.rcp.editors; |
| 29 | 29 |
|
| 30 |
import java.awt.Component; |
|
| 31 |
import java.awt.event.ComponentEvent; |
|
Formats disponibles : Unified diff