List of usage examples for org.eclipse.jface.preference IPreferenceStore getDouble
double getDouble(String name);
From source file:uk.ac.diamond.scisoft.analysis.rcp.plotting.sideplot.Fitting1D.java
License:Apache License
private void addPropertyListeners() { AnalysisRCPActivator.getDefault().getPreferenceStore() .addPropertyChangeListener(new IPropertyChangeListener() { @Override/*from w w w . java 2 s . co m*/ public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore(); if (property.equals(PreferenceConstants.FITTING_1D_ALG_ACCURACY) || property.equals(PreferenceConstants.FITTING_1D_SMOOTHING_VALUE) || property.equals(PreferenceConstants.FITTING_1D_ALG_TYPE) || property.equals(PreferenceConstants.FITTING_1D_AUTO_SMOOTHING) || property.equals(PreferenceConstants.FITTING_1D_PEAKTYPE)) { String peakName; if (preferenceStore.isDefault(PreferenceConstants.FITTING_1D_PEAKTYPE)) { peakName = preferenceStore .getDefaultString(PreferenceConstants.FITTING_1D_PEAKTYPE); } else { peakName = preferenceStore.getString(PreferenceConstants.FITTING_1D_PEAKTYPE); } for (int i = 0; i < peaknames.length; i++) { if (peaknames[i].equalsIgnoreCase(peakName)) { peakType.select(i); break; } } if (preferenceStore.isDefault(PreferenceConstants.FITTING_1D_ALG_ACCURACY)) { accuracy = preferenceStore .getDefaultDouble(PreferenceConstants.FITTING_1D_ALG_ACCURACY); } else { accuracy = preferenceStore.getDouble(PreferenceConstants.FITTING_1D_ALG_ACCURACY); } boolean autoSmooth; if (preferenceStore.isDefault(PreferenceConstants.FITTING_1D_AUTO_SMOOTHING)) { autoSmooth = preferenceStore .getDefaultBoolean(PreferenceConstants.FITTING_1D_AUTO_SMOOTHING); } else { autoSmooth = preferenceStore .getBoolean(PreferenceConstants.FITTING_1D_AUTO_SMOOTHING); } if (autoSmooth) { setupSmoothing(); } else { if (preferenceStore.isDefault(PreferenceConstants.FITTING_1D_SMOOTHING_VALUE)) { smoothing = preferenceStore .getDefaultInt(PreferenceConstants.FITTING_1D_SMOOTHING_VALUE); } else { smoothing = preferenceStore .getInt(PreferenceConstants.FITTING_1D_SMOOTHING_VALUE); } } String algTypeList; if (preferenceStore.isDefault(PreferenceConstants.FITTING_1D_ALG_LIST)) { algTypeList = preferenceStore .getDefaultString(PreferenceConstants.FITTING_1D_ALG_LIST); } else { algTypeList = preferenceStore.getString(PreferenceConstants.FITTING_1D_ALG_LIST); } StringTokenizer st = new StringTokenizer(algTypeList, PreferenceInitializer.DELIMITER); algNames = new String[st.countTokens()]; int numAlgs = 0; while (st.hasMoreTokens()) { algNames[numAlgs++] = st.nextToken(); } String algName; if (preferenceStore.isDefault(PreferenceConstants.FITTING_1D_ALG_TYPE)) algName = preferenceStore.getDefaultString(PreferenceConstants.FITTING_1D_ALG_TYPE); else algName = preferenceStore.getString(PreferenceConstants.FITTING_1D_ALG_TYPE); if (algName.equalsIgnoreCase("Genetic Algorithm")) alg = new GeneticAlg(accuracy); else if (algName.equalsIgnoreCase("Nelder Mead")) alg = new NelderMead(accuracy); else if (algName.equalsIgnoreCase("Apache Nelder Mead")) alg = new ApacheNelderMead(); else throw new IllegalArgumentException("Did not recognise the fitting routine"); } else if (property.equals(PreferenceConstants.FITTING_1D_AUTO_STOPPING) || property.equals(PreferenceConstants.FITTING_1D_THRESHOLD) || property.equals(PreferenceConstants.FITTING_1D_THRESHOLD_MEASURE) || property.equals(PreferenceConstants.FITTING_1D_PEAK_NUM)) { if (preferenceStore.isDefault(PreferenceConstants.FITTING_1D_AUTO_STOPPING)) { autoStopping = preferenceStore .getDefaultBoolean(PreferenceConstants.FITTING_1D_AUTO_STOPPING); } else { autoStopping = preferenceStore .getBoolean(PreferenceConstants.FITTING_1D_AUTO_STOPPING); } if (preferenceStore.isDefault(PreferenceConstants.FITTING_1D_THRESHOLD)) { threshold = preferenceStore.getDefaultInt(PreferenceConstants.FITTING_1D_THRESHOLD); } else { threshold = preferenceStore.getInt(PreferenceConstants.FITTING_1D_THRESHOLD); } String measure; if (preferenceStore.isDefault(PreferenceConstants.FITTING_1D_THRESHOLD_MEASURE)) { measure = preferenceStore .getDefaultString(PreferenceConstants.FITTING_1D_THRESHOLD_MEASURE); } else { measure = preferenceStore .getString(PreferenceConstants.FITTING_1D_THRESHOLD_MEASURE); } determineThresholdMeasure(measure); if (autoStopping) { numPeaks.setSelection(-1); numPeaks.setEnabled(false); } else { numPeaks.setEnabled(true); if (preferenceStore.isDefault(PreferenceConstants.FITTING_1D_PEAK_NUM)) { numPeaks.setSelection( preferenceStore.getDefaultInt(PreferenceConstants.FITTING_1D_PEAK_NUM)); } else { numPeaks.setSelection( preferenceStore.getInt(PreferenceConstants.FITTING_1D_PEAK_NUM)); } } } else if (property.equals(PreferenceConstants.FITTING_1D_DECIMAL_PLACES)) { fittedPeakTable.refresh(); } } }); }
From source file:uk.ac.diamond.scisoft.analysis.rcp.plotting.sideplot.GridProfile.java
License:Apache License
private void addPropertyListeners() { AnalysisRCPActivator.getDefault().getPreferenceStore() .addPropertyChangeListener(new IPropertyChangeListener() { @Override/*from w ww .j a va2 s .c o m*/ public void propertyChange(PropertyChangeEvent event) { String property = event.getProperty(); if (property.equals(PreferenceConstants.GRIDSCAN_RESOLUTION_X) || property.equals(PreferenceConstants.GRIDSCAN_RESOLUTION_Y) || property.equals(PreferenceConstants.GRIDSCAN_BEAMLINE_POSX) || property.equals(PreferenceConstants.GRIDSCAN_BEAMLINE_POSY)) { IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault() .getPreferenceStore(); double gridScanResolutionX; if (preferenceStore.isDefault(PreferenceConstants.GRIDSCAN_RESOLUTION_X)) { gridScanResolutionX = preferenceStore .getDefaultDouble(PreferenceConstants.GRIDSCAN_RESOLUTION_X); } else { gridScanResolutionX = preferenceStore .getDouble(PreferenceConstants.GRIDSCAN_RESOLUTION_X); } getGridPrefs().setResolutionX(gridScanResolutionX); double gridScanResolutionY; if (preferenceStore.isDefault(PreferenceConstants.GRIDSCAN_RESOLUTION_Y)) { gridScanResolutionY = preferenceStore .getDefaultDouble(PreferenceConstants.GRIDSCAN_RESOLUTION_Y); } else { gridScanResolutionY = preferenceStore .getDouble(PreferenceConstants.GRIDSCAN_RESOLUTION_Y); } getGridPrefs().setResolutionY(gridScanResolutionY); double xBeamPos; if (preferenceStore.isDefault(PreferenceConstants.GRIDSCAN_BEAMLINE_POSX)) { xBeamPos = preferenceStore .getDefaultDouble(PreferenceConstants.GRIDSCAN_BEAMLINE_POSX); } else { xBeamPos = preferenceStore.getDouble(PreferenceConstants.GRIDSCAN_BEAMLINE_POSX); } getGridPrefs().setBeamlinePosX(xBeamPos); double yBeamPos; if (preferenceStore.isDefault(PreferenceConstants.GRIDSCAN_BEAMLINE_POSY)) { yBeamPos = preferenceStore .getDefaultDouble(PreferenceConstants.GRIDSCAN_BEAMLINE_POSY); } else { yBeamPos = preferenceStore.getDouble(PreferenceConstants.GRIDSCAN_BEAMLINE_POSY); } getGridPrefs().setBeamlinePosY(yBeamPos); sendPreferences(getGridPrefs()); updateAllSpinners(roi); getControl().getDisplay().asyncExec(new Runnable() { @Override public void run() { tViewer.refresh(); drawEverything(); } }); } } }); }
From source file:uk.ac.diamond.scisoft.analysis.rcp.plotting.sideplot.GridProfile.java
License:Apache License
/** * @return Returns the gridPrefs./*from w w w .ja v a 2 s. c o m*/ */ public GridPreferences getGridPrefs() { if (gridPrefs == null) { if (roi != null) { setGridPrefs(((GridROI) roi).getGridPreferences()); } else { GridPreferences preferences = new GridPreferences(); IPreferenceStore preferenceStore = AnalysisRCPActivator.getDefault().getPreferenceStore(); preferences.setResolutionX(preferenceStore.isDefault(PreferenceConstants.GRIDSCAN_RESOLUTION_X) ? preferenceStore.getDefaultDouble(PreferenceConstants.GRIDSCAN_RESOLUTION_X) : preferenceStore.getDouble(PreferenceConstants.GRIDSCAN_RESOLUTION_X)); preferences.setResolutionY(preferenceStore.isDefault(PreferenceConstants.GRIDSCAN_RESOLUTION_Y) ? preferenceStore.getDefaultDouble(PreferenceConstants.GRIDSCAN_RESOLUTION_Y) : preferenceStore.getDouble(PreferenceConstants.GRIDSCAN_RESOLUTION_Y)); preferences.setBeamlinePosX(preferenceStore.isDefault(PreferenceConstants.GRIDSCAN_BEAMLINE_POSX) ? preferenceStore.getDefaultDouble(PreferenceConstants.GRIDSCAN_BEAMLINE_POSX) : preferenceStore.getDouble(PreferenceConstants.GRIDSCAN_BEAMLINE_POSX)); preferences.setBeamlinePosY(preferenceStore.isDefault(PreferenceConstants.GRIDSCAN_BEAMLINE_POSY) ? preferenceStore.getDefaultDouble(PreferenceConstants.GRIDSCAN_BEAMLINE_POSY) : preferenceStore.getDouble(PreferenceConstants.GRIDSCAN_BEAMLINE_POSY)); setGridPrefs(preferences); } } return gridPrefs; }
From source file:_org.eclipse.dltk.ui.preferences.OverlayPreferenceStore.java
License:Open Source License
protected void loadProperty(IPreferenceStore orgin, OverlayKey key, IPreferenceStore target, boolean forceInitialization) { TypeDescriptor d = key.fDescriptor;/*from w w w . j av a2 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"); //$NON-NLS-1$ target.setValue(key.fKey, orgin.getString(key.fKey)); target.setDefault(key.fKey, orgin.getDefaultString(key.fKey)); } }