package be.nikiroo.utils.resources;
import java.util.ArrayList;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
* @param <E>
* the type of {@link Bundle} to edit
*/
-public class MetaInfo<E extends Enum<E>> {
+public class MetaInfo<E extends Enum<E>> implements Iterable<MetaInfo<E>> {
private final Bundle<E> bundle;
private final E id;
private Meta meta;
+ private List<MetaInfo<E>> children = new ArrayList<MetaInfo<E>>();
private String value;
private List<Runnable> reloadedListeners = new ArrayList<Runnable>();
if (description == null) {
description = meta.description();
+ if (description == null) {
+ description = "";
+ }
if (meta.info() != null && !meta.info().isEmpty()) {
- description += " (" + meta.info() + ")";
+ if (!description.isEmpty()) {
+ description += "\n\n";
+ }
+ description += meta.info();
}
}
return meta.format();
}
+ // for ComboBox, this is mostly a suggestion
+ public String[] getAllowedValues() {
+ return meta.list();
+ }
+
+ // TODO: use it!
+ public boolean isArray() {
+ return meta.array();
+ }
+
/**
* The value stored by this item, as a {@link String}.
*
saveListeners.add(listener);
}
+ @Override
+ public Iterator<MetaInfo<E>> iterator() {
+ return children.iterator();
+ }
+
+ public List<MetaInfo<E>> getChildren() {
+ return children;
+ }
+
/**
* Create a list of {@link MetaInfo}, one for each of the item in the given
* {@link Bundle}.