List of usage examples for org.eclipse.jface.preference IPreferenceStore isDefault
boolean isDefault(String name);
From source file:org.erlide.ui.util.OverlayPreferenceStore.java
License:Open Source License
/** * Propagates the given overlay key from the orgin to the target preference * store.// w w w. j a v a2 s. c o m * * @param orgin * the source preference store * @param key * the overlay key * @param target * the preference store to which the key is propagated */ protected void propagateProperty(final IPreferenceStore orgin, final OverlayKey key, final IPreferenceStore target) { if (orgin.isDefault(key.fKey)) { if (!target.isDefault(key.fKey)) { target.setToDefault(key.fKey); } return; } final TypeDescriptor d = key.fDescriptor; if (TypeDescriptor.BOOLEAN == d) { final boolean originValue = orgin.getBoolean(key.fKey); final boolean targetValue = target.getBoolean(key.fKey); if (targetValue != originValue) { target.setValue(key.fKey, originValue); } } else if (TypeDescriptor.DOUBLE == d) { final double originValue = orgin.getDouble(key.fKey); final double targetValue = target.getDouble(key.fKey); if (targetValue != originValue) { target.setValue(key.fKey, originValue); } } else if (TypeDescriptor.FLOAT == d) { final float originValue = orgin.getFloat(key.fKey); final float targetValue = target.getFloat(key.fKey); if (targetValue != originValue) { target.setValue(key.fKey, originValue); } } else if (TypeDescriptor.INT == d) { final int originValue = orgin.getInt(key.fKey); final int targetValue = target.getInt(key.fKey); if (targetValue != originValue) { target.setValue(key.fKey, originValue); } } else if (TypeDescriptor.LONG == d) { final long originValue = orgin.getLong(key.fKey); final long targetValue = target.getLong(key.fKey); if (targetValue != originValue) { target.setValue(key.fKey, originValue); } } else if (TypeDescriptor.STRING == d) { final String originValue = orgin.getString(key.fKey); final String targetValue = target.getString(key.fKey); if (targetValue != null && originValue != null && !targetValue.equals(originValue)) { target.setValue(key.fKey, originValue); } } }
From source file:org.polymap.service.ui.OwsPropertiesPage.java
License:Open Source License
public boolean performOk() { log.info("performOk()..."); super.performOk(); try {//from w w w .j a v a2s . com IPreferenceStore store = getPreferenceStore(); if (!store.isDefault("WMS")) { Boolean value = store.getBoolean("WMS"); log.info(" value: " + value); SetPropertyOperation op = new SetPropertyOperation(); op.init(IProvidedService.class, providedService, IProvidedService.PROP_ENABLED, value); OperationSupport.instance().execute(op, false, false); } if (!store.isDefault(IProvidedService.PROP_PATHSPEC)) { String value = store.getString(IProvidedService.PROP_PATHSPEC); log.info(" value: " + value); SetPropertyOperation op = new SetPropertyOperation(); op.init(IProvidedService.class, providedService, IProvidedService.PROP_PATHSPEC, value); OperationSupport.instance().execute(op, false, false); } if (!store.isDefault(IProvidedService.PROP_SRS)) { String value = store.getString(IProvidedService.PROP_SRS); log.info(" value: " + value); List<String> srs = Arrays.asList(StringUtils.split(value, ", ")); SetPropertyOperation op = new SetPropertyOperation(); op.init(IProvidedService.class, providedService, IProvidedService.PROP_SRS, srs); OperationSupport.instance().execute(op, false, false); } // message box Polymap.getSessionDisplay().asyncExec(new Runnable() { public void run() { MessageBox mbox = new MessageBox( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), SWT.OK | SWT.ICON_INFORMATION | SWT.APPLICATION_MODAL); mbox.setMessage("Die nderungen werden erst nach dem nchsten Speichern wirksam."); mbox.setText("Hinweis"); mbox.open(); } }); return true; } catch (Exception e) { PolymapWorkbench.handleError(ServicesPlugin.PLUGIN_ID, this, "Fehler beim Speichern der Einstellungen.", e); return false; } }
From source file:org.springsource.ide.eclipse.gradle.ui.cli.editor.TasksViewer.java
License:Open Source License
@SuppressWarnings("unchecked") public TasksViewer(Composite parent, GradleProjectIndex tasksIndex, boolean consoleMode) { super();/*from ww w . j a va 2 s. c o m*/ this.tasksIndex = tasksIndex; DefaultMarkerAnnotationAccess markerAccess = new DefaultMarkerAnnotationAccess(); OverviewRuler overviewRuler = consoleMode ? null : new OverviewRuler(markerAccess, 12, colorsCache); int style = SWT.NONE; if (!consoleMode) { style = SWT.V_SCROLL | SWT.H_SCROLL | SWT.MULTI | SWT.BORDER | SWT.FULL_SELECTION; } viewer = new SourceViewer(parent, null, overviewRuler, true, style); IPreferenceStore preferences = EditorsUI.getPreferenceStore(); viewer.configure(new TasksViewerConfiguration(tasksIndex, preferences)); decorationSupport = new SourceViewerDecorationSupport(viewer, overviewRuler, markerAccess, colorsCache); for (AnnotationPreference preference : (List<AnnotationPreference>) new MarkerAnnotationPreferences() .getAnnotationPreferences()) { decorationSupport.setAnnotationPreference(preference); } decorationSupport.install(preferences); Font font = null; if (preferences != null) { // Backward compatibility if (preferences.contains(JFaceResources.TEXT_FONT) && !preferences.isDefault(JFaceResources.TEXT_FONT)) { FontData data = PreferenceConverter.getFontData(preferences, JFaceResources.TEXT_FONT); if (data != null) { font = new Font(viewer.getTextWidget().getDisplay(), data); } } } if (font == null) font = JFaceResources.getTextFont(); if (!font.equals(viewer.getTextWidget().getFont())) { viewer.getTextWidget().setFont(font); } activateHandler(); }
From source file:org.summer.sdt.internal.ui.JavaPlugin.java
License:Open Source License
/** * Installs backwards compatibility for the preference store. */// w w w .ja va 2 s . c o m private void ensurePreferenceStoreBackwardsCompatibility() { IPreferenceStore store = getPreferenceStore(); // must add here to guarantee that it is the first in the listener list fMembersOrderPreferenceCache = new MembersOrderPreferenceCache(); fMembersOrderPreferenceCache.install(store); /* * Installs backwards compatibility: propagate the Java editor font from a * pre-2.1 plug-in to the Platform UI's preference store to preserve * the Java editor font from a pre-2.1 workspace. This is done only * once. */ String fontPropagatedKey = "fontPropagated"; //$NON-NLS-1$ if (store.contains(JFaceResources.TEXT_FONT) && !store.isDefault(JFaceResources.TEXT_FONT)) { if (!store.getBoolean(fontPropagatedKey)) PreferenceConverter.setValue(getDeprecatedWorkbenchPreferenceStore(), PreferenceConstants.EDITOR_TEXT_FONT, PreferenceConverter.getFontDataArray(store, JFaceResources.TEXT_FONT)); } store.setValue(fontPropagatedKey, true); /* * Backwards compatibility: set the Java editor font in this plug-in's * preference store to let older versions access it. Since 2.1 the * Java editor font is managed by the workbench font preference page. */ PreferenceConverter.putValue(store, JFaceResources.TEXT_FONT, JFaceResources.getFontRegistry().getFontData(PreferenceConstants.EDITOR_TEXT_FONT)); fFontPropertyChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (PreferenceConstants.EDITOR_TEXT_FONT.equals(event.getProperty())) PreferenceConverter.putValue(getPreferenceStore(), JFaceResources.TEXT_FONT, JFaceResources.getFontRegistry().getFontData(PreferenceConstants.EDITOR_TEXT_FONT)); } }; JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener); /* * Backwards compatibility: propagate the Java editor tab width from a * pre-3.0 plug-in to the new preference key. This is done only once. */ final String oldTabWidthKey = DEPRECATED_EDITOR_TAB_WIDTH; final String newTabWidthKey = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH; String tabWidthPropagatedKey = "tabWidthPropagated"; //$NON-NLS-1$ if (store.contains(oldTabWidthKey) && !store.isDefault(oldTabWidthKey)) { if (!store.getBoolean(tabWidthPropagatedKey)) store.setValue(newTabWidthKey, store.getInt(oldTabWidthKey)); } store.setValue(tabWidthPropagatedKey, true); /* * Backwards compatibility: set the Java editor tab width in this plug-in's * preference store with the old key to let older versions access it. * Since 3.0 the tab width is managed by the extended text editor and * uses a new key. */ store.putValue(oldTabWidthKey, store.getString(newTabWidthKey)); fPropertyChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (newTabWidthKey.equals(event.getProperty())) { IPreferenceStore prefStore = getPreferenceStore(); prefStore.putValue(oldTabWidthKey, prefStore.getString(newTabWidthKey)); } } }; store.addPropertyChangeListener(fPropertyChangeListener); /* * Backward compatibility for the refactoring preference key. */ // store.setValue( // PreferenceConstants.REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD, // RefactoringCore.getConditionCheckingFailedSeverity()); // The commented call above triggers the eager loading of the LTK core plug-in // Since the condition checking failed severity is guaranteed to be of RefactoringStatus.SEVERITY_WARNING, // we directly insert the inlined value of this constant store.setToDefault(DEPRECATED_REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD); if (!store.getBoolean(JavaDocLocations.PREF_JAVADOCLOCATIONS_MIGRATED)) { JavaDocLocations.migrateToClasspathAttributes(); } FormatterProfileStore.checkCurrentOptionsVersion(); /* * Backward compatibility: migrate "alphabetic ordering" preference to point the sorter * preference to the alphabetic sorter. */ String proposalOrderMigrated = "proposalOrderMigrated"; //$NON-NLS-1$ if (store.contains(DEPRECATED_CODEASSIST_ORDER_PROPOSALS)) { if (!store.getBoolean(proposalOrderMigrated)) { boolean alphabetic = store.getBoolean(DEPRECATED_CODEASSIST_ORDER_PROPOSALS); if (alphabetic) store.setValue(PreferenceConstants.CODEASSIST_SORTER, "org.summer.sdt.ui.AlphabeticSorter"); //$NON-NLS-1$ } } store.setValue(proposalOrderMigrated, true); }
From source file:org.webcat.eclipse.projectlink.Activator.java
License:Open Source License
public String getDownloadURL() { IPreferenceStore prefs = getPreferenceStore(); String urlType = prefs.getString(IPreferencesConstants.URL_TYPE); if (IPreferencesConstants.URL_TYPE_SEPARATE.equals(urlType)) { return prefs.getString(IPreferencesConstants.DOWNLOAD_URL); } else if (IPreferencesConstants.URL_TYPE_WEBCAT.equals(urlType)) { // FIXME//from w w w. jav a2 s.co m if (!prefs.isDefault(IPreferencesConstants.WEBCAT_URL)) { return prefs.getString(IPreferencesConstants.WEBCAT_URL) + "/FIXME"; } else { return ""; } } else { return ""; } }
From source file:org.webcat.eclipse.projectlink.Activator.java
License:Open Source License
public String getSubmitURL() { IPreferenceStore prefs = getPreferenceStore(); String urlType = prefs.getString(IPreferencesConstants.URL_TYPE); if (IPreferencesConstants.URL_TYPE_SEPARATE.equals(urlType)) { return prefs.getString(IPreferencesConstants.SUBMIT_URL); } else if (IPreferencesConstants.URL_TYPE_WEBCAT.equals(urlType)) { // FIXME//from w w w .j a va 2s . c om if (!prefs.isDefault(IPreferencesConstants.WEBCAT_URL)) { return prefs.getString(IPreferencesConstants.WEBCAT_URL) + "/FIXME"; } else { return ""; } } else { return ""; } }
From source file:patch.org.eclipse.jdt.internal.ui.JavaPlugin.java
License:Open Source License
/** * Installs backwards compatibility for the preference store. *///from w w w. j av a2 s.com private void ensurePreferenceStoreBackwardsCompatibility() { IPreferenceStore store = getPreferenceStore(); // must add here to guarantee that it is the first in the listener list fMembersOrderPreferenceCache = new MembersOrderPreferenceCache(); fMembersOrderPreferenceCache.install(store); /* * Installs backwards compatibility: propagate the Java editor font from a * pre-2.1 plug-in to the Platform UI's preference store to preserve * the Java editor font from a pre-2.1 workspace. This is done only * once. */ String fontPropagatedKey = "fontPropagated"; //$NON-NLS-1$ if (store.contains(JFaceResources.TEXT_FONT) && !store.isDefault(JFaceResources.TEXT_FONT)) { if (!store.getBoolean(fontPropagatedKey)) PreferenceConverter.setValue(getDeprecatedWorkbenchPreferenceStore(), PreferenceConstants.EDITOR_TEXT_FONT, PreferenceConverter.getFontDataArray(store, JFaceResources.TEXT_FONT)); } store.setValue(fontPropagatedKey, true); /* * Backwards compatibility: set the Java editor font in this plug-in's * preference store to let older versions access it. Since 2.1 the * Java editor font is managed by the workbench font preference page. */ PreferenceConverter.putValue(store, JFaceResources.TEXT_FONT, JFaceResources.getFontRegistry().getFontData(PreferenceConstants.EDITOR_TEXT_FONT)); fFontPropertyChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (PreferenceConstants.EDITOR_TEXT_FONT.equals(event.getProperty())) PreferenceConverter.putValue(getPreferenceStore(), JFaceResources.TEXT_FONT, JFaceResources.getFontRegistry().getFontData(PreferenceConstants.EDITOR_TEXT_FONT)); } }; JFaceResources.getFontRegistry().addListener(fFontPropertyChangeListener); /* * Backwards compatibility: propagate the Java editor tab width from a * pre-3.0 plug-in to the new preference key. This is done only once. */ final String oldTabWidthKey = DEPRECATED_EDITOR_TAB_WIDTH; final String newTabWidthKey = AbstractDecoratedTextEditorPreferenceConstants.EDITOR_TAB_WIDTH; String tabWidthPropagatedKey = "tabWidthPropagated"; //$NON-NLS-1$ if (store.contains(oldTabWidthKey) && !store.isDefault(oldTabWidthKey)) { if (!store.getBoolean(tabWidthPropagatedKey)) store.setValue(newTabWidthKey, store.getInt(oldTabWidthKey)); } store.setValue(tabWidthPropagatedKey, true); /* * Backwards compatibility: set the Java editor tab width in this plug-in's * preference store with the old key to let older versions access it. * Since 3.0 the tab width is managed by the extended text editor and * uses a new key. */ store.putValue(oldTabWidthKey, store.getString(newTabWidthKey)); fPropertyChangeListener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { if (newTabWidthKey.equals(event.getProperty())) { IPreferenceStore prefStore = getPreferenceStore(); prefStore.putValue(oldTabWidthKey, prefStore.getString(newTabWidthKey)); } } }; store.addPropertyChangeListener(fPropertyChangeListener); /* * Backward compatibility for the refactoring preference key. */ // store.setValue( // PreferenceConstants.REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD, // RefactoringCore.getConditionCheckingFailedSeverity()); // The commented call above triggers the eager loading of the LTK core plug-in // Since the condition checking failed severity is guaranteed to be of RefactoringStatus.SEVERITY_WARNING, // we directly insert the inlined value of this constant store.setToDefault(DEPRECATED_REFACTOR_ERROR_PAGE_SEVERITY_THRESHOLD); if (!store.getBoolean(JavaDocLocations.PREF_JAVADOCLOCATIONS_MIGRATED)) { JavaDocLocations.migrateToClasspathAttributes(); } FormatterProfileStore.checkCurrentOptionsVersion(); /* * Backward compatibility: migrate "alphabetic ordering" preference to point the sorter * preference to the alphabetic sorter. */ String proposalOrderMigrated = "proposalOrderMigrated"; //$NON-NLS-1$ if (store.contains(DEPRECATED_CODEASSIST_ORDER_PROPOSALS)) { if (!store.getBoolean(proposalOrderMigrated)) { boolean alphabetic = store.getBoolean(DEPRECATED_CODEASSIST_ORDER_PROPOSALS); if (alphabetic) store.setValue(PreferenceConstants.CODEASSIST_SORTER, "org.eclipse.jdt.ui.AlphabeticSorter"); //$NON-NLS-1$ } } store.setValue(proposalOrderMigrated, true); }
From source file:tinyos.dlrc.utility.preferences.OldPluginPreferenceStore.java
License:Open Source License
private void dig(String key) { if (handled.add(key)) { if (!delegate.getBoolean("digged_" + key)) { delegate.setValue("digged_" + key, true); IPreferenceStore old = openOld(); if (!old.isDefault(key)) { delegate.setValue(key, old.getString(key)); }/*from w w w . j a v a 2 s . c o m*/ } } }
From source file:uk.ac.diamond.scisoft.analysis.rcp.DataExplorationPerspective.java
License:Apache License
private int getDefaultPlottingSystemChoice() { IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore(); return preferenceStore.isDefault(PreferenceConstants.PLOT_VIEW_PLOTTING_SYSTEM) ? preferenceStore.getDefaultInt(PreferenceConstants.PLOT_VIEW_PLOTTING_SYSTEM) : preferenceStore.getInt(PreferenceConstants.PLOT_VIEW_PLOTTING_SYSTEM); }
From source file:uk.ac.diamond.scisoft.analysis.rcp.histogram.HistogramUI.java
License:Apache License
private boolean getPreferenceAutoConstrastChoice() { if (histoView != null && autoScaleSettings.get(histoView.getPartName()) != null) { return autoScaleSettings.get(histoView.getPartName()); }//w w w . j ava 2s .c o m IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore(); return preferenceStore.isDefault(PreferenceConstants.PLOT_VIEW_PLOT2D_AUTOCONTRAST) ? preferenceStore.getDefaultBoolean(PreferenceConstants.PLOT_VIEW_PLOT2D_AUTOCONTRAST) : preferenceStore.getBoolean(PreferenceConstants.PLOT_VIEW_PLOT2D_AUTOCONTRAST); }