package be.nikiroo.fanfix.reader.tui; import java.util.List; import jexer.TAction; import jexer.TButton; import jexer.TLabel; import jexer.TPanel; import jexer.TWidget; import be.nikiroo.utils.resources.Bundle; import be.nikiroo.utils.resources.MetaInfo; import be.nikiroo.utils.ui.ConfigItemBase; /** * A graphical item that reflect a configuration option from the given * {@link Bundle}. *
* This graphical item can be edited, and the result will be saved back into the
* linked {@link MetaInfo}; you still have to save the {@link MetaInfo} should
* you wish to, of course.
*
* @author niki
*
* @param
* Has no effect if the class is using automatic dirty handling (see
* {@link ConfigItemBase#ConfigItem(MetaInfo, boolean)}).
*
* @param item
* the item number to get for an array of values, or -1 to get
* the whole value (has no effect if {@link MetaInfo#isArray()}
* is FALSE)
*/
protected void setDirtyItem(int item) {
base.setDirtyItem(item);
}
/**
* Check if the value changed since the last load/save into the linked
* {@link MetaInfo}.
*
* Note that we consider NULL and an Empty {@link String} to be equals.
*
* @param value
* the value to test
* @param item
* the item number to get for an array of values, or -1 to get
* the whole value (has no effect if {@link MetaInfo#isArray()}
* is FALSE)
*
* @return TRUE if it has
*/
protected boolean hasValueChanged(Object value, int item) {
return base.hasValueChanged(value, item);
}
/**
* Create an empty graphical component to be used later by
* {@link ConfigItem#createField(int)}.
*
* Note that {@link ConfigItem#reload(int)} will be called after it was
* created by {@link ConfigItem#createField(int)}.
*
* @param item
* the item number to get for an array of values, or -1 to get
* the whole value (has no effect if {@link MetaInfo#isArray()}
* is FALSE)
*
* @return the graphical component
*/
abstract protected TWidget createEmptyField(int item);
/**
* Get the information from the {@link MetaInfo} in the subclass preferred
* format.
*
* @param item
* the item number to get for an array of values, or -1 to get
* the whole value (has no effect if {@link MetaInfo#isArray()}
* is FALSE)
*
* @return the information in the subclass preferred format
*/
abstract protected Object getFromInfo(int item);
/**
* Set the value to the {@link MetaInfo}.
*
* @param value
* the value in the subclass preferred format
* @param item
* the item number to get for an array of values, or -1 to get
* the whole value (has no effect if {@link MetaInfo#isArray()}
* is FALSE)
*/
abstract protected void setToInfo(Object value, int item);
/**
* The value present in the given item's related field in the subclass
* preferred format.
*
* @param item
* the item number to get for an array of values, or -1 to get
* the whole value (has no effect if {@link MetaInfo#isArray()}
* is FALSE)
*
* @return the value present in the given item's related field in the
* subclass preferred format
*/
abstract protected Object getFromField(int item);
/**
* Set the value (in the subclass preferred format) into the field.
*
* @param value
* the value in the subclass preferred format
* @param item
* the item number to get for an array of values, or -1 to get
* the whole value (has no effect if {@link MetaInfo#isArray()}
* is FALSE)
*/
abstract protected void setToField(Object value, int item);
/**
* Create a label which width is constrained in lock steps.
*
* @param x
* the X position of the label
* @param y
* the Y position of the label
* @param nhgap
* negative horisontal gap in pixel to use for the label, i.e.,
* the step lock sized labels will start smaller by that amount
* (the use case would be to align controls that start at a
* different horisontal position)
*
* @return the label
*/
protected TWidget label(int x, int y, int nhgap) {
// TODO: see Swing version for lock-step sizes
// TODO: see Swing version for help info-buttons
String lbl = getInfo().getName();
return new TLabel(this, lbl, x, y);
}
/**
* Create a new {@link ConfigItem} for the given {@link MetaInfo}.
*
* @param