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

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

Introduction

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

Prototype

@Override
    public boolean contains(String name) 

Source Link

Usage

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

License:Apache License

private void createWidgets(final Shell shell) {
    Color darkGray = shell.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY);

    /*/* ww w . j  a  va 2s  .  c  o  m*/
     * Create three areas: tool bar, split panels, status line
     */
    shell.setLayout(new GridLayout(1, false));

    // 1. panel area
    final Composite panelArea = new Composite(shell, SWT.BORDER);

    // make the panel area absorb all space
    panelArea.setLayoutData(new GridData(GridData.FILL_BOTH));

    // 2. status line.
    mStatusLine = new Label(shell, SWT.NONE);

    // make status line extend all the way across
    mStatusLine.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    mStatusLine.setText("Initializing...");

    /*
     * Configure the split-panel area.
     */
    final PreferenceStore prefs = PrefsDialog.getStore();

    Composite topPanel = new Composite(panelArea, SWT.NONE);
    final Sash sash = new Sash(panelArea, SWT.HORIZONTAL);
    sash.setBackground(darkGray);
    Composite bottomPanel = new Composite(panelArea, SWT.NONE);

    panelArea.setLayout(new FormLayout());

    createTopPanel(topPanel, darkGray);

    mClipboard = new Clipboard(panelArea.getDisplay());
    if (useOldLogCatView()) {
        createBottomPanel(bottomPanel);
    } else {
        createLogCatView(bottomPanel);
    }

    // form layout data
    FormData data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.bottom = new FormAttachment(sash, 0);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    topPanel.setLayoutData(data);

    final FormData sashData = new FormData();
    if (prefs != null && prefs.contains(PREFERENCE_LOGSASH)) {
        sashData.top = new FormAttachment(0, prefs.getInt(PREFERENCE_LOGSASH));
    } else {
        sashData.top = new FormAttachment(50, 0); // 50% across
    }
    sashData.left = new FormAttachment(0, 0);
    sashData.right = new FormAttachment(100, 0);
    sash.setLayoutData(sashData);

    data = new FormData();
    data.top = new FormAttachment(sash, 0);
    data.bottom = new FormAttachment(100, 0);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(100, 0);
    bottomPanel.setLayoutData(data);

    // allow resizes, but cap at minPanelWidth
    sash.addListener(SWT.Selection, new Listener() {
        @Override
        public void handleEvent(Event e) {
            Rectangle sashRect = sash.getBounds();
            Rectangle panelRect = panelArea.getClientArea();
            int bottom = panelRect.height - sashRect.height - 100;
            e.y = Math.max(Math.min(e.y, bottom), 100);
            if (e.y != sashRect.y) {
                sashData.top = new FormAttachment(0, e.y);
                if (prefs != null) {
                    prefs.setValue(PREFERENCE_LOGSASH, e.y);
                }
                panelArea.layout();
            }
        }
    });

    // add a global focus listener for all the tables
    mTableListener = new TableFocusListener();

    // now set up the listener in the various panels
    if (useOldLogCatView()) {
        mLogPanel.setTableFocusListener(mTableListener);
    } else {
        mLogCatPanel.setTableFocusListener(mTableListener);
    }
    mEventLogPanel.setTableFocusListener(mTableListener);
    for (TablePanel p : mPanels) {
        if (p != null) {
            p.setTableFocusListener(mTableListener);
        }
    }

    mStatusLine.setText("");
}

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

License:Apache License

private void createTopPanel(final Composite comp, Color darkGray) {
    final PreferenceStore prefs = PrefsDialog.getStore();

    comp.setLayout(new FormLayout());

    Composite leftPanel = new Composite(comp, SWT.NONE);
    final Sash sash = new Sash(comp, SWT.VERTICAL);
    sash.setBackground(darkGray);/*from w w w. j  a v a 2  s  . co  m*/
    Composite rightPanel = new Composite(comp, SWT.NONE);

    createLeftPanel(leftPanel);
    createRightPanel(rightPanel);

    FormData data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.bottom = new FormAttachment(100, 0);
    data.left = new FormAttachment(0, 0);
    data.right = new FormAttachment(sash, 0);
    leftPanel.setLayoutData(data);

    final FormData sashData = new FormData();
    sashData.top = new FormAttachment(0, 0);
    sashData.bottom = new FormAttachment(100, 0);
    if (prefs != null && prefs.contains(PREFERENCE_SASH)) {
        sashData.left = new FormAttachment(0, prefs.getInt(PREFERENCE_SASH));
    } else {
        // position the sash 380 from the right instead of x% (done by using
        // FormAttachment(x, 0)) in order to keep the sash at the same
        // position
        // from the left when the window is resized.
        // 380px is just enough to display the left table with no horizontal
        // scrollbar with the default font.
        sashData.left = new FormAttachment(0, 380);
    }
    sash.setLayoutData(sashData);

    data = new FormData();
    data.top = new FormAttachment(0, 0);
    data.bottom = new FormAttachment(100, 0);
    data.left = new FormAttachment(sash, 0);
    data.right = new FormAttachment(100, 0);
    rightPanel.setLayoutData(data);

    final int minPanelWidth = 60;

    // allow resizes, but cap at minPanelWidth
    sash.addListener(SWT.Selection, new Listener() {
        @Override
        public void handleEvent(Event e) {
            Rectangle sashRect = sash.getBounds();
            Rectangle panelRect = comp.getClientArea();
            int right = panelRect.width - sashRect.width - minPanelWidth;
            e.x = Math.max(Math.min(e.x, right), minPanelWidth);
            if (e.x != sashRect.x) {
                sashData.left = new FormAttachment(0, e.x);
                if (prefs != null) {
                    prefs.setValue(PREFERENCE_SASH, e.x);
                }
                comp.layout();
            }
        }
    });
}

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

License:Apache License

/**
 * Indicates whether the ping ID is set.
 * This should be true when {@link #isPingOptIn()} is true.
 *
 * @return true if a ping ID is set, which means the user gave permission
 *              to use the ping service.
 *//*ww w  .jav  a  2  s .  c  om*/
public boolean hasPingId() {
    PreferenceStore prefs = getPreferenceStore();
    synchronized (DdmsPreferenceStore.class) {
        return prefs != null && prefs.contains(PING_ID);
    }
}

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

License:Apache License

/**
 * Returns the "ping opt in" value from the preference store.
 * This would be true if there's a valid preference store and
 * the user opted for sending ping statistics.
 *//*from w w  w.j a v  a  2 s  .c om*/
public boolean isPingOptIn() {
    PreferenceStore prefs = getPreferenceStore();
    synchronized (DdmsPreferenceStore.class) {
        return prefs != null && prefs.contains(PING_OPT_IN);
    }
}

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./*  www . j  a va2 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

/**
 * Send a "ping" to the Google toolbar server, if enough time has
 * elapsed since the last ping, and if the user has not opted out.
 * If this is the first time, notify the user and offer an opt-out.
 * Note: UI operations (if any) are synchronous, but the actual ping
 * (if any) is sent in a <i>non-daemon</i> background thread.
 *
 * @param app name to report in the ping
 * @param version to report in the ping/*from   w w w  .  java  2 s . c  om*/
 * @param display an optional {@link Display} object to use, or null, if a new one should be
 * created.
 */
public static void ping(final String app, final String version, final Display display) {
    // Unique, randomly assigned ID for this installation.
    PreferenceStore prefs = getPreferenceStore();
    if (prefs != null) {
        if (prefs.contains(PING_ID) == false) {
            // First time: make up a new ID.  TODO: Use something more random?
            prefs.setValue(PING_ID, new Random().nextLong());

            // ask the user whether he/she wants to opt-out.
            // This will call doPing in the Display thread after the dialog closes.
            getUserPermissionAndPing(app, version, prefs, display);
        } else {
            doPing(app, version, prefs);
        }
    }
}