Example usage for org.eclipse.jface.preference IPreferenceStore getDouble

List of usage examples for org.eclipse.jface.preference IPreferenceStore getDouble

Introduction

In this page you can find the example usage for org.eclipse.jface.preference IPreferenceStore getDouble.

Prototype

double getDouble(String name);

Source Link

Document

Returns the current value of the double-valued preference with the given name.

Usage

From source file:net.sf.solareclipse.ui.preferences.OverlayPreferenceStore.java

License:Open Source License

private void loadProperty(IPreferenceStore orgin, PreferenceDescriptor key, IPreferenceStore target,
        boolean forceInitialization) {
    PreferenceDescriptor.Type d = key.type;
    if (PreferenceDescriptor.BOOLEAN == d) {
        if (forceInitialization) {
            target.setValue(key.key, true);
        }//w w  w . j av  a  2 s .  c o m
        target.setValue(key.key, orgin.getBoolean(key.key));
        target.setDefault(key.key, orgin.getDefaultBoolean(key.key));
    } else if (PreferenceDescriptor.DOUBLE == d) {
        if (forceInitialization) {
            target.setValue(key.key, 1.0D);
        }
        target.setValue(key.key, orgin.getDouble(key.key));
        target.setDefault(key.key, orgin.getDefaultDouble(key.key));
    } else if (PreferenceDescriptor.FLOAT == d) {
        if (forceInitialization) {
            target.setValue(key.key, 1.0F);
        }
        target.setValue(key.key, orgin.getFloat(key.key));
        target.setDefault(key.key, orgin.getDefaultFloat(key.key));
    } else if (PreferenceDescriptor.INT == d) {
        if (forceInitialization) {
            target.setValue(key.key, 1);
        }
        target.setValue(key.key, orgin.getInt(key.key));
        target.setDefault(key.key, orgin.getDefaultInt(key.key));
    } else if (PreferenceDescriptor.LONG == d) {
        if (forceInitialization) {
            target.setValue(key.key, 1L);
        }
        target.setValue(key.key, orgin.getLong(key.key));
        target.setDefault(key.key, orgin.getDefaultLong(key.key));
    } else if (PreferenceDescriptor.STRING == d) {
        if (forceInitialization) {
            target.setValue(key.key, "1"); //$NON-NLS-1$
        }
        target.setValue(key.key, orgin.getString(key.key));
        target.setDefault(key.key, orgin.getDefaultString(key.key));
    }
}

From source file:net.sf.webcat.eclipse.cxxtest.internal.options.ConfigurationPropertyTester.java

License:Open Source License

public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
    IConfiguration configuration = (IConfiguration) receiver;

    if (PROP_CONFIGURATION_NAME.equals(property)) {
        return configuration.getName().equals(expectedValue);
    } else if (PROP_PREFERENCE.equals(property)) {
        IPreferenceStore store = CxxTestPlugin.getDefault().getPreferenceStore();
        String key = CxxTestPlugin.PLUGIN_ID + ".preferences." + args[0]; //$NON-NLS-1$
        String type = (String) args[1];
        Object value = null;// ww w  .  ja v  a  2s .c om

        if ("boolean".equals(type)) //$NON-NLS-1$
        {
            value = store.getBoolean(key);
        } else if ("int".equals(type)) //$NON-NLS-1$
        {
            value = store.getInt(key);
        } else if ("long".equals(type)) //$NON-NLS-1$
        {
            value = store.getLong(key);
        } else if ("string".equals(type)) //$NON-NLS-1$
        {
            value = store.getString(type);
        } else if ("float".equals(type)) //$NON-NLS-1$
        {
            value = store.getFloat(type);
        } else if ("double".equals(type)) //$NON-NLS-1$
        {
            value = store.getDouble(type);
        }

        return expectedValue.equals(value);
    } else if (PROP_EVALUATE_PREDICATE.equals(property)) {
        String typename = (String) args[0];

        try {
            @SuppressWarnings("unchecked")
            Class<? extends IExtraOptionsEnablement> klass = (Class<? extends IExtraOptionsEnablement>) Class
                    .forName(typename);

            IExtraOptionsEnablement predicate = klass.newInstance();
            boolean value = predicate.shouldProcessOptions(configuration.getOwner().getProject(),
                    configuration);

            return expectedValue.equals(value);
        } catch (Exception e) {
            e.printStackTrace();
        }

        return false;
    } else {
        assert false;
        return false;
    }
}

From source file:org.bonitasoft.studio.properties.sections.appearance.BonitaRulerGridPropertySection.java

License:Open Source License

/**
 * /*from w  w  w .j a v  a  2s  .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_SOLID) {
                wsPrefStore.setValue(WorkspaceViewerProperties.GRIDLINESTYLE, SWT.LINE_SOLID);
            }
            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.cfeclipse.cfml.preferences.OverlayPreferenceStore.java

License:Open Source License

private void propagateProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target) {
    if (orgin.isDefault(key.fKey)) {
        if (!target.isDefault(key.fKey))
            target.setToDefault(key.fKey);
        return;//w  w w. ja va 2s.c om
    }
    TypeDescriptor d = key.fDescriptor;
    if (BOOLEAN == d) {
        boolean originValue = orgin.getBoolean(key.fKey);
        boolean targetValue = target.getBoolean(key.fKey);

        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);
    } else if (DOUBLE == d) {
        double originValue = orgin.getDouble(key.fKey);
        double targetValue = target.getDouble(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);
    } else if (FLOAT == d) {
        float originValue = orgin.getFloat(key.fKey);
        float targetValue = target.getFloat(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);
    } else if (INT == d) {
        int originValue = orgin.getInt(key.fKey);
        int targetValue = target.getInt(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);
    } else if (LONG == d) {
        long originValue = orgin.getLong(key.fKey);
        long targetValue = target.getLong(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);
    } else if (STRING == d) {
        String originValue = orgin.getString(key.fKey);
        String targetValue = target.getString(key.fKey);
        //System.out.println("Propogating " + key.fKey + " with a value of " + originValue);
        if (targetValue != null && originValue != null && !targetValue.equals(originValue))
            target.setValue(key.fKey, originValue);
    }
}

From source file:org.cfeclipse.cfml.preferences.OverlayPreferenceStore.java

License:Open Source License

private void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target,
        boolean forceInitialization) {
    TypeDescriptor d = key.fDescriptor;/*from   w w  w .  j  a v a  2 s . c  om*/
    if (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 (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 (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 (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 (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 (STRING == d) {

        if (forceInitialization)
            target.setValue(key.fKey, "1");
        target.setValue(key.fKey, orgin.getString(key.fKey));
        target.setDefault(key.fKey, orgin.getDefaultString(key.fKey));
    }
}

From source file:org.csstudio.diirt.util.preferences.DIIRTPreferencesPlugin.java

License:Open Source License

public static void copyChannelAccess(IPreferenceStore source, DIIRTPreferences destination) {

    destination.setDefaultBoolean(PREF_DBE_PROPERTY_SUPPORTED,
            source.getDefaultBoolean(PREF_DBE_PROPERTY_SUPPORTED));
    destination.setDefaultBoolean(PREF_HONOR_ZERO_PRECISION,
            source.getDefaultBoolean(PREF_HONOR_ZERO_PRECISION));
    destination.setDefaultString(PREF_MONITOR_MASK, source.getDefaultString(PREF_MONITOR_MASK));
    destination.setDefaultInteger(PREF_CUSTOM_MASK, source.getDefaultInt(PREF_CUSTOM_MASK));
    destination.setDefaultBoolean(PREF_VALUE_RTYP_MONITOR, source.getDefaultBoolean(PREF_VALUE_RTYP_MONITOR));
    destination.setDefaultString(PREF_VARIABLE_LENGTH_ARRAY,
            source.getDefaultString(PREF_VARIABLE_LENGTH_ARRAY));
    destination.setDefaultString(PREF_ADDR_LIST, source.getDefaultString(PREF_ADDR_LIST));
    destination.setDefaultBoolean(PREF_AUTO_ADDR_LIST, source.getDefaultBoolean(PREF_AUTO_ADDR_LIST));
    destination.setDefaultDouble(PREF_BEACON_PERIOD, source.getDefaultDouble(PREF_BEACON_PERIOD));
    destination.setDefaultDouble(PREF_CONNECTION_TIMEOUT, source.getDefaultDouble(PREF_CONNECTION_TIMEOUT));
    destination.setDefaultInteger(PREF_MAX_ARRAY_SIZE, source.getDefaultInt(PREF_MAX_ARRAY_SIZE));
    destination.setDefaultInteger(PREF_REPEATER_PORT, source.getDefaultInt(PREF_REPEATER_PORT));
    destination.setDefaultInteger(PREF_SERVER_PORT, source.getDefaultInt(PREF_SERVER_PORT));

    destination.setBoolean(PREF_DBE_PROPERTY_SUPPORTED, source.getBoolean(PREF_DBE_PROPERTY_SUPPORTED));
    destination.setBoolean(PREF_HONOR_ZERO_PRECISION, source.getBoolean(PREF_HONOR_ZERO_PRECISION));
    destination.setString(PREF_MONITOR_MASK, source.getString(PREF_MONITOR_MASK));
    destination.setInteger(PREF_CUSTOM_MASK, source.getInt(PREF_CUSTOM_MASK));
    destination.setBoolean(PREF_VALUE_RTYP_MONITOR, source.getBoolean(PREF_VALUE_RTYP_MONITOR));
    destination.setString(PREF_VARIABLE_LENGTH_ARRAY, source.getString(PREF_VARIABLE_LENGTH_ARRAY));
    destination.setString(PREF_ADDR_LIST, source.getString(PREF_ADDR_LIST));
    destination.setBoolean(PREF_AUTO_ADDR_LIST, source.getBoolean(PREF_AUTO_ADDR_LIST));
    destination.setDouble(PREF_BEACON_PERIOD, source.getDouble(PREF_BEACON_PERIOD));
    destination.setDouble(PREF_CONNECTION_TIMEOUT, source.getDouble(PREF_CONNECTION_TIMEOUT));
    destination.setInteger(PREF_MAX_ARRAY_SIZE, source.getInt(PREF_MAX_ARRAY_SIZE));
    destination.setInteger(PREF_REPEATER_PORT, source.getInt(PREF_REPEATER_PORT));
    destination.setInteger(PREF_SERVER_PORT, source.getInt(PREF_SERVER_PORT));

}

From source file:org.dawb.common.ui.util.CalibrationUtils.java

License:Open Source License

/**
 * Returns the calibrated abstract data set if required, otherwise returns set
 * unchanged.//from  w  ww .  j av  a 2s .  co m
 * 
 * @param set
 * @param scalar optionally specify some extra scalar values for the calibration expression.
 * @return
 * @throws Exception
 */
public static IDataset getCalibrated(final IDataset set, final Map<String, String> scalar,
        final boolean checkEnabled) throws Exception {

    final IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE,
            "org.dawb.tango.extensions");

    if (checkEnabled) {
        final boolean isCalib = store.getBoolean(CalibrationConstants.USE);
        if (!isCalib)
            return DatasetFactory.createRange(0, set.getSize(), 1, Dataset.INT32);
    }

    final String expr = store.getString(CalibrationConstants.EXPR);
    final String name = store.getString(CalibrationConstants.LABEL);
    final double a = store.getDouble(CalibrationConstants.A);
    final double b = store.getDouble(CalibrationConstants.B);
    final double c = store.getDouble(CalibrationConstants.C);
    final double d = store.getDouble(CalibrationConstants.D);

    final double[] calib = new double[set.getSize()];

    // TODO FIXME - What is the definition of p and p0??
    final double p0 = 0;

    final IExpressionEvaluator eval = ExpressionFactory.createExpressionEvaluator();
    eval.setExpression(expr);

    final Map<String, Object> vals = new HashMap<String, Object>(7);
    for (int i = 0; i < calib.length; i++) {

        vals.clear();
        if (scalar != null)
            vals.putAll(scalar);
        vals.put("p", i);
        vals.put("p0", p0);
        vals.put("a", a);
        vals.put("b", b);
        vals.put("c", c);
        vals.put("d", d);

        calib[i] = eval.evaluate(vals);
    }

    DoubleDataset ret = new DoubleDataset(calib, calib.length);
    ret.setName(name);
    return ret;
}

From source file:org.dawnsci.plotting.services.ImageService.java

License:Open Source License

@Override
public ImageServiceBean createBeanFromPreferences() {

    IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, "org.dawnsci.plotting");
    ImageServiceBean imageServiceBean = new ImageServiceBean();
    imageServiceBean.setOrigin(ImageOrigin.forLabel(store.getString(BasePlottingConstants.ORIGIN_PREF)));
    imageServiceBean.setHistogramType(HistoType.forLabel(store.getString(BasePlottingConstants.HISTO_PREF)));
    imageServiceBean//  w  w w  .  ja v  a2s .  c o  m
            .setMinimumCutBound(HistogramBound.fromString(store.getString(BasePlottingConstants.MIN_CUT)));
    imageServiceBean
            .setMaximumCutBound(HistogramBound.fromString(store.getString(BasePlottingConstants.MAX_CUT)));
    imageServiceBean.setNanBound(HistogramBound.fromString(store.getString(BasePlottingConstants.NAN_CUT)));
    imageServiceBean.setLo(store.getDouble(BasePlottingConstants.HISTO_LO));
    imageServiceBean.setHi(store.getDouble(BasePlottingConstants.HISTO_HI));

    try {
        IPaletteService pservice = (IPaletteService) ServiceManager.getService(IPaletteService.class);
        if (pservice != null) {
            final String scheme = store.getString(BasePlottingConstants.COLOUR_SCHEME);

            if (store.getBoolean(BasePlottingConstants.USE_PALETTE_FUNCTIONS)) {
                FunctionContainer container = pservice.getFunctionContainer(scheme);
                if (container != null) {
                    imageServiceBean.setFunctionObject(container);
                } else {
                    imageServiceBean.setPalette(pservice.getDirectPaletteData(scheme));
                }
            } else {

                // if 8-bit, set direct palette, otherwise set palette functions.
                imageServiceBean.setPalette(pservice.getDirectPaletteData(scheme));
            }

        }
    } catch (Exception e) {
        // Ignored
    }

    return imageServiceBean;
}

From source file:org.dawnsci.plotting.tools.grid.GridTool.java

License:Open Source License

private GridPreferences getGridFromStore() {
    final IPreferenceStore preferenceStore = new ScopedPreferenceStore(InstanceScope.INSTANCE,
            "uk.ac.diamond.scisoft.analysis.rcp");
    double xRes = preferenceStore.getDouble(GridTreeModel.GRIDSCAN_RESOLUTION_X);
    double yRes = preferenceStore.getDouble(GridTreeModel.GRIDSCAN_RESOLUTION_Y);
    double xbeam = preferenceStore.getDouble(GridTreeModel.GRIDSCAN_BEAMLINE_POSX);
    double ybeam = preferenceStore.getDouble(GridTreeModel.GRIDSCAN_BEAMLINE_POSY);

    return new GridPreferences(xRes, yRes, xbeam, ybeam);
}

From source file:org.eclipse.birt.report.designer.ui.preferences.OverlayPreferenceStore.java

License:Open Source License

private void propagateProperty(IPreferences orgin, OverlayKey key, IPreferenceStore target) {

    if (orgin.isDefault(key.fKey)) {
        if (!target.isDefault(key.fKey))
            target.setToDefault(key.fKey);
        return;/*from  w ww .java2  s  .  com*/
    }

    TypeDescriptor d = key.fDescriptor;
    if (BOOLEAN == d) {

        boolean originValue = orgin.getBoolean(key.fKey);
        boolean targetValue = target.getBoolean(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (DOUBLE == d) {

        double originValue = orgin.getDouble(key.fKey);
        double targetValue = target.getDouble(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (FLOAT == d) {

        float originValue = orgin.getFloat(key.fKey);
        float targetValue = target.getFloat(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (INT == d) {

        int originValue = orgin.getInt(key.fKey);
        int targetValue = target.getInt(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (LONG == d) {

        long originValue = orgin.getLong(key.fKey);
        long targetValue = target.getLong(key.fKey);
        if (targetValue != originValue)
            target.setValue(key.fKey, originValue);

    } else if (STRING == d) {

        String originValue = orgin.getString(key.fKey);
        String targetValue = target.getString(key.fKey);
        if (targetValue != null && originValue != null && !targetValue.equals(originValue))
            target.setValue(key.fKey, originValue);

    }
}