List of usage examples for org.eclipse.jface.preference PreferenceStore PreferenceStore
public PreferenceStore()
From source file:org.eclipse.andmore.internal.editors.formatting.EclipseXmlPrettyPrinterTest.java
License:Open Source License
@Before public void setUp() throws Exception { PreferenceStore store = new PreferenceStore(); AdtPrefs.init(store);//from www . j av a 2 s .c om AdtPrefs prefs = AdtPrefs.getPrefs(); prefs.initializeStoreWithDefaults(store); prefs.loadValues(null); EclipseXmlFormatPreferences formatPrefs = EclipseXmlFormatPreferences.create(); assertTrue(formatPrefs.oneAttributeOnFirstLine); }
From source file:org.eclipse.birt.chart.ui.swt.fieldassist.FieldAssistHelper.java
License:Open Source License
/** * Private constructor./*from www . jav a2 s . c o m*/ */ private FieldAssistHelper() { if (soPreferenceStore == null) { if (ChartUIExtensionPlugin.getDefault() == null) { soPreferenceStore = new PreferenceStore(); FieldAssistPreferenceInitializer.setDefaultPreferences(soPreferenceStore); return; } soPreferenceStore = ChartUIExtensionPlugin.getDefault().getPreferenceStore(); } }
From source file:org.eclipse.birt.report.designer.ui.preferences.OverlayPreferenceStore.java
License:Open Source License
public OverlayPreferenceStore(IPreferences preference, OverlayKey[] overlayKeys) { fParent = preference; fOverlayKeys = overlayKeys; fStore = new PreferenceStore(); }
From source file:org.eclipse.cdt.codan.internal.ui.widgets.FileScopeComposite.java
License:Open Source License
/** * @param parent// ww w . ja v a 2s . c o m * @param problem * @param resource * @param style */ public FileScopeComposite(Composite parent, final IProblem problem, IResource resource) { super(parent, SWT.NONE); if (problem == null) throw new NullPointerException(); this.setLayout(new GridLayout(2, false)); this.problem = problem; this.prefStore = new PreferenceStore(); IProblemPreference info = problem.getPreference(); FileScopeProblemPreference scopeIn = null; if (info == null || (!(info instanceof MapProblemPreference)) || ((scopeIn = (FileScopeProblemPreference) ((MapProblemPreference) info) .getChildDescriptor(FileScopeProblemPreference.KEY)) == null)) { Label label = new Label(this, 0); label.setText(CodanUIMessages.ParametersComposite_None); return; } scope = (FileScopeProblemPreference) scopeIn.clone(); scope.setResource(resource); initPrefStore(); page = new FileScopePreferencePage(scope); page.setPreferenceStore(prefStore); page.noDefaultAndApplyButton(); page.createControl(parent); page.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); }
From source file:org.eclipse.cdt.codan.internal.ui.widgets.LaunchingTabComposite.java
License:Open Source License
/** * @param parent// ww w . j ava 2s . c o m * @param problem * @param resource * @param style */ public LaunchingTabComposite(Composite parent, final IProblem problem, IResource resource) { super(parent, SWT.NONE); if (problem == null) throw new NullPointerException(); this.setLayout(new GridLayout(2, false)); this.problem = problem; this.prefStore = new PreferenceStore(); IProblemPreference info = problem.getPreference(); if (info == null || (!(info instanceof RootProblemPreference))) { Label label = new Label(this, 0); label.setText(CodanUIMessages.ParametersComposite_None); return; } LaunchModeProblemPreference launchModes = ((RootProblemPreference) info).getLaunchModePreference(); launchPref = (LaunchModeProblemPreference) launchModes.clone(); initPrefStore(); page = new LaunchModesPropertyPage(problem, prefStore); page.noDefaultAndApplyButton(); page.createControl(parent); page.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); }
From source file:org.eclipse.cdt.codan.internal.ui.widgets.ParametersComposite.java
License:Open Source License
/** * @param parent// w w w .j a v a 2 s .co m * @param problem * @param style */ public ParametersComposite(Composite parent, final IProblem problem) { super(parent, SWT.NONE); if (problem == null) throw new NullPointerException(); this.setLayout(new GridLayout(2, false)); this.problem = problem; this.prefStore = new PreferenceStore(); page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) { @Override protected void createFieldEditors() { noDefaultAndApplyButton(); ((GridLayout) getFieldEditorParent().getLayout()).numColumns = 2; addField(new BooleanFieldEditor(PREF_ENABLED, CodanUIMessages.ParametersComposite_IsEnabled, getFieldEditorParent())); String[][] entries = { { CodanSeverity.Error.toTranslatableString(), CodanSeverity.Error.toString() }, // { CodanSeverity.Warning.toTranslatableString(), CodanSeverity.Warning.toString() }, // { CodanSeverity.Info.toTranslatableString(), CodanSeverity.Info.toString() }, // { NO_CHANGE, NO_CHANGE }, // }; addField(new ComboFieldEditor(PREF_SEVERITY, CodanUIMessages.ParametersComposite_Severity, entries, getFieldEditorParent())); StringFieldEditor messagePatternEditor = new StringFieldEditor(PREF_MESSAGE, CodanUIMessages.ParametersComposite_MessagePattern, getFieldEditorParent()); // We are using read-only text field for message pattern to allow copy to clipboard. makeUneditable(messagePatternEditor); addField(messagePatternEditor); IProblemPreference pref = problem.getPreference(); createFieldEditorsForParameters(pref); } private void makeUneditable(StringFieldEditor editor) { /* * Here we are doing 2 things to make a text control "uneditable": * 1. 'setUneditable(false)' the problem with with just doing this is that * the background of the text control doesn't change, and it looks like * an editable one. This is confusing to the user. * 2. Getting the background of a label control and applying it * to the "uneditable" text control. This way it is easier to figure out that * the contents of the text control cannot be changed. * Why not just setEnable(false)? Because it changes the text of the text control * to light gray, making it difficult to read. Also, users cannot select and copy * text from a disabled text field. */ Color background = editor.getLabelControl(getFieldEditorParent()).getBackground(); Text text = editor.getTextControl(getFieldEditorParent()); text.setBackground(background); text.setEditable(false); } @Override protected Control createContents(Composite parent) { return super.createContents(parent); } /** * @param info */ private void createFieldEditorsForParameters(final IProblemPreference info) { if (info == null) return; if (info.getKey() == FileScopeProblemPreference.KEY) return; // skip the scope if (info.getKey() == LaunchModeProblemPreference.KEY) return; // skip the launch switch (info.getType()) { case TYPE_STRING: { StringFieldEditor fe = new StringFieldEditor(info.getQualifiedKey(), info.getLabel(), getFieldEditorParent()); addField(fe); break; } case TYPE_BOOLEAN: { BooleanFieldEditor fe = new BooleanFieldEditor(info.getQualifiedKey(), info.getLabel(), getFieldEditorParent()); addField(fe); break; } case TYPE_LIST: ListEditor le = new ListEditor(info.getQualifiedKey(), info.getLabel(), getFieldEditorParent()) { @Override protected String[] parseString(String stringList) { ListProblemPreference list = (ListProblemPreference) info; IProblemPreference[] childDescriptors = list.getChildDescriptors(); if (childDescriptors.length == 0) return new String[0]; String res[] = new String[childDescriptors.length]; for (int i = 0; i < childDescriptors.length; i++) { IProblemPreference item = childDescriptors[i]; res[i] = String.valueOf(item.getValue()); } return res; } @Override protected String getNewInputObject() { ListProblemPreference list = (ListProblemPreference) info; String label = list.getChildDescriptor().getLabel(); InputDialog dialog = new InputDialog(getShell(), CodanUIMessages.ParametersComposite_NewValue, label, "", null); //$NON-NLS-1$ if (dialog.open() == Window.OK) { return dialog.getValue(); } return null; } @Override protected String createList(String[] items) { ListProblemPreference list = (ListProblemPreference) info.clone(); list.clear(); for (int i = 0; i < items.length; i++) { String val = items[i]; list.addChildValue(val); } return list.exportValue(); } }; addField(le); break; case TYPE_MAP: IProblemPreference[] childrenDescriptor = ((IProblemPreferenceCompositeDescriptor) info) .getChildDescriptors(); for (int i = 0; i < childrenDescriptor.length; i++) { IProblemPreference desc = childrenDescriptor[i]; createFieldEditorsForParameters(desc); } break; case TYPE_CUSTOM: { StringFieldEditor fe = new StringFieldEditor(info.getQualifiedKey(), info.getLabel(), getFieldEditorParent()); addField(fe); break; } case TYPE_FILE: { FileFieldEditor fe = new FileFieldEditor(info.getQualifiedKey(), info.getLabel(), getFieldEditorParent()); addField(fe); break; } default: throw new UnsupportedOperationException(info.getType().toString()); } } }; load(problem); page.setPreferenceStore(prefStore); page.createControl(parent); page.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); }
From source file:org.eclipse.cdt.debug.internal.ui.preferences.CDebugPreferencePage.java
License:Open Source License
/** * Set the values of the component widgets based on the values in the preference store *///from www .ja v a 2s. c o m private void setValues() { // Set the number format combo boxes. fVariableFormatCombo .select(getFormatIndex(Platform.getPreferencesService().getInt(CDebugCorePlugin.PLUGIN_ID, ICDebugConstants.PREF_DEFAULT_VARIABLE_FORMAT, ICDIFormat.NATURAL, null))); fExpressionFormatCombo .select(getFormatIndex(Platform.getPreferencesService().getInt(CDebugCorePlugin.PLUGIN_ID, ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT, ICDIFormat.NATURAL, null))); fRegisterFormatCombo .select(getFormatIndex(Platform.getPreferencesService().getInt(CDebugCorePlugin.PLUGIN_ID, ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT, ICDIFormat.NATURAL, null))); // Set the charset editors. // Create a temporary preference store. PreferenceStore ps = new PreferenceStore(); // Get the default charset and the default wide charset. String defaultCharset = DefaultScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID) .get(ICDebugConstants.PREF_DEBUG_CHARSET, null); if (defaultCharset != null) { ps.setDefault(ICDebugConstants.PREF_DEBUG_CHARSET, defaultCharset); } String defaultWideCharset = DefaultScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID) .get(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, null); if (defaultWideCharset != null) { ps.setDefault(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, defaultWideCharset); } // Get the charset and the wide charset. If they're unset, use the default instead. // Note that we have to call the setValue() function of the PreferenceStore even if we // want to use the default. This is to ensure proper display of the encoding field editor. String charset = InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID) .get(ICDebugConstants.PREF_DEBUG_CHARSET, null); if (charset != null) { ps.setValue(ICDebugConstants.PREF_DEBUG_CHARSET, charset); } else if (defaultCharset != null) { ps.setValue(ICDebugConstants.PREF_DEBUG_CHARSET, defaultCharset); } String wideCharset = InstanceScope.INSTANCE.getNode(CDebugCorePlugin.PLUGIN_ID) .get(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, null); if (wideCharset != null) { ps.setValue(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, wideCharset); } else if (defaultWideCharset != null) { ps.setValue(ICDebugConstants.PREF_DEBUG_WIDE_CHARSET, defaultWideCharset); } // Initialize the encoding field editors with the values from the preference store. fCharsetEditor.setPreferenceStore(ps); fCharsetEditor.load(); fWideCharsetEditor.setPreferenceStore(ps); fWideCharsetEditor.load(); // Tell the encoding field editors to check the "Default" option if we're currently using the default values. if (charset == null) { fCharsetEditor.loadDefault(); } if (wideCharset == null) { fWideCharsetEditor.loadDefault(); } // Set the values for the remaining preferences. fShowBinarySourceFilesButton.setSelection(Platform.getPreferencesService().getBoolean(CCorePlugin.PLUGIN_ID, CCorePreferenceConstants.SHOW_SOURCE_FILES_IN_BINARIES, true, null)); }
From source file:org.eclipse.cdt.internal.ui.preferences.formatter.CPreview.java
License:Open Source License
/** * Create a new C preview/*w ww . ja v a 2s . c om*/ * @param workingValues * @param parent */ public CPreview(Map<String, String> workingValues, Composite parent) { CTextTools tools = CUIPlugin.getDefault().getTextTools(); fPreviewDocument = new Document(); fWorkingValues = workingValues; tools.setupCDocumentPartitioner(fPreviewDocument, ICPartitions.C_PARTITIONING, null); PreferenceStore prioritizedSettings = new PreferenceStore(); IPreferenceStore[] chain = { prioritizedSettings, CUIPlugin.getDefault().getCombinedPreferenceStore() }; fPreferenceStore = new ChainedPreferenceStore(chain); fSourceViewer = new CSourceViewer(parent, null, null, false, SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER, fPreferenceStore); fViewerConfiguration = new SimpleCSourceViewerConfiguration(tools.getColorManager(), fPreferenceStore, null, ICPartitions.C_PARTITIONING, true); fSourceViewer.configure(fViewerConfiguration); fSourceViewer.getTextWidget().setFont(JFaceResources.getFont(PreferenceConstants.EDITOR_TEXT_FONT)); fMarginPainter = new MarginPainter(fSourceViewer); final RGB rgb = PreferenceConverter.getColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_PRINT_MARGIN_COLOR); fMarginPainter.setMarginRulerColor(tools.getColorManager().getColor(rgb)); fSourceViewer.addPainter(fMarginPainter); new CSourcePreviewerUpdater(); fSourceViewer.setDocument(fPreviewDocument); }
From source file:org.eclipse.cdt.internal.ui.preferences.SpellingConfigurationBlock.java
License:Open Source License
/** * Creates the encoding field editor.// w w w.j av a 2 s. co m * * @param composite the parent composite * @param allControls list with all controls */ private void createEncodingFieldEditor(Composite composite, List<Control> allControls) { Label filler = new Label(composite, SWT.NONE); GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 4; filler.setLayoutData(gd); Label label = new Label(composite, SWT.NONE); label.setText(PreferencesMessages.SpellingPreferencePage_encoding_label); label.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); allControls.add(label); fEncodingEditorParent = new Composite(composite, SWT.NONE); GridLayout layout = new GridLayout(2, false); layout.marginWidth = 0; layout.marginHeight = 0; fEncodingEditorParent.setLayout(layout); gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); gd.horizontalSpan = 3; fEncodingEditorParent.setLayoutData(gd); fEncodingEditor = new EncodingFieldEditor(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), "", null, //$NON-NLS-1$ fEncodingEditorParent); PreferenceStore store = new PreferenceStore(); String defaultEncoding = ResourcesPlugin.getEncoding(); store.setDefault(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), defaultEncoding); String encoding = getValue(PREF_SPELLING_USER_DICTIONARY_ENCODING); if (encoding != null && encoding.length() > 0) store.setValue(PREF_SPELLING_USER_DICTIONARY_ENCODING.getName(), encoding); fEncodingEditor.setPreferenceStore(store); // Redirect status messages from the field editor to the status change listener DialogPage fakePage = new DialogPage() { @Override public void createControl(Composite c) { } @Override public void setErrorMessage(String newMessage) { StatusInfo status = new StatusInfo(); if (newMessage != null) status.setError(newMessage); fEncodingFieldEditorStatus = status; fContext.statusChanged(StatusUtil.getMostSevere( new IStatus[] { fThresholdStatus, fFileStatus, fEncodingFieldEditorStatus })); } }; fEncodingEditor.setPage(fakePage); fEncodingEditor.load(); if (encoding == null || encoding.equals(defaultEncoding) || encoding.length() == 0) fEncodingEditor.loadDefault(); }
From source file:org.eclipse.dirigible.ide.repository.AbstractRepositoryPreferenceStore.java
License:Open Source License
public AbstractRepositoryPreferenceStore(String path, String name) { delegate = new PreferenceStore(); this.path = path; this.name = name; }