Class PromptSupport
java.lang.Object
org.eclipse.nebula.widgets.opal.promptsupport.PromptSupport
public class PromptSupport
extends java.lang.Object
This utility class allows the user to add a prompt to a text or combo
component (see https://designinginterfaces.com/Input_Prompt).
This class is inspired by work of Peter Weishapl
This class is inspired by work of Peter Weishapl
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
PromptSupport.FocusBehavior
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.String
BACKGROUND
(package private) static java.lang.String
BEHAVIOR
(package private) static java.lang.String
FOCUS_CONTROL_LISTENER
(package private) static java.lang.String
FOREGROUND
(package private) static java.lang.String
IS_PROMPT_DISPLAYED
(package private) static java.lang.String
PROMPT
(package private) static java.lang.String
STYLE
-
Constructor Summary
Constructors Constructor Description PromptSupport()
-
Method Summary
Modifier and Type Method Description static org.eclipse.swt.graphics.Color
getBackground(org.eclipse.swt.widgets.Control control)
Get the background color of thecontrol
, when no text is present.static PromptSupport.FocusBehavior
getFocusBehavior(org.eclipse.swt.widgets.Control control)
Get thePromptSupport.FocusBehavior
ofcontrol
.static int
getFontStyle(org.eclipse.swt.widgets.Control control)
Returns the font style of the prompt text, which is a OR mix of SWT.ITALIC, SWT.NONE or SWT.BOLDstatic org.eclipse.swt.graphics.Color
getForeground(org.eclipse.swt.widgets.Control control)
Get the foreground color of the prompt text.static java.lang.String
getPrompt(org.eclipse.swt.widgets.Control control)
Get the prompt text ofcontrol
.static void
init(java.lang.String promptText, org.eclipse.swt.graphics.Color promptForeground, org.eclipse.swt.graphics.Color promptBackground, org.eclipse.swt.widgets.Control control)
Convenience method to set thepromptText
andpromptTextColor
on aControl
.(package private) static boolean
isPromptDisplayed(org.eclipse.swt.widgets.Control control)
(package private) static boolean
isPromptSet(org.eclipse.swt.widgets.Control control)
static void
setBackground(org.eclipse.swt.graphics.Color color, org.eclipse.swt.widgets.Control control)
Sets the prompts background color oncontrol
.static void
setFocusBehavior(PromptSupport.FocusBehavior focusBehavior, org.eclipse.swt.widgets.Control control)
Sets thePromptSupport.FocusBehavior
oncontrol
, if it is the focus owner.static void
setFontStyle(int fontStyle, org.eclipse.swt.widgets.Control control)
Set the style of the prompt font, which is a OR mix of SWT.ITALIC, SWT.NONE or SWT.BOLDstatic void
setForeground(org.eclipse.swt.graphics.Color color, org.eclipse.swt.widgets.Control control)
Sets the foreground color of the prompt oncontrol
.static void
setPrompt(java.lang.String promptText, org.eclipse.swt.widgets.Control control)
Sets the prompt text oncontrol
(package private) static void
setPromptDisplayed(org.eclipse.swt.widgets.Control control, boolean newValue)
-
Field Details
-
BACKGROUND
static final java.lang.String BACKGROUND- See Also:
- Constant Field Values
-
FOREGROUND
static final java.lang.String FOREGROUND- See Also:
- Constant Field Values
-
STYLE
static final java.lang.String STYLE- See Also:
- Constant Field Values
-
BEHAVIOR
static final java.lang.String BEHAVIOR- See Also:
- Constant Field Values
-
PROMPT
static final java.lang.String PROMPT- See Also:
- Constant Field Values
-
IS_PROMPT_DISPLAYED
static final java.lang.String IS_PROMPT_DISPLAYED- See Also:
- Constant Field Values
-
FOCUS_CONTROL_LISTENER
static final java.lang.String FOCUS_CONTROL_LISTENER- See Also:
- Constant Field Values
-
-
Constructor Details
-
PromptSupport
public PromptSupport()
-
-
Method Details
-
init
public static void init(java.lang.String promptText, org.eclipse.swt.graphics.Color promptForeground, org.eclipse.swt.graphics.Color promptBackground, org.eclipse.swt.widgets.Control control)Convenience method to set the
promptText
andpromptTextColor
on aControl
.- Parameters:
promptText
- Prompt TextpromptForeground
- ForegroundpromptBackground
- Backgroundcontrol
- control- Throws:
java.lang.IllegalArgumentException
- if the control is not a Text Box, a Combo Box, a StyledText or a CCombo
-
getBackground
public static org.eclipse.swt.graphics.Color getBackground(org.eclipse.swt.widgets.Control control)Get the background color of thecontrol
, when no text is present. If no color has been set, thecontrol
background color will be returned.- Parameters:
textComponent
-- Returns:
- the the background color of the text component, when no text is present
-
setBackground
public static void setBackground(org.eclipse.swt.graphics.Color color, org.eclipse.swt.widgets.Control control)Sets the prompts background color on
control
. This background color will only be used when no text is present.- Parameters:
background
-control
-- Throws:
java.lang.IllegalArgumentException
- if the control is not a Text Box, a Combo Box, a StyledText or a CCombo
-
getFocusBehavior
public static PromptSupport.FocusBehavior getFocusBehavior(org.eclipse.swt.widgets.Control control)Get thePromptSupport.FocusBehavior
ofcontrol
.- Parameters:
control
-- Returns:
- the
PromptSupport.FocusBehavior
orPromptSupport.FocusBehavior.HIDE_PROMPT
if none is set
-
setFocusBehavior
public static void setFocusBehavior(PromptSupport.FocusBehavior focusBehavior, org.eclipse.swt.widgets.Control control)Sets thePromptSupport.FocusBehavior
oncontrol
, if it is the focus owner.- Parameters:
focusBehavior
-control
-- Throws:
java.lang.IllegalArgumentException
- if the control is not a Text Box, a Combo Box, a StyledText or a CCombo
-
getFontStyle
public static int getFontStyle(org.eclipse.swt.widgets.Control control)Returns the font style of the prompt text, which is a OR mix of SWT.ITALIC, SWT.NONE or SWT.BOLD- Parameters:
control
-- Returns:
- font style of the prompt text
-
setFontStyle
public static void setFontStyle(int fontStyle, org.eclipse.swt.widgets.Control control)Set the style of the prompt font, which is a OR mix of SWT.ITALIC, SWT.NONE or SWT.BOLD
- Parameters:
fontStyle
-control
-- Throws:
java.lang.IllegalArgumentException
- if the control is not a Text Box, a Combo Box, a StyledText or a CCombo
-
getForeground
public static org.eclipse.swt.graphics.Color getForeground(org.eclipse.swt.widgets.Control control)Get the foreground color of the prompt text. If no color has been set, theGREY
color will be returned.- Parameters:
color
-- Returns:
- the color of the prompt text or
GREY
if none is set
-
setForeground
public static void setForeground(org.eclipse.swt.graphics.Color color, org.eclipse.swt.widgets.Control control)Sets the foreground color of the prompt oncontrol
. This color will be used when no text is present.- Parameters:
promptTextColor
-textComponent
-- Throws:
java.lang.IllegalArgumentException
- if the control is not a Text Box, a Combo Box, a StyledText or a CCombo
-
getPrompt
public static java.lang.String getPrompt(org.eclipse.swt.widgets.Control control)Get the prompt text ofcontrol
.- Parameters:
control
-- Returns:
- the prompt text
-
setPrompt
public static void setPrompt(java.lang.String promptText, org.eclipse.swt.widgets.Control control)Sets the prompt text on
control
- Parameters:
promptText
-textComponent
-- Throws:
java.lang.IllegalArgumentException
- if the control is not a Text Box, a Combo Box, a StyledText or a CCombo
-
isPromptDisplayed
static boolean isPromptDisplayed(org.eclipse.swt.widgets.Control control) -
setPromptDisplayed
static void setPromptDisplayed(org.eclipse.swt.widgets.Control control, boolean newValue) -
isPromptSet
static boolean isPromptSet(org.eclipse.swt.widgets.Control control)
-