List of usage examples for org.eclipse.jface.preference PreferenceConverter setValue
public static void setValue(IPreferenceStore store, String name, RGB value)
From source file:ar.com.tadp.xml.rinzo.core.preferences.ColorPreferenceEditor.java
License:Open Source License
protected void doStore() { for (ColorPreferenceModel colorModel : getColorModelList()) { PreferenceConverter.setValue(getPreferenceStore(), colorModel.getPreferenceKey(), colorModel.getColorValue()); getPreferenceStore().setValue(colorModel.getPreferenceKey() + "#bold", colorModel.isBold()); }//from w w w . j av a2 s. com }
From source file:ca.mcgill.cs.swevo.qualyzer.editors.RTFEditor.java
License:Open Source License
/** * Constructor.//from ww w . j a v a 2 s .com * Initialises the actions. */ public RTFEditor() { super(); setSourceViewerConfiguration(new RTFSourceViewerConfiguration(getTextColorer())); setDocumentProvider(new RTFDocumentProvider2()); fIsDirty = false; fRegistry = QualyzerActivator.getDefault().getImageRegistry(); getPreferenceStore().setValue(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON, false); QualyzerActivator.getDefault().getPreferenceStore().addPropertyChangeListener(this); FontData font = PreferenceConverter.getFontData(QualyzerActivator.getDefault().getPreferenceStore(), IQualyzerPreferenceConstants.FONT); PreferenceConverter.setValue(getPreferenceStore(), JFaceResources.TEXT_FONT, font); }
From source file:ca.mcgill.cs.swevo.qualyzer.editors.RTFEditor.java
License:Open Source License
/** * Propagates a change in the font preference to the editor preference store. *//*from ww w.j a v a 2s.c o m*/ @Override public void propertyChange(PropertyChangeEvent e) { if (e == null || e.getProperty().equals(IQualyzerPreferenceConstants.FONT)) { IPreferenceStore pref = getPreferenceStore(); FontData oldFont = PreferenceConverter.getFontData(pref, JFaceResources.TEXT_FONT); FontData font = PreferenceConverter.getFontData(QualyzerActivator.getDefault().getPreferenceStore(), IQualyzerPreferenceConstants.FONT); PreferenceConverter.setValue(pref, JFaceResources.TEXT_FONT, font); pref.firePropertyChangeEvent(JFaceResources.TEXT_FONT, oldFont, font); } else { super.propertyChange(e); } }
From source file:ccw.preferences.SyntaxColoringPreferencePage.java
License:Open Source License
private Control createSyntaxPage(final Composite parent) { fOverlayStore.load();/*from www . j a va 2s .c o m*/ 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
/** * @see org.eclipse.jface.preference.FieldEditorPreferencePage#performOk() *//*w w w . j a va 2 s . c om*/ public boolean performOk() { getPreferenceStore().setValue(IPreferenceConstants.COLORIZER_TEXT_HIGHLIGHT_ENABLED, enableOccurrences.getSelection()); getPreferenceStore().setValue(IPreferenceConstants.INSERT_SPACES_FOR_TABS, spaces.getSelection()); PreferenceConverter.setValue(getPreferenceStore(), IPreferenceConstants.COLORIZER_TEXT_HIGHLIGHT_BACKGROUND_COLOR, occurrenceColor.getColorValue()); getPreferenceStore().setValue(IPreferenceConstants.PIANO_KEY_DIFFERENCE, pianoKeySlider.getSelection()); LanguageColorizer.fireColorizationEvent(); return super.performOk(); }
From source file:com.aptana.ide.editors.unified.UnifiedEditor.java
License:Open Source License
/** * This method circumvents that the line change ruler on AbstractDecoratedTextEditor is private. A placeholder pref * store is used to sync our colorization values with the Eclipse values that this ruler pulls from. *//*from w w w . j av a 2 s . com*/ private void syncFoldingPreferenceStore() { if (this._baseContributor != null) { String language = this._baseContributor.getLocalContentType(); LanguageColorizer colorizer = LanguageRegistry.getLanguageColorizer(language); if (colorizer != null && colorizer.getFoldingBg() != null) { this._runtimeStore.setDefault(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, true); this._runtimeStore.setValue(PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT, false); PreferenceConverter.setValue(this._runtimeStore, PREFERENCE_COLOR_BACKGROUND, colorizer.getFoldingBg().getRGB()); } } }
From source file:com.aptana.ide.logging.LoggingPreferences.java
License:Open Source License
/** * Sets cursor line color. * @param rgb - RGB to set. */ public void setCursorLineColor(RGB rgb) { PreferenceConverter.setValue(getPreferenceStore(), CURSORLINE_COLOR_KEY, rgb); }
From source file:com.aptana.ide.logging.LoggingPreferences.java
License:Open Source License
/** * Sets text color./* w w w .ja va2 s .c o m*/ * @param rgb - RGB to set. */ public void setTextColor(RGB rgb) { PreferenceConverter.setValue(getPreferenceStore(), TEXT_COLOR_KEY, rgb); colorRegistry.put(TEXT_COLOR_KEY, rgb); notifyForegroundColorChanged(colorRegistry.get(TEXT_COLOR_KEY)); }
From source file:com.aptana.ide.logging.LoggingPreferences.java
License:Open Source License
/** * Sets font data.//from w w w.ja v a 2 s. c om * @param data - data to set. */ public void setFontData(FontData[] data) { synchronized (fontRegistry) { PreferenceConverter.setValue(getPreferenceStore(), MAIN_TEXT_FONT_KEY, data); fontRegistry.put(MAIN_TEXT_FONT_KEY, data); notifyFontChanged(fontRegistry.get(MAIN_TEXT_FONT_KEY)); mainFontLoaded = true; } }
From source file:com.astra.ses.spell.dev.spelleditor.preferences.ColorPreferences.java
License:Open Source License
@Override public void initializeDefaultPreferences() { PreferenceConverter.setValue(PREFERENCES, FUNCTION_COLOR, new RGB(128, 0, 0)); PreferenceConverter.setValue(PREFERENCES, MODIFIER_COLOR, new RGB(170, 115, 0)); PreferenceConverter.setValue(PREFERENCES, CONSTANT_COLOR, new RGB(255, 0, 0)); }