public abstract class ArgumentComponent
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static java.awt.Color |
CL_DEFAULT |
static java.awt.Color |
CL_ERROR |
static java.awt.Font |
DEFAULT_FONT |
static javax.swing.border.Border |
DEFAULT_INNER_BORDER |
static javax.swing.border.Border |
DEFAULT_TEXT_BORDER |
protected boolean |
markIfError |
Constructor and Description |
---|
ArgumentComponent()
Creates an instance but does not initialize it.
|
Modifier and Type | Method and Description |
---|---|
void |
addKeyListener(java.awt.event.KeyListener keyListener)
Adds the given key listener to this and eventually inner components
|
protected ExecutionReturn |
checkAndExecute(java.lang.String statement,
MainControl mainControl)
Executes the given statement and returns the result if it is not an error.
|
void |
error(java.lang.String errorMessage)
Highlights the component to indicate that the value is invalid.
|
abstract ExecutionReturn |
evaluate()
Evaluates the user input and creates a respective graphana value
|
java.lang.String |
evaluateToString()
Evalutates the user input and returns it in its string representation
|
abstract java.awt.Component |
getComponent()
Returns the topmost component to add it into a GUI
|
int |
getComponentHeight()
Returns the height of the component in pixels
|
int |
getComponentMinWidth()
Returns the width of the component in pixels
|
java.awt.Component |
getInnerComponent()
Returns the inner component of this component or the component itself, if there is no inner component.
|
protected java.awt.Container |
getTopParent()
Returns the parent of this component.
|
protected abstract void |
init(MainControl mainControl,
ScriptType scriptType,
ArgumentComponentManager argumentComponentManager) |
void |
init(MainControl mainControl,
ScriptType scriptType,
ArgumentComponentManager argumentComponentManager,
java.awt.Container topParent)
Initializes and builds the component and sub components
|
void |
resetToolTip()
Disables the tooltip
|
void |
setComponentColor(java.awt.Color color)
Sets the color of the component and eventually the sub components
|
void |
setMarkIfError(boolean markIfError)
If set to true, then the component will be highlighted once it detected an error during evaluation
|
void |
setParameterName(java.lang.String parameterName)
Sets a special name of the type.
|
abstract void |
setToolTip(java.lang.String tooltip)
Sets the tooltip of the component and eventually of sub components
|
abstract void |
setValue(ExecutionReturn value)
Sets the value within the component to the given value
|
protected ExecutionError |
throwError(ExecutionError error)
Outputs the given error.
|
ExecutionErrorMessage |
throwError(java.lang.String message)
Outputs the given error.
|
protected java.lang.String |
throwStringError(ExecutionError error)
Outputs the given error.
|
protected java.lang.String |
throwStringError(java.lang.String errorMessage)
Outputs the given error.
|
void |
unmark()
Sets the appearance back to normal
|
public static final java.awt.Color CL_DEFAULT
public static final java.awt.Color CL_ERROR
public static final java.awt.Font DEFAULT_FONT
public static final javax.swing.border.Border DEFAULT_INNER_BORDER
public static final javax.swing.border.Border DEFAULT_TEXT_BORDER
protected boolean markIfError
public ArgumentComponent()
protected abstract void init(MainControl mainControl, ScriptType scriptType, ArgumentComponentManager argumentComponentManager)
public abstract java.awt.Component getComponent()
public abstract void setValue(ExecutionReturn value)
public abstract ExecutionReturn evaluate()
public abstract void setToolTip(java.lang.String tooltip)
public void init(MainControl mainControl, ScriptType scriptType, ArgumentComponentManager argumentComponentManager, java.awt.Container topParent)
mainControl
- the main control of GraphanascriptType
- the graphana typeargumentComponentManager
- the manager instance which handles all argument componentstopParent
- the parent within which this component is to be addedprotected java.awt.Container getTopParent()
public void setParameterName(java.lang.String parameterName)
public void setMarkIfError(boolean markIfError)
public int getComponentHeight()
public int getComponentMinWidth()
public java.awt.Component getInnerComponent()
public void setComponentColor(java.awt.Color color)
public void error(java.lang.String errorMessage)
errorMessage
- the message to display (for example as tooltip)public void unmark()
public void addKeyListener(java.awt.event.KeyListener keyListener)
protected ExecutionError throwError(ExecutionError error)
public ExecutionErrorMessage throwError(java.lang.String message)
message
- the error message to output, for example as a tooltippublic void resetToolTip()
protected java.lang.String throwStringError(java.lang.String errorMessage)
errorMessage
- the error message to output, for example as a tooltipprotected java.lang.String throwStringError(ExecutionError error)
error
- the error to output in its string representation, for example as a tooltippublic java.lang.String evaluateToString()
protected ExecutionReturn checkAndExecute(java.lang.String statement, MainControl mainControl)
statement
- the statement to execute in Graphana syntaxmainControl
- the main control of Graphana