Class PromptSupport
- java.lang.Object
-
- org.eclipse.nebula.widgets.opal.promptsupport.PromptSupport
-
public class PromptSupport extends java.lang.ObjectThis utility class allows the user to add a prompt to a text or combo component (see http://designinginterfaces.com/Input_Prompt).
This class is inspired by work of Peter Weishapl
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classPromptSupport.FocusBehavior
-
Field Summary
Fields Modifier and Type Field Description (package private) static java.lang.StringBACKGROUND(package private) static java.lang.StringBEHAVIOR(package private) static java.lang.StringFOREGROUND(package private) static java.lang.StringIS_PROMPT_DISPLAYEDprivate static java.lang.StringKEY(package private) static java.lang.StringPROMPT(package private) static java.lang.StringSET(package private) static java.lang.StringSTYLE
-
Constructor Summary
Constructors Constructor Description PromptSupport()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description private static voidcheckControl(org.eclipse.swt.widgets.Control control)Check if the control is a Text, a Combo, a StyledText or a CCombostatic org.eclipse.swt.graphics.ColorgetBackground(org.eclipse.swt.widgets.Control control)Get the background color of thecontrol, when no text is present.static PromptSupport.FocusBehaviorgetFocusBehavior(org.eclipse.swt.widgets.Control control)Get thePromptSupport.FocusBehaviorofcontrol.static intgetFontStyle(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.ColorgetForeground(org.eclipse.swt.widgets.Control control)Get the foreground color of the prompt text.static java.lang.StringgetPrompt(org.eclipse.swt.widgets.Control control)Get the prompt text ofcontrol.static voidinit(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 thepromptTextandpromptTextColoron aControl.(package private) static booleanisPromptDisplayed(org.eclipse.swt.widgets.Control control)static voidsetBackground(org.eclipse.swt.graphics.Color color, org.eclipse.swt.widgets.Control control)Sets the prompts background color oncontrol.static voidsetFocusBehavior(PromptSupport.FocusBehavior focusBehavior, org.eclipse.swt.widgets.Control control)Sets thePromptSupport.FocusBehavioroncontrol, if it is the focus owner.static voidsetFontStyle(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 voidsetForeground(org.eclipse.swt.graphics.Color color, org.eclipse.swt.widgets.Control control)Sets the foreground color of the prompt oncontrol.static voidsetPrompt(java.lang.String promptText, org.eclipse.swt.widgets.Control control)Sets the prompt text oncontrol(package private) static voidsetPromptDisplayed(org.eclipse.swt.widgets.Control control, boolean newValue)
-
-
-
Field Detail
-
KEY
private static final java.lang.String KEY
- See Also:
- Constant Field Values
-
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
-
SET
static final java.lang.String SET
- See Also:
- Constant Field Values
-
IS_PROMPT_DISPLAYED
static final java.lang.String IS_PROMPT_DISPLAYED
- See Also:
- Constant Field Values
-
-
Method Detail
-
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
promptTextandpromptTextColoron 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, thecontrolbackground 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.FocusBehaviorofcontrol.- Parameters:
control-- Returns:
- the
PromptSupport.FocusBehaviororPromptSupport.FocusBehavior.HIDE_PROMPTif none is set
-
setFocusBehavior
public static void setFocusBehavior(PromptSupport.FocusBehavior focusBehavior, org.eclipse.swt.widgets.Control control)
Sets thePromptSupport.FocusBehavioroncontrol, 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, theGREYcolor will be returned.- Parameters:
color-- Returns:
- the color of the prompt text or
GREYif 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
-
checkControl
private static void checkControl(org.eclipse.swt.widgets.Control control)
Check if the control is a Text, a Combo, a StyledText or a CCombo- Parameters:
control- control to check
-
isPromptDisplayed
static boolean isPromptDisplayed(org.eclipse.swt.widgets.Control control)
-
setPromptDisplayed
static void setPromptDisplayed(org.eclipse.swt.widgets.Control control, boolean newValue)
-
-