Package org.eclipse.jface.preference
Class ColorSelector
java.lang.Object
org.eclipse.core.commands.common.EventManager
org.eclipse.jface.preference.ColorSelector
The
ColorSelector is a wrapper for a button that displays a
swatch of the selected color and allows the user to change the selection
using the operating system's native color chooser dialog.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringProperty name that signifies the selected color of thisColorSelectorhas changed. -
Constructor Summary
ConstructorsConstructorDescriptionColorSelector(Composite parent) Create a new instance of the receiver and the button that it wrappers in the supplied parentComposite. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(IPropertyChangeListener listener) Adds a property change listener to thisColorSelector.Get the button control being wrappered by the selector.Return the currently displayed color.voidopen()Activate the editor for this selector.voidremoveListener(IPropertyChangeListener listener) Removes the given listener from thisColorSelector.voidsetColorValue(RGB rgb) Set the current color value and update the control.voidsetEnabled(boolean state) Set whether or not the button is enabled.protected voidUpdate the image being displayed on the button using the current color setting.Methods inherited from class org.eclipse.core.commands.common.EventManager
addListenerObject, clearListeners, getListeners, isListenerAttached, removeListenerObject
-
Field Details
-
PROP_COLORCHANGE
Property name that signifies the selected color of thisColorSelectorhas changed.- Since:
- 3.0
- See Also:
-
-
Constructor Details
-
ColorSelector
Create a new instance of the receiver and the button that it wrappers in the supplied parentComposite.- Parameters:
parent- The parent of the button.
-
-
Method Details
-
addListener
Adds a property change listener to thisColorSelector. Events are fired when the color in the control changes via the user clicking an selecting a new one in the color dialog. No event is fired in the case wheresetColorValue(RGB)is invoked.- Parameters:
listener- a property change listener- Since:
- 3.0
-
getButton
Get the button control being wrappered by the selector.- Returns:
Button
-
getColorValue
Return the currently displayed color.- Returns:
RGB
-
removeListener
Removes the given listener from thisColorSelector. Has no effect if the listener is not registered.- Parameters:
listener- a property change listener- Since:
- 3.0
-
setColorValue
Set the current color value and update the control.- Parameters:
rgb- The new color.
-
setEnabled
public void setEnabled(boolean state) Set whether or not the button is enabled.- Parameters:
state- the enabled state.
-
updateColorImage
protected void updateColorImage()Update the image being displayed on the button using the current color setting. -
open
public void open()Activate the editor for this selector. This causes the color selection dialog to appear and wait for user input.- Since:
- 3.2
-