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

The following examples show how to use org.eclipse.swt.widgets.ColorDialog#setText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EditingPane.java    From pmTrans with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void changeBackgroundColor() {
	ColorDialog cd = new ColorDialog(getShell());
	cd.setRGB(text.getBackground().getRGB());
	cd.setText("Choose a color");

	RGB newColor = cd.open();
	if (newColor != null)
		Config.getInstance().setValue(Config.BACKGROUND_COLOR,
				new Color(Display.getCurrent(), newColor));
	updateFont();
}
 
Example 2
Source File: EditingPane.java    From pmTrans with GNU Lesser General Public License v3.0 5 votes vote down vote up
public void changeFontColor() {
	ColorDialog cd = new ColorDialog(getShell());
	cd.setRGB(text.getBackground().getRGB());
	cd.setText("Choose a color");

	RGB newColor = cd.open();
	if (newColor != null)
		Config.getInstance().setValue(Config.FONT_COLOR,
				new Color(Display.getCurrent(), newColor));
	updateFont();
}
 
Example 3
Source File: SWTColorChooser.java    From tuxguitar with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void choose(UIColorChooserHandler selectionHandler) {
	ColorDialog dlg = new ColorDialog(this.window.getControl());
	if( this.text != null ) {
		dlg.setText(this.text);
	}
	if( this.defaultModel != null ) {
		dlg.setRGB(new RGB(this.defaultModel.getRed(), this.defaultModel.getGreen(), this.defaultModel.getBlue()));
	}
	
	RGB rgb = dlg.open();
	
	selectionHandler.onSelectColor(rgb != null ? new UIColorModel(rgb.red, rgb.green, rgb.blue) : null); 
}
 
Example 4
Source File: OptionsDesign.java    From ldparteditor with MIT License 5 votes vote down vote up
@Override
public void mouseDoubleClick(MouseEvent e) {
    final TreeItem selection;
    if (tree.getSelectionCount() == 1 && (selection = tree.getSelection()[0]).getData() != null) {
        ColorDialog dlg = new ColorDialog(getShell());
        // Change the title bar text
        dlg.setText(selection.getText(0));
        dlg.setRGB(selection.getParent().getMapInv().get(selection).getBackground(1).getRGB());
        // Open the dialog and retrieve the selected color
        RGB rgb = dlg.open();
        if (rgb != null) {
            GColour refCol = new GColour(-1, rgb.red / 255f, rgb.green / 255f, rgb.blue / 255f, 1f);
            tree.getMapInv().get(selection).setBackground(1, SWTResourceManager.getColor(rgb));
            Object[] colourObj = (Object[]) selection.getData();
            ColourType type = (ColourType) colourObj[0];
            switch (type) {
            case OPENGL_COLOUR:
                ((float[]) ((Object[]) colourObj[1])[0])[0] = refCol.getR();
                ((float[]) ((Object[]) colourObj[1])[1])[0] = refCol.getG();
                ((float[]) ((Object[]) colourObj[1])[2])[0] = refCol.getB();
                break;
            case SWT_COLOUR:
                ((Color[]) colourObj[1])[0] = SWTResourceManager.getColor(rgb) ;
                break;
            default:
                break;
            }

            for (EditorTextWindow w : Project.getOpenTextWindows()) {
                for (CTabItem t : w.getTabFolder().getItems()) {
                    ((CompositeTab) t).updateColours();
                }
            }
            tree.build();
            tree.update();
        }
    }
}
 
Example 5
Source File: GamaColorMenu.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public static void openView(final IColorRunnable runnable, final RGB initial) {
	final Shell shell = new Shell(WorkbenchHelper.getDisplay(), SWT.MODELESS);
	final ColorDialog dlg = new ColorDialog(shell, SWT.MODELESS);
	dlg.setText("Choose a custom color");
	dlg.setRGB(initial);
	final RGB rgb = dlg.open();
	// final int a = StringUtils.INDEX_NOT_FOUND;
	if (rgb != null) {
		if (runnable != null) {
			runnable.run(rgb.red, rgb.green, rgb.blue);
		}
	}
}
 
Example 6
Source File: PageSupport.java    From slr-toolkit with Eclipse Public License 1.0 5 votes vote down vote up
protected static RGB openAndGetColor(Composite parent, Label label) {
	
	ColorDialog dlg = new ColorDialog(parent.getShell());
	dlg.setRGB(label.getBackground().getRGB());
	dlg.setText("Choose a Color");
	RGB rgb = dlg.open();
       label.setBackground(new Color(parent.getShell().getDisplay(), rgb));
       
	return rgb;
}