import java.util.Iterator;
import java.util.List;
-import be.nikiroo.fanfix.data.MetaData;
import be.nikiroo.utils.resources.Meta.Format;
/**
/**
* 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>
}
/**
- * A manual flag to specify if the {@link MetaData} has been changed or not,
- * which can be used by {@link MetaInfo#save(boolean)}.
+ * A manual flag to specify if the data has been changed or not, which can
+ * be used by {@link MetaInfo#save(boolean)}.
*
* @return TRUE if it is dirty (if it has changed)
*/
}
/**
- * A manual flag to specify that the {@link MetaData} has been changed,
- * which can be used by {@link MetaInfo#save(boolean)}.
+ * A manual flag to specify that the data has been changed, which can be
+ * used by {@link MetaInfo#save(boolean)}.
*/
public void setDirty() {
this.dirty = true;
*/
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;
}
* The value stored by this item, as a colour (represented here as an
* {@link Integer}) if it represents a colour, or NULL if it doesn't.
* <p>
- * The returned colour value is an ARGB value.
+ * The colour value is an ARGB value.
*
* @param value
* the 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) {