git://git.nikiroo.be
/
fanfix.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
ConfigItem: add all types except LOCALE (array still not working)
[fanfix.git]
/
src
/
be
/
nikiroo
/
utils
/
resources
/
MetaInfo.java
diff --git
a/src/be/nikiroo/utils/resources/MetaInfo.java
b/src/be/nikiroo/utils/resources/MetaInfo.java
index 746fd4d939a71f346c3529b63fd65b13af5f9be9..d95e98c986a0e53266bbd203f95efa90066a7580 100644
(file)
--- a/
src/be/nikiroo/utils/resources/MetaInfo.java
+++ b/
src/be/nikiroo/utils/resources/MetaInfo.java
@@
-1,6
+1,7
@@
package be.nikiroo.utils.resources;
import java.util.ArrayList;
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;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@
-17,11
+18,12
@@
import be.nikiroo.utils.resources.Meta.Format;
* @param <E>
* the type of {@link Bundle} to edit
*/
* @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 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>();
private String value;
private List<Runnable> reloadedListeners = new ArrayList<Runnable>();
@@
-53,8
+55,14
@@
public class MetaInfo<E extends Enum<E>> {
if (description == null) {
description = meta.description();
if (description == null) {
description = meta.description();
+ if (description == null) {
+ description = "";
+ }
if (meta.info() != null && !meta.info().isEmpty()) {
if (meta.info() != null && !meta.info().isEmpty()) {
- description += " (" + meta.info() + ")";
+ if (!description.isEmpty()) {
+ description += "\n\n";
+ }
+ description += meta.info();
}
}
}
}
@@
-94,6
+102,16
@@
public class MetaInfo<E extends Enum<E>> {
return meta.format();
}
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}.
*
/**
* The value stored by this item, as a {@link String}.
*
@@
-217,6
+235,15
@@
public class MetaInfo<E extends Enum<E>> {
saveListeners.add(listener);
}
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}.
/**
* Create a list of {@link MetaInfo}, one for each of the item in the given
* {@link Bundle}.