private List<Runnable> saveListeners = new ArrayList<Runnable>();
private String name;
+ private boolean hidden;
private String description;
private boolean dirty;
}
this.name = name;
+ this.hidden = meta.hidden();
this.description = description;
reload();
public String getName() {
return name;
}
+
+ /**
+ * This item should be hidden from the user (she will still be able to
+ * modify it if she opens the file manually).
+ *
+ * @return TRUE if it should stay hidden
+ */
+ public boolean isHidden() {
+ return hidden;
+ }
/**
* A description for this item: what it is or does, how to explain that item
/**
* The allowed list of values that a {@link Format#FIXED_LIST} item is
* allowed to be, or a list of suggestions for {@link Format#COMBO_LIST}
- * items.
+ * items. Also works for {@link Format#LOCALE}.
* <p>
* Will always allow an empty string in addition to the rest.
*
return withEmpty;
}
+ /**
+ * Return all the languages known by the program for this bundle.
+ * <p>
+ * This only works for {@link TransBundle}, and will return an empty list if
+ * this is not a {@link TransBundle}.
+ *
+ * @return the known language codes
+ */
+ public List<String> getKnownLanguages() {
+ if (bundle instanceof TransBundle) {
+ return ((TransBundle<E>) bundle).getKnownLanguages();
+ }
+
+ return new ArrayList<String>();
+ }
+
/**
* This item is a comma-separated list of values instead of a single value.
* <p>
*/
public void setString(String value, int item) {
if (isArray() && item >= 0) {
- List<String> values = BundleHelper.parseList(this.value, -1);
- for (int i = values.size(); i <= item; i++) {
- values.add(null);
- }
- values.set(item, value);
- this.value = BundleHelper.fromList(values);
+ this.value = BundleHelper.fromList(this.value, value, item);
} else {
this.value = value;
}
value = null;
}
- for (Runnable listener : reloadedListeners) {
+ // Copy the list so we can create new listener in a listener
+ for (Runnable listener : new ArrayList<Runnable>(reloadedListeners)) {
try {
listener.run();
} catch (Exception e) {
* dirty flag)
*/
public void save(boolean onlyIfDirty) {
- for (Runnable listener : saveListeners) {
+ // Copy the list so we can create new listener in a listener
+ for (Runnable listener : new ArrayList<Runnable>(saveListeners)) {
try {
listener.run();
} catch (Exception e) {
return children;
}
+ /**
+ * The number of sub-items, if any.
+ *
+ * @return the number or 0
+ */
+ public int size() {
+ return children.size();
+ }
+
@Override
public Iterator<MetaInfo<E>> iterator() {
return children.iterator();
List<MetaInfo<E>> shadow = new ArrayList<MetaInfo<E>>();
for (E id : type.getEnumConstants()) {
MetaInfo<E> info = new MetaInfo<E>(type, bundle, id);
- list.add(info);
- shadow.add(info);
+ if (!info.hidden) {
+ list.add(info);
+ shadow.add(info);
+ }
}
for (int i = 0; i < list.size(); i++) {