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

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

Introduction

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

Prototype

int getInt(String name);

Source Link

Document

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

Usage

From source file:com.clustercontrol.monitor.preference.MonitorPreferencePage.java

License:Open Source License

/**
 * ?????//from  w w  w  .  j  av a  2  s .c  om
 */
private void applySetting() {
    IPreferenceStore store = this.getPreferenceStore();

    // ?????

    IWorkbench workbench = ClusterControlPlugin.getDefault().getWorkbench();
    IWorkbenchWindow[] windows = workbench.getWorkbenchWindows();

    int windowCount = windows.length;

    for (int i = 0; i < windowCount; i++) {
        IWorkbenchPage[] pages = windows[i].getPages();
        int pageCount = pages.length;

        for (int j = 0; j < pageCount; j++) {
            ScopeView scopeView = (ScopeView) pages[j].findView(ScopeView.ID);
            if (scopeView != null) {
                int cycle = store.getInt(P_SCOPE_UPDATE_CYCLE);
                scopeView.setInterval(cycle);
                if (store.getBoolean(P_SCOPE_UPDATE_FLG)) {
                    scopeView.startAutoReload();
                } else {
                    scopeView.stopAutoReload();
                }
            }

            StatusView statusView = (StatusView) pages[j].findView(StatusView.ID);
            if (statusView != null) {
                int cycle = store.getInt(P_STATUS_UPDATE_CYCLE);
                statusView.setInterval(cycle);
                if (store.getBoolean(P_STATUS_UPDATE_FLG)) {
                    statusView.startAutoReload();
                } else {
                    statusView.stopAutoReload();
                }
            }

            EventView eventView = (EventView) pages[j].findView(EventView.ID);
            if (eventView != null) {
                int cycle = store.getInt(P_EVENT_UPDATE_CYCLE);
                eventView.setInterval(cycle);
                if (store.getBoolean(P_EVENT_UPDATE_FLG)) {
                    eventView.startAutoReload();
                } else {
                    eventView.stopAutoReload();
                }
            }
        }
    }
}

From source file:com.clustercontrol.monitor.view.EventView.java

License:Open Source License

/**
 * ????/*  ww w . j ava  2s .  c  o  m*/
 * <p>
 * <ol>
 * <li>????</li>
 * <li>??????</li>
 * <li>???</li>
 * <li>??[]??????????</li>
 * <li>??[]??????????</li>
 * <li>???</li>
 * </ol>
 *
 * @param parent ??
 * @return ?
 *
 * @see com.clustercontrol.monitor.composite.EventListComposite#EventListComposite(Composite, int)
 * @see #createContextMenu()
 * @see #update()
 */
@Override
protected Composite createListContents(Composite parent) {
    GridLayout layout = new GridLayout(1, true);
    parent.setLayout(layout);
    layout.marginHeight = 0;
    layout.marginWidth = 0;

    this.tableComposite = new EventListComposite(parent, SWT.NONE);
    WidgetTestUtil.setTestId(this, null, tableComposite);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    this.tableComposite.setLayoutData(gridData);

    //??
    createContextMenu();

    // ??
    IPreferenceStore store = ClusterControlPlugin.getDefault().getPreferenceStore();

    this.setInterval(store.getInt(MonitorPreferencePage.P_EVENT_UPDATE_CYCLE));

    if (store.getBoolean(MonitorPreferencePage.P_EVENT_UPDATE_FLG)) {
        this.startAutoReload();
    }
    // ?
    this.tableComposite.getTableViewer().addSelectionChangedListener(new EventListSelectionChangedListener());

    return this.tableComposite;
}

From source file:com.clustercontrol.monitor.view.ScopeView.java

License:Open Source License

/**
 * ????/*from w  w  w.jav  a 2s . c om*/
 * <p>
 * <ol>
 * <li>????</li>
 * <li>???</li>
 * <li>??[]??????????</li>
 * <li>??[]??????????</li>
 * <li>???</li>
 * </ol>
 *
 * @param parent ??
 * @return ?
 *
 * @see com.clustercontrol.monitor.composite.ScopeListComposite#ScopeListComposite(Composite, int)
 * @see #update()
 */
@Override
protected Composite createListContents(Composite parent) {
    GridLayout layout = new GridLayout(1, true);
    parent.setLayout(layout);
    layout.marginHeight = 0;
    layout.marginWidth = 0;

    this.tableComposite = new ScopeListComposite(parent, SWT.NONE);
    WidgetTestUtil.setTestId(this, null, tableComposite);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    this.tableComposite.setLayoutData(gridData);

    this.update(false);

    // ??
    IPreferenceStore store = ClusterControlPlugin.getDefault().getPreferenceStore();

    this.setInterval(store.getInt(MonitorPreferencePage.P_SCOPE_UPDATE_CYCLE));

    if (store.getBoolean(MonitorPreferencePage.P_SCOPE_UPDATE_FLG)) {
        this.startAutoReload();
    }

    return this.tableComposite;
}

From source file:com.clustercontrol.monitor.view.StatusView.java

License:Open Source License

/**
 * ????//  w w w . j a  v  a2 s  .  c o m
 * <p>
 * <ol>
 * <li>????</li>
 * <li>??????</li>
 * <li>???</li>
 * <li>??[]??????????</li>
 * <li>??[]??????????</li>
 * <li>???</li>
 * </ol>
 *
 * @param parent ??
 * @return ?
 *
 * @see com.clustercontrol.monitor.composite.StatusListComposite#StatusListComposite(Composite, int)
 * @see #createContextMenu()
 * @see #update()
 */
@Override
protected Composite createListContents(Composite parent) {
    GridLayout layout = new GridLayout(1, true);
    parent.setLayout(layout);
    layout.marginHeight = 0;
    layout.marginWidth = 0;

    this.tableComposite = new StatusListComposite(parent, SWT.NONE);
    WidgetTestUtil.setTestId(this, null, tableComposite);
    GridData gridData = new GridData();
    gridData.horizontalAlignment = GridData.FILL;
    gridData.verticalAlignment = GridData.FILL;
    gridData.grabExcessHorizontalSpace = true;
    gridData.grabExcessVerticalSpace = true;
    this.tableComposite.setLayoutData(gridData);

    //??
    createContextMenu();

    // ??
    IPreferenceStore store = ClusterControlPlugin.getDefault().getPreferenceStore();

    this.setInterval(store.getInt(MonitorPreferencePage.P_STATUS_UPDATE_CYCLE));

    if (store.getBoolean(MonitorPreferencePage.P_STATUS_UPDATE_FLG)) {
        this.startAutoReload();
    }

    // ?
    this.tableComposite.getTableViewer().addSelectionChangedListener(new StatusListSelectionChangedListener());

    return this.tableComposite;
}

From source file:com.clustercontrol.util.LoginManager.java

License:Open Source License

private static void connect(String managerName) throws Exception {
    synchronized (getInstance()) {
        EndpointUnit endpointUnit = EndpointManager.get(managerName);
        try {/*  w  w w  .  ja va 2  s  . co m*/
            endpointUnit.connect();
            String url = endpointUnit.getUrlListStr();
            IPreferenceStore store = ClusterControlPlugin.getDefault().getPreferenceStore();
            // ????
            // ?URL?URL?????
            int numOfUrlHistory = store.getInt(LoginManager.KEY_URL_NUM);
            boolean urlExist = false;
            for (int i = 0; i < numOfUrlHistory; i++) {
                String histUrl = store.getString(LoginManager.KEY_URL + "_" + i);
                if (url.equals(histUrl)) {
                    //TODO ????URL??????URL??????
                    urlExist = true;
                    break;
                }
            }
            //?????URL??
            if (!urlExist && !url.equals("")) {
                store.setValue(LoginManager.KEY_URL + "_" + numOfUrlHistory, url);
                numOfUrlHistory++;
                store.setValue(LoginManager.KEY_URL_NUM, numOfUrlHistory);
            }
        } catch (Exception e) {
            throw e;
        }
    }
}

From source file:com.clustercontrol.util.LoginManager.java

License:Open Source License

public static void login(Map<String, String> map) {
    setup();/* w ww. java 2  s  .c o  m*/

    Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
    int returnCode = IDialogConstants.RETRY_ID;

    // Increase login attempt time
    getInstance().loginAttempts++;

    //
    LoginDialog dialog = new LoginDialog(shell, map);

    if (map.containsKey(KEY_BASIC_AUTH) && map.get(KEY_BASIC_AUTH).equals("true")) {
        // ?
        returnCode = IDialogConstants.OK_ID;
    }

    // Reopen if RETRY_ID returned
    while (returnCode == IDialogConstants.RETRY_ID) {
        returnCode = dialog.open();
    }

    // Close all if no connection left
    if (returnCode != IDialogConstants.OK_ID && !LoginManager.isLogin()) {
        m_log.info("login() : cancel, " + returnCode);
        updateStatusBar();
        return;
    }

    // Proceed connecting if not Close button pressed
    if (returnCode == IDialogConstants.OK_ID) {
        if (addConnect(dialog.getLoginList())) {
            ClientSession.doCheck();

            // ??
            IPreferenceStore store = ClusterControlPlugin.getDefault().getPreferenceStore();
            int interval = store.getInt(KEY_INTERVAL);
            m_log.trace("LoginManager.getInterval() interval = " + interval);
            ClientSession.startChecktask(interval);

            // Save login info
            saveLoginState();
        }
    }
    updateStatusBar();
}

From source file:com.clustercontrol.util.LoginManager.java

License:Open Source License

public static void setup() {
    IPreferenceStore store = ClusterControlPlugin.getDefault().getPreferenceStore();

    // Timeout (ms)
    int httpRequestTimeout = store.getInt(KEY_HTTP_REQUEST_TIMEOUT);
    EndpointManager.setHttpRequestTimeout(httpRequestTimeout);
    m_log.info("request.timeout=" + httpRequestTimeout);

    // Proxy//from  w  w  w  . j av  a  2s .  co  m
    if (store.getBoolean(KEY_PROXY_ENABLE) == true) {
        String proxyHost = store.getString(KEY_PROXY_HOST);
        int proxyPort = store.getInt(KEY_PROXY_PORT);
        String proxyUser = store.getString(KEY_PROXY_USER);
        String proxyPass = store.getString(KEY_PROXY_PASSWORD);
        EndpointManager.setProxy(proxyHost, proxyPort);
        EndpointManager.setAuthenticator(proxyUser, proxyPass);
    } else {
        EndpointManager.setProxy(null, 0);
        EndpointManager.setAuthenticator(null, null);
    }
}

From source file:com.dubture.pdt.formatter.IndentGuidePainter.java

License:Open Source License

/**
 * Creates a new painter for the given text viewer.
 * //from   ww  w.  j  av  a  2s .c  om
 * @param textViewer
 *            the text viewer the painter should be attached to
 */
public IndentGuidePainter(ITextViewer textViewer) {
    super();
    fTextViewer = textViewer;
    fTextWidget = textViewer.getTextWidget();
    GC gc = new GC(fTextWidget);
    gc.setAdvanced(true);
    fIsAdvancedGraphicsPresent = gc.getAdvanced();
    gc.dispose();

    IPreferenceStore store = FormatterPlugin.getDefault().getPreferenceStore();
    lineAlpha = store.getInt(PreferenceConstants.LINE_ALPHA);
    lineStyle = store.getInt(PreferenceConstants.LINE_STYLE);
    lineWidth = store.getInt(PreferenceConstants.LINE_WIDTH);
    lineShift = store.getInt(PreferenceConstants.LINE_SHIFT);
    drawLeftEnd = store.getBoolean(PreferenceConstants.DRAW_LEFT_END);
    drawBlankLine = store.getBoolean(PreferenceConstants.DRAW_BLANK_LINE);
    skipCommentBlock = store.getBoolean(PreferenceConstants.SKIP_COMMENT_BLOCK);
}

From source file:com.essiembre.eclipse.rbe.ui.preferences.RBEFormattingPrefPage.java

License:Apache License

@Override
protected Control createContents(Composite parent) {
    IPreferenceStore prefs = getPreferenceStore();
    Composite field = null;/*from   w  w w .  j a va2s  .  c om*/
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(1, false));

    // Show generated by comment?
    field = createFieldComposite(composite);
    showGeneratedBy = new Button(field, SWT.CHECK);
    showGeneratedBy.setSelection(prefs.getBoolean(RBEPreferences.SHOW_GENERATOR));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.showGeneratedBy"));

    // Convert unicode to encoded?
    field = createFieldComposite(composite);
    convertUnicodeToEncoded = new Button(field, SWT.CHECK);
    convertUnicodeToEncoded.setSelection(prefs.getBoolean(RBEPreferences.CONVERT_UNICODE_TO_ENCODED));
    convertUnicodeToEncoded.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
        }
    });
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.convertUnicode"));

    // Use upper case for encoded hexadecimal values?
    field = createFieldComposite(composite, indentPixels);
    convertUnicodeUpperCase = new Button(field, SWT.CHECK);
    convertUnicodeUpperCase.setSelection(prefs.getBoolean(RBEPreferences.CONVERT_UNICODE_TO_ENCODED_UPPER));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.convertUnicode.upper"));

    // Align equal signs?
    field = createFieldComposite(composite);
    alignEqualSigns = new Button(field, SWT.CHECK);
    alignEqualSigns.setSelection(prefs.getBoolean(RBEPreferences.ALIGN_EQUAL_SIGNS));
    alignEqualSigns.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
        }
    });
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.alignEquals"));

    field = createFieldComposite(composite);
    ensureSpacesAroundEquals = new Button(field, SWT.CHECK);
    ensureSpacesAroundEquals.setSelection(prefs.getBoolean(RBEPreferences.SPACES_AROUND_EQUAL_SIGNS));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.spacesAroundEquals"));

    // Group keys?
    field = createFieldComposite(composite);
    groupKeys = new Button(field, SWT.CHECK);
    groupKeys.setSelection(prefs.getBoolean(RBEPreferences.GROUP_KEYS));
    groupKeys.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
        }
    });
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.groupKeys"));

    // Group keys by how many level deep?
    field = createFieldComposite(composite, indentPixels);
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.levelDeep"));
    groupLevelDeep = new Text(field, SWT.BORDER);
    groupLevelDeep.setText(prefs.getString(RBEPreferences.GROUP_LEVEL_DEPTH));
    groupLevelDeep.setTextLimit(2);
    setWidthInChars(groupLevelDeep, 2);
    groupLevelDeep
            .addKeyListener(new IntTextValidatorKeyListener(RBEPlugin.getString("prefs.levelDeep.error")));

    // How many lines between groups?
    field = createFieldComposite(composite, indentPixels);
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.linesBetween"));
    groupLineBreaks = new Text(field, SWT.BORDER);
    groupLineBreaks.setText(prefs.getString(RBEPreferences.GROUP_LINE_BREAKS));
    groupLineBreaks.setTextLimit(2);
    setWidthInChars(groupLineBreaks, 2);
    groupLineBreaks
            .addKeyListener(new IntTextValidatorKeyListener(RBEPlugin.getString("prefs.linesBetween.error")));

    // Align equal signs within groups?
    field = createFieldComposite(composite, indentPixels);
    groupAlignEqualSigns = new Button(field, SWT.CHECK);
    groupAlignEqualSigns.setSelection(prefs.getBoolean(RBEPreferences.GROUP_ALIGN_EQUAL_SIGNS));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.groupAlignEquals"));

    // Wrap lines?
    field = createFieldComposite(composite);
    wrapLines = new Button(field, SWT.CHECK);
    wrapLines.setSelection(prefs.getBoolean(RBEPreferences.WRAP_LINES));
    wrapLines.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
        }
    });
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.wrapLines"));

    // After how many characters should we wrap?
    field = createFieldComposite(composite, indentPixels);
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.wrapLinesChar"));
    wrapCharLimit = new Text(field, SWT.BORDER);
    wrapCharLimit.setText(prefs.getString(RBEPreferences.WRAP_CHAR_LIMIT));
    wrapCharLimit.setTextLimit(4);
    setWidthInChars(wrapCharLimit, 4);
    wrapCharLimit
            .addKeyListener(new IntTextValidatorKeyListener(RBEPlugin.getString("prefs.wrapLinesChar.error")));

    // Align wrapped lines with equal signs?
    field = createFieldComposite(composite, indentPixels);
    wrapAlignEqualSigns = new Button(field, SWT.CHECK);
    wrapAlignEqualSigns.setSelection(prefs.getBoolean(RBEPreferences.WRAP_ALIGN_EQUAL_SIGNS));
    wrapAlignEqualSigns.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
        }
    });
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.wrapAlignEquals"));

    // How many spaces/tabs to use for indenting?
    field = createFieldComposite(composite, indentPixels);
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.wrapIndent"));
    wrapIndentSpaces = new Text(field, SWT.BORDER);
    wrapIndentSpaces.setText(prefs.getString(RBEPreferences.WRAP_INDENT_SPACES));
    wrapIndentSpaces.setTextLimit(2);
    setWidthInChars(wrapIndentSpaces, 2);
    wrapIndentSpaces
            .addKeyListener(new IntTextValidatorKeyListener(RBEPlugin.getString("prefs.wrapIndent.error")));

    // Should we wrap after new line characters
    field = createFieldComposite(composite);
    wrapNewLine = new Button(field, SWT.CHECK);
    wrapNewLine.setSelection(prefs.getBoolean(RBEPreferences.NEW_LINE_NICE));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.newline.nice"));

    // How should new lines appear in properties file
    field = createFieldComposite(composite);
    newLineTypeForce = new Button(field, SWT.CHECK);
    newLineTypeForce.setSelection(prefs.getBoolean(RBEPreferences.FORCE_NEW_LINE_TYPE));
    newLineTypeForce.addSelectionListener(new SelectionAdapter() {
        public void widgetSelected(SelectionEvent event) {
            refreshEnabledStatuses();
        }
    });
    Composite newLineRadioGroup = new Composite(field, SWT.NONE);
    new Label(newLineRadioGroup, SWT.NONE).setText(RBEPlugin.getString("prefs.newline.force"));
    newLineRadioGroup.setLayout(new RowLayout());
    newLineTypes[RBEPreferences.NEW_LINE_UNIX] = new Button(newLineRadioGroup, SWT.RADIO);
    newLineTypes[RBEPreferences.NEW_LINE_UNIX].setText("UNIX (\\n)");
    newLineTypes[RBEPreferences.NEW_LINE_WIN] = new Button(newLineRadioGroup, SWT.RADIO);
    newLineTypes[RBEPreferences.NEW_LINE_WIN].setText("Windows (\\r\\n)");
    newLineTypes[RBEPreferences.NEW_LINE_MAC] = new Button(newLineRadioGroup, SWT.RADIO);
    newLineTypes[RBEPreferences.NEW_LINE_MAC].setText("Mac (\\r)");
    newLineTypes[prefs.getInt(RBEPreferences.NEW_LINE_TYPE)].setSelection(true);

    // Keep empty fields?
    field = createFieldComposite(composite);
    keepEmptyFields = new Button(field, SWT.CHECK);
    keepEmptyFields.setSelection(prefs.getBoolean(RBEPreferences.KEEP_EMPTY_FIELDS));
    new Label(field, SWT.NONE).setText(RBEPlugin.getString("prefs.keepEmptyFields"));

    refreshEnabledStatuses();

    return composite;
}

From source file:com.foosbar.mailsnag.smtp.Server.java

License:Open Source License

public void run() {

    setStatus(ServerState.STARTING);//w  ww  .  j ava  2 s  . com

    // Get Preferences
    IPreferenceStore pStore = Activator.getDefault().getPreferenceStore();

    // Port to listen on.
    int port = pStore.getInt(PreferenceConstants.PARAM_PORT);

    try {
        serverSocket = new ServerSocket(port);

        setStatus(ServerState.LISTENING);

        if (Activator.isDebugMode()) {
            System.out.println("MailSnag Server listening on port " + port);
        }
    } catch (BindException e) {
        System.err.println(String.format(Activator.getResourceBundle().getString("exception.port.bind"), port));
        // Make sure server is marked as stopped
        setStatus(ServerState.STOPPED);
        // Exit thread execution
        throw new RuntimeException(e);
    } catch (IOException e) {
        // Print error to System.err
        e.printStackTrace(System.err);
        // Make sure server is marked as stopped
        setStatus(ServerState.STOPPED);
        // Exit thread execution
        throw new RuntimeException(e);
    }

    try {
        while (ServerState.LISTENING == status) {
            new MailHandler(serverSocket.accept()).start();
        }
    } catch (IOException e) {
        if (Activator.isDebugMode()) {
            // Print error to System.err
            e.printStackTrace(System.err);
        }
    } finally {
        close();
    }
}