List of usage examples for org.eclipse.jface.preference IPreferenceStore getDouble
double getDouble(String name);
From source file:org.eclipse.gmf.runtime.diagram.ui.properties.sections.grid.RulerGridPropertySection.java
License:Open Source License
/** * /*w w w .ja v a 2 s. c o m*/ * Sets up controls with proper layouts and groups * @param parent */ private void initializeControls(Composite parent) { parent.setLayout(new GridLayout(1, false)); // Top row composite Composite topComposite = getWidgetFactory().createComposite(parent); topComposite.setLayout(new GridLayout(2, false)); // Create the groups for this section createDisplayGroup(topComposite); createMeasurementGroup(topComposite); // Bottom row composite Composite bottomComposite = getWidgetFactory().createComposite(parent); bottomComposite.setLayout(new GridLayout(2, false)); // Create grid line settings createGridlineGroup(bottomComposite); Composite extraComposite = getWidgetFactory().createComposite(bottomComposite); extraComposite.setLayout(new GridLayout(1, false)); // Create snap to grid checkbox snapToGridButton = getWidgetFactory().createButton(extraComposite, SNAP_TO_GRID_LABEL, SWT.CHECK); snapToGridButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Set the snap to grid workspace property setWorkspaceProperty(WorkspaceViewerProperties.SNAPTOGRID, snapToGridButton.getSelection()); } }); // Create snap to geometry checkbox snapToGeometryButton = getWidgetFactory().createButton(extraComposite, SNAP_TO_GEOMETRY_LABEL, SWT.CHECK); snapToGeometryButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Set the snap to geometry workspace property setWorkspaceProperty(WorkspaceViewerProperties.SNAPTOGEOMETRY, snapToGeometryButton.getSelection()); } }); // Create restore to preferences defaults restoreButton = getWidgetFactory().createButton(extraComposite, RESTORE_LABEL, SWT.PUSH); restoreButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { restorePreferenceValues(); } private void restorePreferenceValues() { IPreferenceStore preferenceStore = getPreferenceStore(); // The workspace properties will always exist because it is set // IPreferenceStore wsPrefStore = getWorkspaceViewerProperties(); if (wsPrefStore.getBoolean(WorkspaceViewerProperties.GRIDORDER) == false) { wsPrefStore.setValue(WorkspaceViewerProperties.GRIDORDER, true); } if (wsPrefStore.getInt(WorkspaceViewerProperties.GRIDLINECOLOR) != LIGHT_GRAY_RGB) { wsPrefStore.setValue(WorkspaceViewerProperties.GRIDLINECOLOR, LIGHT_GRAY_RGB); } if (wsPrefStore.getInt(WorkspaceViewerProperties.GRIDLINESTYLE) != SWT.LINE_CUSTOM) { wsPrefStore.setValue(WorkspaceViewerProperties.GRIDLINESTYLE, SWT.LINE_CUSTOM); } if (wsPrefStore.getBoolean(WorkspaceViewerProperties.VIEWRULERS) != preferenceStore .getBoolean(IPreferenceConstants.PREF_SHOW_RULERS)) { wsPrefStore.setValue(WorkspaceViewerProperties.VIEWRULERS, preferenceStore.getBoolean(IPreferenceConstants.PREF_SHOW_RULERS)); } if (wsPrefStore.getBoolean(WorkspaceViewerProperties.VIEWGRID) != preferenceStore .getBoolean(IPreferenceConstants.PREF_SHOW_GRID)) { wsPrefStore.setValue(WorkspaceViewerProperties.VIEWGRID, preferenceStore.getBoolean(IPreferenceConstants.PREF_SHOW_GRID)); } if (wsPrefStore.getBoolean(WorkspaceViewerProperties.SNAPTOGRID) != preferenceStore .getBoolean(IPreferenceConstants.PREF_SNAP_TO_GRID)) { wsPrefStore.setValue(WorkspaceViewerProperties.SNAPTOGRID, preferenceStore.getBoolean(IPreferenceConstants.PREF_SNAP_TO_GRID)); } if (wsPrefStore.getBoolean(WorkspaceViewerProperties.SNAPTOGEOMETRY) != preferenceStore .getBoolean(IPreferenceConstants.PREF_SNAP_TO_GEOMETRY)) { wsPrefStore.setValue(WorkspaceViewerProperties.SNAPTOGEOMETRY, preferenceStore.getBoolean(IPreferenceConstants.PREF_SNAP_TO_GEOMETRY)); } if ((wsPrefStore.getInt(WorkspaceViewerProperties.RULERUNIT) != preferenceStore .getInt(IPreferenceConstants.PREF_RULER_UNITS)) || (wsPrefStore.getDouble(WorkspaceViewerProperties.GRIDSPACING) != preferenceStore .getDouble(IPreferenceConstants.PREF_GRID_SPACING))) { wsPrefStore.setValue(WorkspaceViewerProperties.RULERUNIT, preferenceStore.getInt(IPreferenceConstants.PREF_RULER_UNITS)); wsPrefStore.setValue(WorkspaceViewerProperties.GRIDSPACING, preferenceStore.getDouble(IPreferenceConstants.PREF_GRID_SPACING)); } // reset the input values setInput(getPart(), null); } }); }
From source file:org.eclipse.m2m.atl.adt.ui.preferences.AtlPreferenceStore.java
License:Open Source License
/** * Sets the value of the source key in the target fPreferenceeStore. * /*w w w . j a v a 2 s.c om*/ * @param source * the source fPreferenceeStore * @param key * the key to copy * @param target * the target fPreferenceeStore */ private void setProperty(IPreferenceStore source, Key key, IPreferenceStore target) { Descriptor d = key.descriptor; if (BOOLEAN == d) { target.setValue(key.key, source.getBoolean(key.key)); } else if (DOUBLE == d) { target.setValue(key.key, source.getDouble(key.key)); } else if (FLOAT == d) { target.setValue(key.key, source.getFloat(key.key)); } else if (INT == d) { target.setValue(key.key, source.getInt(key.key)); } else if (LONG == d) { target.setValue(key.key, source.getLong(key.key)); } else if (STRING == d) { target.setValue(key.key, source.getString(key.key)); } }
From source file:org.eclipse.ui.texteditor.ChainedPreferenceStore.java
License:Open Source License
public double getDouble(String name) { IPreferenceStore visibleStore = getVisibleStore(name); if (visibleStore != null) return visibleStore.getDouble(name); return DOUBLE_DEFAULT_DEFAULT; }
From source file:org.eclipse.ui.texteditor.ChainedPreferenceStore.java
License:Open Source License
/** * Returns an object of the same dynamic type as <code>thisValue</code>, the returned object * encapsulates the value of the <code>property</code> from the preference <code>store</code>. * * @param property the name of the considered property * @param store the preference store//from www . j a v a 2s . c o m * @param thisValue the given value * @return the other value */ private Object getOtherValue(String property, IPreferenceStore store, Object thisValue) { if (thisValue instanceof Boolean) return store.getBoolean(property) ? Boolean.TRUE : Boolean.FALSE; else if (thisValue instanceof Double) return new Double(store.getDouble(property)); else if (thisValue instanceof Float) return new Float(store.getFloat(property)); else if (thisValue instanceof Integer) return new Integer(store.getInt(property)); else if (thisValue instanceof Long) return new Long(store.getLong(property)); else if (thisValue instanceof String) return store.getString(property); return store.getString(property); }
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./*from ww w . ja v a 2 s. co 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.erlide.ui.util.OverlayPreferenceStore.java
License:Open Source License
/** * Loads the given key from the orgin into the target. * /* w ww . j a va 2s . co m*/ * @param orgin * the source preference store * @param key * the overlay key * @param target * the preference store to which the key is propagated * @param forceInitialization * if <code>true</code> the value in the target gets initialized * before loading */ private void loadProperty(final IPreferenceStore orgin, final OverlayKey key, final IPreferenceStore target, final boolean forceInitialization) { final TypeDescriptor d = key.fDescriptor; if (TypeDescriptor.BOOLEAN == d) { if (forceInitialization) { target.setValue(key.fKey, true); } target.setValue(key.fKey, orgin.getBoolean(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultBoolean(key.fKey)); } else if (TypeDescriptor.DOUBLE == d) { if (forceInitialization) { target.setValue(key.fKey, 1.0D); } target.setValue(key.fKey, orgin.getDouble(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultDouble(key.fKey)); } else if (TypeDescriptor.FLOAT == d) { if (forceInitialization) { target.setValue(key.fKey, 1.0F); } target.setValue(key.fKey, orgin.getFloat(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultFloat(key.fKey)); } else if (TypeDescriptor.INT == d) { if (forceInitialization) { target.setValue(key.fKey, 1); } target.setValue(key.fKey, orgin.getInt(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultInt(key.fKey)); } else if (TypeDescriptor.LONG == d) { if (forceInitialization) { target.setValue(key.fKey, 1L); } target.setValue(key.fKey, orgin.getLong(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultLong(key.fKey)); } else if (TypeDescriptor.STRING == d) { if (forceInitialization) { target.setValue(key.fKey, "1"); //$NON-NLS-1$ } target.setValue(key.fKey, orgin.getString(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultString(key.fKey)); } }
From source file:org.gluster.storage.management.console.AlertsManager.java
License:Open Source License
public AlertsManager(Cluster cluster) { this.cluster = cluster; IPreferenceStore preferenceStore = Activator.getDefault().getPreferenceStore(); CPU_USAGE_THRESHOLD = preferenceStore.getDouble(PreferenceConstants.P_SERVER_CPU_CRITICAL_THRESHOLD); MEMORY_USAGE_THRESHOLD = preferenceStore.getDouble(PreferenceConstants.P_SERVER_MEMORY_USAGE_THRESHOLD); DISK_SPACE_USAGE_THRESHOLD = preferenceStore.getDouble(PreferenceConstants.P_DISK_SPACE_USAGE_THRESHOLD); }
From source file:org.talend.designer.business.diagram.views.jobsettings.BusinessRulersAndGridComposite.java
License:Open Source License
/** * /*from w w w . j a v a 2s. c om*/ * Sets up controls with proper layouts and groups * * @param parent */ private void initializeControls(Composite parent) { parent.setLayout(new GridLayout(1, false)); // Top row composite Composite topComposite = widgetFactory.createComposite(parent); topComposite.setLayout(new GridLayout(2, false)); // Create the groups for this section createDisplayGroup(topComposite); createMeasurementGroup(topComposite); // Bottom row composite Composite bottomComposite = widgetFactory.createComposite(parent); bottomComposite.setLayout(new GridLayout(2, false)); // Create grid line settings createGridlineGroup(bottomComposite); Composite extraComposite = widgetFactory.createComposite(bottomComposite); extraComposite.setLayout(new GridLayout(1, false)); // Create snap to grid checkbox snapToGridButton = widgetFactory.createButton(extraComposite, SNAP_TO_GRID_LABEL, SWT.CHECK); snapToGridButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Set the snap to grid workspace property setWorkspaceProperty(WorkspaceViewerProperties.SNAPTOGRID, snapToGridButton.getSelection()); } }); // Create snap to geometry checkbox snapToGeometryButton = widgetFactory.createButton(extraComposite, SNAP_TO_GEOMETRY_LABEL, SWT.CHECK); snapToGeometryButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { // Set the snap to geometry workspace property setWorkspaceProperty(WorkspaceViewerProperties.SNAPTOGEOMETRY, snapToGeometryButton.getSelection()); } }); // Create restore to preferences defaults restoreButton = widgetFactory.createButton(extraComposite, RESTORE_LABEL, SWT.PUSH); restoreButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent event) { restorePreferenceValues(); } private void restorePreferenceValues() { IPreferenceStore preferenceStore = getPreferenceStore(); // The workspace properties will always exist because it is set // IPreferenceStore wsPrefStore = getWorkspaceViewerProperties(); if (wsPrefStore.getBoolean(WorkspaceViewerProperties.GRIDORDER) == false) { wsPrefStore.setValue(WorkspaceViewerProperties.GRIDORDER, true); } if (wsPrefStore.getInt(WorkspaceViewerProperties.GRIDLINECOLOR) != LIGHT_GRAY_RGB) { wsPrefStore.setValue(WorkspaceViewerProperties.GRIDLINECOLOR, LIGHT_GRAY_RGB); } if (wsPrefStore.getInt(WorkspaceViewerProperties.GRIDLINESTYLE) != SWT.LINE_CUSTOM) { wsPrefStore.setValue(WorkspaceViewerProperties.GRIDLINESTYLE, SWT.LINE_CUSTOM); } if (wsPrefStore.getBoolean(WorkspaceViewerProperties.VIEWRULERS) != preferenceStore .getBoolean(IPreferenceConstants.PREF_SHOW_RULERS)) { wsPrefStore.setValue(WorkspaceViewerProperties.VIEWRULERS, preferenceStore.getBoolean(IPreferenceConstants.PREF_SHOW_RULERS)); } if (wsPrefStore.getBoolean(WorkspaceViewerProperties.VIEWGRID) != preferenceStore .getBoolean(IPreferenceConstants.PREF_SHOW_GRID)) { wsPrefStore.setValue(WorkspaceViewerProperties.VIEWGRID, preferenceStore.getBoolean(IPreferenceConstants.PREF_SHOW_GRID)); } if (wsPrefStore.getBoolean(WorkspaceViewerProperties.SNAPTOGRID) != preferenceStore .getBoolean(IPreferenceConstants.PREF_SNAP_TO_GRID)) { wsPrefStore.setValue(WorkspaceViewerProperties.SNAPTOGRID, preferenceStore.getBoolean(IPreferenceConstants.PREF_SNAP_TO_GRID)); } if (wsPrefStore.getBoolean(WorkspaceViewerProperties.SNAPTOGEOMETRY) != preferenceStore .getBoolean(IPreferenceConstants.PREF_SNAP_TO_GEOMETRY)) { wsPrefStore.setValue(WorkspaceViewerProperties.SNAPTOGEOMETRY, preferenceStore.getBoolean(IPreferenceConstants.PREF_SNAP_TO_GEOMETRY)); } if ((wsPrefStore.getInt(WorkspaceViewerProperties.RULERUNIT) != preferenceStore .getInt(IPreferenceConstants.PREF_RULER_UNITS)) || (wsPrefStore.getDouble(WorkspaceViewerProperties.GRIDSPACING) != preferenceStore .getDouble(IPreferenceConstants.PREF_GRID_SPACING))) { wsPrefStore.setValue(WorkspaceViewerProperties.RULERUNIT, preferenceStore.getInt(IPreferenceConstants.PREF_RULER_UNITS)); wsPrefStore.setValue(WorkspaceViewerProperties.GRIDSPACING, preferenceStore.getDouble(IPreferenceConstants.PREF_GRID_SPACING)); } // reset the input values setInput(); } }); setInput(); }
From source file:uk.ac.diamond.scisoft.analysis.rcp.plotting.sideplot.DiffractionViewer.java
License:Apache License
private void setThreshold() { IMetadata md = data.getMetadata();//from www. j a v a 2 s . c om if (md != null) { if (mainPlotter instanceof DataSetPlotter) { try { Serializable s = md.getMetaValue("NXdetector:pixel_overload"); Double threshold = null; if (s instanceof String) { threshold = Double.valueOf((String) s); } else if (s instanceof Number) { threshold = ((Number) s).doubleValue(); } if (threshold != null) { ((DataSetPlotter) mainPlotter).setOverloadThreshold(threshold); diffViewMetadata.setThreshold(threshold); } return; } catch (Exception e) { } } } IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore(); double thresholdFromPrefs; if (preferenceStore.isDefault(PreferenceConstants.DIFFRACTION_VIEWER_PIXELOVERLOAD_THRESHOLD)) thresholdFromPrefs = preferenceStore .getDefaultDouble(PreferenceConstants.DIFFRACTION_VIEWER_PIXELOVERLOAD_THRESHOLD); else thresholdFromPrefs = preferenceStore .getDouble(PreferenceConstants.DIFFRACTION_VIEWER_PIXELOVERLOAD_THRESHOLD); if (mainPlotter instanceof DataSetPlotter) { ((DataSetPlotter) mainPlotter).setOverloadThreshold(thresholdFromPrefs); diffViewMetadata.setThreshold(thresholdFromPrefs); } }
From source file:uk.ac.diamond.scisoft.analysis.rcp.plotting.sideplot.Fitting1D.java
License:Apache License
private void setupInitialValues() { IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore(); accuracy = preferenceStore.getDouble(PreferenceConstants.FITTING_1D_ALG_ACCURACY); threshold = preferenceStore.getInt(PreferenceConstants.FITTING_1D_THRESHOLD); String peaksList = preferenceStore.getString(PreferenceConstants.FITTING_1D_PEAKLIST); String selectedPeakName = preferenceStore.getString(PreferenceConstants.FITTING_1D_PEAKTYPE); populateAndSelectPeak(peaksList, selectedPeakName); if (preferenceStore.getBoolean(PreferenceConstants.FITTING_1D_AUTO_STOPPING)) { numPeaks.setSelection(-1);/*from www . ja v a 2s.c om*/ numPeaks.setEnabled(false); } else { numPeaks.setEnabled(true); numPeaks.setSelection(preferenceStore.getInt(PreferenceConstants.FITTING_1D_PEAK_NUM)); } autoStopping = preferenceStore.getBoolean(PreferenceConstants.FITTING_1D_AUTO_STOPPING); determineThresholdMeasure(preferenceStore.getString(PreferenceConstants.FITTING_1D_THRESHOLD_MEASURE)); String algList = preferenceStore.getDefaultString(PreferenceConstants.FITTING_1D_ALG_LIST); String algDefaultName = preferenceStore.getString(PreferenceConstants.FITTING_1D_ALG_TYPE); populateAndSelectAlgnames(algList, algDefaultName); // Adding UUID for fitting jobs BUTTON_FITTING_UUID = UUID.randomUUID().toString(); REFITTING_UUID = UUID.randomUUID().toString(); }