r2738 - in trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config: . model
Author: tchemit Date: 2013-10-08 15:27:38 +0200 (Tue, 08 Oct 2013) New Revision: 2738 Url: http://nuiton.org/projects/jaxx/repository/revisions/2738 Log: fixes #2868: [ConfigUI] Improve the shortLabel of an option Modified: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigTableRenderer.java trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUIHelper.java trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigTableModel.java trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigUIModelBuilder.java trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/OptionModel.java Modified: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigTableRenderer.java =================================================================== --- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigTableRenderer.java 2013-10-07 09:08:10 UTC (rev 2737) +++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigTableRenderer.java 2013-10-08 13:27:38 UTC (rev 2738) @@ -47,8 +47,11 @@ public class ConfigTableRenderer extends DefaultTableCellRenderer { private static final long serialVersionUID = 1L; + protected static Color col; + protected static Font font; + protected static Font font2; public ConfigTableRenderer() { @@ -87,7 +90,7 @@ } protected Component getKeyCellRenderer(JTable table, Object value, boolean isSelected, boolean hasFocus, int row, int column, OptionModel key, boolean isValid, boolean isModified) { - String tooltip = _(key.getDescription()); + String tooltip = _(key.getDescription()) + " (" + key.getKey() + ")"; String originalValue = key.toString(key.getOriginalValue()); boolean isFinal = key.isFinal(); if (isFinal) { Modified: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUIHelper.java =================================================================== --- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUIHelper.java 2013-10-07 09:08:10 UTC (rev 2737) +++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/ConfigUIHelper.java 2013-10-08 13:27:38 UTC (rev 2738) @@ -109,6 +109,7 @@ return modelBuilder; } + @Deprecated public ConfigUIModelBuilder addOption(ConfigOptionDef def, String propertyName) throws IllegalStateException, NullPointerException { modelBuilder.addOption(def, propertyName); @@ -121,6 +122,12 @@ return modelBuilder; } + public ConfigUIModelBuilder setOptionShortLabel(String shortLabel) + throws IllegalStateException, NullPointerException { + modelBuilder.setOptionShortLabel(shortLabel); + return modelBuilder; + } + public ConfigUIModelBuilder setOptionEditor(TableCellEditor editor) throws IllegalStateException, NullPointerException { modelBuilder.setOptionEditor(editor); Modified: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigTableModel.java =================================================================== --- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigTableModel.java 2013-10-07 09:08:10 UTC (rev 2737) +++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigTableModel.java 2013-10-08 13:27:38 UTC (rev 2738) @@ -24,6 +24,7 @@ * #L% */ +import org.apache.commons.lang3.StringUtils; import org.nuiton.util.converter.ConverterUtil; import javax.swing.table.AbstractTableModel; @@ -95,7 +96,13 @@ Object value = null; switch (column) { case 0: - value = key.getKey(); + // try first to use the shortLabel + value = key.getShortLabel(); + if (StringUtils.isBlank((String) value)) { + + // fallback to key + value = key.getKey(); + } break; case 1: value = key.getValue(); @@ -108,10 +115,6 @@ break; } return value; -// if (column == 0) { -// return key.getKey(); -// } -// return key.getValue(); } @Override Modified: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigUIModelBuilder.java =================================================================== --- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigUIModelBuilder.java 2013-10-07 09:08:10 UTC (rev 2737) +++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/ConfigUIModelBuilder.java 2013-10-08 13:27:38 UTC (rev 2738) @@ -251,7 +251,9 @@ * @throws IllegalStateException if there is not a current model, nor * category * @throws NullPointerException if any of parameter is {@code null} + * @deprecated since 2.5.29, prefer use the {@link #setOptionPropertyName(String)} method instead, will be removed soon */ + @Deprecated public ConfigUIModelBuilder addOption(ConfigOptionDef def, String propertyName) throws IllegalStateException, NullPointerException { @@ -279,6 +281,24 @@ } /** + * Set the short label on the current option. + * + * @param shortLabel the propertyName to set in the current option. + * @return the builder + * @throws IllegalStateException if there is not a current option set. + * @throws NullPointerException if any of parameter is {@code null} + * @see OptionModel#setShortLabel(String) + * @since 2.5.29 + */ + public ConfigUIModelBuilder setOptionShortLabel(String shortLabel) + throws IllegalStateException, NullPointerException { + checkCurrent(option, "option"); + checkNotNull(shortLabel, "setShortLabel", "shortLabel"); + option.setShortLabel(shortLabel); + return this; + } + + /** * Set the editor on the current option. * * @param editor the editor to set in the current option. Modified: trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/OptionModel.java =================================================================== --- trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/OptionModel.java 2013-10-07 09:08:10 UTC (rev 2737) +++ trunk/jaxx-config/src/main/java/jaxx/runtime/swing/config/model/OptionModel.java 2013-10-08 13:27:38 UTC (rev 2738) @@ -59,6 +59,13 @@ /** le nom de la propriété javaBean (peut etre null, si option sans support javaBean) */ protected String propertyName; + /** + * Une description courte à utiliser à la place de la clef i18n. + * + * @since 2.5.29 + */ + protected String shortLabel; + /** l'editeur utilise pour modifier graphiquement l'option */ protected TableCellEditor editor; @@ -70,6 +77,14 @@ initValue(value); } + public String getShortLabel() { + return shortLabel; + } + + public void setShortLabel(String shortLabel) { + this.shortLabel = shortLabel; + } + @Override public String getKey() { return def.getKey();
participants (1)
-
tchemit@users.nuiton.org