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.centurylink.mdw.plugin.preferences.UrlsPreferencePage.java

License:Apache License

protected void initializeValues() {
    IPreferenceStore store = getPreferenceStore();

    mdwReleasesUrlTextField.setText(store.getString(PREFS_MDW_RELEASES_URL));
    includePreviewReleasesCheckbox.setSelection(store.getBoolean(PREFS_INCLUDE_PREVIEW_BUILDS));
    workspaceSetupUrlTextField.setText(store.getString(PREFS_WORKSPACE_SETUP_URL));
    discoveryUrlTextField.setText(store.getString(PREFS_DISCOVERY_URL));
    httpConnectTimeoutText.setText(String.valueOf(store.getInt(PREFS_HTTP_CONNECT_TIMEOUT_MS)));
    httpReadTimeoutText.setText(String.valueOf(store.getInt(PREFS_HTTP_READ_TIMEOUT_MS)));
    smtpHostTextField.setText(store.getString(PREFS_SMTP_HOST));
    smtpPortTextField.setText(String.valueOf(store.getInt(PREFS_SMTP_PORT)));
}

From source file:com.chookapp.org.bracketeer.preferences.PreferencesInitializer.java

License:Open Source License

@Override
public void initializeDefaultPreferences() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();

    IConfigurationElement[] config = Platform.getExtensionRegistry()
            .getConfigurationElementsFor(ProcessorsRegistry.PROC_FACTORY_ID);

    for (IConfigurationElement element : config) {
        String pluginName = element.getAttribute("name"); //$NON-NLS-1$

        defualtHighlights(store, element, pluginName);
        defualtHints(store, element, pluginName);
    }// www .  ja va  2 s.  co m

    IPreferenceStore editorsStore = EditorsUI.getPreferenceStore();
    store.setDefault(PreferencesConstants.General.HYPERLINK_MODIFIERS, editorsStore
            .getInt(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_HYPERLINK_KEY_MODIFIER_MASK));
}

From source file:com.cisco.yangide.editor.editors.text.YangFormattingStrategy.java

License:Open Source License

@SuppressWarnings("unchecked")
@Override/*from w  w  w .j ava2s. c o m*/
public void format() {
    super.format();
    final IDocument document = documents.removeFirst();
    final TypedPosition partition = partitions.removeFirst();

    if (document != null && partition != null) {
        Map<String, IDocumentPartitioner> partitioners = null;
        try {
            YangFormattingPreferences pref = new YangFormattingPreferences();

            IPreferenceStore store = YangUIPlugin.getDefault().getPreferenceStore();
            pref.setSpaceForTabs(store.getBoolean(YangPreferenceConstants.FMT_INDENT_SPACE));
            pref.setIndentSize(store.getInt(YangPreferenceConstants.FMT_INDENT_WIDTH));
            pref.setCompactImport(store.getBoolean(YangPreferenceConstants.FMT_COMPACT_IMPORT));
            pref.setFormatComment(store.getBoolean(YangPreferenceConstants.FMT_COMMENT));
            pref.setFormatStrings(store.getBoolean(YangPreferenceConstants.FMT_STRING));
            pref.setMaxLineLength(store.getInt(YangPreferenceConstants.FMT_MAX_LINE_LENGTH));

            int offset = partition.getOffset();
            final TextEdit edit = new YangCodeFormatter(pref).format(document.get(), offset,
                    partition.getLength(), getIndentationLevel(document, offset),
                    TextUtilities.getDefaultLineDelimiter(document));
            if (edit != null) {
                if (edit.getChildrenSize() > 20) {
                    partitioners = TextUtilities.removeDocumentPartitioners(document);
                }

                edit.apply(document);
            }

        } catch (MalformedTreeException | BadLocationException e) {
            YangEditorPlugin.log(e);
        } finally {
            if (partitioners != null) {
                TextUtilities.addDocumentPartitioners(document, partitioners);
            }
        }
    }
}

From source file:com.cisco.yangide.ext.refactoring.RefactorUtil.java

License:Open Source License

/**
 * Format code snippet according formating preferences.
 *
 * @param snipped code snippet//  www . j  a va 2 s .c  o m
 * @param indentationLevel indentation level
 * @return formatted code
 */
public static String formatCodeSnipped(String snipped, int indentationLevel) {
    YangFormattingPreferences pref = new YangFormattingPreferences();

    IPreferenceStore store = YangUIPlugin.getDefault().getPreferenceStore();
    pref.setSpaceForTabs(store.getBoolean(YangPreferenceConstants.FMT_INDENT_SPACE));
    pref.setIndentSize(store.getInt(YangPreferenceConstants.FMT_INDENT_WIDTH));
    pref.setCompactImport(store.getBoolean(YangPreferenceConstants.FMT_COMPACT_IMPORT));
    pref.setFormatComment(store.getBoolean(YangPreferenceConstants.FMT_COMMENT));
    pref.setFormatStrings(store.getBoolean(YangPreferenceConstants.FMT_STRING));
    pref.setMaxLineLength(store.getInt(YangPreferenceConstants.FMT_MAX_LINE_LENGTH));

    return YangParserUtil.formatYangSource(pref, snipped.toCharArray(), indentationLevel,
            System.getProperty("line.separator")); //$NON-NLS-1$
}

From source file:com.cisco.yangide.ui.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);
        }//from   w  ww.  j a  va 2 s.c o m
        return;
    }

    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);
        }

    }
}

From source file:com.cisco.yangide.ui.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.ja v a  2s.co m*/
    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));

    }
}

From source file:com.clustercontrol.accesscontrol.dialog.LoginDialog.java

License:Open Source License

/**
* ????//from w  w  w  .j  a  va2  s. co  m
* 
* @param parent ?
*/
@Override
protected Control createDialogArea(Composite parent) {
    // Configure scrolled composite
    ScrolledComposite scrolledComposite = new ScrolledComposite(parent, SWT.V_SCROLL | SWT.H_SCROLL);
    scrolledComposite.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, true));
    scrolledComposite.setExpandVertical(true);
    scrolledComposite.setExpandHorizontal(true);

    scrolledComposite.setLayout(new GridLayout());
    // Add content to scrolled composite
    Composite scrolledContent = new Composite(scrolledComposite, SWT.NONE);
    scrolledContent.setLayout(new GridLayout(4, false));

    if (inputList.isEmpty()) {
        if (0 < EndpointManager.sizeOfAll()) {
            // 1. Load manager from EndpointManager
            List<EndpointUnit> endpointUnitList = EndpointManager.getAllManagerList();
            int connectedLen = endpointUnitList.size();
            for (int i = 0; i < connectedLen; i++) {
                EndpointUnit endpointUnit = endpointUnitList.get(i);
                inputList.add(new LoginInput(endpointUnit.getUserId(), endpointUnit.getPassword(),
                        endpointUnit.getUrlListStr(), endpointUnit.getManagerName(), endpointUnit.getStatus()));
            }
        } else if (paramMap.size() > 0) {
            // 2. Load manager from GET query
            String[] urls = new String[] {};
            String[] users = new String[] {};
            String[] managerNames = new String[] {};

            if (paramMap.containsKey(LoginManager.KEY_URL_LOGIN_URL)) {
                urls = paramMap.get(LoginManager.KEY_URL_LOGIN_URL).split(";");
            }
            if (paramMap.containsKey(LoginManager.KEY_URL_UID)) {
                users = paramMap.get(LoginManager.KEY_URL_UID).split(";");
            }
            if (paramMap.containsKey(LoginManager.KEY_URL_MANAGER_NAME)) {
                managerNames = paramMap.get(LoginManager.KEY_URL_MANAGER_NAME).split(";");
            }

            for (int cnt = 0; cnt < maxConnectManager; ++cnt) {
                if (urls.length > cnt) {
                    // URL?????
                    String url = urls[cnt];
                    String userId = LoginManager.VALUE_UID;
                    String managerName = null;

                    if (users.length > cnt) {
                        userId = users[cnt];
                    }

                    if (managerNames.length > cnt) {
                        managerName = managerNames[cnt];
                    }

                    inputList.add(new LoginInput(userId, "", url, managerName));
                } else {
                    // URL???????
                    break;
                }
            }
        } else {
            // 3. Load record(s) from history
            IPreferenceStore store = ClusterControlPlugin.getDefault().getPreferenceStore();
            int historyNum = store.getInt(LoginManager.KEY_LOGIN_STATUS_NUM);
            if (historyNum > maxConnectManager) {
                // ????
                historyNum = maxConnectManager;
            }
            if (0 < historyNum) {
                // 1. Try to reload from history
                for (int i = 0; i < historyNum; i++) {
                    String userId = store.getString(LoginManager.KEY_LOGIN_STATUS_UID + "_" + i);
                    String password = "";
                    String url = store.getString(LoginManager.KEY_LOGIN_STATUS_URL + "_" + i);
                    String managerName = store.getString(LoginManager.KEY_LOGIN_STATUS_MANAGERNAME + "_" + i);

                    // Use ENV setting at first when existed
                    if (0 == i) {
                        // ??
                        String envUserId = System.getenv(LoginManager.ENV_HINEMOS_MANAGER_USER);
                        if (null != envUserId && 0 != envUserId.length()) {
                            userId = envUserId;
                        }
                        String envPassword = System.getenv(LoginManager.ENV_HINEMOS_MANAGER_PASS);
                        if (null != envPassword && 0 != envPassword.length()) {
                            password = envPassword;
                        }
                        String envUrl = System.getenv(LoginManager.ENV_HINEMOS_MANAGER_URL);
                        if (null != envUrl && 0 != envUrl.length()) {
                            url = envUrl;
                        }
                    }
                    inputList.add(new LoginInput(userId, password, url, managerName));
                }
            }
        }
    }

    int unconnected = 0;
    if (inputList.isEmpty()) {
        // Create a default blank one
        LoginInput loginInput = new LoginInput();
        loginInput.render(scrolledContent, true);
        // ?????????????.
        loginInput.setFocus();
        inputList.add(loginInput);
        unconnected++;
    } else {
        // Show inputList
        int newLen = inputList.size();
        for (int i = 0; i < newLen; i++) {
            LoginInput input = inputList.get(i);
            input.render(scrolledContent, 0 == i);

            if (input.getAccount().getStatus() == LoginAccount.STATUS_UNCONNECTED) {
                unconnected++;
            }
            if (newLen - 1 == i) {
                //?????????????. Always focus on the last one
                input.setFocus();
            }
        }
        disableLoginButton = unconnected == 0;
    }

    Label separatorLabel = new Label(parent, SWT.SEPARATOR | SWT.HORIZONTAL);
    separatorLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    m_log.debug("unconnected=" + unconnected + ", inputList.size=" + inputList.size());
    if (1 < inputList.size()) {
        Button useSameIDChkBox = new Button(parent, SWT.CHECK);
        WidgetTestUtil.setTestId(this, "usesameid", useSameIDChkBox);
        useSameIDChkBox.setText(Messages.getString("checkbox.usesameaccount"));

        if (useSameID) {
            autoIDInput(useSameID);
        }
        useSameIDChkBox.setSelection(useSameID);
        useSameIDChkBox.addSelectionListener(new SelectionAdapter() {
            @Override
            public void widgetSelected(SelectionEvent e) {
                autoIDInput(((Button) e.widget).getSelection());
            }
        });
    }

    scrolledComposite.setContent(scrolledContent);
    scrolledComposite.setMinSize(scrolledContent.computeSize(SWT.DEFAULT, SWT.DEFAULT));

    return scrolledComposite;
}

From source file:com.clustercontrol.accesscontrol.dialog.LoginDialog.java

License:Open Source License

/**
 * URL??????//from  ww  w  . j  a  v  a2s  .com
 */
private List<String> getPrefURLs() {
    ArrayList<String> ret = new ArrayList<String>();
    //?URL??
    IPreferenceStore store = ClusterControlPlugin.getDefault().getPreferenceStore();
    int numOfUrlHistory = store.getInt(LoginManager.KEY_URL_NUM);

    for (int i = numOfUrlHistory - 1; i >= 0; i--) {
        String url = store.getString(LoginManager.KEY_URL + "_" + i);
        if (!url.equals("")) {
            ret.add(url);
        }
    }
    return ret;
}

From source file:com.clustercontrol.jobmanagement.preference.JobManagementPreferencePage.java

License:Open Source License

/**
 * []??????//from   www .  jav  a2  s .  c  o  m
 */
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++) {
            int cycle = store.getInt(P_HISTORY_UPDATE_CYCLE);
            boolean flag = store.getBoolean(P_HISTORY_UPDATE_FLG);

            // ?[]
            setUpdateSetting((AutoUpdateView) pages[j].findView(JobHistoryView.ID), cycle, flag);
            // ?[]
            setUpdateSetting(
                    (AutoUpdateView) pages[j].findView("com.clustercontrol.jobmap.view.JobHistoryViewM"), cycle,
                    flag);
            // ?[]
            setUpdateSetting(
                    (AutoUpdateView) pages[j].findView("com.clustercontrol.jobmap.view.JobMapHistoryView"),
                    cycle, flag);
        }
    }
}

From source file:com.clustercontrol.jobmanagement.view.JobHistoryView.java

License:Open Source License

/**
 * ???/*from  www. j  a va 2s .  c o m*/
 *
 * @param parent ?
 *
 * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
 * @see com.clustercontrol.view.AutoUpdateView#setInterval(int)
 * @see com.clustercontrol.view.AutoUpdateView#startAutoReload()
 * @see #createContextMenu()
 * @see #update()
 */
@Override
public void createPartControl(Composite parent) {
    super.createPartControl(parent);
    GridLayout layout = new GridLayout(1, true);
    parent.setLayout(layout);
    layout.marginHeight = 0;
    layout.marginWidth = 0;

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

    //??
    createContextMenu();

    // ?
    this.m_history.getTableViewer().addSelectionChangedListener(new JobHistorySelectionChangedListener());

    //
    this.update(false);

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

    this.setInterval(store.getInt(JobManagementPreferencePage.P_HISTORY_UPDATE_CYCLE));

    if (store.getBoolean(JobManagementPreferencePage.P_HISTORY_UPDATE_FLG)) {
        this.startAutoReload();
    }
}