r20 - in trunk: jmexico-model/src/main/java/fr/reseaumexico/model jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/factorValue
Author: sletellier Date: 2012-01-09 16:19:24 +0100 (Mon, 09 Jan 2012) New Revision: 20 Url: http://forge.codelutin.com/repositories/revision/jmexico/20 Log: - Clean code - For option value editing, fire stop editing on combo selection Modified: trunk/jmexico-model/src/main/java/fr/reseaumexico/model/InputDesignImpl.java trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/InputDesignTableModel.java trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/factorValue/FactorValueCellEditor.java Modified: trunk/jmexico-model/src/main/java/fr/reseaumexico/model/InputDesignImpl.java =================================================================== --- trunk/jmexico-model/src/main/java/fr/reseaumexico/model/InputDesignImpl.java 2012-01-06 14:39:48 UTC (rev 19) +++ trunk/jmexico-model/src/main/java/fr/reseaumexico/model/InputDesignImpl.java 2012-01-09 15:19:24 UTC (rev 20) @@ -101,6 +101,7 @@ } } + @Override public void setScenario(Collection<Scenario> scenarios) { addAllScenario(scenarios); } Modified: trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/InputDesignTableModel.java =================================================================== --- trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/InputDesignTableModel.java 2012-01-06 14:39:48 UTC (rev 19) +++ trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/InputDesignTableModel.java 2012-01-09 15:19:24 UTC (rev 20) @@ -192,13 +192,11 @@ } int scenarioIndex = columnIndex - 1; Scenario scenario = getScenario(scenarioIndex); - Map<Factor,Object> factorValues = scenario.getFactorValues(); // get key if rowIndex Factor factor = getFactor(rowIndex); - factorValues.put(factor, o); - scenario.setFactorValues(factorValues); + scenario.setFactorValue(factor, o); fireTableCellUpdated(rowIndex, columnIndex); } Modified: trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/factorValue/FactorValueCellEditor.java =================================================================== --- trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/factorValue/FactorValueCellEditor.java 2012-01-06 14:39:48 UTC (rev 19) +++ trunk/jmexico-swing-editor/src/main/java/fr/reseaumexico/editor/ui/editor/factorValue/FactorValueCellEditor.java 2012-01-09 15:19:24 UTC (rev 20) @@ -26,9 +26,12 @@ import fr.reseaumexico.model.Factor; import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.awt.event.FocusEvent; import java.awt.event.FocusListener; import javax.swing.AbstractCellEditor; +import javax.swing.JComboBox; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.table.TableCellEditor; @@ -90,7 +93,20 @@ specificEditor = factory.getCellEditor(factor, currentValue); if (specificEditor != null) { - return specificEditor.getComponent(); + Component component = specificEditor.getComponent(); + + // stop editing on select for combos + if (component instanceof JComboBox) { + ((JComboBox)component).addActionListener(new ActionListener() { + + @Override + public void actionPerformed(ActionEvent e) { + fireEditingStopped(); + } + }); + } + + return component; } defaultInlineEditor.setText(currentValue == null ? "" : String.valueOf(currentValue)); return defaultInlineEditor;
participants (1)
-
sletellier@users.forge.codelutin.com