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

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

Introduction

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

Prototype

String getDefaultString(String name);

Source Link

Document

Returns the default value for the string-valued preference with the given name.

Usage

From source file:org.eclipse.dltk.mod.ui.preferences.NewScriptProjectPreferencePage.java

License:Open Source License

protected void performDefaults() {
    IPreferenceStore store = getPreferenceStore();
    for (int i = 0; i < fCheckBoxes.size(); i++) {
        Button button = (Button) fCheckBoxes.get(i);
        String key = (String) button.getData();
        button.setSelection(store.getDefaultBoolean(key));
    }//from w  w  w  .  ja v  a2  s  .co  m
    for (int i = 0; i < fRadioButtons.size(); i++) {
        Button button = (Button) fRadioButtons.get(i);
        String[] info = (String[]) button.getData();
        button.setSelection(info[1].equals(store.getDefaultString(info[0])));
    }
    for (int i = 0; i < fTextControls.size(); i++) {
        Text text = (Text) fTextControls.get(i);
        String key = (String) text.getData();
        text.setText(store.getDefaultString(key));
    }
    //      if (fInterpreterEnvironmentCombo != null) {
    //         fInterpreterEnvironmentCombo.select(store.getDefaultInt(CLASSPATH_InterpreterEnvironmentLIBRARY_INDEX));
    //      }

    validateFolders();
    super.performDefaults();
}

From source file:org.eclipse.dltk.ui.preferences.NewScriptProjectPreferencePage.java

License:Open Source License

protected void performDefaults() {
    IPreferenceStore store = getPreferenceStore();
    for (int i = 0; i < fCheckBoxes.size(); i++) {
        Button button = (Button) fCheckBoxes.get(i);
        String key = (String) button.getData();
        button.setSelection(store.getDefaultBoolean(key));
    }/*w  w w  .jav  a2s  .c  o m*/
    for (int i = 0; i < fRadioButtons.size(); i++) {
        Button button = (Button) fRadioButtons.get(i);
        String[] info = (String[]) button.getData();
        button.setSelection(info[1].equals(store.getDefaultString(info[0])));
    }
    for (int i = 0; i < fTextControls.size(); i++) {
        Text text = (Text) fTextControls.get(i);
        String key = (String) text.getData();
        text.setText(store.getDefaultString(key));
    }
    // if (fInterpreterEnvironmentCombo != null) {
    // fInterpreterEnvironmentCombo.select(store.getDefaultInt(CLASSPATH_InterpreterEnvironmentLIBRARY_INDEX));
    // }

    validateFolders();
    super.performDefaults();
}

From source file:org.eclipse.edt.ide.core.utils.ProjectSettingsUtility.java

License:Open Source License

/**
 * Returns the directory in which to generate the resource. First we check for a project-level setting, and fall back on the
 * default generation directory specified in preferences, if there is a preference store.
 * /*  ww  w.ja  v  a  2 s .c om*/
 * @param resource      The resource
 * @param store         The workspace-level preference store
 * @param prefs         The project-level preference store
 * @param propertyID    The project-level property ID
 * @param preferenceID  The workspace-level preference ID
 * @return the directory in which to generate the resource
 */
public static String getGenerationDirectory(IResource resource, IPreferenceStore store,
        IEclipsePreferences prefs, String propertyID, String preferenceID) {
    Preferences propertyPrefs;
    synchronized (lock) {
        propertyPrefs = prefs.node(propertyID);
    }

    String setting = ProjectSettingsUtility.findSetting(resource.getFullPath(), propertyPrefs, true);
    if (setting != null && setting.length() > 0) {
        return setting;
    }

    if (store != null && preferenceID != null && preferenceID.length() > 0) {
        // Use the current or default value from preferences, making sure to convert to the internal format.
        if (setting == null || setting.length() == 0) {
            setting = store.getString(preferenceID);
        }
        if (setting == null || setting.length() == 0) {
            // Shouldn't get here - preference page should display an error if you don't specify a valid default directory.
            setting = store.getDefaultString(preferenceID);
        }
    }
    return EclipseUtilities.convertToInternalPath(setting);
}

From source file:org.eclipse.edt.ide.ui.internal.preferences.SQLRetrievePreferencePage.java

License:Open Source License

/**
 * Initializes states of the controls using default values
 * in the preference store./* w  w  w  .  j a  v a 2s  . co  m*/
 */
private void initializeDefaults() {
    IPreferenceStore store = getPreferenceStore();

    String option = store.getDefaultString(ISQLPreferenceConstants.SQL_RETRIEVE_ITEM_CHAR_CONTROL_OPTION);
    /*for (int i = 0; i < SQLPlugin.EGL_CHAR_OPTION_NON_MNEMONIC_STRINGS.length; i++) {
       if (i == 0 || i == 1) {
    charTypeControlButtons[i].setEnabled(true);
       }
       if (SQLPlugin.EGL_CHAR_OPTION_NON_MNEMONIC_STRINGS[i].equalsIgnoreCase(option))
    charTypeControlButtons[i].setSelection(true);
       else
    charTypeControlButtons[i].setSelection(false);
    }*/

    option = store.getDefaultString(ISQLPreferenceConstants.SQL_RETRIEVE_ITEM_NATIONAL_CHAR_CONTROL_OPTION);
    /*for (int i = 0; i < SQLPlugin.EGL_NATIONAL_CHAR_OPTION_NON_MNEMONIC_STRINGS.length; i++) {
       if (i == 2 || i == 3) {
    nationalCharControlButtons[i].setEnabled(true);
       }
       if (SQLPlugin.EGL_NATIONAL_CHAR_OPTION_NON_MNEMONIC_STRINGS[i].equalsIgnoreCase(option))
    nationalCharControlButtons[i].setSelection(true);
       else
    nationalCharControlButtons[i].setSelection(false);
    }*/

    option = store.getDefaultString(ISQLPreferenceConstants.SQL_RETRIEVE_ITEM_NAME_CASE_CONTROL_OPTION);
    for (int i = 0; i < SQLPlugin.NAME_CASE_OPTION_NON_MNEMONIC_STRINGS.length; i++) {
        if (SQLPlugin.NAME_CASE_OPTION_NON_MNEMONIC_STRINGS[i].equalsIgnoreCase(option))
            caseControlButtons[i].setSelection(true);
        else
            caseControlButtons[i].setSelection(false);
    }

    option = store.getDefaultString(ISQLPreferenceConstants.SQL_RETRIEVE_ITEM_NAME_UNDERSCORE_CONTROL_OPTION);
    for (int i = 0; i < SQLPlugin.NAME_UNDERSCORE_OPTION_NON_MNEMONIC_STRINGS.length; i++) {
        if (SQLPlugin.NAME_UNDERSCORE_OPTION_NON_MNEMONIC_STRINGS[i].equalsIgnoreCase(option))
            underscoreControlButtons[i].setSelection(true);
        else
            underscoreControlButtons[i].setSelection(false);
    }

    retrievePrimaryKeys
            .setSelection(store.getDefaultBoolean(ISQLPreferenceConstants.SQL_RETRIEVE_PRIMARY_KEY_OPTION));
    sqlPromptButton.setSelection(
            store.getDefaultBoolean(ISQLPreferenceConstants.SQL_PROMPT_USERID_AND_PASSWORD_OPTION));
    addSqlDataCode.setSelection(
            store.getDefaultBoolean(ISQLPreferenceConstants.SQL_RETRIEVE_ADD_SQL_DATA_CODE_OPTION));
    addSqlDataCode.setEnabled(false);

    // Version 7.5.1.4 had a boolean preference, but in 7.5.1.5 there are 4 possible
    // values.  To migrate smoothly from the old preference to the new, check if the old
    // preference is set.
    if (store.getBoolean(ISQLPreferenceConstants.SQL_RETRIEVE_USE_CHAR_FOR_DATE_OPTION)) {
        option = IEGLConstants.KEYWORD_CHAR;
    } else {
        option = store.getDefaultString(ISQLPreferenceConstants.SQL_RETRIEVE_USE_TEXT_TYPE_FOR_DATE_OPTION);
    }
    for (int i = 0; i < SQLPlugin.TEXT_TYPE_FOR_DATE_OPTION_NON_MNEMONIC_STRINGS.length; i++) {
        if (SQLPlugin.TEXT_TYPE_FOR_DATE_OPTION_NON_MNEMONIC_STRINGS[i].equalsIgnoreCase(option))
            typeForDateTypesButtons[i].setSelection(true);
        else
            typeForDateTypesButtons[i].setSelection(false);
    }
}

From source file:org.eclipse.emf.compare.tests.performance.large.TestLargeLogicalModel.java

License:Open Source License

@SuppressWarnings("restriction")
@Test//from  w  ww  .j a  v a 2 s .c  om
public void b_logicalModelUMLLargeSplit() {
    try {
        PerformanceMonitor monitor = getPerformance().createMonitor("logicalModelUMLLargeSplit");
        final Data data = new LargeSplitInputData();

        Bundle bundle = Platform.getBundle("org.eclipse.emf.compare.tests.performance");

        final ResourceSet leftResourceSet = (ResourceSet) data.getLeft();
        final ResourceSet rightResourceSet = (ResourceSet) data.getRight();

        IFile leftFile = null;
        IFile rightFile = null;

        final List<IProject> projects = new ArrayList<IProject>();

        leftFile = createProjects(bundle, leftResourceSet, "model_size_large_split",
                "model_size_large_original_model", projects);
        rightFile = createProjects(bundle, rightResourceSet, "model_size_large_split",
                "model_size_large_modified_model", projects);

        final ITypedElement leftTypedElement = new StorageTypedElement(leftFile,
                leftFile.getFullPath().toOSString());
        final ITypedElement rightTypedElement = new StorageTypedElement(rightFile,
                rightFile.getFullPath().toOSString());

        final IPreferenceStore store = EMFCompareIDEUIPlugin.getDefault().getPreferenceStore();
        monitor.measure(false, getStepsNumber(), new Runnable() {
            public void run() {
                store.setValue(EMFCompareUIPreferences.RESOLUTION_SCOPE_PREFERENCE,
                        CrossReferenceResolutionScope.WORKSPACE.name());
                data.logicalModel(leftTypedElement, rightTypedElement);
                store.setValue(EMFCompareUIPreferences.RESOLUTION_SCOPE_PREFERENCE,
                        store.getDefaultString(EMFCompareUIPreferences.RESOLUTION_SCOPE_PREFERENCE));
            }
        });
        data.dispose();

        for (IProject project : projects) {
            project.close(new NullProgressMonitor());
            project.delete(false, new NullProgressMonitor());
        }
        projects.clear();
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail();
    }
}

From source file:org.eclipse.emf.compare.tests.performance.TestLogicalModel.java

License:Open Source License

@SuppressWarnings("restriction")
@Test//from   ww w .  ja  va2 s.  c  o m
public void c_logicalModelUMLSmallSplit() {
    try {
        PerformanceMonitor monitor = getPerformance().createMonitor("logicalModelUMLSmallSplit");
        final Data data = new SmallSplitInputData();

        Bundle bundle = Platform.getBundle("org.eclipse.emf.compare.tests.performance");

        final ResourceSet leftResourceSet = (ResourceSet) data.getLeft();
        final ResourceSet rightResourceSet = (ResourceSet) data.getRight();

        IFile leftFile = null;
        IFile rightFile = null;

        final List<IProject> projects = new ArrayList<IProject>();

        leftFile = createProjects(bundle, leftResourceSet, "model_size_small_split",
                "model_size_small_original_model", projects);
        rightFile = createProjects(bundle, rightResourceSet, "model_size_small_split",
                "model_size_small_modified_model", projects);

        final ITypedElement leftTypedElement = new StorageTypedElement(leftFile,
                leftFile.getFullPath().toOSString());
        final ITypedElement rightTypedElement = new StorageTypedElement(rightFile,
                rightFile.getFullPath().toOSString());

        final IPreferenceStore store = EMFCompareIDEUIPlugin.getDefault().getPreferenceStore();
        monitor.measure(false, getStepsNumber(), new Runnable() {
            public void run() {
                store.setValue(EMFCompareUIPreferences.RESOLUTION_SCOPE_PREFERENCE,
                        CrossReferenceResolutionScope.WORKSPACE.name());
                data.logicalModel(leftTypedElement, rightTypedElement);
                store.setValue(EMFCompareUIPreferences.RESOLUTION_SCOPE_PREFERENCE,
                        store.getDefaultString(EMFCompareUIPreferences.RESOLUTION_SCOPE_PREFERENCE));
            }
        });
        data.dispose();

        for (IProject project : projects) {
            project.close(new NullProgressMonitor());
            project.delete(false, new NullProgressMonitor());
        }
        projects.clear();
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail();
    }
}

From source file:org.eclipse.emf.compare.tests.performance.TestLogicalModel.java

License:Open Source License

@SuppressWarnings("restriction")
@Test//from ww w  . jav  a 2s.co m
public void d_logicalModelUMLNominalSplit() {
    try {
        PerformanceMonitor monitor = getPerformance().createMonitor("logicalModelUMLNominalSplit");
        final Data data = new NominalSplitInputData();

        Bundle bundle = Platform.getBundle("org.eclipse.emf.compare.tests.performance");

        final ResourceSet leftResourceSet = (ResourceSet) data.getLeft();
        final ResourceSet rightResourceSet = (ResourceSet) data.getRight();

        IFile leftFile = null;
        IFile rightFile = null;

        final List<IProject> projects = new ArrayList<IProject>();

        leftFile = createProjects(bundle, leftResourceSet, "model_size_nominal_split",
                "model_size_nominal_original_model", projects);
        rightFile = createProjects(bundle, rightResourceSet, "model_size_nominal_split",
                "model_size_nominal_modified_model", projects);

        final ITypedElement leftTypedElement = new StorageTypedElement(leftFile,
                leftFile.getFullPath().toOSString());
        final ITypedElement rightTypedElement = new StorageTypedElement(rightFile,
                rightFile.getFullPath().toOSString());

        final IPreferenceStore store = EMFCompareIDEUIPlugin.getDefault().getPreferenceStore();
        monitor.measure(false, getStepsNumber(), new Runnable() {
            public void run() {
                store.setValue(EMFCompareUIPreferences.RESOLUTION_SCOPE_PREFERENCE,
                        CrossReferenceResolutionScope.WORKSPACE.name());
                data.logicalModel(leftTypedElement, rightTypedElement);
                store.setValue(EMFCompareUIPreferences.RESOLUTION_SCOPE_PREFERENCE,
                        store.getDefaultString(EMFCompareUIPreferences.RESOLUTION_SCOPE_PREFERENCE));
            }
        });
        data.dispose();

        for (IProject project : projects) {
            project.close(new NullProgressMonitor());
            project.delete(false, new NullProgressMonitor());
        }
        projects.clear();
    } catch (Exception e) {
        e.printStackTrace();
        Assert.fail();
    }
}

From source file:org.eclipse.epf.authoring.ui.preferences.ProcessEditorPreferencePage.java

License:Open Source License

/**
 * Loads data from preference store/* w w  w.  ja  va2  s  .co m*/
 */
private void initData() {
    IPreferenceStore store = getPreferenceStore();

    String str = store.getString(ApplicationPreferenceConstants.PREF_WBS_COLUMNS);
    if (str == null) {
        str = store.getDefaultString(ApplicationPreferenceConstants.PREF_WBS_COLUMNS);
    }
    wbsColumnDescriptors = ProcessEditor.toColumnDescriptorList(str);

    str = store.getString(ApplicationPreferenceConstants.PREF_TBS_COLUMNS);
    if (str == null) {
        str = store.getDefaultString(ApplicationPreferenceConstants.PREF_TBS_COLUMNS);
    }
    tbsColumnDescriptors = ProcessEditor.toColumnDescriptorList(str);

    str = store.getString(ApplicationPreferenceConstants.PREF_WPBS_COLUMNS);
    if (str == null) {
        str = store.getDefaultString(ApplicationPreferenceConstants.PREF_WPBS_COLUMNS);
    }
    wpbsColumnDescriptors = ProcessEditor.toColumnDescriptorList(str);

    // load and set to the default if nothing in the store
    // 154758 - Processes: WBS is blank as default preference is not set for the first time
    if (wbsColumnDescriptors.size() == 0) {
        wbsColumnDescriptors.addAll(ProcessEditor.DEFAULT_WBS_COLUMNS);
        store.setValue(ApplicationPreferenceConstants.PREF_WBS_COLUMNS, toString(wbsColumnDescriptors));

    }

    if (tbsColumnDescriptors.size() == 0) {
        tbsColumnDescriptors.addAll(ProcessEditor.DEFAULT_TBS_COLUMNS);
        store.setValue(ApplicationPreferenceConstants.PREF_TBS_COLUMNS, toString(tbsColumnDescriptors));
    }

    if (wpbsColumnDescriptors.size() == 0) {
        wpbsColumnDescriptors.addAll(ProcessEditor.DEFAULT_WPBS_COLUMNS);
        store.setValue(ApplicationPreferenceConstants.PREF_WPBS_COLUMNS, toString(wpbsColumnDescriptors));
    }

    columnDescriptorLists = new List[] { wbsColumnDescriptors, tbsColumnDescriptors, wpbsColumnDescriptors };
}

From source file:org.eclipse.equinox.internal.p2.ui.sdk.scheduler.AutomaticUpdatesPreferencePage.java

License:Open Source License

protected void performDefaults() {
    super.performDefaults();
    IPreferenceStore pref = AutomaticUpdatePlugin.getDefault().getPreferenceStore();
    enabledCheck.setSelection(pref.getDefaultBoolean(PreferenceConstants.PREF_AUTO_UPDATE_ENABLED));

    setSchedule(pref.getDefaultString(PreferenceConstants.PREF_AUTO_UPDATE_SCHEDULE));
    onScheduleRadio.setSelection(pref.getDefaultBoolean(PreferenceConstants.PREF_AUTO_UPDATE_SCHEDULE));

    dayCombo.setText(AutomaticUpdateScheduler.DAYS[getDay(pref, true)]);
    hourCombo.setText(AutomaticUpdateScheduler.HOURS[getHour(pref, true)]);

    remindOnceRadio.setSelection(!pref.getDefaultBoolean(PreferenceConstants.PREF_REMIND_SCHEDULE));
    remindScheduleRadio.setSelection(pref.getDefaultBoolean(PreferenceConstants.PREF_REMIND_SCHEDULE));
    remindElapseCombo.setText(AutomaticUpdatesPopup
            .getElapsedTimeString(pref.getDefaultString(PreferenceConstants.PREF_REMIND_ELAPSED)));

    searchOnlyRadio.setSelection(!pref.getDefaultBoolean(PreferenceConstants.PREF_DOWNLOAD_ONLY));
    searchAndDownloadRadio.setSelection(pref.getDefaultBoolean(PreferenceConstants.PREF_DOWNLOAD_ONLY));
    pageChanged();//from  ww  w .j a v  a  2s .c o  m
}

From source file:org.eclipse.equinox.internal.p2.ui.sdk.scheduler.AutomaticUpdatesPreferencePage.java

License:Open Source License

private int getDay(IPreferenceStore pref, boolean useDefault) {
    String day = useDefault ? pref.getDefaultString(AutomaticUpdateScheduler.P_DAY)
            : pref.getString(AutomaticUpdateScheduler.P_DAY);
    for (int i = 0; i < AutomaticUpdateScheduler.DAYS.length; i++)
        if (AutomaticUpdateScheduler.DAYS[i].equals(day))
            return i;
    return 0;/*  w ww .j a  v  a2 s.  c  om*/
}