Package org.esa.snap.core.param
Class AbstractParamEditor
- java.lang.Object
-
- org.esa.snap.core.param.AbstractParamEditor
-
- All Implemented Interfaces:
ParamEditor
,ParamExceptionHandler
- Direct Known Subclasses:
AbstractParamXEditor
,BooleanEditor
,ComboBoxEditor
,LabelEditor
,ListEditor
,RadioButtonEditor
,TextFieldEditor
public abstract class AbstractParamEditor extends Object implements ParamEditor, ParamExceptionHandler
TheAbstractParamEditor
acts as a base class for implementations ofParamEditor
interface by providing some default method implementations and several utility methods for common editors.- Version:
- $Revision$ $Date$
- See Also:
ParamEditor
,ParamValidator
,ParamExceptionHandler
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractParamEditor(Parameter parameter, boolean useDefaultVerifier)
Creates the object with a given parameter.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
checkParameterValue(JTextComponent textComponent)
Checks whether or not the given text component provides a valid value for this parameter.JComponent
getComponent()
Simply returnsParamEditor.getEditorComponent()
.protected ActionListener
getDefaultActionListener()
protected InputVerifier
getDefaultInputVerifier()
ParamExceptionHandler
getExceptionHandler()
Returns an optional error handler for this editor.JLabel
getLabelComponent()
Gets the label component.Parameter
getParameter()
Gets the parameter to which this editor belongs to.JLabel
getPhysUnitLabelComponent()
Gets the physical unit label component.boolean
handleParamException(ParamException e)
Implements the default behaviour for _parameter errors: A message box is shown for the given message string.protected void
initUI()
Initialized the UI of this editor.boolean
isEnabled()
Checks whether or not the editor is enabled,protected void
nameComponent(JComponent component, String suffix)
protected void
nameEditorComponent(JComponent component)
protected void
nameLabelComponent(JComponent component)
protected void
nameUnitComponent(JComponent component)
void
reconfigureUI()
Tells the UI component to reconfigure itself, since the parameter's properties have changed.protected void
setDefaultLabelComponent(boolean ensureTrailingColon)
protected void
setDefaultPhysUnitLabelComponent(boolean ensureLeadingSpace)
void
setEnabled(boolean enabled)
Enables/disables this editor.void
setLabelComponent(JLabel labelComponent)
Sets the label component.protected boolean
setParameterValue(JTextComponent textComponent)
void
setPhysUnitLabelComponent(JLabel labelComponent)
Sets the physical unit component.void
updateUI()
Tells the UI to update it's state.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.esa.snap.core.param.ParamEditor
getEditorComponent
-
-
-
-
Constructor Detail
-
AbstractParamEditor
protected AbstractParamEditor(Parameter parameter, boolean useDefaultVerifier)
Creates the object with a given parameter.- Parameters:
parameter
- theParameter
to be edited.useDefaultVerifier
-true
if a default verifier should be used
-
-
Method Detail
-
getParameter
public Parameter getParameter()
Gets the parameter to which this editor belongs to.- Specified by:
getParameter
in interfaceParamEditor
-
getLabelComponent
public JLabel getLabelComponent()
Gets the label component.- Specified by:
getLabelComponent
in interfaceParamEditor
-
setLabelComponent
public void setLabelComponent(JLabel labelComponent)
Sets the label component.- Specified by:
setLabelComponent
in interfaceParamEditor
-
getPhysUnitLabelComponent
public JLabel getPhysUnitLabelComponent()
Gets the physical unit label component.- Specified by:
getPhysUnitLabelComponent
in interfaceParamEditor
-
setPhysUnitLabelComponent
public void setPhysUnitLabelComponent(JLabel labelComponent)
Sets the physical unit component.- Specified by:
setPhysUnitLabelComponent
in interfaceParamEditor
-
setDefaultLabelComponent
protected void setDefaultLabelComponent(boolean ensureTrailingColon)
-
setDefaultPhysUnitLabelComponent
protected void setDefaultPhysUnitLabelComponent(boolean ensureLeadingSpace)
-
isEnabled
public boolean isEnabled()
Checks whether or not the editor is enabled,- Specified by:
isEnabled
in interfaceParamEditor
-
setEnabled
public void setEnabled(boolean enabled)
Enables/disables this editor.- Specified by:
setEnabled
in interfaceParamEditor
-
initUI
protected void initUI()
Initialized the UI of this editor. Called only once within this editor's constructor.The default implementation creates a label component for the parameter's "label" and "physicalUnit" properties.
-
updateUI
public void updateUI()
Tells the UI to update it's state. The default implementations en-/disables the label components (if any) of this editor.Note: If you override this method, you should call this base class version first.
- Specified by:
updateUI
in interfaceParamEditor
-
reconfigureUI
public void reconfigureUI()
Tells the UI component to reconfigure itself, since the parameter's properties have changed.The default implementation simply calls the
updateUI
method.- Specified by:
reconfigureUI
in interfaceParamEditor
-
handleParamException
public boolean handleParamException(ParamException e)
Implements the default behaviour for _parameter errors: A message box is shown for the given message string.- Specified by:
handleParamException
in interfaceParamExceptionHandler
- Parameters:
e
- the exception- Returns:
true
if the exception was handled successfully,false
otherwise
-
getDefaultInputVerifier
protected InputVerifier getDefaultInputVerifier()
-
getDefaultActionListener
protected ActionListener getDefaultActionListener()
-
setParameterValue
protected boolean setParameterValue(JTextComponent textComponent)
-
checkParameterValue
protected boolean checkParameterValue(JTextComponent textComponent)
Checks whether or not the given text component provides a valid value for this parameter. This method has no side-effects.- Parameters:
textComponent
- the text component which provides the parameter value.- Returns:
true
if so
-
getExceptionHandler
public ParamExceptionHandler getExceptionHandler()
Returns an optional error handler for this editor. The default implementation simply returnsthis
instance.- Specified by:
getExceptionHandler
in interfaceParamEditor
-
getComponent
public JComponent getComponent()
Simply returnsParamEditor.getEditorComponent()
.- Specified by:
getComponent
in interfaceParamEditor
- Returns:
- the editor component or the editor component wrapped
- See Also:
ParamEditor.getEditorComponent()
-
nameLabelComponent
protected void nameLabelComponent(JComponent component)
-
nameEditorComponent
protected void nameEditorComponent(JComponent component)
-
nameUnitComponent
protected void nameUnitComponent(JComponent component)
-
nameComponent
protected void nameComponent(JComponent component, String suffix)
-
-