Class ConfigUIModelBuilder
- java.lang.Object
-
- org.nuiton.jaxx.widgets.config.model.ConfigUIModelBuilder
-
public class ConfigUIModelBuilder extends Object
A builder ofConfigUIModelCreated: 22 déc. 2009- Since:
- 2.5.11
- Author:
- Tony Chemit - dev@tchemit.fr
-
-
Constructor Summary
Constructors Constructor Description ConfigUIModelBuilder()
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description ConfigUIModelBuilderaddCategory(String categoryName, String categoryLabel)Add a new category, and set it as current.ConfigUIModelBuilderaddCategory(String categoryName, String categoryLabel, String defaultCallback)Add a new category, and set it as current.ConfigUIModelBuilderaddOption(io.ultreia.java4all.config.ConfigOptionDef def)Add a new option, and set it as current.ConfigUIModelBuilderaddOption(io.ultreia.java4all.config.ConfigOptionDef def, String propertyName)Deprecated.since 2.5.29, prefer use thesetOptionPropertyName(String)method instead, will be removed soonprotected voidcheckCurrent(Object o, String type)protected voidcheckNoCurrent(Object o, String type)protected voidcheckNotNull(Object o, String method, String parameter)ConfigUIModelBuildercreateModel(com.google.common.base.Supplier<io.ultreia.java4all.config.ApplicationConfig> config)Deprecated.since 2.33, prefer use thecreateModel(Object, ApplicationConfig, File)method instead, will be removed soonConfigUIModelBuildercreateModel(com.google.common.base.Supplier<io.ultreia.java4all.config.ApplicationConfig> config, File configFile)Deprecated.since 2.33, prefer use thecreateModel(Object, ApplicationConfig, File)method instead, will be removed soonConfigUIModelBuildercreateModel(io.ultreia.java4all.config.ApplicationConfig config)Deprecated.since 2.33, prefer use thecreateModel(Object, ApplicationConfig, File)method instead, will be removed soonConfigUIModelBuildercreateModel(io.ultreia.java4all.config.ApplicationConfig config, File configFile)Deprecated.since 2.33, prefer use thecreateModel(Object, ApplicationConfig, File)method instead, will be removed soonConfigUIModelBuildercreateModel(Object configurationBean, io.ultreia.java4all.config.ApplicationConfig config)Deprecated.since 2.33, prefer use thecreateModel(Object, ApplicationConfig, File)method instead, will be removed soonConfigUIModelBuildercreateModel(Object configurationBean, io.ultreia.java4all.config.ApplicationConfig config, File configFile)Create a new model and set it as current model.protected CategoryModelflushCategory()ConfigUIModelflushModel()Flush the model and return it.protected OptionModelflushOption()ConfigUIModelBuilderregisterCallBack(String name, String description, Icon icon, Runnable action)Registers a new callback.ConfigUIModelBuildersetCategory(CategoryModel categoryModel)Set the given category as current category.ConfigUIModelBuildersetCategoryDefaultCallBack(String categoryDefaultCallBack)Sets the default callback to use for this category (the call back will be add to all options of this category until you set another one or nullify it).ConfigUIModelBuildersetCloseAction(Runnable runnable)ConfigUIModelBuildersetFinalizer(CallBackFinalizer finalizer)Sets the callback finalizetConfigUIModelBuildersetModel(ConfigUIModel model)Set the given model as current model.ConfigUIModelBuildersetOption(OptionModel optionModel)Sets the given option as current option.ConfigUIModelBuildersetOptionCallBack(String name)Registers the current option into a known callback.ConfigUIModelBuildersetOptionEditor(TableCellEditor editor)Set the editor on the current option.ConfigUIModelBuildersetOptionPropertyName(String propertyName)Set the propertyName on the current option.ConfigUIModelBuildersetOptionRenderer(TableCellRenderer renderer)Set the renderer on the current option.ConfigUIModelBuildersetOptionShortLabel(String shortLabel)Set the short label on the current option.
-
-
-
Method Detail
-
createModel
public ConfigUIModelBuilder createModel(Object configurationBean, io.ultreia.java4all.config.ApplicationConfig config, File configFile) throws IllegalStateException, NullPointerException
Create a new model and set it as current model.- Parameters:
configurationBean- configuration bean used in model (optional)config- the configuration used in model (can not be null)configFile- configuration file where to save (can not be null)- Returns:
- the builder
- Throws:
IllegalStateException- if there is already a current modelNullPointerException- if config or configFile isnull- Since:
- 2.33
-
createModel
@Deprecated public ConfigUIModelBuilder createModel(com.google.common.base.Supplier<io.ultreia.java4all.config.ApplicationConfig> config) throws IllegalStateException, NullPointerException
Deprecated.since 2.33, prefer use thecreateModel(Object, ApplicationConfig, File)method instead, will be removed soonCreate a new model and set it as current model.- Parameters:
config- the configuration used in model- Returns:
- the builder
- Throws:
IllegalStateException- if there is already a current modelNullPointerException- if config isnull
-
createModel
@Deprecated public ConfigUIModelBuilder createModel(com.google.common.base.Supplier<io.ultreia.java4all.config.ApplicationConfig> config, File configFile) throws IllegalStateException, NullPointerException
Deprecated.since 2.33, prefer use thecreateModel(Object, ApplicationConfig, File)method instead, will be removed soonCreate a new model and set it as current model.- Parameters:
config- the configuration used in modelconfigFile- configuration file where to save (can not be null)- Returns:
- the builder
- Throws:
IllegalStateException- if there is already a current modelNullPointerException- if config or configFile isnull- Since:
- 2.5.21
-
createModel
@Deprecated public ConfigUIModelBuilder createModel(Object configurationBean, io.ultreia.java4all.config.ApplicationConfig config) throws IllegalStateException, NullPointerException
Deprecated.since 2.33, prefer use thecreateModel(Object, ApplicationConfig, File)method instead, will be removed soonCreate a new model and set it as current model.- Parameters:
configurationBean- configuration bean used in modelconfig- the configuration used in model- Returns:
- the builder
- Throws:
IllegalStateException- if there is already a current modelNullPointerException- if there is some null parameters
-
createModel
@Deprecated public ConfigUIModelBuilder createModel(io.ultreia.java4all.config.ApplicationConfig config) throws IllegalStateException, NullPointerException
Deprecated.since 2.33, prefer use thecreateModel(Object, ApplicationConfig, File)method instead, will be removed soonCreate a new model and set it as current model.- Parameters:
config- the configuration used in model- Returns:
- the builder
- Throws:
IllegalStateException- if there is already a current modelNullPointerException- if config isnull
-
createModel
@Deprecated public ConfigUIModelBuilder createModel(io.ultreia.java4all.config.ApplicationConfig config, File configFile) throws IllegalStateException, NullPointerException
Deprecated.since 2.33, prefer use thecreateModel(Object, ApplicationConfig, File)method instead, will be removed soonCreate a new model and set it as current model.- Parameters:
config- the configuration used in modelconfigFile- configuration file where to save (can not be null)- Returns:
- the builder
- Throws:
IllegalStateException- if there is already a current modelNullPointerException- if config or configFile isnull- Since:
- 2.5.21
-
addCategory
public ConfigUIModelBuilder addCategory(String categoryName, String categoryLabel) throws IllegalStateException, NullPointerException
Add a new category, and set it as current. Note: As side effets, if a previous category, then store it to the model.- Parameters:
categoryName- the name of the new category (can not to benull)categoryLabel- the label of the new category (can not to benull)- Returns:
- the builder
- Throws:
IllegalStateException- if there is not a current model, nor categoryNullPointerException- if any of parameter isnull
-
addCategory
public ConfigUIModelBuilder addCategory(String categoryName, String categoryLabel, String defaultCallback) throws IllegalStateException, NullPointerException
Add a new category, and set it as current. Note: As side effets, if a previous category, then store it to the model.- Parameters:
categoryName- the name of the new category (can not to benull)categoryLabel- the label of the new category (can not to benull)- Returns:
- the builder
- Throws:
IllegalStateException- if there is not a current model, nor categoryNullPointerException- if any of parameter isnull
-
addOption
public ConfigUIModelBuilder addOption(io.ultreia.java4all.config.ConfigOptionDef def) throws IllegalStateException, NullPointerException
Add a new option, and set it as current. Note: As side effets, if a previous option, then store it to the model.- Parameters:
def- the def ot the new option- Returns:
- the builder
- Throws:
IllegalStateException- if there is not a current model, nor categoryNullPointerException- if any of parameter isnull
-
addOption
@Deprecated public ConfigUIModelBuilder addOption(io.ultreia.java4all.config.ConfigOptionDef def, String propertyName) throws IllegalStateException, NullPointerException
Deprecated.since 2.5.29, prefer use thesetOptionPropertyName(String)method instead, will be removed soonAdd a new option with a propertyName, and set it as current. Note: As side effets, if a previous option, then store it to the model. Note: This method is a short-cut foraddOption(ConfigOptionDef)thensetOptionPropertyName(String).- Parameters:
def- the def ot the new optionpropertyName- the propertyName to set on the option- Returns:
- the builder
- Throws:
IllegalStateException- if there is not a current model, nor categoryNullPointerException- if any of parameter isnull
-
setOptionPropertyName
public ConfigUIModelBuilder setOptionPropertyName(String propertyName) throws IllegalStateException, NullPointerException
Set the propertyName on the current option.- Parameters:
propertyName- the propertyName to set in the current option.- Returns:
- the builder
- Throws:
IllegalStateException- if there is not a current option set.NullPointerException- if any of parameter isnull- See Also:
OptionModel.setPropertyName(String)
-
setOptionShortLabel
public ConfigUIModelBuilder setOptionShortLabel(String shortLabel) throws IllegalStateException, NullPointerException
Set the short label on the current option.- Parameters:
shortLabel- the propertyName to set in the current option.- Returns:
- the builder
- Throws:
IllegalStateException- if there is not a current option set.NullPointerException- if any of parameter isnull- Since:
- 2.5.29
- See Also:
OptionModel.setShortLabel(String)
-
setOptionEditor
public ConfigUIModelBuilder setOptionEditor(TableCellEditor editor) throws IllegalStateException, NullPointerException
Set the editor on the current option.- Parameters:
editor- the editor to set in the current option.- Returns:
- the builder
- Throws:
IllegalStateException- if there is not a current option set.NullPointerException- if any of parameter isnull- See Also:
OptionModel.setEditor(TableCellEditor)
-
setOptionRenderer
public ConfigUIModelBuilder setOptionRenderer(TableCellRenderer renderer) throws IllegalStateException, NullPointerException
Set the renderer on the current option.- Parameters:
renderer- the renderer to set in the current option.- Returns:
- the builder
- Throws:
IllegalStateException- if there is not a current option set.NullPointerException- if any of parameter isnull- See Also:
OptionModel.setRenderer(TableCellRenderer)
-
registerCallBack
public ConfigUIModelBuilder registerCallBack(String name, String description, Icon icon, Runnable action)
Registers a new callback. Note: the order of registred callback is used to determine the higher priority of callback to launch if required.- Parameters:
name- the unique name of a callbackdescription- the i18n key to describe the actionicon- the icon of the callBack (used in ui)action- the action of the callback- Returns:
- the builder
-
setOptionCallBack
public ConfigUIModelBuilder setOptionCallBack(String name)
Registers the current option into a known callback.- Parameters:
name- the name of the callback- Returns:
- the builder
-
setFinalizer
public ConfigUIModelBuilder setFinalizer(CallBackFinalizer finalizer)
Sets the callback finalizet- Parameters:
finalizer- callback finalize- Returns:
- the builder
- See Also:
CallBackFinalizer
-
setCategoryDefaultCallBack
public ConfigUIModelBuilder setCategoryDefaultCallBack(String categoryDefaultCallBack)
Sets the default callback to use for this category (the call back will be add to all options of this category until you set another one or nullify it).- Parameters:
categoryDefaultCallBack- default callbakc name for the category- Returns:
- the buider
-
flushModel
public ConfigUIModel flushModel() throws IllegalStateException
Flush the model and return it. Note: As a side effect, nothing is available in the builder after this operation. To reuse the builder on a model, use the dedicated setter.- Returns:
- the final model
- Throws:
IllegalStateException- if there is not a current model set.
-
setModel
public ConfigUIModelBuilder setModel(ConfigUIModel model) throws IllegalStateException
Set the given model as current model. Note: As side effets, il will clean current category and option.- Parameters:
model- the model to use- Returns:
- the buider
- Throws:
IllegalStateException- if there is already a current model
-
setCategory
public ConfigUIModelBuilder setCategory(CategoryModel categoryModel) throws IllegalStateException
Set the given category as current category. Note: As side effets, il will clean current option.- Parameters:
categoryModel- the category to use- Returns:
- the buider
- Throws:
IllegalStateException- if there is not a current model or a current category
-
setOption
public ConfigUIModelBuilder setOption(OptionModel optionModel) throws IllegalStateException
Sets the given option as current option.- Parameters:
optionModel- the option to use- Returns:
- the buider
- Throws:
IllegalStateException- if there is not a current model, nor category, or a current option
-
setCloseAction
public ConfigUIModelBuilder setCloseAction(Runnable runnable)
-
flushCategory
protected CategoryModel flushCategory()
-
flushOption
protected OptionModel flushOption()
-
-