org.eclipse.swt.widgets.ColorDialog Java Examples
The following examples show how to use
org.eclipse.swt.widgets.ColorDialog.
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: PTColorEditor.java From nebula with Eclipse Public License 2.0 | 6 votes |
@Override protected void openWindow(final PTWidget widget, final Item item, final PTProperty property) { final ColorDialog dialog = new ColorDialog(widget.getWidget().getShell()); final RGB result = dialog.open(); if (result != null) { property.setValue(result); final Color bgColor = getBackgroundColor(property); if (bgColor != null) { if (item instanceof TableItem) { ((TableItem) item).setBackground(1, bgColor); } if (item instanceof TreeItem) { ((TreeItem) item).setBackground(1, bgColor); } SWTGraphicUtil.addDisposer(item, bgColor); } if (item instanceof TableItem) { ((TableItem) item).setText(1, getTextFor(property)); } else { ((TreeItem) item).setText(1, getTextFor(property)); } } }
Example #2
Source File: ColorPicker.java From translationstudio8 with GNU General Public License v2.0 | 6 votes |
public ColorPicker(Composite parent, final Color originalColor) { super(parent, SWT.SHADOW_OUT); if (originalColor == null) throw new IllegalArgumentException("null"); this.selectedColor = originalColor; setImage(getColorImage(originalColor)); addMouseListener( new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { ColorDialog dialog = new ColorDialog(new Shell(Display.getDefault(), SWT.SHELL_TRIM)); dialog.setRGB(selectedColor.getRGB()); RGB selected = dialog.open(); if (selected != null) { update(selected); } } }); }
Example #3
Source File: ColorPicker.java From tmxeditor8 with GNU General Public License v2.0 | 6 votes |
public ColorPicker(Composite parent, final Color originalColor) { super(parent, SWT.SHADOW_OUT); if (originalColor == null) throw new IllegalArgumentException("null"); this.selectedColor = originalColor; setImage(getColorImage(originalColor)); addMouseListener( new MouseAdapter() { @Override public void mouseDown(MouseEvent e) { ColorDialog dialog = new ColorDialog(new Shell(Display.getDefault(), SWT.SHELL_TRIM)); dialog.setRGB(selectedColor.getRGB()); RGB selected = dialog.open(); if (selected != null) { update(selected); } } }); }
Example #4
Source File: BoxDecoratorImpl.java From gama with GNU General Public License v3.0 | 6 votes |
@Override public void mouseDoubleClick(final MouseEvent e) { final int x = e.x + boxText.getHorizontalPixel(); final int y = e.y + boxText.getTopPixel(); int level = -1; for (final Box b : visibleBoxes()) { if (contains(b.rec, x, y)) { if (level < b.level) { level = b.level; } } } level++; final ColorDialog colorDialog = new ColorDialog(boxText.getShell()); final Color oldColor1 = settings.getColor(level); if (oldColor1 != null) { colorDialog.setRGB(oldColor1.getRGB()); } settings.setColor(level, colorDialog.open()); }
Example #5
Source File: ColourDialog.java From ldparteditor with MIT License | 6 votes |
public void run() { this.setBlockOnOpen(true); this.setShellStyle(SWT.APPLICATION_MODAL | SWT.SHELL_TRIM ^ SWT.MIN); this.create(); // MARK All final listeners will be configured here.. WidgetUtil(btn_colourChoose[0]).addSelectionListener(e -> { ColorDialog dlg = new ColorDialog(getShell()); // Change the title bar text dlg.setText(I18n.COLOURDIALOG_ChooseDirectColour); // Open the dialog and retrieve the selected color RGB rgb = dlg.open(); if (rgb != null) { refCol[0] = new GColour(-1, rgb.red / 255f, rgb.green / 255f, rgb.blue / 255f, 1f); me.close(); } }); WidgetUtil(btn_colourTable[0]).addSelectionListener(e -> { new ColourTableDialog(getShell(), refCol).run(); me.close(); }); if (randomColours) WidgetUtil(btn_randomColours[0]).addSelectionListener(e -> { refCol[0] = View.RANDOM_COLOUR; me.close(); }); this.open(); }
Example #6
Source File: OptionsDesign.java From ldparteditor with MIT License | 5 votes |
@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 #7
Source File: PageSupport.java From slr-toolkit with Eclipse Public License 1.0 | 5 votes |
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; }
Example #8
Source File: GamaColorMenu.java From gama with GNU General Public License v3.0 | 5 votes |
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 #9
Source File: StolenColorEditor.java From gama with GNU General Public License v3.0 | 5 votes |
public StolenColorEditor(final Composite parent, final SelectionListener parentListener) { this.listener = parentListener; fButton = new Button(parent, SWT.PUSH); fExtent = computeImageSize(parent); fImage = new Image(parent.getDisplay(), fExtent.x, fExtent.y); final GC gc = new GC(fImage); gc.setBackground(fButton.getBackground()); gc.fillRectangle(0, 0, fExtent.x, fExtent.y); gc.dispose(); fButton.setImage(fImage); fButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { final ColorDialog colorDialog = new ColorDialog(fButton.getShell()); colorDialog.setRGB(fColorValue); final RGB newColor = colorDialog.open(); if (newColor != null) { fColorValue = newColor; updateColorImage(); } notifyParent(event); } }); fButton.addDisposeListener(event -> { if (fImage != null) { fImage.dispose(); fImage = null; } if (fColor != null) { fColor.dispose(); fColor = null; } }); }
Example #10
Source File: SWTColorChooser.java From tuxguitar with GNU Lesser General Public License v2.1 | 5 votes |
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 #11
Source File: FXColorPicker.java From gef with Eclipse Public License 2.0 | 5 votes |
/** * Opens a {@link ColorDialog} to let the user pick a {@link Color}. Returns * the picked {@link Color}, or <code>null</code> if no color was picked. * * @param shell * The {@link Shell} which serves as the parent for the * {@link ColorDialog}. * @param initial * The initial {@link Color} to display in the * {@link ColorDialog}. * @return The picked {@link Color}, or <code>null</code>. */ protected static Color pickColor(Shell shell, Color initial) { ColorDialog cd = new ColorDialog(shell); RGB rgb = new RGB((int) (255 * initial.getRed()), (int) (255 * initial.getGreen()), (int) (255 * initial.getBlue())); cd.setRGB(rgb); RGB newRgb = cd.open(); if (newRgb != null) { return Color.rgb(newRgb.red, newRgb.green, newRgb.blue); } return null; }
Example #12
Source File: EditingPane.java From pmTrans with GNU Lesser General Public License v3.0 | 5 votes |
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 #13
Source File: EditingPane.java From pmTrans with GNU Lesser General Public License v3.0 | 5 votes |
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 #14
Source File: DecoratedStringChooser.java From elexis-3-core with Eclipse Public License 1.0 | 4 votes |
public DecoratedStringChooser(Composite parent, final Settings cfg, final DecoratedString[] strings){ super(parent, SWT.BORDER); int num = strings.length; int typRows = ((int) Math.sqrt(num)); int typCols = typRows + (num - (typRows * typRows)); if (typCols < 4) { typCols = 4; } setLayout(new GridLayout(typCols, true)); Label expl = new Label(this, SWT.WRAP); expl.setText(Messages.DecoratedStringChooser_howToChange); //$NON-NLS-1$ expl.setLayoutData(SWTHelper.getFillGridData(typCols, false, 1, false)); for (int i = 0; i < num; i++) { Label lab = new Label(this, SWT.NONE); lab.setText(strings[i].getText()); lab.setData(strings[i].getValue()); String coldesc; if(strings[i].getValue() != null) { coldesc = cfg.get(strings[i].getValue(), "FFFFFF"); //$NON-NLS-1$ } else { coldesc = cfg.get(strings[i].getText(), "FFFFFF"); //$NON-NLS-1$ } Color background = UiDesk.getColorFromRGB(coldesc); lab.setBackground(background); GridData gd = new GridData(GridData.FILL_BOTH); lab.setLayoutData(gd); lab.addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e){ ColorDialog cd = new ColorDialog(getShell()); Label l = (Label) e.getSource(); RGB selected = cd.open(); if (selected != null) { String symbolic = UiDesk.createColor(selected); l.setBackground(UiDesk.getColorFromRGB(symbolic)); if(l.getData() != null) { cfg.set((String) l.getData(), symbolic); } else { cfg.set(l.getText(), symbolic); } } } }); } }
Example #15
Source File: SWTOtherEditor.java From buffer_bci with GNU General Public License v3.0 | 4 votes |
/** * Creates a new instance. * * @param parent the parent. * @param style the style. * @param chart the chart. */ public SWTOtherEditor(Composite parent, int style, JFreeChart chart) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; setLayout(layout); Group general = new Group(this, SWT.NONE); general.setLayout(new GridLayout(3, false)); general.setText(localizationResources.getString("General")); // row 1: antialiasing this.antialias = new Button(general, SWT.CHECK); this.antialias.setText(localizationResources.getString( "Draw_anti-aliased")); this.antialias.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1)); this.antialias.setSelection(chart.getAntiAlias()); //row 2: background paint for the chart new Label(general, SWT.NONE).setText(localizationResources.getString( "Background_paint")); this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), chart.getBackgroundPaint())); GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); bgGridData.heightHint = 20; this.backgroundPaintCanvas.setLayoutData(bgGridData); Button selectBgPaint = new Button(general, SWT.PUSH); selectBgPaint.setText(localizationResources.getString("Select...")); selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectBgPaint.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString( "Background_paint")); dlg.setRGB(SWTOtherEditor.this.backgroundPaintCanvas .getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTOtherEditor.this.backgroundPaintCanvas.setColor( new Color(getDisplay(), rgb)); } } } ); }
Example #16
Source File: ComboBoxColorCellEditor.java From birt with Eclipse Public License 1.0 | 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; }
Example #17
Source File: SWTOtherEditor.java From openstock with GNU General Public License v3.0 | 4 votes |
/** * Creates a new instance. * * @param parent the parent. * @param style the style. * @param chart the chart. */ public SWTOtherEditor(Composite parent, int style, JFreeChart chart) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; setLayout(layout); Group general = new Group(this, SWT.NONE); general.setLayout(new GridLayout(3, false)); general.setText(localizationResources.getString("General")); // row 1: antialiasing this.antialias = new Button(general, SWT.CHECK); this.antialias.setText(localizationResources.getString( "Draw_anti-aliased")); this.antialias.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1)); this.antialias.setSelection(chart.getAntiAlias()); //row 2: background paint for the chart new Label(general, SWT.NONE).setText(localizationResources.getString( "Background_paint")); this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), chart.getBackgroundPaint())); GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); bgGridData.heightHint = 20; this.backgroundPaintCanvas.setLayoutData(bgGridData); Button selectBgPaint = new Button(general, SWT.PUSH); selectBgPaint.setText(localizationResources.getString("Select...")); selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectBgPaint.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString( "Background_paint")); dlg.setRGB(SWTOtherEditor.this.backgroundPaintCanvas .getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTOtherEditor.this.backgroundPaintCanvas.setColor( new Color(getDisplay(), rgb)); } } } ); }
Example #18
Source File: SWTOtherEditor.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Creates a new instance. * * @param parent the parent. * @param style the style. * @param chart the chart. */ public SWTOtherEditor(Composite parent, int style, JFreeChart chart) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; setLayout(layout); Group general = new Group(this, SWT.NONE); general.setLayout(new GridLayout(3, false)); general.setText(localizationResources.getString("General")); // row 1: antialiasing this.antialias = new Button(general, SWT.CHECK); this.antialias.setText(localizationResources.getString( "Draw_anti-aliased")); this.antialias.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1)); this.antialias.setSelection(chart.getAntiAlias()); //row 2: background paint for the chart new Label(general, SWT.NONE).setText(localizationResources.getString( "Background_paint")); this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), chart.getBackgroundPaint())); GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); bgGridData.heightHint = 20; this.backgroundPaintCanvas.setLayoutData(bgGridData); Button selectBgPaint = new Button(general, SWT.PUSH); selectBgPaint.setText(localizationResources.getString("Select...")); selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectBgPaint.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString( "Background_paint")); dlg.setRGB(SWTOtherEditor.this.backgroundPaintCanvas .getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTOtherEditor.this.backgroundPaintCanvas.setColor( new Color(getDisplay(), rgb)); } } } ); }
Example #19
Source File: SWTOtherEditor.java From astor with GNU General Public License v2.0 | 4 votes |
/** * Creates a new instance. * * @param parent the parent. * @param style the style. * @param chart the chart. */ public SWTOtherEditor(Composite parent, int style, JFreeChart chart) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; setLayout(layout); Group general = new Group(this, SWT.NONE); general.setLayout(new GridLayout(3, false)); general.setText(localizationResources.getString("General")); // row 1: antialiasing this.antialias = new Button(general, SWT.CHECK); this.antialias.setText(localizationResources.getString( "Draw_anti-aliased")); this.antialias.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1)); this.antialias.setSelection(chart.getAntiAlias()); //row 2: background paint for the chart new Label(general, SWT.NONE).setText(localizationResources.getString( "Background_paint")); this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), chart.getBackgroundPaint())); GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); bgGridData.heightHint = 20; this.backgroundPaintCanvas.setLayoutData(bgGridData); Button selectBgPaint = new Button(general, SWT.PUSH); selectBgPaint.setText(localizationResources.getString("Select...")); selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectBgPaint.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString( "Background_paint")); dlg.setRGB(SWTOtherEditor.this.backgroundPaintCanvas .getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTOtherEditor.this.backgroundPaintCanvas.setColor( new Color(getDisplay(), rgb)); } } } ); }
Example #20
Source File: SWTOtherEditor.java From ECG-Viewer with GNU General Public License v2.0 | 4 votes |
/** * Creates a new instance. * * @param parent the parent. * @param style the style. * @param chart the chart. */ public SWTOtherEditor(Composite parent, int style, JFreeChart chart) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; setLayout(layout); Group general = new Group(this, SWT.NONE); general.setLayout(new GridLayout(3, false)); general.setText(localizationResources.getString("General")); // row 1: antialiasing this.antialias = new Button(general, SWT.CHECK); this.antialias.setText(localizationResources.getString( "Draw_anti-aliased")); this.antialias.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1)); this.antialias.setSelection(chart.getAntiAlias()); //row 2: background paint for the chart new Label(general, SWT.NONE).setText(localizationResources.getString( "Background_paint")); this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), chart.getBackgroundPaint())); GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); bgGridData.heightHint = 20; this.backgroundPaintCanvas.setLayoutData(bgGridData); Button selectBgPaint = new Button(general, SWT.PUSH); selectBgPaint.setText(localizationResources.getString("Select...")); selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectBgPaint.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString( "Background_paint")); dlg.setRGB(SWTOtherEditor.this.backgroundPaintCanvas .getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTOtherEditor.this.backgroundPaintCanvas.setColor( new Color(getDisplay(), rgb)); } } } ); }
Example #21
Source File: ThemePreferencePage.java From APICloud-Studio with GNU General Public License v3.0 | 4 votes |
private void createButton(final Table table, final TableItem tableItem, final int index, final RGBa color) { TableEditor editor = new TableEditor(table); Button button = new Button(table, SWT.PUSH | SWT.FLAT); Image image = createColorImage(table, color); button.setImage(image); button.pack(); editor.minimumWidth = button.getSize().x - 4; editor.horizontalAlignment = SWT.CENTER; editor.setEditor(button, tableItem, index); fTableEditors.add(editor); button.setData("color", color); //$NON-NLS-1$ button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { ColorDialog colorDialog = new ColorDialog(table.getShell()); Button self = ((Button) e.widget); RGBa theColor = (RGBa) self.getData("color"); //$NON-NLS-1$ if (theColor == null) { theColor = color; } colorDialog.setRGB(theColor.toRGB()); RGB newRGB = colorDialog.open(); if (newRGB == null) { return; } ThemeRule token = (ThemeRule) tableItem.getData(); RGBa newColor = new RGBa(newRGB); if (index == 1) { getTheme().updateRule(table.indexOf(tableItem), token.updateFG(newColor)); } else { getTheme().updateRule(table.indexOf(tableItem), token.updateBG(newColor)); } // Update the image for this button! self.setImage(createColorImage(table, newColor)); self.setData("color", newColor); //$NON-NLS-1$ tableViewer.refresh(); } }); // Allow dragging the button out of it's location to remove the fg/bg for the rule! Transfer[] types = new Transfer[] { TextTransfer.getInstance() }; final DragSource source = new DragSource(button, DND.DROP_MOVE); source.setTransfer(types); source.addDragListener(new DragSourceAdapter() { public void dragSetData(DragSourceEvent event) { event.data = "button:" + table.indexOf(tableItem) + ":" + index; //$NON-NLS-1$ //$NON-NLS-2$ } }); }
Example #22
Source File: SWTChartEditor.java From gama with GNU General Public License v3.0 | 4 votes |
/** * Creates a new instance. * * @param parent * the parent. * @param style * the style. * @param chart * the chart. */ public SWTOtherEditor(final Composite parent, final int style, final JFreeChart chart) { super(parent, style); final FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; setLayout(layout); final Group general = new Group(this, SWT.NONE); general.setLayout(new GridLayout(3, false)); general.setText("General"); // row 1: antialiasing this.antialias = new Button(general, SWT.CHECK); this.antialias.setText("Draw anti-aliased"); this.antialias.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1)); this.antialias.setSelection(chart.getAntiAlias()); // row 2: background paint for the chart new Label(general, SWT.NONE).setText("Background paint"); this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, GraphicsHelper.toSwtColor(getDisplay(), chart.getBackgroundPaint())); final GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); bgGridData.heightHint = 20; this.backgroundPaintCanvas.setLayoutData(bgGridData); final Button selectBgPaint = new Button(general, SWT.PUSH); selectBgPaint.setText("Select..."); selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectBgPaint.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { final ColorDialog dlg = new ColorDialog(getShell()); dlg.setText("Background_paint"); dlg.setRGB(SWTOtherEditor.this.backgroundPaintCanvas.getColor().getRGB()); final RGB rgb = dlg.open(); if (rgb != null) { SWTOtherEditor.this.backgroundPaintCanvas.setColor(new Color(getDisplay(), rgb)); } } }); }
Example #23
Source File: SWTOtherEditor.java From SIMVA-SoS with Apache License 2.0 | 4 votes |
/** * Creates a new instance. * * @param parent the parent. * @param style the style. * @param chart the chart. */ public SWTOtherEditor(Composite parent, int style, JFreeChart chart) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; setLayout(layout); Group general = new Group(this, SWT.NONE); general.setLayout(new GridLayout(3, false)); general.setText(localizationResources.getString("General")); // row 1: antialiasing this.antialias = new Button(general, SWT.CHECK); this.antialias.setText(localizationResources.getString( "Draw_anti-aliased")); this.antialias.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1)); this.antialias.setSelection(chart.getAntiAlias()); //row 2: background paint for the chart new Label(general, SWT.NONE).setText(localizationResources.getString( "Background_paint")); this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), chart.getBackgroundPaint())); GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); bgGridData.heightHint = 20; this.backgroundPaintCanvas.setLayoutData(bgGridData); Button selectBgPaint = new Button(general, SWT.PUSH); selectBgPaint.setText(localizationResources.getString("Select...")); selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectBgPaint.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString( "Background_paint")); dlg.setRGB(SWTOtherEditor.this.backgroundPaintCanvas .getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTOtherEditor.this.backgroundPaintCanvas.setColor( new Color(getDisplay(), rgb)); } } } ); }
Example #24
Source File: SWTOtherEditor.java From ccu-historian with GNU General Public License v3.0 | 4 votes |
/** * Creates a new instance. * * @param parent the parent. * @param style the style. * @param chart the chart. */ public SWTOtherEditor(Composite parent, int style, JFreeChart chart) { super(parent, style); FillLayout layout = new FillLayout(); layout.marginHeight = layout.marginWidth = 4; setLayout(layout); Group general = new Group(this, SWT.NONE); general.setLayout(new GridLayout(3, false)); general.setText(localizationResources.getString("General")); // row 1: antialiasing this.antialias = new Button(general, SWT.CHECK); this.antialias.setText(localizationResources.getString( "Draw_anti-aliased")); this.antialias.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 3, 1)); this.antialias.setSelection(chart.getAntiAlias()); //row 2: background paint for the chart new Label(general, SWT.NONE).setText(localizationResources.getString( "Background_paint")); this.backgroundPaintCanvas = new SWTPaintCanvas(general, SWT.NONE, SWTUtils.toSwtColor(getDisplay(), chart.getBackgroundPaint())); GridData bgGridData = new GridData(SWT.FILL, SWT.CENTER, true, false); bgGridData.heightHint = 20; this.backgroundPaintCanvas.setLayoutData(bgGridData); Button selectBgPaint = new Button(general, SWT.PUSH); selectBgPaint.setText(localizationResources.getString("Select...")); selectBgPaint.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, false, false)); selectBgPaint.addSelectionListener( new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { ColorDialog dlg = new ColorDialog(getShell()); dlg.setText(localizationResources.getString( "Background_paint")); dlg.setRGB(SWTOtherEditor.this.backgroundPaintCanvas .getColor().getRGB()); RGB rgb = dlg.open(); if (rgb != null) { SWTOtherEditor.this.backgroundPaintCanvas.setColor( new Color(getDisplay(), rgb)); } } } ); }