Class Plugins
- java.lang.Object
-
- org.pepstock.charba.client.commons.NativeObjectContainer
-
- org.pepstock.charba.client.commons.AbstractNode
-
- org.pepstock.charba.client.options.AbstractModel<Options,IsDefaultPlugins>
-
- org.pepstock.charba.client.options.Plugins
-
- All Implemented Interfaces:
IsDefaultPlugins
public class Plugins extends AbstractModel<Options,IsDefaultPlugins> implements IsDefaultPlugins
Definitions about plugins options. This is used to configure plugins (mainly the global ones).
Every plugin could have own configuration structure.
The java script object key is the plugin id.- Author:
- Andrea "Stock" Stocchero
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
Plugins(ChartEnvelop<Plugins> envelop)
Creates the object wrapping another plugin.
This constructor is used ONLY fromGlobalOptions
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description List<Key>
getAllIds()
Returns the unmodifiable list of registered plugin ids.<T extends AbstractPluginOptions>
TgetOptions(String pluginId, AbstractPluginOptionsFactory<T> factory)
Returns the plugin options, if exist.
It uses a factory instance to create a plugin options.
If factory argument is not consistent,null
is returned.<T extends AbstractPluginOptions>
TgetOptions(AbstractPluginOptionsFactory<T> factory)
Returns the plugin options, if exist.
It uses a factory instance to create a plugin options.
If factory argument is not consistent,null
is returned.boolean
hasEnabled(String pluginId)
Returns if a global plugin has been set or not.boolean
hasOptions(String pluginId)
Checks if there is any options for a specific plugin, by its id.boolean
isEnabled(String pluginId)
Returns if a plugin is enabled or not.boolean
isEnabled(DefaultPluginId pluginId)
Returns if a plugin is enabled or not.void
removeOptions(String pluginId)
Removes the plugin options.void
setEmptyOptions(String pluginId)
Sets an empty configuration for the plugin.
The plugin will use the default configurationvoid
setEnabled(String pluginId, boolean enabled)
Sets if a global plugin must be enabled or not.void
setEnabled(ConfigurationEnvelop<DefaultPluginId> envelop, boolean enabled)
Sets if a default CHART.JS plugin must be enabled or not.
Callable only for chart configuration scope (no global or other).<T extends AbstractPluginOptions>
voidsetOptions(String pluginId, T options)
Sets the plugin options.
If passed options isnull
, the configuration of plugin will be removed.<T extends AbstractPluginOptions>
voidsetOptions(T options)
Sets the plugin options.-
Methods inherited from class org.pepstock.charba.client.options.AbstractModel
getDefaultValues, getParent, loadPadding, setCallbackToModel, setCallbackToModel, setEventToModel
-
Methods inherited from class org.pepstock.charba.client.commons.AbstractNode
checkAndAddToParent, getChildKey, getParentNode, getRootNode, getUpdateListener, retrieveRoot, setArrayValueAndAddToParent, setArrayValueAndAddToParent, setArrayValueAndAddToParent, setElementAndAddToParent, setInternalCallbackToModel, setInternalCallbackToModel, setUpdateListener, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent, setValueOrArrayAndAddToParent
-
Methods inherited from class org.pepstock.charba.client.commons.NativeObjectContainer
checkAndGetColor, checkDefaultValuesArgument, empty, getArrayValue, getElement, getIncrementalId, getNativeChart, getNativeEvent, getNativeObject, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValue, getValueForMultipleKeyTypes, getValueForMultipleKeyTypes, getValueForMultipleKeyTypes, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, getValueOrArray, has, has, isType, keys, loadNativeObject, remove, remove, setArrayValue, setArrayValue, setArrayValue, setElement, setEmptyValue, setNewIncrementalId, setNewIncrementalId, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValue, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, setValueOrArray, toJSON, type
-
-
-
-
Constructor Detail
-
Plugins
protected Plugins(ChartEnvelop<Plugins> envelop)
Creates the object wrapping another plugin.
This constructor is used ONLY fromGlobalOptions
.- Parameters:
envelop
- envelop passed by chart package in oredr to wrap another plugin.
-
-
Method Detail
-
getAllIds
public final List<Key> getAllIds()
Returns the unmodifiable list of registered plugin ids.- Returns:
- the unmodifiable list of registered plugin ids
-
setEnabled
public final void setEnabled(String pluginId, boolean enabled)
Sets if a global plugin must be enabled or not.- Parameters:
pluginId
- plugin id.enabled
-false
disable a global plugin.
-
setEnabled
public final void setEnabled(ConfigurationEnvelop<DefaultPluginId> envelop, boolean enabled)
Sets if a default CHART.JS plugin must be enabled or not.
Callable only for chart configuration scope (no global or other).- Parameters:
envelop
- default CHART.JS plugin instance.enabled
-false
disable a default CHART.JS plugin.
-
isEnabled
public final boolean isEnabled(DefaultPluginId pluginId)
Returns if a plugin is enabled or not.- Parameters:
pluginId
- plugin id.- Returns:
false
if a global plugin is not enabled otherwisetrue
.
-
isEnabled
public final boolean isEnabled(String pluginId)
Returns if a plugin is enabled or not.- Specified by:
isEnabled
in interfaceIsDefaultPlugins
- Parameters:
pluginId
- plugin id.- Returns:
false
if a plugin is not enabled otherwisetrue
.
-
hasEnabled
public final boolean hasEnabled(String pluginId)
Returns if a global plugin has been set or not.- Parameters:
pluginId
- plugin id.- Returns:
false
if a global plugin has not been set otherwisetrue
.
-
removeOptions
public final void removeOptions(String pluginId)
Removes the plugin options.- Parameters:
pluginId
- plugin id.
-
setEmptyOptions
public void setEmptyOptions(String pluginId)
Sets an empty configuration for the plugin.
The plugin will use the default configuration- Parameters:
pluginId
- plugin id.
-
setOptions
public <T extends AbstractPluginOptions> void setOptions(T options)
Sets the plugin options.- Type Parameters:
T
- type of plugin options to store- Parameters:
options
- plugin options used to configure the plugin
-
setOptions
public <T extends AbstractPluginOptions> void setOptions(String pluginId, T options)
Sets the plugin options.
If passed options isnull
, the configuration of plugin will be removed.- Type Parameters:
T
- type of plugin options to store- Parameters:
pluginId
- plugin id.options
- plugin options used to configure the plugin.
Passnull
to remove the configuration if exist.
-
hasOptions
public final boolean hasOptions(String pluginId)
Checks if there is any options for a specific plugin, by its id.- Specified by:
hasOptions
in interfaceIsDefaultPlugins
- Parameters:
pluginId
- plugin id.- Returns:
true
if there is an options, otherwisefalse
.
-
getOptions
public final <T extends AbstractPluginOptions> T getOptions(AbstractPluginOptionsFactory<T> factory)
Returns the plugin options, if exist.
It uses a factory instance to create a plugin options.
If factory argument is not consistent,null
is returned.- Type Parameters:
T
- type of plugin options to return- Parameters:
factory
- factory instance to create a plugin options- Returns:
- plugin options used to configure the plugin or an empty object if not exist.
If factory argument is not consistent,null
is returned.
-
getOptions
public final <T extends AbstractPluginOptions> T getOptions(String pluginId, AbstractPluginOptionsFactory<T> factory)
Returns the plugin options, if exist.
It uses a factory instance to create a plugin options.
If factory argument is not consistent,null
is returned.- Specified by:
getOptions
in interfaceIsDefaultPlugins
- Type Parameters:
T
- type of plugin options to return- Parameters:
pluginId
- plugin id.factory
- factory instance to create a plugin options- Returns:
- plugin options used to configure the plugin or an empty object if not exist.
If factory argument is not consistent,null
is returned.
-
-