com.gridsystems.config
Class Configurator

java.lang.Object
  extended by com.gridsystems.config.Configurator
Direct Known Subclasses:
JVMConfigurator, TomcatConfigurator

public abstract class Configurator
extends java.lang.Object

Plugin Configurator base class. Subclasses will act as controllers in an MVC pattern.

Version:
1.0
Author:
Rodrigo Ruiz Aguayo

Field Summary
static int MODE_CONSOLE
          This mode forces ConsoleUI to be used.
static int MODE_SILENT
          This mode forces NullUI to be used.
static int MODE_SWING
          This mode forces SwingUI to be used.
 
Constructor Summary
Configurator(java.util.ResourceBundle bundle, java.lang.String keyBase)
          Constructor.
Configurator(java.lang.String bundleName, java.lang.String keyBase)
          Constructor.
 
Method Summary
 void apply()
          Saves the view values into the model, and applies it.
protected abstract  ConfiguratorModel createModel()
          Creates a new model instance.
 void discard()
          Cancels the current view changes, and reloads the model values into it.
 java.util.ResourceBundle getBundle()
          Gets the resource bundle associated to this configuration instance.
protected abstract  ConsoleConfiguratorView getConsoleView()
          Gets a view for MODE_CONSOLE.
static java.lang.String getContextDir()
          Gets the path to the kernel context directory.
 ConfiguratorModel getModel()
          Gets a reference to the model of this configurator.
 java.lang.String getName()
          Gets a name for this instance.
 java.lang.String getPath()
          Gets a path for this instance.
protected abstract  SwingConfiguratorView getSwingView()
          Gets a view for MODE_SWING.
static java.lang.String getUsername()
          Gets the username.
 ConfiguratorView getView()
          Gets the view corresponding to the current view mode, or null if no suitable view is available.
static int getViewMode()
          Gets the current global view mode.
 boolean hasView()
          Gets if a view exists for the current mode.
static boolean isClosing()
          Tells if the configurator is being closed.
static void setClosing(boolean closing)
          Sets if the configurator is being closed.
 void setErrorListener(ErrorListener listener)
          Sets the error listener of this configurator.
 void setModel(ConfiguratorModel model)
          Sets the model of this configurator.
static void setUsername(java.lang.String newUsername)
          Sets the username.
static void setViewMode(int mode)
          Sets the global view mode.
 void updateError(java.lang.String id, java.lang.String message, boolean add)
          Notifies the listener about an error.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MODE_SILENT

public static final int MODE_SILENT
This mode forces NullUI to be used.

See Also:
Constant Field Values

MODE_SWING

public static final int MODE_SWING
This mode forces SwingUI to be used.

See Also:
Constant Field Values

MODE_CONSOLE

public static final int MODE_CONSOLE
This mode forces ConsoleUI to be used.

See Also:
Constant Field Values
Constructor Detail

Configurator

public Configurator(java.lang.String bundleName,
                    java.lang.String keyBase)
Constructor.

Parameters:
bundleName - The name of the bundle to use
keyBase - The root of the bundle keys

Configurator

public Configurator(java.util.ResourceBundle bundle,
                    java.lang.String keyBase)
Constructor.

Parameters:
bundle - The bundle to use
keyBase - The root of the bundle keys
Method Detail

getName

public java.lang.String getName()
Gets a name for this instance. It is extracted from the bundle, using the key keyBase + ".name"

Returns:
The name of this instance

getPath

public java.lang.String getPath()
Gets a path for this instance. It is extracted from the bundle, using the key keyBase + ".path".

The path syntax is its path in the menu tree, with nodes separated by dot (.) characters.

Returns:
The path for this instance in the menu tree

getBundle

public java.util.ResourceBundle getBundle()
Gets the resource bundle associated to this configuration instance.

Returns:
The resource bundle of this instance

getModel

public ConfiguratorModel getModel()
Gets a reference to the model of this configurator.

Returns:
The model

setModel

public void setModel(ConfiguratorModel model)
Sets the model of this configurator. It SHOULD be called from the subclass constructor.

Parameters:
model - The model

setViewMode

public static void setViewMode(int mode)
Sets the global view mode.

Parameters:
mode - The new view mode

getViewMode

public static int getViewMode()
Gets the current global view mode.

Returns:
The current view mode

setUsername

public static void setUsername(java.lang.String newUsername)
Sets the username.

Parameters:
newUsername - the new username

getUsername

public static java.lang.String getUsername()
Gets the username.

Returns:
a String containing the username

getContextDir

public static java.lang.String getContextDir()
Gets the path to the kernel context directory. This method returns the path ../webapps/kernel as its default value. The user can specify an alternate path by adding -Dkernel.context=[path] to the command line.

Returns:
The path to the kernel context directory

getView

public ConfiguratorView getView()
Gets the view corresponding to the current view mode, or null if no suitable view is available.

Returns:
A view for this view mode, or null if it is not supported

hasView

public boolean hasView()
Gets if a view exists for the current mode.

Returns:
true if this instance defines a view for the current mode

getSwingView

protected abstract SwingConfiguratorView getSwingView()
Gets a view for MODE_SWING.

Returns:
The view

getConsoleView

protected abstract ConsoleConfiguratorView getConsoleView()
Gets a view for MODE_CONSOLE.

Returns:
The view

createModel

protected abstract ConfiguratorModel createModel()
Creates a new model instance.

Returns:
A newly created ConfiguratorModel instance

apply

public void apply()
           throws java.lang.Exception
Saves the view values into the model, and applies it.

Throws:
java.lang.Exception - In case of error during model apply

discard

public void discard()
Cancels the current view changes, and reloads the model values into it.


setErrorListener

public void setErrorListener(ErrorListener listener)
Sets the error listener of this configurator.

Parameters:
listener - The listener

updateError

public void updateError(java.lang.String id,
                        java.lang.String message,
                        boolean add)
Notifies the listener about an error.

Parameters:
id - The error identifier
message - The error message
add - The error action flag

setClosing

public static void setClosing(boolean closing)
Sets if the configurator is being closed.

Parameters:
closing - true if and only if the configurator is being closed.

isClosing

public static boolean isClosing()
Tells if the configurator is being closed.

Returns:
true if and only if the configurator is being closed.


Copyright © 2007-2008 Grid Systems, S.A.. All Rights Reserved.