List of usage examples for org.eclipse.jface.preference ColorSelector getButton
public Button getButton()
From source file:com.byterefinery.rmbench.preferences.DDLSourcePreferencePage.java
License:Open Source License
protected void computeButtonSize(ColorSelector selector) { GridData gd = new GridData(); int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); gd.widthHint = Math.max(widthHint, selector.getButton().computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); selector.getButton().setLayoutData(gd); }
From source file:com.siteview.mde.internal.ui.preferences.SyntaxColorTab.java
License:Open Source License
private void createElementTable(Composite parent) { Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, true); layout.marginWidth = layout.marginHeight = 0; container.setLayout(layout);/* w w w . ja v a 2s .co m*/ container.setLayoutData(new GridData(GridData.FILL_BOTH)); Label label = new Label(container, SWT.LEFT); label.setText(MDEUIMessages.SyntaxColorTab_elements); GridData gd = new GridData(); gd.horizontalSpan = 2; label.setLayoutData(gd); fElementViewer = new TableViewer(container, SWT.SINGLE | SWT.V_SCROLL | SWT.BORDER); fElementViewer.setLabelProvider(new LabelProvider()); fElementViewer.setContentProvider(ArrayContentProvider.getInstance()); fElementViewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); Composite colorComposite = new Composite(container, SWT.NONE); colorComposite.setLayout(new GridLayout(2, false)); colorComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); label = new Label(colorComposite, SWT.LEFT); label.setText(MDEUIMessages.SyntaxColorTab_color); final ColorSelector colorSelector = new ColorSelector(colorComposite); Button colorButton = colorSelector.getButton(); colorButton.setLayoutData(new GridData(GridData.BEGINNING)); colorButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ColorElement item = getColorElement(fElementViewer); item.setColorValue(colorSelector.getColorValue()); } }); fBoldButton = new Button(colorComposite, SWT.CHECK); gd = new GridData(); gd.horizontalSpan = 2; fBoldButton.setLayoutData(gd); fBoldButton.setText(MDEUIMessages.SyntaxColorTab_bold); fBoldButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ColorElement item = getColorElement(fElementViewer); item.setBold(fBoldButton.getSelection()); } }); fItalicButton = new Button(colorComposite, SWT.CHECK); gd = new GridData(); gd.horizontalSpan = 2; fItalicButton.setLayoutData(gd); fItalicButton.setText(MDEUIMessages.SyntaxColorTab_italic); fItalicButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ColorElement item = getColorElement(fElementViewer); item.setItalic(fItalicButton.getSelection()); } }); fElementViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { ColorElement item = getColorElement(fElementViewer); colorSelector.setColorValue(item.getColorValue()); fBoldButton.setSelection(item.isBold()); fItalicButton.setSelection(item.isItalic()); } }); fElementViewer.setInput(getColorData()); fElementViewer.setComparator(new ViewerComparator()); fElementViewer.setSelection(new StructuredSelection(fElementViewer.getElementAt(0))); }
From source file:de.byteholder.geoclipse.mapprovider.DialogMPProfile.java
License:Open Source License
private ColorSelector createUIColorSelector(final Composite parent, final IPropertyChangeListener colorListener, final GridDataFactory gd) { final ColorSelector colorSelector = new ColorSelector(parent); colorSelector.addListener(colorListener); gd.applyTo(colorSelector.getButton()); return colorSelector; }
From source file:de.byteholder.geoclipse.mapprovider.DialogMPProfile.java
License:Open Source License
/** * @param colorSelector/*w w w. j ava 2 s . co m*/ * @return Returns the color value of the {@link ColorSelector} or -1 when the color is black */ private int getColorValue(final ColorSelector colorSelector) { final RGB rgb = colorSelector.getColorValue(); colorSelector.getButton().setToolTipText(rgb.toString()); final int colorValue = ((rgb.red & 0xFF) << 0) | ((rgb.green & 0xFF) << 8) | ((rgb.blue & 0xFF) << 16); return colorValue == 0 ? -1 : colorValue; }
From source file:de.byteholder.geoclipse.mapprovider.DialogMPProfile.java
License:Open Source License
private void setColorValue(final ColorSelector colorSelector, int colorValue) { if (colorValue == -1) { colorValue = 0;//from www.j a va 2 s .c o m } final RGB rgb = getRGB(colorValue); colorSelector.setColorValue(rgb); colorSelector.getButton().setToolTipText(rgb.toString()); }
From source file:de.walware.ecommons.preferences.ui.ColorSelectorObservableValue.java
License:Open Source License
/** * @param selector/* w w w. j ava 2 s. c o m*/ */ public ColorSelectorObservableValue(final ColorSelector selector) { super(selector.getButton()); fSelector = selector; fSelector.addListener(fUpdateListener); }
From source file:eu.geclipse.traceview.preferences.EventPreferenceEditor.java
License:Open Source License
/** * Creates a new EventSubTypePreferenceEditor * // w ww . j a va 2s .c om * @param composite * @param label * @param preference */ public EventPreferenceEditor(final Composite composite, final String label, final String preference) { this.label = label; this.preference = preference; this.store = Activator.getDefault().getPreferenceStore(); // Label Label name = new Label(composite, SWT.NONE); name.setText(label); // ColorSelector ColorSelector colorSelector = new ColorSelector(composite); colorSelector .setColorValue(PreferenceConverter.getColor(this.store, preference + PreferenceConstants.P_COLOR)); GridData gd = new GridData(); gd.widthHint = 32; gd.heightHint = 16; colorSelector.getButton().setLayoutData(gd); colorSelector.addListener(new IPropertyChangeListener() { public void propertyChange(final PropertyChangeEvent event) { handleColorPropertyChangeEvent(event); } }); // CheckBox this.drawButton = new Button(composite, SWT.CHECK); this.drawButton.setSelection(this.store.getBoolean(preference + PreferenceConstants.P_DRAW)); this.drawButton.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { handleDrawPropertyChangeEvent(); } }); // ColorSelector colorSelector = new ColorSelector(composite); colorSelector.setColorValue( PreferenceConverter.getColor(this.store, preference + PreferenceConstants.P_FILL_COLOR)); gd = new GridData(); gd.widthHint = 32; gd.heightHint = 16; colorSelector.getButton().setLayoutData(gd); colorSelector.addListener(new IPropertyChangeListener() { public void propertyChange(final PropertyChangeEvent event) { handleFillColorPropertyChangeEvent(event); } }); // CheckBox this.button = new Button(composite, SWT.CHECK); this.button.setSelection(this.store.getBoolean(preference + PreferenceConstants.P_FILL)); this.button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { handleFillPropertyChangeEvent(); } }); // Type Combo this.combo = new Combo(composite, SWT.READ_ONLY); // int selection = this.store.getInt( this.name + PreferenceConstants.shape // ); int selection = 0; switch (selection) { case IEventMarker.No_Event: selection = 0; break; case IEventMarker.Rectangle_Event: selection = 1; break; case IEventMarker.Ellipse_Event: selection = 2; break; case IEventMarker.Cross_Event: selection = 3; break; case IEventMarker.Triangle_Event: selection = 4; break; case IEventMarker.Diamond_Event: selection = 5; break; default: selection = 0; } this.combo.setItems(new String[] { "None", //$NON-NLS-1$ "Rectangle", //$NON-NLS-1$ "Circle", //$NON-NLS-1$ "Cross", //$NON-NLS-1$ "Triangle", //$NON-NLS-1$ "Diamond" //$NON-NLS-1$ }); this.combo.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { handleSelectionEvent2(); } }); this.combo.select(selection); }
From source file:eu.geclipse.traceview.preferences.PreferencesPage.java
License:Open Source License
private void createMessagesGroup(final Composite composite) { GridLayout layout = new GridLayout(); layout.numColumns = 2;// w w w.j a v a 2 s . c om GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, false); Group messageGroup = new Group(composite, SWT.NONE); messageGroup.setLayout(layout); messageGroup.setLayoutData(layoutData); messageGroup.setText(Messages.getString("PreferencePage.Messages")); //$NON-NLS-1$ // Label Label name = new Label(messageGroup, SWT.NONE); name.setText(Messages.getString("PreferencePage.Message")); //$NON-NLS-1$ // ColorSelector ColorSelector colorSelector = new ColorSelector(messageGroup); colorSelector.setColorValue(PreferenceConverter.getColor(this.store, PreferenceConstants.P_MESSAGE + PreferenceConstants.P_COLOR)); GridData gd = new GridData(); gd.widthHint = 32; gd.heightHint = 16; colorSelector.getButton().setLayoutData(gd); colorSelector.addListener(new IPropertyChangeListener() { public void propertyChange(final PropertyChangeEvent event) { if (event.getNewValue() instanceof RGB) { RGB rgb = (RGB) event.getNewValue(); PreferenceConverter.setValue(PreferencesPage.this.store, PreferenceConstants.P_MESSAGE + PreferenceConstants.P_COLOR, rgb); } } }); }
From source file:eu.geclipse.traceview.preferences.PreferencesPage.java
License:Open Source License
private void createSettingsGroup(final Composite composite) { GridLayout layout = new GridLayout(); layout.numColumns = 2;// w w w . j av a 2 s . c om GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, false); Group settingsGroup = new Group(composite, SWT.NONE); settingsGroup.setLayout(layout); settingsGroup.setLayoutData(layoutData); settingsGroup.setText(Messages.getString("PreferencePage.Settings")); //$NON-NLS-1$ // CheckBox layoutData = new GridData(SWT.FILL, SWT.FILL, true, false); layoutData.horizontalSpan = 2; this.button = new Button(settingsGroup, SWT.CHECK); this.button.setText(Messages.getString("PreferencePage.AntiAliasing")); //$NON-NLS-1$ this.button.setSelection(this.store.getBoolean(PreferenceConstants.P_ANTI_ALIASING)); this.button.setLayoutData(layoutData); this.button.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent event) { PreferencesPage.this.store.setValue(PreferenceConstants.P_ANTI_ALIASING, PreferencesPage.this.button.getSelection()); } }); // Selection Color Label name = new Label(settingsGroup, SWT.NONE); name.setText(Messages.getString("PreferencePage.SelectionColor")); //$NON-NLS-1$ // ColorSelector ColorSelector colorSelector = new ColorSelector(settingsGroup); colorSelector .setColorValue(PreferenceConverter.getColor(this.store, PreferenceConstants.P_SELECTION_COLOR)); GridData gd = new GridData(); gd.widthHint = 32; gd.heightHint = 16; colorSelector.getButton().setLayoutData(gd); colorSelector.addListener(new IPropertyChangeListener() { public void propertyChange(final PropertyChangeEvent event) { if (event.getNewValue() instanceof RGB) { RGB rgb = (RGB) event.getNewValue(); PreferenceConverter.setValue(PreferencesPage.this.store, PreferenceConstants.P_SELECTION_COLOR, rgb); } } }); }
From source file:eu.hydrologis.jgrass.annotationlayer.AnnotationsPropertiesView.java
License:Open Source License
public void createPartControl(Composite parent) { Composite propsComposite = new Composite(parent, SWT.None); propsComposite.setLayout(new RowLayout()); propsComposite.setLayoutData(//w ww. ja v a2 s. com new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL)); // stroke width Image img1 = AbstractUIPlugin .imageDescriptorFromPlugin(BeegisUtilsPlugin.PLUGIN_ID, "/icons/strokewidth_1.png").createImage(); Image img2 = AbstractUIPlugin .imageDescriptorFromPlugin(BeegisUtilsPlugin.PLUGIN_ID, "/icons/strokewidth_2.png").createImage(); Image img3 = AbstractUIPlugin .imageDescriptorFromPlugin(BeegisUtilsPlugin.PLUGIN_ID, "/icons/strokewidth_3.png").createImage(); Image img4 = AbstractUIPlugin .imageDescriptorFromPlugin(BeegisUtilsPlugin.PLUGIN_ID, "/icons/strokewidth_4.png").createImage(); Image img5 = AbstractUIPlugin .imageDescriptorFromPlugin(BeegisUtilsPlugin.PLUGIN_ID, "/icons/strokewidth_5.png").createImage(); Composite strokeComposite = new Composite(propsComposite, SWT.None); strokeComposite.setLayout(new GridLayout(2, false)); final ImageCombo strokeWidthCombo = new ImageCombo(strokeComposite, SWT.READ_ONLY); GridData gridDataWidth = new GridData(SWT.FILL, SWT.FILL, true, true); gridDataWidth.widthHint = 30; strokeWidthCombo.setLayoutData(gridDataWidth); strokeWidthCombo.add("1", img1); strokeWidthCombo.add("2", img2); strokeWidthCombo.add("3", img3); strokeWidthCombo.add("4", img4); strokeWidthCombo.add("5", img5); strokeWidthCombo.select(0); strokeWidthCombo.setToolTipText("stroke width"); strokeWidthCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selectedIndex = strokeWidthCombo.getSelectionIndex(); int strokeWidth = STROKES[selectedIndex]; AnnotationPlugin.getDefault().setCurrentStrokeWidth(strokeWidth); double scale = ApplicationGIS.getActiveMap().getViewportModel().getScaleDenominator(); AnnotationPlugin.getDefault().setCurrentScale(scale); } }); // alpha final Combo alphaCombo = new Combo(strokeComposite, SWT.DROP_DOWN | SWT.READ_ONLY); GridData gridData2 = new GridData(SWT.FILL, SWT.FILL, true, true); alphaCombo.setLayoutData(gridData2); String[] items = new String[ALPHAS.length]; for (int i = 0; i < items.length; i++) { items[i] = ALPHAS[i] + "%"; } alphaCombo.setItems(items); alphaCombo.select(ALPHAS.length - 1); alphaCombo.setToolTipText("stroke alpha"); alphaCombo.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { int selectedIndex = alphaCombo.getSelectionIndex(); int alphaInPercent = ALPHAS[selectedIndex]; int strokeAlpha = 255 * alphaInPercent / 100; Color c = AnnotationPlugin.getDefault().getCurrentStrokeColor(); AnnotationPlugin.getDefault() .setCurrentStrokeColor(new Color(c.getRed(), c.getGreen(), c.getBlue(), strokeAlpha)); } }); // color // final Label strokeColLabel = new Label(propsComposite, SWT.NONE); // strokeColLabel.setText("Stroke color"); final ColorSelector cs = new ColorSelector(propsComposite); RowData rd1 = new RowData(); rd1.height = 30; rd1.width = 50; cs.getButton().setLayoutData(rd1); // new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL)); int[] cc = AnnotationPlugin.getDefault().getCurrentStrokeColorInt(); cs.setColorValue(new RGB(cc[0], cc[1], cc[2])); cs.getButton().setToolTipText("stroke color"); cs.getButton().addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { RGB rgb = cs.getColorValue(); int alpha = AnnotationPlugin.getDefault().getCurrentStrokeColorInt()[3]; AnnotationPlugin.getDefault().setCurrentStrokeColor(new Color(rgb.red, rgb.green, rgb.blue, alpha)); } }); // clear all ImageDescriptor clearID = AbstractUIPlugin.imageDescriptorFromPlugin(AnnotationPlugin.PLUGIN_ID, "icons/trash.gif"); //$NON-NLS-1$ final Button clearButton = new Button(propsComposite, SWT.PUSH); // GridData gd1 = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); // clearButton.setLayoutData(gd1); RowData rd2 = new RowData(); rd2.height = 30; rd2.width = 50; clearButton.setLayoutData(rd2); clearButton.setImage(clearID.createImage()); clearButton.setToolTipText("clear the area from all drawings"); clearButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean answer = MessageDialog.openQuestion(clearButton.getShell(), "Removal warning", "Do you really want to remove all annotations?"); if (!answer) { return; } AnnotationPlugin.getDefault().getStrokes().clear(); JGrassCatalogUtilities.getMapgraphicLayerByClass(AnnotationLayerMapGraphic.class).refresh(null); } }); // clear last ImageDescriptor clearLast = AbstractUIPlugin.imageDescriptorFromPlugin(AnnotationPlugin.PLUGIN_ID, "icons/trashlast.gif"); //$NON-NLS-1$ Button clearLastButton = new Button(propsComposite, SWT.PUSH); RowData rd3 = new RowData(); rd3.height = 30; rd3.width = 50; clearLastButton.setLayoutData(rd3); // GridData gd2 = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL); // clearLastButton.setLayoutData(gd2); clearLastButton.setImage(clearLast.createImage()); clearLastButton.setToolTipText("remove last stroke from annotations layer"); clearLastButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { List<DressedWorldStroke> strokes = AnnotationPlugin.getDefault().getStrokes(); int size = strokes.size(); if (size < 1) return; strokes.remove(size - 1); JGrassCatalogUtilities.getMapgraphicLayerByClass(AnnotationLayerMapGraphic.class).refresh(null); } }); }