X-Git-Url: http://git.nikiroo.be/?a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Futils%2Fui%2FConfigItem.java;h=8545485d0dc2a98196796bb2ec305c502acb2755;hb=db31c35860081535d6e7ddc83ab4af573bb0522e;hp=3593d7ce3c8ded39e42289f08285f32b131accdf;hpb=d350b96b06c55189e5d0ceed9db6f237e7d8d871;p=nikiroo-utils.git diff --git a/src/be/nikiroo/utils/ui/ConfigItem.java b/src/be/nikiroo/utils/ui/ConfigItem.java index 3593d7c..8545485 100644 --- a/src/be/nikiroo/utils/ui/ConfigItem.java +++ b/src/be/nikiroo/utils/ui/ConfigItem.java @@ -11,32 +11,59 @@ import javax.swing.JTextField; import javax.swing.border.EmptyBorder; import be.nikiroo.utils.resources.Bundle; +import be.nikiroo.utils.resources.Meta; /** * A graphical item that reflect a configuration option from the given * {@link Bundle}. * * @author niki - * + * * @param * the type of {@link Bundle} to edit */ public class ConfigItem> extends JPanel { private static final long serialVersionUID = 1L; + private Class type; private final Bundle bundle; private final E id; + + private Meta meta; private String value; private JTextField valueField; public ConfigItem(Class type, Bundle bundle, E id) { + this.type = type; this.bundle = bundle; this.id = id; + try { + this.meta = type.getDeclaredField(id.name()).getAnnotation( + Meta.class); + } catch (NoSuchFieldException e) { + } catch (SecurityException e) { + } + this.setLayout(new BorderLayout()); this.setBorder(new EmptyBorder(2, 10, 2, 10)); - JLabel nameLabel = new JLabel(id.toString()); + String tooltip = null; + if (bundle.getDescriptionBundle() != null) { + tooltip = bundle.getDescriptionBundle().getString(id); + if (tooltip.trim().isEmpty()) { + tooltip = null; + } + } + + String name = id.toString(); + if (name.length() > 1) { + name = name.substring(0, 1) + name.substring(1).toLowerCase(); + name = name.replace("_", " "); + } + + JLabel nameLabel = new JLabel(name); + nameLabel.setToolTipText(tooltip); nameLabel.setPreferredSize(new Dimension(400, 0)); this.add(nameLabel, BorderLayout.WEST); @@ -67,6 +94,8 @@ public class ConfigItem> extends JPanel { * Create a list of {@link ConfigItem}, one for each of the item in the * given {@link Bundle}. * + * @param + * the type of {@link Bundle} to edit * @param type * a class instance of the item type to work on * @param bundle