Index: lutinutil/src/java/org/codelutin/option/ui/ConfigTableModel.java diff -u lutinutil/src/java/org/codelutin/option/ui/ConfigTableModel.java:1.3 lutinutil/src/java/org/codelutin/option/ui/ConfigTableModel.java:1.4 --- lutinutil/src/java/org/codelutin/option/ui/ConfigTableModel.java:1.3 Tue Jan 8 23:50:20 2008 +++ lutinutil/src/java/org/codelutin/option/ui/ConfigTableModel.java Wed Jan 9 01:35:35 2008 @@ -35,6 +35,32 @@ */ public class ConfigTableModel implements TableModel { + /** + * Une enum pour définir les types de données à ajouter au model + * + * @author chemit + */ + public enum TypeModel { + all { + protected boolean accept(ConfigPropertyKey key) { + return true; + }}, + nontech { + protected boolean accept(ConfigPropertyKey key) { + return !(tech.accept(key) || key.isTransient()); + }}, + tech { + protected boolean accept(ConfigPropertyKey key) { + return key.isFinal(); + //return key.isFinal() && key.isTransient() && key.isStatic(); + }}; + + abstract boolean accept(ConfigPropertyKey key); + } + + // par défaut on affiche uniquement les propriétés non techniques + private static final TypeModel DEFAULT_TYPE = TypeModel.nontech; + private final String[] columnNames = {_("lutinutil.common.key"), _("lutinutil.common.value")}; private final Class[] columnClass = {String.class, Object.class}; @@ -43,18 +69,20 @@ protected Map, Object> props; public ConfigTableModel(Config config) { + this(config, null); + } + + public ConfigTableModel(Config config, TypeModel type) { props = new LinkedHashMap, Object>(); - for (ConfigPropertyKey key : config.getUniverse()) { - if (!key.isFinal()) { - props.put(key, key.getCurrentValue()); - } + if (type == null) { + type = DEFAULT_TYPE; } - for (ConfigPropertyKey key : config.getUniverse()) { - if (key.isFinal()) { + for (ConfigPropertyKey key : config.getUniverse()) { + if (type.accept(key)) { props.put(key, key.getCurrentValue()); } } - keys = ArrayUtil.toArray(props.keySet(),ConfigPropertyKey.class); + keys = ArrayUtil.toArray(props.keySet(), ConfigPropertyKey.class); } public ConfigPropertyKey getKey(int rowIndex) { @@ -69,7 +97,7 @@ public boolean isValid(int rowIndex) { ConfigPropertyKey key = getKey(rowIndex); Object value = props.get(key); - return !key.isMandatory() || value != null; + return !key.isMandatory() || value != null && !"".equals(value); } public boolean isModified() {