Java Code Examples for org.eclipse.swt.widgets.ColorDialog.getRGB()

The following are Jave code examples for showing how to use getRGB() of the org.eclipse.swt.widgets.ColorDialog class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
+ Save this method
Example 1
Project: ForgedUI-Eclipse   File: ColorCellEditor2.java   View Source Code Vote up 5 votes
protected Object openDialogBox(Control cellEditorWindow) {
	ColorDialog dialog = new ColorDialog(cellEditorWindow.getShell());
       Object value = getValue();
       if (value != null) {
		dialog.setRGB((RGB) value);
	}
       value = dialog.open();
       RGB rgb = dialog.getRGB();//return the same if cancelled
       if (rgb != null){
       	return rgb;//rgbToString(rgb);
       }
       return null;
}
 
Example 2
Project: gef-gwt   File: ColorCellEditor.java   View Source Code Vote up 5 votes
protected Object openDialogBox(Control cellEditorWindow) {
      ColorDialog dialog = new ColorDialog(cellEditorWindow.getShell());
      Object value = getValue();
      if (value != null) {
	dialog.setRGB((RGB) value);
}
      value = dialog.open();
      return dialog.getRGB();
  }
 
Example 3
Project: birt   File: ComboBoxColorCellEditor.java   View Source Code Vote up 4 votes
protected Object openDialogBox( Control cellEditorWindow )
{
	Shell shell = new Shell( Display.getCurrent( ), SWT.SHELL_TRIM );
	shell.setLocation( cellEditorWindow.toDisplay( 0, 0 ).x
			+ cellEditorWindow.getBounds( ).width,
			cellEditorWindow.toDisplay( 0, 0 ).y
					- cellEditorWindow.getBounds( ).height );
	ColorDialog dialog = new ColorDialog( shell, SWT.APPLICATION_MODAL );
	RGB[] rgbs = ReportPlugin.getDefault( ).getCustomColorsPreference( );
	if ( rgbs != null )
	{
		dialog.setRGBs( rgbs );
	}
	Object value = getValue( );

	try
	{
		int color;

		if ( value instanceof String )
		{
			color = ColorUtil.parseColor( (String) value );
		}
		else
		{
			color = ( (Integer) value ).intValue( );
		}

		dialog.setRGB( DEUtil.getRGBValue( color ) );

	}
	catch ( Exception e )
	{
		// ignore.
	}

	value = dialog.open( );
	ReportPlugin.getDefault( )
			.setCustomColorsPreference( dialog.getRGBs( ) );
	if ( value != null && dialog.getRGB( ) != null )
	{
		deactivate( );
		return ColorUtil.format( ColorUtil.formRGB( dialog.getRGB( ).red,
				dialog.getRGB( ).green,
				dialog.getRGB( ).blue ), ColorUtil.HTML_FORMAT );
	}
	comboBox.setFocus( );
	shell.dispose( );
	return value;
}