List of usage examples for org.eclipse.jface.preference ColorSelector ColorSelector
public ColorSelector(Composite parent)
Composite. From source file:ar.com.tadp.xml.rinzo.core.preferences.ColorChooser.java
License:Open Source License
public void initGUI() { try {//from w ww.j a v a 2 s.c o m label = new Label(this, 0); changeControl = new ColorSelector(this); setSize(new Point(87, 25)); GridData label1LData = new GridData(); label1LData.verticalAlignment = 2; label1LData.horizontalAlignment = 2; label1LData.widthHint = -1; label1LData.heightHint = -1; label1LData.horizontalIndent = 0; label1LData.horizontalSpan = 1; label1LData.verticalSpan = 1; label1LData.grabExcessHorizontalSpace = false; label1LData.grabExcessVerticalSpace = false; label.setLayoutData(label1LData); label.setText("Color: "); GridData griddata = new GridData(30, 20); griddata.horizontalAlignment = 1; label = new Label(this, 0); label.setText("Bold:"); label.setLayoutData(griddata); bold = new Button(this, SWT.CHECK); bold.setLayoutData(griddata); GridData changeControlLData = new GridData(); changeControlLData.verticalAlignment = 2; changeControlLData.horizontalAlignment = 1; changeControlLData.widthHint = -1; changeControlLData.heightHint = -1; changeControlLData.horizontalIndent = 0; changeControlLData.horizontalSpan = 1; changeControlLData.verticalSpan = 1; changeControlLData.grabExcessHorizontalSpace = false; changeControlLData.grabExcessVerticalSpace = false; changeControl.getButton().setLayoutData(changeControlLData); GridLayout thisLayout = new GridLayout(2, true); thisLayout.marginWidth = 1; thisLayout.marginHeight = 1; thisLayout.numColumns = 2; thisLayout.makeColumnsEqualWidth = false; thisLayout.horizontalSpacing = 5; thisLayout.verticalSpacing = 5; setLayout(thisLayout); layout(); } catch (Exception e) { e.printStackTrace(); } }
From source file:au.gov.ga.earthsci.common.ui.color.ColorMapEditor.java
License:Apache License
/** * Add the entry editor area. Allows users to edit: * <ul>//from w ww . java 2 s . com * <li>Value * <li>Colour * <li>Transparency * </ul> * For a single selected entry in the colour map */ private void addEntryEditor(Composite parent) { Composite editorContainer = new Composite(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; editorContainer.setLayoutData(gd); editorContainer.setLayout(new GridLayout(7, false)); Label valueLabel = new Label(editorContainer, SWT.NONE); valueLabel.setText(Messages.ColorMapEditor_EntryValueLabel); editorValueField = new NumericTextField(editorContainer, SWT.SINGLE | SWT.BORDER); editorValueField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { map.moveEntry(currentEntryValue, editorValueField.getNumber().doubleValue()); currentEntryValue = editorValueField.getNumber().doubleValue(); } }); Label colorLabel = new Label(editorContainer, SWT.NONE); colorLabel.setText(Messages.ColorMapEditor_EntryColorLabel); editorColorField = new ColorSelector(editorContainer); editorColorField.addListener(new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { updateCurrentEntryColor(); } }); Label alphaLabel = new Label(editorContainer, SWT.NONE); alphaLabel.setText(Messages.ColorMapEditor_EntryAlphaLabel); editorAlphaScale = new Scale(editorContainer, SWT.HORIZONTAL); editorAlphaScale.setMinimum(0); editorAlphaScale.setMaximum(255); editorAlphaScale.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); editorAlphaField = new NumericTextField(editorContainer, SWT.BORDER, false, false); editorAlphaField.setMinValue(0); editorAlphaField.setMaxValue(255); gd = new GridData(); gd.widthHint = 35; editorAlphaField.setLayoutData(gd); editorAlphaScale.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { updateCurrentEntryColor(); editorAlphaField.setNumber(editorAlphaScale.getSelection()); } }); editorAlphaField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { editorAlphaScale.setSelection(editorAlphaField.getNumber().intValue()); updateCurrentEntryColor(); } }); disableEntryEditor(); }
From source file:au.gov.ga.earthsci.common.ui.color.ColorMapEditor.java
License:Apache License
/** * Add an editor area for changing the NODATA colour used *//*from w w w .jav a2s .com*/ private void addNodataEditor(Composite parent) { Composite editorContainer = new Composite(parent, SWT.BORDER); GridData gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 2; editorContainer.setLayoutData(gd); editorContainer.setLayout(new GridLayout(7, false)); nodataCheckBox = new Button(editorContainer, SWT.CHECK); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalSpan = 7; nodataCheckBox.setLayoutData(gd); nodataCheckBox.setText(Messages.ColorMapEditor_NoDataOptionLabel); nodataCheckBox.setToolTipText(Messages.ColorMapEditor_NoDataOptionTooltip); nodataCheckBox.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { enableNodataEditor(nodataCheckBox.getSelection()); updateNodataColorFromEditor(); } }); Label colorLabel = new Label(editorContainer, SWT.NONE); colorLabel.setText("Color:"); //$NON-NLS-1$ nodataColorField = new ColorSelector(editorContainer); nodataColorField.addListener(new IPropertyChangeListener() { @Override public void propertyChange(PropertyChangeEvent event) { updateNodataColorFromEditor(); } }); nodataColorField.setColorValue(toRGB(Color.BLACK)); Label alphaLabel = new Label(editorContainer, SWT.NONE); alphaLabel.setText("Alpha:"); //$NON-NLS-1$ nodataAlphaScale = new Scale(editorContainer, SWT.HORIZONTAL); nodataAlphaScale.setMinimum(0); nodataAlphaScale.setMaximum(255); nodataAlphaScale.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); nodataAlphaScale.setSelection(255); nodataAlphaField = new NumericTextField(editorContainer, SWT.BORDER, false, false); nodataAlphaField.setMinValue(0); nodataAlphaField.setMaxValue(255); gd = new GridData(); gd.widthHint = 35; nodataAlphaField.setLayoutData(gd); nodataAlphaField.setNumber(255); nodataAlphaScale.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { updateNodataColorFromEditor(); nodataAlphaField.setNumber(nodataAlphaScale.getSelection()); } }); nodataAlphaField.addFocusListener(new FocusAdapter() { @Override public void focusLost(FocusEvent e) { nodataAlphaScale.setSelection(nodataAlphaField.getNumber().intValue()); updateNodataColorFromEditor(); } }); updateNodataEditorFromMap(); }
From source file:cc.warlock.rcp.stormfront.ui.prefs.PresetsPreferencePage.java
License:Open Source License
private ColorSelector colorSelectorWithLabel(Composite parent, String text) { Label label = new Label(parent, SWT.NONE); label.setText(text);/* ww w .ja v a 2s.co m*/ ColorSelector selector = new ColorSelector(parent); selector.addListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { colorChanged((ColorSelector) event.getSource(), (RGB) event.getNewValue()); } }); return selector; }
From source file:ccw.preferences.SyntaxColoringPreferencePage.java
License:Open Source License
private Control createSyntaxPage(final Composite parent) { fOverlayStore.load();/*from w ww . j av a 2s.c om*/ fOverlayStore.start(); Composite colorComposite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; colorComposite.setLayout(layout); Link link = new Link(colorComposite, SWT.NONE); link.setText(Messages.SyntaxColoringPreferencePage_link); link.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { PreferencesUtil.createPreferenceDialogOn(parent.getShell(), e.text, null, null); } }); // TODO replace by link-specific tooltips when // bug https://bugs.eclipse.org/bugs/show_bug.cgi?id=88866 gets fixed // link.setToolTipText(Messages.JavaEditorColoringConfigurationBlock_link_tooltip); GridData gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false); gridData.widthHint = 150; // only expand further if anyone else requires it gridData.horizontalSpan = 2; link.setLayoutData(gridData); Label label; label = new Label(colorComposite, SWT.LEFT); label.setText(Messages.SyntaxColoringPreferencePage_coloring_element); label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Composite editorComposite = new Composite(colorComposite, SWT.NONE); layout = new GridLayout(); layout.numColumns = 2; layout.marginHeight = 0; layout.marginWidth = 0; editorComposite.setLayout(layout); GridData gd = new GridData(SWT.FILL, SWT.BEGINNING, true, false); editorComposite.setLayoutData(gd); fListViewer = new ListViewer(editorComposite, SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL); fListViewer.setLabelProvider(new ColorListLabelProvider()); fListViewer.setContentProvider(new ColorListContentProvider()); fListViewer.setInput(fListModel); gd = new GridData(SWT.BEGINNING, SWT.BEGINNING, false, true); gd.heightHint = convertHeightInCharsToPixels(30); int maxWidth = 0; for (Iterator<HighlightingColorListItem> it = fListModel.iterator(); it.hasNext();) { HighlightingColorListItem item = it.next(); maxWidth = Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length())); } ScrollBar vBar = ((Scrollable) fListViewer.getControl()).getVerticalBar(); if (vBar != null) maxWidth += vBar.getSize().x * 3; // scrollbars and tree indentation guess gd.widthHint = maxWidth; fListViewer.getControl().setLayoutData(gd); Composite stylesComposite = new Composite(editorComposite, SWT.NONE); layout = new GridLayout(); layout.marginHeight = 0; layout.marginWidth = 0; layout.numColumns = 2; stylesComposite.setLayout(layout); stylesComposite.setLayoutData(new GridData(GridData.FILL_BOTH)); fEnableCheckbox = new Button(stylesComposite, SWT.CHECK); fEnableCheckbox.setText(Messages.SyntaxColoringPreferencePage_enable); gd = new GridData(GridData.FILL_HORIZONTAL); gd.horizontalAlignment = GridData.BEGINNING; gd.horizontalSpan = 2; fEnableCheckbox.setLayoutData(gd); fColorEditorLabel = new Label(stylesComposite, SWT.LEFT); fColorEditorLabel.setText(Messages.SyntaxColoringPreferencePage_color); gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); gd.horizontalIndent = 20; fColorEditorLabel.setLayoutData(gd); fSyntaxForegroundColorEditor = new ColorSelector(stylesComposite); Button foregroundColorButton = fSyntaxForegroundColorEditor.getButton(); gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); foregroundColorButton.setLayoutData(gd); fBoldCheckBox = new Button(stylesComposite, SWT.CHECK); fBoldCheckBox.setText(Messages.SyntaxColoringPreferencePage_bold); gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); gd.horizontalIndent = 20; gd.horizontalSpan = 2; fBoldCheckBox.setLayoutData(gd); fItalicCheckBox = new Button(stylesComposite, SWT.CHECK); fItalicCheckBox.setText(Messages.SyntaxColoringPreferencePage_italic); gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); gd.horizontalIndent = 20; gd.horizontalSpan = 2; fItalicCheckBox.setLayoutData(gd); /* TODO enable once text attributes are used fStrikethroughCheckBox= new Button(stylesComposite, SWT.CHECK); fStrikethroughCheckBox.setText(Messages.SyntaxColoringPreferencePage_strikethrough); gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); gd.horizontalIndent= 20; gd.horizontalSpan= 2; fStrikethroughCheckBox.setLayoutData(gd); fUnderlineCheckBox= new Button(stylesComposite, SWT.CHECK); fUnderlineCheckBox.setText(Messages.SyntaxColoringPreferencePage_underline); gd= new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); gd.horizontalIndent= 20; gd.horizontalSpan= 2; fUnderlineCheckBox.setLayoutData(gd); */ label = new Label(colorComposite, SWT.LEFT); label.setText(Messages.SyntaxColoringPreferencePage_preview); label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); Control previewer = createPreviewer(colorComposite); gd = new GridData(GridData.FILL_BOTH); gd.widthHint = convertWidthInCharsToPixels(20); gd.heightHint = convertHeightInCharsToPixels(5); previewer.setLayoutData(gd); fListViewer.addSelectionChangedListener(new ISelectionChangedListener() { public void selectionChanged(SelectionChangedEvent event) { handleSyntaxColorListSelection(); } }); foregroundColorButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item = getHighlightingColorListItem(); // TODO: remove this ? PreferenceConverter.setValue(getPreferenceStore(), item.getColorKey(), fSyntaxForegroundColorEditor.getColorValue()); PreferenceConverter.setValue(fOverlayStore, item.getColorKey(), fSyntaxForegroundColorEditor.getColorValue()); } }); fBoldCheckBox.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item = getHighlightingColorListItem(); fOverlayStore.setValue(item.getBoldKey(), fBoldCheckBox.getSelection()); } }); fItalicCheckBox.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item = getHighlightingColorListItem(); fOverlayStore.setValue(item.getItalicKey(), fItalicCheckBox.getSelection()); } }); /* fStrikethroughCheckBox.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item= getHighlightingColorListItem(); fOverlayStore.setValue(item.getStrikethroughKey(), fStrikethroughCheckBox.getSelection()); } }); fUnderlineCheckBox.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item= getHighlightingColorListItem(); fOverlayStore.setValue(item.getUnderlineKey(), fUnderlineCheckBox.getSelection()); } }); */ fEnableCheckbox.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { // do nothing } public void widgetSelected(SelectionEvent e) { HighlightingColorListItem item = getHighlightingColorListItem(); boolean enable = fEnableCheckbox.getSelection(); fOverlayStore.setValue(item.getEnableKey(), enable); fEnableCheckbox.setSelection(enable); fSyntaxForegroundColorEditor.getButton().setEnabled(enable); fColorEditorLabel.setEnabled(enable); fBoldCheckBox.setEnabled(enable); fItalicCheckBox.setEnabled(enable); /* TODO re-enable once text attributes are used fStrikethroughCheckBox.setEnabled(enable); fUnderlineCheckBox.setEnabled(enable); */ } }); colorComposite.layout(false); fListViewer.setSelection(new StructuredSelection(fListModel.get(0))); return colorComposite; }
From source file:com.aptana.ide.editors.preferences.GeneralPreferencePage.java
License:Open Source License
/** * Creates the field editors. Field editors are abstractions of the common GUI blocks needed to manipulate various * types of preferences. Each field editor knows how to save and restore itself. *//*from w ww .ja v a2s . co m*/ public void createFieldEditors() { addTab(Messages.GeneralPreferencePage_General); Composite appearanceComposite = getFieldEditorParent(); Composite group = com.aptana.ide.core.ui.preferences.GeneralPreferencePage.createGroup(appearanceComposite, Messages.GeneralPreferencePage_Formatting); Composite occurrenceComp = new Composite(group, SWT.NONE); GridLayout occLayout = new GridLayout(2, false); occLayout.marginWidth = 0; occLayout.marginHeight = 0; occurrenceComp.setLayout(occLayout); occurrenceComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); enableOccurrences = new Button(occurrenceComp, SWT.CHECK); enableOccurrences.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { occurrenceColor.setEnabled(enableOccurrences.getSelection()); } }); enableOccurrences.setSelection( getPreferenceStore().getBoolean(IPreferenceConstants.COLORIZER_TEXT_HIGHLIGHT_ENABLED)); enableOccurrences.setText(Messages.GeneralPreferencePage_MarkOccurrences); occurrenceColor = new ColorSelector(occurrenceComp); occurrenceColor.setEnabled(enableOccurrences.getSelection()); occurrenceColor.setColorValue(PreferenceConverter.getColor(getPreferenceStore(), IPreferenceConstants.COLORIZER_TEXT_HIGHLIGHT_BACKGROUND_COLOR)); // addField(new BooleanFieldEditor(IPreferenceConstants.ENABLE_WORD_WRAP, // Messages.GeneralPreferencePage_EnableWordWrap, group)); addField(new BooleanFieldEditor(IPreferenceConstants.INSERT_ON_TAB, Messages.GeneralPreferencePage_InsertSelectedProposal, group)); addField(new RadioGroupFieldEditor(AbstractTextEditor.PREFERENCE_NAVIGATION_SMART_HOME_END, Messages.GeneralPreferencePage_HomeEndBehavior, 1, new String[][] { { Messages.GeneralPreferencePage_ToggleBetween, "true" }, //$NON-NLS-1$ { Messages.GeneralPreferencePage_JumpsStartEnd, "false" } }, //$NON-NLS-1$ appearanceComposite, true)); group = com.aptana.ide.core.ui.preferences.GeneralPreferencePage.createGroup(appearanceComposite, Messages.GeneralPreferencePage_LBL_Colorization); Composite pianoKeyComp = new Composite(group, SWT.NONE); GridLayout pkcLayout = new GridLayout(3, false); pkcLayout.marginWidth = 0; pkcLayout.marginHeight = 0; pianoKeyComp.setLayout(pkcLayout); pianoKeyComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); Label pianoKeyLabel = new Label(pianoKeyComp, SWT.LEFT); pianoKeyLabel.setText(Messages.GeneralPreferencePage_LBL_PianoKeyColorDifference); GridData pklData = new GridData(SWT.FILL, SWT.FILL, true, false); pklData.horizontalSpan = 3; pianoKeyLabel.setLayoutData(pklData); Label less = new Label(pianoKeyComp, SWT.LEFT); less.setText(Messages.GeneralPreferencePage_LBL_Less); pianoKeySlider = new Scale(pianoKeyComp, SWT.HORIZONTAL); pianoKeySlider.setIncrement(5); pianoKeySlider.setMinimum(1); pianoKeySlider.setMaximum(50); pianoKeySlider.setSelection(getPreferenceStore().getInt(IPreferenceConstants.PIANO_KEY_DIFFERENCE)); Label more = new Label(pianoKeyComp, SWT.LEFT); more.setText(Messages.GeneralPreferencePage_LBL_More); Composite wsGroup = com.aptana.ide.core.ui.preferences.GeneralPreferencePage .createGroup(appearanceComposite, Messages.GeneralPreferencePage_TabInsertion); Composite wsComp = new Composite(wsGroup, SWT.NONE); GridLayout wsLayout = new GridLayout(3, false); wsLayout.marginWidth = 0; wsLayout.marginHeight = 0; wsComp.setLayout(wsLayout); wsComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); tabs = new Button(wsComp, SWT.RADIO); Composite spaceComp = new Composite(wsComp, SWT.NONE); wsLayout = new GridLayout(2, false); wsLayout.marginWidth = 0; wsLayout.marginHeight = 0; wsLayout.horizontalSpacing = 0; spaceComp.setLayout(wsLayout); spaceComp.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); spaces = new Button(spaceComp, SWT.RADIO); final Link currentTabSize = new Link(spaceComp, SWT.NONE); IPreferenceStore store = EditorsPlugin.getDefault().getPreferenceStore(); int size = store.getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH); spaces.setText(StringUtils.format(Messages.GeneralPreferencePage_UseSpaces, size)); tabs.setText(Messages.GeneralPreferencePage_UseTabs); store.addPropertyChangeListener(tabWidthListener); currentTabSize.setText(Messages.GeneralPreferencePage_EditLink); currentTabSize.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ((IWorkbenchPreferenceContainer) getContainer()) .openPage("org.eclipse.ui.preferencePages.GeneralTextEditor", null); //$NON-NLS-1$ } }); boolean useSpaces = getPreferenceStore().getBoolean(IPreferenceConstants.INSERT_SPACES_FOR_TABS); spaces.setSelection(useSpaces); tabs.setSelection(!useSpaces); tabs.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { spaces.setSelection(!tabs.getSelection()); } }); spaces.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { tabs.setSelection(!spaces.getSelection()); } }); // Link to general text editor prefs from Eclipse - they can set tabs/spaces/whitespace drawing, etc Link link = new Link(appearanceComposite, SWT.NONE); link.setText(Messages.GeneralPreferencePage_GeneralTextEditorPrefLink); link.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { ((IWorkbenchPreferenceContainer) getContainer()) .openPage("org.eclipse.ui.preferencePages.GeneralTextEditor", null); //$NON-NLS-1$ } }); addTab(Messages.GeneralPreferencePage_Advanced); appearanceComposite = getFieldEditorParent(); addField(new BooleanFieldEditor(IPreferenceConstants.ENABLE_WORD_WRAP, Messages.GeneralPreferencePage_EnableWordWrap, appearanceComposite)); appearanceComposite = getFieldEditorParent(); addField(new IntegerFieldEditor(IPreferenceConstants.COLORIZER_MAXCOLUMNS, Messages.GeneralPreferencePage_MaxColorizeColumns, appearanceComposite, 4)); group = com.aptana.ide.core.ui.preferences.GeneralPreferencePage.createGroup(appearanceComposite, Messages.GeneralPreferencePage_CodeAssist); addField(new IntegerFieldEditor(IPreferenceConstants.CONTENT_ASSIST_DELAY, Messages.GeneralPreferencePage_DelayBeforeShowing, group, 4)); }
From source file:com.aptana.ide.logging.preferences.LoggingPreferenceWidget.java
License:Open Source License
/** * Creates appearance settings./* w w w .ja va2 s .c om*/ * @param parent - parent. */ private void createAppearance(Composite parent) { final Group appearanceGroup = new Group(parent, SWT.NONE); appearanceGroup.setLayout(new GridLayout(3, false)); appearanceGroup.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); appearanceGroup.setText(Messages.LoggingPreferenceWidget_1); Label label = new Label(appearanceGroup, SWT.NONE); label.setText(Messages.LoggingPreferenceWidget_CursorLineColor_Label); cursorLineColorSelector = new ColorSelector(appearanceGroup); cursorLineColorSelector.getButton() .setLayoutData(new GridData(SWT.LEFT, GridData.CENTER, false, false, 2, 1)); cursorLineColorSelector.setEnabled(true); cursorLineColorSelector.addListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { RGB newRGB = (RGB) event.getNewValue(); if (!newRGB.equals(event.getOldValue())) { provider.setCursorLineColor(newRGB); } cursorLineColorSelector.setColorValue(newRGB); } }); label = new Label(appearanceGroup, SWT.NONE); label.setText(Messages.LoggingPreferenceWidget_TextForegroundColor_Label); textForegroundColorSelector = new ColorSelector(appearanceGroup); textForegroundColorSelector.getButton() .setLayoutData(new GridData(SWT.LEFT, GridData.CENTER, false, false, 2, 1)); textForegroundColorSelector.setEnabled(true); textForegroundColorSelector.addListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { RGB newRGB = (RGB) event.getNewValue(); if (!newRGB.equals(event.getOldValue())) { provider.setTextForegroundColor(newRGB); } textForegroundColorSelector.setColorValue(newRGB); } }); label = new Label(appearanceGroup, SWT.LEFT | SWT.CENTER); label.setText(Messages.LoggingPreferenceWidget_Font_Label); label.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); fontStyleLabel = new Label(appearanceGroup, SWT.LEFT | SWT.CENTER); fontStyleLabel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); final Button fontButton = new Button(appearanceGroup, SWT.NONE); fontButton.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { if (provider != null) { FontDialog dialog = new FontDialog(fontButton.getShell()); dialog.setFontList(getPreferences().getFontData()); if (dialog.open() != null) { FontData[] font = dialog.getFontList(); provider.setFont(font); if (font != null && font.length > 0) { String fontStr = font[0].getName() + "-" + font[0].getHeight(); //$NON-NLS-1$ fontStyleLabel.setText(fontStr); appearanceGroup.layout(true, true); } } } } }); fontButton.setLayoutData(new GridData(GridData.CENTER, GridData.CENTER, false, false)); fontButton.setText(Messages.LoggingPreferenceWidget_4); final Label charsetLabel = new Label(appearanceGroup, SWT.LEFT | SWT.CENTER); charsetLabel.setLayoutData(new GridData(GridData.FILL, GridData.CENTER, false, false)); charsetLabel.setText(Messages.LoggingPreferenceWidget_5); charsetCombo = new Combo(appearanceGroup, SWT.LEFT | SWT.CENTER | SWT.READ_ONLY); charsetCombo.setLayoutData(new GridData(SWT.LEFT, GridData.CENTER, false, false, 2, 1)); Collection<String> charsets = Charset.availableCharsets().keySet(); String[] items = new String[charsets.size()]; charsets.toArray(items); charsetCombo.setItems(items); charsetCombo.addSelectionListener(new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { if (provider != null) { String selected = charsetCombo.getItem(charsetCombo.getSelectionIndex()); provider.setDefaultEncoding(selected); } } }); }
From source file:com.aptana.ide.logging.preferences.LoggingPreferenceWidget.java
License:Open Source License
private void styleEditorOptions() { GridLayout gridLayout = new GridLayout(); gridLayout.numColumns = 1;//www . j ava 2s.c om editorExpandable = new ExpandableComposite(displayArea, SWT.NONE, ExpandableComposite.TWISTIE | ExpandableComposite.CLIENT_INDENT); editorExpandable.setText(Messages.LoggingColorizationWidget_33); editorExpandable.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, false)); editorExpandable.setLayout(gridLayout); editorExpandable.setExpanded(UnifiedEditorsPlugin.getDefault().getPreferenceStore() .getBoolean(IPreferenceConstants.EXPAND_EDITOR_OPTIONS)); editorExpandable.addExpansionListener(new ExpansionAdapter() { public void expansionStateChanged(ExpansionEvent e) { expandedStateChanged((ExpandableComposite) e.getSource()); } }); makeScrollableCompositeAware(editorExpandable); Composite inner = new Composite(editorExpandable, SWT.NONE); inner.setLayout(gridLayout); editorExpandable.setClient(inner); override = new Button(inner, SWT.CHECK); override.setEnabled(false); override.setText(Messages.LoggingColorizationWidget_34); override.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent e) { boolean isSelected = override.getSelection(); if (isSelected) { Color blackColor = UnifiedColorManager.getInstance().getColor(black); Color grayColor = UnifiedColorManager.getInstance().getColor(new RGB(139, 139, 139)); IPreferenceStore store = EditorsPlugin.getDefault().getPreferenceStore(); RGB background = PreferenceConverter.getColor(store, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND); RGB lineHighlight = PreferenceConverter.getColor(store, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_CURRENT_LINE_COLOR); RGB selectionFg = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION_TEXT) .getRGB(); RGB selectionBg = getControl().getDisplay().getSystemColor(SWT.COLOR_LIST_SELECTION).getRGB(); Color eclipseBackgroundColor = UnifiedColorManager.getInstance().getColor(background); Color eclipseLineHighlightColor = UnifiedColorManager.getInstance().getColor(lineHighlight); Color eclipseSelectionFgColor = UnifiedColorManager.getInstance().getColor(selectionFg); Color eclipseSelectionBgColor = UnifiedColorManager.getInstance().getColor(selectionBg); Color systemWidgetBGColor = getControl().getDisplay() .getSystemColor(SWT.COLOR_WIDGET_BACKGROUND); provider.setBackgroundColor(eclipseBackgroundColor); provider.setCaretColor(blackColor); provider.setLineHighlightColor(eclipseLineHighlightColor); provider.setSelectionForegroundColor(eclipseSelectionFgColor); provider.setSelectionBackgroundColor(eclipseSelectionBgColor); provider.setFoldingBackgroundColor(systemWidgetBGColor); provider.setFoldingForegroundColor(grayColor); backgroundSelector.setColorValue(provider.getBackgroundColor().getRGB()); lineHighlightSelector.setColorValue(provider.getLineHighlightColor().getRGB()); selectionForegroundSelector.setColorValue(provider.getSelectionForegroundColor().getRGB()); selectionBackgroundSelector.setColorValue(provider.getSelectionBackgroundColor().getRGB()); foldingBackgroundSelector.setColorValue(provider.getFoldingBackgroundColor().getRGB()); foldingForegroundSelector.setColorValue(provider.getFoldingForegroundColor().getRGB()); caretSelector.setColorValue(provider.getCaretColor().getRGB()); } else { provider.setBackgroundColor(null); provider.setCaretColor(null); provider.setLineHighlightColor(null); provider.setSelectionForegroundColor(null); provider.setSelectionBackgroundColor(null); provider.setFoldingBackgroundColor(null); provider.setFoldingForegroundColor(null); } backgroundSelector.setEnabled(isSelected); lineHighlightSelector.setEnabled(isSelected); selectionForegroundSelector.setEnabled(isSelected); selectionBackgroundSelector.setEnabled(isSelected); foldingBackgroundSelector.setEnabled(isSelected); foldingForegroundSelector.setEnabled(isSelected); caretSelector.setEnabled(isSelected); } }); Composite buttons = new Composite(inner, SWT.NONE); gridLayout = new GridLayout(); gridLayout.numColumns = 2; gridLayout.horizontalSpacing = 0; gridLayout.verticalSpacing = 0; gridLayout.marginRight = 0; gridLayout.marginLeft = 0; gridLayout.makeColumnsEqualWidth = true; buttons.setLayout(gridLayout); buttons.setLayoutData(new GridData(GridData.FILL, GridData.FILL, true, true)); gridLayout = new GridLayout(); gridLayout.numColumns = 2; gridLayout.marginRight = 0; gridLayout.marginLeft = 0; gridLayout.horizontalSpacing = 5; gridLayout.verticalSpacing = 0; gridLayout.makeColumnsEqualWidth = false; Composite bgComp = new Composite(buttons, SWT.NONE); bgComp.setLayout(gridLayout); bgComp.setLayoutData(new GridData(SWT.RIGHT, GridData.FILL, true, true)); Label bgLabel = new Label(bgComp, SWT.RIGHT); bgLabel.setText(Messages.LoggingColorizationWidget_35); backgroundSelector = new ColorSelector(bgComp); backgroundSelector.addListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { provider.setBackgroundColor(UnifiedColorManager.getInstance().getColor((RGB) event.getNewValue())); } }); Composite lComp = new Composite(buttons, SWT.NONE); lComp.setLayoutData(new GridData(SWT.RIGHT, GridData.FILL, true, true)); lComp.setLayout(gridLayout); Label lLabel = new Label(lComp, SWT.RIGHT); lLabel.setText(Messages.LoggingColorizationWidget_36); lineHighlightSelector = new ColorSelector(lComp); lineHighlightSelector.addListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { provider.setLineHighlightColor( UnifiedColorManager.getInstance().getColor((RGB) event.getNewValue())); } }); Composite sfComp = new Composite(buttons, SWT.NONE); sfComp.setLayoutData(new GridData(SWT.RIGHT, GridData.FILL, true, true)); sfComp.setLayout(gridLayout); Label sfLabel = new Label(sfComp, SWT.RIGHT); sfLabel.setText(Messages.LoggingColorizationWidget_37); selectionForegroundSelector = new ColorSelector(sfComp); selectionForegroundSelector.addListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { provider.setSelectionForegroundColor( UnifiedColorManager.getInstance().getColor((RGB) event.getNewValue())); } }); Composite sbComp = new Composite(buttons, SWT.NONE); sbComp.setLayoutData(new GridData(SWT.RIGHT, GridData.FILL, true, true)); sbComp.setLayout(gridLayout); Label sbLabel = new Label(sbComp, SWT.RIGHT); sbLabel.setText(Messages.LoggingColorizationWidget_38); selectionBackgroundSelector = new ColorSelector(sbComp); selectionBackgroundSelector.addListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { provider.setSelectionBackgroundColor( UnifiedColorManager.getInstance().getColor((RGB) event.getNewValue())); } }); Composite fbgComp = new Composite(buttons, SWT.NONE); fbgComp.setLayoutData(new GridData(SWT.RIGHT, GridData.FILL, true, true)); fbgComp.setLayout(gridLayout); Label fbgLabel = new Label(fbgComp, SWT.RIGHT); fbgLabel.setText(Messages.LoggingColorizationWidget_39); foldingBackgroundSelector = new ColorSelector(fbgComp); foldingBackgroundSelector.addListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { provider.setFoldingBackgroundColor( UnifiedColorManager.getInstance().getColor((RGB) event.getNewValue())); } }); Composite ffgComp = new Composite(buttons, SWT.NONE); ffgComp.setLayoutData(new GridData(SWT.RIGHT, GridData.FILL, true, true)); ffgComp.setLayout(gridLayout); Label ffgLabel = new Label(ffgComp, SWT.RIGHT); ffgLabel.setText(Messages.LoggingColorizationWidget_40); foldingForegroundSelector = new ColorSelector(ffgComp); foldingForegroundSelector.addListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { provider.setFoldingForegroundColor( UnifiedColorManager.getInstance().getColor((RGB) event.getNewValue())); } }); Composite cComp = new Composite(buttons, SWT.NONE); cComp.setLayoutData(new GridData(SWT.RIGHT, GridData.FILL, true, true)); cComp.setLayout(gridLayout); Label cLabel = new Label(cComp, SWT.RIGHT); cLabel.setText(Messages.LoggingColorizationWidget_41); caretSelector = new ColorSelector(cComp); caretSelector.addListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { provider.setCaretColor(UnifiedColorManager.getInstance().getColor((RGB) event.getNewValue())); } }); // Hide caret color option on Mac OS X since it causes cursor lag if (Platform.getOS().equals(Platform.OS_MACOSX)) { cComp.setVisible(false); } loadEditorOptions(); if (provider != null) { viewer.setContentProvider(provider); viewer.setLabelProvider(provider); initializeColorizerView(); } }
From source file:com.aptana.theme.preferences.ThemePreferencePage.java
License:Open Source License
private void createGlobalColorControls(Composite composite) { Composite colors = new Composite(composite, SWT.NONE); colors.setLayout(new GridLayout(4, false)); // TODO Make the ColorSelector buttons be SWT.FLAT, and let them handle alpha values as Textmate does Label label = new Label(colors, SWT.NONE); label.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); label.setText(Messages.ThemePreferencePage_ForegroundLabel); fgSelector = new ColorSelector(colors); fgSelector.addListener(this); label = new Label(colors, SWT.NONE); label.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); label.setText(Messages.ThemePreferencePage_SelectionLabel); selectionSelector = new ColorSelector(colors); selectionSelector.addListener(this); label = new Label(colors, SWT.NONE); label.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); label.setText(Messages.ThemePreferencePage_BackgroundLabel); bgSelector = new ColorSelector(colors); bgSelector.addListener(this); label = new Label(colors, SWT.NONE); label.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); label.setText(Messages.ThemePreferencePage_LineHighlightLabel); lineHighlightSelector = new ColorSelector(colors); lineHighlightSelector.addListener(this); label = new Label(colors, SWT.NONE); label.setLayoutData(new GridData(SWT.END, SWT.CENTER, false, false)); label.setText(Messages.ThemePreferencePage_CaretLabel); caretSelector = new ColorSelector(colors); caretSelector.addListener(this); }
From source file:com.astra.ses.spell.gui.preferences.ui.pages.GUIColorsPreferencePage.java
License:Open Source License
@Override protected Control createContents(Composite parent) { // CONTAINER/*from w w w .j av a 2 s.c o m*/ Composite container = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(2, true); GridData layoutData = new GridData(GridData.FILL_HORIZONTAL); layoutData.grabExcessHorizontalSpace = true; container.setLayout(layout); container.setLayoutData(layoutData); /* * Fill the widget with the color chooser controls */ IConfigurationManager conf = getConfigurationManager(); m_colorSelectors = new ColorSelector[GuiColorKey.values().length]; for (GuiColorKey key : GuiColorKey.values()) { Label label = new Label(container, SWT.NONE); label.setText(key.description); label.setLayoutData(GridDataFactory.copyData(layoutData)); ColorSelector selector = new ColorSelector(container); selector.setColorValue(conf.getGuiColor(key).getRGB()); m_colorSelectors[key.ordinal()] = selector; } return container; }