Example usage for org.eclipse.jface.preference PreferenceStore getBoolean

List of usage examples for org.eclipse.jface.preference PreferenceStore getBoolean

Introduction

In this page you can find the example usage for org.eclipse.jface.preference PreferenceStore getBoolean.

Prototype

@Override
    public boolean getBoolean(String name) 

Source Link

Usage

From source file:com.android.ddms.PrefsDialog.java

License:Apache License

/**
 * Do some one-time prep./*  ww w . j a va2 s .c  om*/
 *
 * The original plan was to let the individual classes define their
 * own defaults, which we would get and then override with the config
 * file.  However, PreferencesStore.load() doesn't trigger the "changed"
 * events, which means we have to pull the loaded config values out by
 * hand.
 *
 * So, we set the defaults, load the values from the config file, and
 * then run through and manually export the values.  Then we duplicate
 * the second part later on for the "changed" events.
 */
public static void init() {
    PreferenceStore prefStore = mStore.getPreferenceStore();

    if (prefStore == null) {
        // we have a serious issue here...
        Log.e("ddms",
                "failed to access both the user HOME directory and the system wide temp folder. Quitting.");
        System.exit(1);
    }

    // configure default values
    setDefaults(System.getProperty("user.home")); //$NON-NLS-1$

    // listen for changes
    prefStore.addPropertyChangeListener(new ChangeListener());

    // Now we initialize the value of the preference, from the values in the store.

    // First the ddm lib.
    DdmPreferences.setDebugPortBase(prefStore.getInt(PREFS_DEBUG_PORT_BASE));
    DdmPreferences.setSelectedDebugPort(prefStore.getInt(PREFS_SELECTED_DEBUG_PORT));
    DdmPreferences.setLogLevel(prefStore.getString(PREFS_LOG_LEVEL));
    DdmPreferences.setInitialThreadUpdate(prefStore.getBoolean(PREFS_DEFAULT_THREAD_UPDATE));
    DdmPreferences.setInitialHeapUpdate(prefStore.getBoolean(PREFS_DEFAULT_HEAP_UPDATE));
    DdmPreferences.setTimeOut(prefStore.getInt(PREFS_TIMEOUT));
    DdmPreferences.setProfilerBufferSizeMb(prefStore.getInt(PREFS_PROFILER_BUFFER_SIZE_MB));
    DdmPreferences.setUseAdbHost(prefStore.getBoolean(PREFS_USE_ADBHOST));
    DdmPreferences.setAdbHostValue(prefStore.getString(PREFS_ADBHOST_VALUE));

    // some static values
    String out = System.getenv("ANDROID_PRODUCT_OUT"); //$NON-NLS-1$
    DdmUiPreferences.setSymbolsLocation(out + File.separator + "symbols"); //$NON-NLS-1$
    DdmUiPreferences.setAddr2LineLocation("arm-linux-androideabi-addr2line"); //$NON-NLS-1$
    DdmUiPreferences.setAddr2LineLocation64("aarch64-linux-android-addr2line");
    String traceview = System.getProperty("com.android.ddms.bindir"); //$NON-NLS-1$
    if (traceview != null && traceview.length() != 0) {
        traceview += File.separator + DdmConstants.FN_TRACEVIEW;
    } else {
        traceview = DdmConstants.FN_TRACEVIEW;
    }
    DdmUiPreferences.setTraceviewLocation(traceview);

    // Now the ddmui lib
    DdmUiPreferences.setStore(prefStore);
    DdmUiPreferences.setThreadRefreshInterval(prefStore.getInt(PREFS_THREAD_REFRESH_INTERVAL));
}

From source file:com.android.sdkstats.DdmsPreferenceStore.java

License:Apache License

/**
 * True if this is the first time the users runs ADT, which is detected by
 * the lack of the setting set using {@link #setAdtUsed(boolean)}
 * or this value being set to true./*from ww w  .  j a  va  2 s .  c om*/
 *
 * @return true if ADT has been used  before
 *
 * @see #setAdtUsed(boolean)
 */
public boolean isAdtUsed() {
    PreferenceStore prefs = getPreferenceStore();
    synchronized (DdmsPreferenceStore.class) {
        if (prefs == null || !prefs.contains(ADT_USED)) {
            return false;
        }
        return prefs.getBoolean(ADT_USED);
    }
}

From source file:com.android.sdkstats.SdkStatsService.java

License:Apache License

/**
 * Pings the usage stats server, as long as the prefs contain the opt-in boolean
 * @param app name to report in the ping
 * @param version to report in the ping//from  w  w w  .j  a  v a  2  s . c om
 * @param prefs the preference store where the opt-in value and ping times are store
 */
private static void doPing(final String app, String version, PreferenceStore prefs) {
    // Validate the application and version input.
    final String normalVersion = normalizeVersion(app, version);

    // If the user has not opted in, do nothing and quietly return.
    if (!prefs.getBoolean(PING_OPT_IN)) {
        // user opted out.
        return;
    }

    // If the last ping *for this app* was too recent, do nothing.
    String timePref = PING_TIME + "." + app; //$NON-NLS-1$
    long now = System.currentTimeMillis();
    long then = prefs.getLong(timePref);
    if (now - then < PING_INTERVAL_MSEC) {
        // too soon after a ping.
        return;
    }

    // Record the time of the attempt, whether or not it succeeds.
    prefs.setValue(timePref, now);
    try {
        prefs.save();
    } catch (IOException ioe) {
    }

    // Send the ping itself in the background (don't block if the
    // network is down or slow or confused).
    final long id = prefs.getLong(PING_ID);
    new Thread() {
        @Override
        public void run() {
            try {
                actuallySendPing(app, normalVersion, id);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }.start();
}

From source file:com.mindquarry.desktop.preferences.pages.ProxySettingsPage.java

License:Open Source License

/**
 * Creates the controls for this page// ww  w .  j  a  va2  s . c o  m
 */
@Override
protected Control createContents(Composite parent) {
    PreferenceStore store = (PreferenceStore) getPreferenceStore();

    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, true));

    enableProxy = new Button(composite, SWT.CHECK);
    enableProxy.setText(I18N.get("Enable proxy support"));
    enableProxy.setSelection(store.getBoolean(PREF_PROXY_ENABLED));
    enableProxy.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent e) {
            enableProxyFields(enableProxy.getSelection());
            performValidation();
        }
    });

    Group proxyGroup = new Group(composite, SWT.SHADOW_ETCHED_IN);
    proxyGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    //settingsGroup.setText(Messages.get("Profile Settings")); //$NON-NLS-1$
    proxyGroup.setLayout(new GridLayout(1, true));

    CLabel label = new CLabel(proxyGroup, SWT.LEFT);
    label.setText(I18N.get("Proxy URL:"));
    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Composite errorComp = createErrorBorderComposite(proxyGroup);
    url = new Text(errorComp, SWT.SINGLE | SWT.BORDER);
    url.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    registerErrorBorderComposite(errorComp, url);
    url.setText(store.getString(PREF_PROXY_URL));
    url.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            performValidation();
        }
    });
    url.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent e) {
            url.selectAll();
        }
    });

    label = new CLabel(proxyGroup, SWT.LEFT);
    label.setText(I18N.get("Proxy Login:"));
    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    login = new Text(proxyGroup, SWT.SINGLE | SWT.BORDER);
    login.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    login.setText(store.getString(PREF_PROXY_LOGIN));
    login.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            performValidation();
        }
    });
    login.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent e) {
            login.selectAll();
        }
    });
    label = new CLabel(proxyGroup, SWT.LEFT);
    label.setText(I18N.get("Proxy Password:"));
    label.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    pwd = new Text(proxyGroup, SWT.PASSWORD | SWT.BORDER);
    pwd.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    pwd.setText(store.getString(PREF_PROXY_PASSWORD));
    pwd.addModifyListener(new ModifyListener() {
        public void modifyText(ModifyEvent e) {
            performValidation();
        }
    });
    pwd.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent e) {
            pwd.selectAll();
        }
    });

    enableProxyFields(enableProxy.getSelection());
    performValidation();
    return composite;
}

From source file:org.archicontribs.database.DBSelectDatabase.java

License:Open Source License

private void loadValues() {
    PreferenceStore store = new PreferenceStore("org.archicontribs.database");

    //if preferences are not set, that's not an error
    try {/* w  w w.jav a 2 s .  c o m*/
        store.load();
    } catch (IOException e) {
        return;
    }

    driver.setText(store.getString("driver"));
    server.setText(store.getString("server"));
    port.setText(store.getString("port"));
    database.setText(store.getString("database"));
    remember.setSelection(store.getBoolean("remember"));
    doNotAskAgain.setSelection(store.getBoolean("doNotAskAgain"));
    username.setText(store.getString("username"));
    password.setText(store.getString("password"));
}