import org.eclipse.nebula.widgets.nattable.edit.editor.IComboBoxDataProvider;
import org.eclipse.nebula.widgets.nattable.filterrow.combobox.FilterRowComboBoxCellEditor;
+import org.eclipse.nebula.widgets.nattable.widget.NatCombo;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import eu.etaxonomy.cdm.model.description.CategoricalData;
import eu.etaxonomy.cdm.model.description.State;
+import eu.etaxonomy.taxeditor.editor.workingSet.matrix.CharacterMatrix;
/**
* @author pplitzner
*/
public class CategoricalDataCellEditor extends FilterRowComboBoxCellEditor{
- public CategoricalDataCellEditor(IComboBoxDataProvider dataProvider, int maxVisibleItems) {
+ private CharacterMatrix matrix;
+
+ public CategoricalDataCellEditor(IComboBoxDataProvider dataProvider, int maxVisibleItems, CharacterMatrix matrix) {
super(dataProvider, maxVisibleItems);
+ this.matrix = matrix;
}
@Override
}
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Control activateCell(Composite parent, Object originalCanonicalValue) {
+ Control editorControl = super.activateCell(parent, originalCanonicalValue);
+ ((NatCombo)editorControl).addSelectionListener(new SelectionListener() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ matrix.setDirty();
+ }
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ }
+ });
+ return editorControl;
+ }
+
}
import java.util.Set;
import org.eclipse.nebula.widgets.nattable.edit.editor.AbstractCellEditor;
+import org.eclipse.nebula.widgets.nattable.selection.SelectionLayer.MoveDirectionEnum;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Text;
-import eu.etaxonomy.cdm.model.description.CategoricalData;
+import eu.etaxonomy.cdm.model.description.QuantitativeData;
import eu.etaxonomy.cdm.model.description.StatisticalMeasure;
+import eu.etaxonomy.taxeditor.editor.workingSet.matrix.CharacterMatrix;
/**
* @author pplitzner
private Map<StatisticalMeasure, Text> measureToTextMap = new HashMap<>();
- public QuantitativeDataCellEditor(Set<StatisticalMeasure> statisticalMeasures) {
+ private Object editorValue;
+
+ private CharacterMatrix matrix;
+
+ private boolean dirty = false;
+
+ public QuantitativeDataCellEditor(Set<StatisticalMeasure> statisticalMeasures, CharacterMatrix matrix) {
super();
+ this.matrix = matrix;
this.statisticalMeasures = statisticalMeasures;
}
+
/**
* {@inheritDoc}
*/
@Override
public Object getEditorValue() {
- return null;
+ return this.editorValue;
}
/**
*/
@Override
public void setEditorValue(Object value) {
- if(value instanceof CategoricalData){
- }
+ this.editorValue = value;
}
/**
return composite;
}
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean commit(MoveDirectionEnum direction, boolean closeAfterCommit, boolean skipValidation) {
+ if(dirty){
+ matrix.setDirty();
+ dirty = false;
+ }
+ return super.commit(direction, closeAfterCommit, skipValidation);
+ }
+
/**
* {@inheritDoc}
*/
@Override
protected Control activateCell(Composite parent, Object originalCanonicalValue) {
- System.out.println(originalCanonicalValue);
this.editorControl = createEditorControl(parent);
+ this.setEditorValue(originalCanonicalValue);
+
+ if(originalCanonicalValue instanceof QuantitativeData){
+ QuantitativeData quantitativeData = (QuantitativeData)originalCanonicalValue;
+ Set<StatisticalMeasure> statisticalValues = quantitativeData.getFeature().getRecommendedStatisticalMeasures();
+ //Fill text controls with actual values and add modify listeners for editing
+ for (StatisticalMeasure value : statisticalValues) {
+ Text text = measureToTextMap.get(value);
+ text.addModifyListener(e->{
+ quantitativeData.setSpecificStatisticalValue(Float.parseFloat(text.getText()), null, value);
+ dirty = true;
+ });
+
+ Float specificStatisticalValue = quantitativeData.getSpecificStatisticalValue(value);
+ if(specificStatisticalValue!=null){
+ Listener[] listeners = text.getListeners(SWT.Modify);
+ for (Listener listener : listeners) {
+ text.removeListener(SWT.Modify, listener);
+ }
+ text.setText(Float.toString(specificStatisticalValue));
+ for (Listener listener : listeners) {
+ text.addListener(SWT.Modify, listener);
+ }
+ }
+ }
+ }
return this.editorControl;
}
-
}
+++ /dev/null
-/**
-* Copyright (C) 2017 EDIT
-* European Distributed Institute of Taxonomy
-* http://www.e-taxonomy.eu
-*
-* The contents of this file are subject to the Mozilla Public License Version 1.1
-* See LICENSE.TXT at the top of this package for the full license terms.
-*/
-package eu.etaxonomy.taxeditor.editor.workingSet.matrix.quantitative;
-
-import org.eclipse.swt.SWT;
-import org.eclipse.swt.layout.FillLayout;
-import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
-
-/**
- * @author pplitzner
- * @since Dec 11, 2017
- *
- */
-public class QuantitativeDataComposite extends Composite {
- private Text min;
- private Text avg;
- private Text max;
-
- /**
- * Create the composite.
- * @param parent
- * @param style
- */
- public QuantitativeDataComposite(Composite parent, int style) {
- super(parent, style);
- setLayout(new FillLayout(SWT.HORIZONTAL));
-
- min = new Text(this, SWT.NONE);
-
- avg = new Text(this, SWT.BORDER);
-
- max = new Text(this, SWT.BORDER);
-
- }
-
- @Override
- protected void checkSubclass() {
- // Disable the check that prevents subclassing of SWT components
- }
-
- public Text getMin() {
- return min;
- }
- public Text getAvg() {
- return avg;
- }
- public Text getMax() {
- return max;
- }
-}