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

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

Introduction

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

Prototype

@Override
    public void putValue(String name, String value) 

Source Link

Usage

From source file:com.mindquarry.desktop.preferences.profile.Profile.java

License:Open Source License

public static void storeProfiles(PreferenceStore store, List<Profile> profiles) {
    if (store == null) {
        return;/*from  w  w w. j a v  a  2 s .  c o  m*/
    }
    // PreferenceStore cannot properly delete entries, so we first "delete"
    // all entries by setting them to the empty string and then set all
    // entries that are left in the following loop (on reading the config,
    // we ignore empty entries):
    int pos = 0;
    for (String storeKey : store.preferenceNames()) {
        if (storeKey.startsWith(Profile.PROFILE_KEY_BASE)) {
            store.putValue(Profile.PROFILE_KEY_BASE + pos + DELIM + Profile.PREF_NAME, EMPTY);
            store.putValue(Profile.PROFILE_KEY_BASE + pos + DELIM + Profile.PREF_TYPE, EMPTY);
            store.putValue(Profile.PROFILE_KEY_BASE + pos + DELIM + Profile.PREF_SVN_REPOS, EMPTY);
            store.putValue(Profile.PROFILE_KEY_BASE + pos + DELIM + Profile.PREF_LOGIN, EMPTY);
            store.putValue(Profile.PROFILE_KEY_BASE + pos + DELIM + Profile.PREF_SERVER_URL, EMPTY);
            store.putValue(Profile.PROFILE_KEY_BASE + pos + DELIM + Profile.PREF_WORKSPACES, EMPTY);
            store.putValue(Profile.PROFILE_KEY_BASE + pos + DELIM + Profile.PREF_PASSWORD, EMPTY);
            pos++;
        }
    }
    // reset counter and store profiles
    pos = 0;
    for (Profile profile : profiles) {
        store.putValue(Profile.PROFILE_KEY_BASE + pos + DELIM + Profile.PREF_NAME, profile.getName());
        store.putValue(Profile.PROFILE_KEY_BASE + pos + DELIM + Profile.PREF_TYPE, profile.getType().name());

        String svnReposValue = "";
        for (SVNRepoData svnRepo : profile.getSvnRepos()) {
            if (svnReposValue.equals("")) {
                svnReposValue += svnRepo.toString();
            } else {
                svnReposValue += ("," + svnRepo.toString());
            }
        }
        store.putValue(Profile.PROFILE_KEY_BASE + pos + DELIM + Profile.PREF_SVN_REPOS, svnReposValue);

        store.putValue(Profile.PROFILE_KEY_BASE + pos + DELIM + Profile.PREF_LOGIN, profile.getLogin());
        store.putValue(Profile.PROFILE_KEY_BASE + pos + DELIM + Profile.PREF_SERVER_URL,
                profile.getServerURL());
        store.putValue(Profile.PROFILE_KEY_BASE + pos + DELIM + Profile.PREF_WORKSPACES,
                profile.getWorkspaceFolder());

        // pseudo-encrypt and store password
        store.putValue(Profile.PROFILE_KEY_BASE + pos + DELIM + Profile.PREF_PASSWORD,
                encodeBase64(profile.getPassword()));

        // store selected teams
        String selectedTeamsValue = "";
        for (String teamID : profile.getSelectedTeams()) {
            if (selectedTeamsValue.equals("")) {
                selectedTeamsValue += teamID;
            } else {
                selectedTeamsValue += ("," + teamID);
            }
        }
        store.putValue(Profile.PROFILE_KEY_BASE + pos + DELIM + Profile.PREF_SELECTED_TEAMS,
                selectedTeamsValue);
        pos++;
    }
}

From source file:com.mindquarry.desktop.preferences.profile.Profile.java

License:Open Source License

public static void selectProfile(PreferenceStore store, String name) {
    store.putValue(PROFILE_SELECTED, name);
}

From source file:org.eclipse.team.internal.ui.mapping.DiffTreeChangesSection.java

License:Open Source License

private Composite getInitializationPane(Composite parent) {
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setBackground(getListBackgroundColor());
    GridLayout layout = new GridLayout();
    layout.numColumns = 2;/*from   ww w .  ja v a  2 s .c o  m*/
    composite.setLayout(layout);
    GridData data = new GridData(GridData.FILL_BOTH);
    data.grabExcessVerticalSpace = true;
    composite.setLayoutData(data);

    createDescriptionLabel(composite, NLS.bind(TeamUIMessages.DiffTreeChangesSection_3, new String[] { Utils
            .shortenText(SynchronizeView.MAX_NAME_LENGTH, getConfiguration().getParticipant().getName()) }));

    final boolean[] remember = new boolean[] { false };
    final PreferenceStore store = (PreferenceStore) getConfiguration()
            .getProperty(StartupPreferencePage.STARTUP_PREFERENCES);
    Hyperlink link = getForms().createHyperlink(composite, TeamUIMessages.DiffTreeChangesSection_4, SWT.WRAP);
    link.addHyperlinkListener(new HyperlinkAdapter() {
        public void linkActivated(HyperlinkEvent e) {
            if (remember[0] && store != null) {
                store.putValue(StartupPreferencePage.PROP_STARTUP_ACTION,
                        StartupPreferencePage.STARTUP_ACTION_POPULATE);
            }
            getHandler().initializeIfNeeded();
        }
    });
    getForms().getHyperlinkGroup().add(link);

    link = getForms().createHyperlink(composite, TeamUIMessages.DiffTreeChangesSection_5, SWT.WRAP);
    link.addHyperlinkListener(new HyperlinkAdapter() {
        public void linkActivated(HyperlinkEvent e) {
            if (remember[0] && store != null) {
                store.putValue(StartupPreferencePage.PROP_STARTUP_ACTION,
                        StartupPreferencePage.STARTUP_ACTION_SYNCHRONIZE);
            }
            getConfiguration().getParticipant().run(getConfiguration().getSite().getPart());
        }
    });
    getForms().getHyperlinkGroup().add(link);

    if (store != null) {
        final Button rememberButton = getForms().createButton(composite,
                TeamUIMessages.DiffTreeChangesSection_14, SWT.CHECK);
        rememberButton.setToolTipText(TeamUIMessages.DiffTreeChangesSection_14);
        data = new GridData(GridData.FILL_HORIZONTAL);
        data.horizontalSpan = 2;
        data.horizontalIndent = 5;
        data.verticalIndent = 5;
        data.widthHint = 100;
        rememberButton.setLayoutData(data);
        rememberButton.addSelectionListener(new SelectionListener() {
            public void widgetSelected(SelectionEvent e) {
                remember[0] = rememberButton.getSelection();
            }

            public void widgetDefaultSelected(SelectionEvent e) {
                // Do nothing
            }
        });
    }

    return composite;
}

From source file:org.eclipsetrader.ui.internal.application.Activator.java

License:Open Source License

private void migrateSettings() throws Exception {
    IPath workspacePath = Platform.getLocation().append(".metadata").append(".plugins")
            .append("org.eclipse.core.runtime").append(".settings");

    File preferencesFile = workspacePath.append("org.eclipsetrader.ui.prefs").toFile();
    PreferenceStore preferences = new PreferenceStore(preferencesFile.toString());
    if (preferencesFile.exists()) {
        preferences.load();/*from   w  ww . j a  v a  2s. co m*/
    }

    File legacyPreferencesFile = workspacePath.append("org.eclipsetrader.ui.charts.prefs").toFile();
    if (legacyPreferencesFile.exists()) {
        PreferenceStore legacyPreferences = new PreferenceStore(legacyPreferencesFile.toString());
        legacyPreferences.load();
        for (String name : legacyPreferences.preferenceNames()) {
            preferences.putValue(name, legacyPreferences.getString(name));
        }
        legacyPreferencesFile.delete();
    }

    legacyPreferencesFile = workspacePath.append("org.eclipsetrader.ui.trading.prefs").toFile();
    if (legacyPreferencesFile.exists()) {
        PreferenceStore legacyPreferences = new PreferenceStore(legacyPreferencesFile.toString());
        legacyPreferences.load();
        for (String name : legacyPreferences.preferenceNames()) {
            preferences.putValue(name, legacyPreferences.getString(name));
        }
        legacyPreferencesFile.delete();
    }

    legacyPreferencesFile = workspacePath.append("org.eclipsetrader.ui.ats.prefs").toFile();
    if (legacyPreferencesFile.exists()) {
        PreferenceStore legacyPreferences = new PreferenceStore(legacyPreferencesFile.toString());
        legacyPreferences.load();
        for (String name : legacyPreferences.preferenceNames()) {
            preferences.putValue(name, legacyPreferences.getString(name));
        }
        legacyPreferencesFile.delete();
    }

    if (!preferencesFile.exists()) {
        preferencesFile.getParentFile().mkdirs();
    }
    preferences.save();
}

From source file:org.python.pydev.editor.PyCodeScannerTest.java

License:Open Source License

private PyCodeScanner createCodeScanner() {
    PreferenceStore store = new PreferenceStore();
    store.putValue(PydevEditorPrefs.KEYWORD_COLOR, StringConverter.asString(new RGB(1, 0, 0)));
    store.putValue(PydevEditorPrefs.SELF_COLOR, StringConverter.asString(new RGB(2, 0, 0)));
    store.putValue(PydevEditorPrefs.CODE_COLOR, StringConverter.asString(new RGB(3, 0, 0)));
    store.putValue(PydevEditorPrefs.DECORATOR_COLOR, StringConverter.asString(new RGB(4, 0, 0)));
    store.putValue(PydevEditorPrefs.NUMBER_COLOR, StringConverter.asString(new RGB(5, 0, 0)));
    store.putValue(PydevEditorPrefs.FUNC_NAME_COLOR, StringConverter.asString(new RGB(6, 0, 0)));
    store.putValue(PydevEditorPrefs.CLASS_NAME_COLOR, StringConverter.asString(new RGB(7, 0, 0)));
    store.putValue(PydevEditorPrefs.OPERATORS_COLOR, StringConverter.asString(new RGB(8, 0, 0)));
    store.putValue(PydevEditorPrefs.PARENS_COLOR, StringConverter.asString(new RGB(9, 0, 0)));

    this.colorCache = new ColorAndStyleCache(store);
    PyCodeScanner scanner = new PyCodeScanner(colorCache);
    return scanner;
}