Class ConfigUIModelBuilder

java.lang.Object
jaxx.runtime.swing.config.model.ConfigUIModelBuilder

public class ConfigUIModelBuilder
extends java.lang.Object
A builder of ConfigUIModel Created: 22 déc. 2009
Since:
2.5.11
Author:
Tony Chemit - chemit@codelutin.com
  • Constructor Details

    • ConfigUIModelBuilder

      public ConfigUIModelBuilder()
  • Method Details

    • createModel

      public ConfigUIModelBuilder createModel​(java.lang.Object configurationBean, org.nuiton.config.ApplicationConfig config, java.io.File configFile) throws java.lang.IllegalStateException, java.lang.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:
      java.lang.IllegalStateException - if there is already a current model
      java.lang.NullPointerException - if config or configFile is null
      Since:
      2.33
    • createModel

      @Deprecated public ConfigUIModelBuilder createModel​(com.google.common.base.Supplier<org.nuiton.config.ApplicationConfig> config) throws java.lang.IllegalStateException, java.lang.NullPointerException
      Deprecated.
      since 2.33, prefer use the createModel(Object, ApplicationConfig, File) method instead, will be removed soon
      Create a new model and set it as current model.
      Parameters:
      config - the configuration used in model
      Returns:
      the builder
      Throws:
      java.lang.IllegalStateException - if there is already a current model
      java.lang.NullPointerException - if config is null
    • createModel

      @Deprecated public ConfigUIModelBuilder createModel​(com.google.common.base.Supplier<org.nuiton.config.ApplicationConfig> config, java.io.File configFile) throws java.lang.IllegalStateException, java.lang.NullPointerException
      Deprecated.
      since 2.33, prefer use the createModel(Object, ApplicationConfig, File) method instead, will be removed soon
      Create a new model and set it as current model.
      Parameters:
      config - the configuration used in model
      configFile - configuration file where to save (can not be null)
      Returns:
      the builder
      Throws:
      java.lang.IllegalStateException - if there is already a current model
      java.lang.NullPointerException - if config or configFile is null
      Since:
      2.5.21
    • createModel

      @Deprecated public ConfigUIModelBuilder createModel​(java.lang.Object configurationBean, org.nuiton.config.ApplicationConfig config) throws java.lang.IllegalStateException, java.lang.NullPointerException
      Deprecated.
      since 2.33, prefer use the createModel(Object, ApplicationConfig, File) method instead, will be removed soon
      Create a new model and set it as current model.
      Parameters:
      configurationBean - configuration bean used in model
      config - the configuration used in model
      Returns:
      the builder
      Throws:
      java.lang.IllegalStateException - if there is already a current model
      java.lang.NullPointerException - if there is some null parameters
    • createModel

      @Deprecated public ConfigUIModelBuilder createModel​(org.nuiton.config.ApplicationConfig config) throws java.lang.IllegalStateException, java.lang.NullPointerException
      Deprecated.
      since 2.33, prefer use the createModel(Object, ApplicationConfig, File) method instead, will be removed soon
      Create a new model and set it as current model.
      Parameters:
      config - the configuration used in model
      Returns:
      the builder
      Throws:
      java.lang.IllegalStateException - if there is already a current model
      java.lang.NullPointerException - if config is null
    • createModel

      @Deprecated public ConfigUIModelBuilder createModel​(org.nuiton.config.ApplicationConfig config, java.io.File configFile) throws java.lang.IllegalStateException, java.lang.NullPointerException
      Deprecated.
      since 2.33, prefer use the createModel(Object, ApplicationConfig, File) method instead, will be removed soon
      Create a new model and set it as current model.
      Parameters:
      config - the configuration used in model
      configFile - configuration file where to save (can not be null)
      Returns:
      the builder
      Throws:
      java.lang.IllegalStateException - if there is already a current model
      java.lang.NullPointerException - if config or configFile is null
      Since:
      2.5.21
    • addCategory

      public ConfigUIModelBuilder addCategory​(java.lang.String categoryName, java.lang.String categoryLabel) throws java.lang.IllegalStateException, java.lang.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 be null)
      categoryLabel - the label of the new category (can not to be null)
      Returns:
      the builder
      Throws:
      java.lang.IllegalStateException - if there is not a current model, nor category
      java.lang.NullPointerException - if any of parameter is null
    • addCategory

      public ConfigUIModelBuilder addCategory​(java.lang.String categoryName, java.lang.String categoryLabel, java.lang.String defaultCallback) throws java.lang.IllegalStateException, java.lang.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 be null)
      categoryLabel - the label of the new category (can not to be null)
      Returns:
      the builder
      Throws:
      java.lang.IllegalStateException - if there is not a current model, nor category
      java.lang.NullPointerException - if any of parameter is null
    • addOption

      public ConfigUIModelBuilder addOption​(org.nuiton.config.ConfigOptionDef def) throws java.lang.IllegalStateException, java.lang.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:
      java.lang.IllegalStateException - if there is not a current model, nor category
      java.lang.NullPointerException - if any of parameter is null
    • addOption

      @Deprecated public ConfigUIModelBuilder addOption​(org.nuiton.config.ConfigOptionDef def, java.lang.String propertyName) throws java.lang.IllegalStateException, java.lang.NullPointerException
      Deprecated.
      since 2.5.29, prefer use the setOptionPropertyName(String) method instead, will be removed soon
      Add 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 for addOption(ConfigOptionDef) then setOptionPropertyName(String).
      Parameters:
      def - the def ot the new option
      propertyName - the propertyName to set on the option
      Returns:
      the builder
      Throws:
      java.lang.IllegalStateException - if there is not a current model, nor category
      java.lang.NullPointerException - if any of parameter is null
    • setOptionPropertyName

      public ConfigUIModelBuilder setOptionPropertyName​(java.lang.String propertyName) throws java.lang.IllegalStateException, java.lang.NullPointerException
      Set the propertyName on the current option.
      Parameters:
      propertyName - the propertyName to set in the current option.
      Returns:
      the builder
      Throws:
      java.lang.IllegalStateException - if there is not a current option set.
      java.lang.NullPointerException - if any of parameter is null
      See Also:
      OptionModel.setPropertyName(String)
    • setOptionShortLabel

      public ConfigUIModelBuilder setOptionShortLabel​(java.lang.String shortLabel) throws java.lang.IllegalStateException, java.lang.NullPointerException
      Set the short label on the current option.
      Parameters:
      shortLabel - the propertyName to set in the current option.
      Returns:
      the builder
      Throws:
      java.lang.IllegalStateException - if there is not a current option set.
      java.lang.NullPointerException - if any of parameter is null
      Since:
      2.5.29
      See Also:
      OptionModel.setShortLabel(String)
    • setOptionEditor

      public ConfigUIModelBuilder setOptionEditor​(javax.swing.table.TableCellEditor editor) throws java.lang.IllegalStateException, java.lang.NullPointerException
      Set the editor on the current option.
      Parameters:
      editor - the editor to set in the current option.
      Returns:
      the builder
      Throws:
      java.lang.IllegalStateException - if there is not a current option set.
      java.lang.NullPointerException - if any of parameter is null
      See Also:
      OptionModel.setEditor(TableCellEditor)
    • setOptionRenderer

      public ConfigUIModelBuilder setOptionRenderer​(javax.swing.table.TableCellRenderer renderer) throws java.lang.IllegalStateException, java.lang.NullPointerException
      Set the renderer on the current option.
      Parameters:
      renderer - the renderer to set in the current option.
      Returns:
      the builder
      Throws:
      java.lang.IllegalStateException - if there is not a current option set.
      java.lang.NullPointerException - if any of parameter is null
      See Also:
      OptionModel.setRenderer(TableCellRenderer)
    • registerCallBack

      public ConfigUIModelBuilder registerCallBack​(java.lang.String name, java.lang.String description, javax.swing.Icon icon, java.lang.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 callback
      description - the i18n key to describe the action
      icon - the icon of the callBack (used in ui)
      action - the action of the callback
      Returns:
      the builder
    • setOptionCallBack

      public ConfigUIModelBuilder setOptionCallBack​(java.lang.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​(java.lang.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 java.lang.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:
      java.lang.IllegalStateException - if there is not a current model set.
    • setModel

      public ConfigUIModelBuilder setModel​(ConfigUIModel model) throws java.lang.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:
      java.lang.IllegalStateException - if there is already a current model
    • setCategory

      public ConfigUIModelBuilder setCategory​(CategoryModel categoryModel) throws java.lang.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:
      java.lang.IllegalStateException - if there is not a current model or a current category
    • setOption

      public ConfigUIModelBuilder setOption​(OptionModel optionModel) throws java.lang.IllegalStateException
      Sets the given option as current option.
      Parameters:
      optionModel - the option to use
      Returns:
      the buider
      Throws:
      java.lang.IllegalStateException - if there is not a current model, nor category, or a current option
    • setCloseAction

      public ConfigUIModelBuilder setCloseAction​(java.lang.Runnable runnable)
    • flushCategory

      protected CategoryModel flushCategory()
    • flushOption

      protected OptionModel flushOption()
    • checkCurrent

      protected void checkCurrent​(java.lang.Object o, java.lang.String type)
    • checkNoCurrent

      protected void checkNoCurrent​(java.lang.Object o, java.lang.String type)
    • checkNotNull

      protected void checkNotNull​(java.lang.Object o, java.lang.String method, java.lang.String parameter)