com.ibm.commons.swt.controls
Class ColorButton

java.lang.Object
  extended by com.ibm.commons.swt.controls.ColorButton
All Implemented Interfaces:
ICustomControl
Direct Known Subclasses:
DCColorButton

public class ColorButton
extends java.lang.Object
implements ICustomControl

An instance of ICustomControl that creates a button that when pressed pops up the color picker dialog. When the color picked via the dialog changes the color of the button will also change, and clients who are registered listeners of this control will be notified that a color update has occured.


Constructor Summary
ColorButton(org.eclipse.swt.widgets.Composite parent, java.lang.String id)
          Constructs a new instance of the class given the parent Composite, and id which can be used to later identify this control.
 
Method Summary
 void addListener(org.eclipse.jface.util.IPropertyChangeListener listener)
          Adds a listener to the control.
 void dispose()
           
 org.eclipse.swt.widgets.Button getButton()
          Returns the button that is used to launch the Color Picker dialog.
 org.eclipse.swt.graphics.RGB getColorValue()
          Return the current color value (could be null).
 java.lang.String getId()
          Returns a string identifier associated with the current widget/control
 void removeListener(org.eclipse.jface.util.IPropertyChangeListener listener)
          Removes a listener from the control.
 void setColorValue(org.eclipse.swt.graphics.RGB rgbVal)
          Sets the initial color of the control.
 void setId(java.lang.String id)
          Sets a string identifier on the current widget/control.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ColorButton

public ColorButton(org.eclipse.swt.widgets.Composite parent,
                   java.lang.String id)
Constructs a new instance of the class given the parent Composite, and id which can be used to later identify this control.

Parameters:
parent - a Composite control which will be the parent of the new instance (CANNOT be null).
id - the programmatic ID of the control once constructed.
Method Detail

dispose

public void dispose()

getId

public java.lang.String getId()
Description copied from interface: ICustomControl
Returns a string identifier associated with the current widget/control

Specified by:
getId in interface ICustomControl
Returns:
String

setId

public void setId(java.lang.String id)
Description copied from interface: ICustomControl
Sets a string identifier on the current widget/control.

Specified by:
setId in interface ICustomControl

addListener

public void addListener(org.eclipse.jface.util.IPropertyChangeListener listener)
Adds a listener to the control. When the color is changed via user events the listener will be notified of the newly selected color (a long with the existing color). Listeners should listen for changes to the "Color" property, e.g.

if("Color".equals(event.getProperty()){
    //DO SOMETHING BASED ON THE NEW COLOR
}

Parameters:
listener - org.eclipse.jface.util.IPropertyChangeListener

removeListener

public void removeListener(org.eclipse.jface.util.IPropertyChangeListener listener)
Removes a listener from the control. Once successfully called the client will no longer be notified of updates to this control.

Parameters:
listener - org.eclipse.jface.util.IPropertyChangeListener

getButton

public org.eclipse.swt.widgets.Button getButton()
Returns the button that is used to launch the Color Picker dialog.

Returns:
org.eclipse.swt.widgets.Button

getColorValue

public org.eclipse.swt.graphics.RGB getColorValue()
Return the current color value (could be null).

Returns:
org.eclipse.swt.graphics.RGB

setColorValue

public void setColorValue(org.eclipse.swt.graphics.RGB rgbVal)
Sets the initial color of the control.

Parameters:
rgbVal - org.eclipse.swt.graphics.RGB