Search in sources :

Example 26 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project linuxtools by eclipse.

the class CreaterepoDeltaPropertyPageTest method testRestoreDefaults.

/**
 * Test if all preferences modified in the deltas createrepo property
 * page will reset to default.
 */
@Test
public void testRestoreDefaults() {
    bot.checkBox(Messages.CreaterepoDeltaPropertyPage_booleanEnableLabel).click();
    // $NON-NLS-1$
    bot.textWithLabel(Messages.CreaterepoDeltaPropertyPage_maxNumberOfDeltas).setText("9");
    // $NON-NLS-1$
    bot.textWithLabel(Messages.CreaterepoDeltaPropertyPage_maxDeltaSize).setText("13");
    bot.button(ICreaterepoTestConstants.APPLY_AND_CLOSE_BUTTON).click();
    openPropertyPage();
    bot.button(ICreaterepoTestConstants.DEFAULTS).click();
    bot.button(ICreaterepoTestConstants.APPLY_AND_CLOSE_BUTTON).click();
    IEclipsePreferences pref = project.getEclipsePreferences();
    IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
    assertTrue(prefStore.isDefault(CreaterepoPreferenceConstants.PREF_DELTA_ENABLE));
    assertEquals(pref.getInt(CreaterepoPreferenceConstants.PREF_NUM_DELTAS, prefStore.getInt(CreaterepoPreferenceConstants.PREF_NUM_DELTAS)), prefStore.getDefaultInt(CreaterepoPreferenceConstants.PREF_NUM_DELTAS));
    assertEquals(pref.getInt(CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE, prefStore.getInt(CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE)), prefStore.getDefaultInt(CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE));
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Test(org.junit.Test)

Example 27 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project linuxtools by eclipse.

the class CreaterepoGeneralPropertyPageTest method testRestoreDefaults.

/**
 * Test if all preferences modified in the general createrepo property
 * page will reset to default.
 */
@Test
public void testRestoreDefaults() {
    bot.checkBox(Messages.CreaterepoGeneralPropertyPage_projectSettings).click();
    bot.checkBox(Messages.CreaterepoPreferencePage_booleanChecksumName).click();
    bot.checkBox(Messages.CreaterepoPreferencePage_booleanGenerateSQLDB).click();
    bot.checkBox(Messages.CreaterepoPreferencePage_booleanIgnoreSymlinks).click();
    bot.checkBox(Messages.CreaterepoPreferencePage_booleanPrettyXML).click();
    // $NON-NLS-1$
    bot.textWithLabel(Messages.CreaterepoPreferencePage_numWorkers).setText("9");
    // $NON-NLS-1$
    bot.textWithLabel(Messages.CreaterepoPreferencePage_numChangelogLimit).setText("13");
    bot.checkBox(Messages.CreaterepoPreferencePage_booleanCheckTS).click();
    bot.radio(ICreaterepoChecksums.SHA512).click();
    bot.radio(ICreaterepoCompressionTypes.XZ).click();
    bot.button(ICreaterepoTestConstants.APPLY_AND_CLOSE_BUTTON).click();
    openPropertyPage();
    bot.button(ICreaterepoTestConstants.DEFAULTS).click();
    bot.button(ICreaterepoTestConstants.APPLY_AND_CLOSE_BUTTON).click();
    IEclipsePreferences pref = project.getEclipsePreferences();
    IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
    assertTrue(prefStore.isDefault(CreaterepoPreferenceConstants.PREF_GENERAL_ENABLED));
    assertEquals(pref.getBoolean(CreaterepoPreferenceConstants.PREF_UNIQUE_MD_NAME, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_UNIQUE_MD_NAME)), prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_UNIQUE_MD_NAME));
    assertEquals(pref.getBoolean(CreaterepoPreferenceConstants.PREF_GENERATE_DB, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_GENERATE_DB)), prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_GENERATE_DB));
    assertEquals(pref.getBoolean(CreaterepoPreferenceConstants.PREF_IGNORE_SYMLINKS, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_IGNORE_SYMLINKS)), prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_IGNORE_SYMLINKS));
    assertEquals(pref.getBoolean(CreaterepoPreferenceConstants.PREF_PRETTY_XML, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_PRETTY_XML)), prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_PRETTY_XML));
    assertEquals(pref.getInt(CreaterepoPreferenceConstants.PREF_WORKERS, prefStore.getInt(CreaterepoPreferenceConstants.PREF_WORKERS)), prefStore.getDefaultInt(CreaterepoPreferenceConstants.PREF_WORKERS));
    assertEquals(pref.getInt(CreaterepoPreferenceConstants.PREF_CHANGELOG_LIMIT, prefStore.getInt(CreaterepoPreferenceConstants.PREF_CHANGELOG_LIMIT)), prefStore.getDefaultInt(CreaterepoPreferenceConstants.PREF_CHANGELOG_LIMIT));
    assertEquals(pref.getBoolean(CreaterepoPreferenceConstants.PREF_CHECK_TS, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_CHECK_TS)), prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_CHECK_TS));
    assertEquals(pref.get(CreaterepoPreferenceConstants.PREF_CHECKSUM, prefStore.getDefaultString(CreaterepoPreferenceConstants.PREF_CHECKSUM)), prefStore.getDefaultString(CreaterepoPreferenceConstants.PREF_CHECKSUM));
    assertEquals(pref.get(CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE, prefStore.getDefaultString(CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE)), prefStore.getDefaultString(CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE));
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Test(org.junit.Test)

Example 28 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project linuxtools by eclipse.

the class CreaterepoGeneralPropertyPageTest method testCancel.

/**
 * Test if all preferences stay the same as it was after pressing cancel
 * instead of ok.
 */
@Test
public void testCancel() {
    bot.checkBox(Messages.CreaterepoGeneralPropertyPage_projectSettings).click();
    bot.checkBox(Messages.CreaterepoPreferencePage_booleanChecksumName).click();
    bot.checkBox(Messages.CreaterepoPreferencePage_booleanGenerateSQLDB).click();
    bot.checkBox(Messages.CreaterepoPreferencePage_booleanIgnoreSymlinks).click();
    bot.checkBox(Messages.CreaterepoPreferencePage_booleanPrettyXML).click();
    // $NON-NLS-1$
    bot.textWithLabel(Messages.CreaterepoPreferencePage_numWorkers).setText("9");
    // $NON-NLS-1$
    bot.textWithLabel(Messages.CreaterepoPreferencePage_numChangelogLimit).setText("13");
    bot.checkBox(Messages.CreaterepoPreferencePage_booleanCheckTS).click();
    bot.radio(ICreaterepoChecksums.SHA512).click();
    bot.radio(ICreaterepoCompressionTypes.XZ).click();
    bot.button(ICreaterepoTestConstants.APPLY_AND_CLOSE_BUTTON).click();
    openPropertyPage();
    bot.button(ICreaterepoTestConstants.DEFAULTS).click();
    bot.button(ICreaterepoTestConstants.CANCEL_BUTTON).click();
    openPropertyPage();
    IEclipsePreferences pref = project.getEclipsePreferences();
    IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
    assertEquals(prefStore.getBoolean(CreaterepoPreferenceConstants.PREF_GENERAL_ENABLED), bot.checkBox(Messages.CreaterepoGeneralPropertyPage_projectSettings).isChecked());
    assertEquals(pref.getBoolean(CreaterepoPreferenceConstants.PREF_UNIQUE_MD_NAME, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_UNIQUE_MD_NAME)), bot.checkBox(Messages.CreaterepoPreferencePage_booleanChecksumName).isChecked());
    assertEquals(pref.getBoolean(CreaterepoPreferenceConstants.PREF_GENERATE_DB, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_GENERATE_DB)), bot.checkBox(Messages.CreaterepoPreferencePage_booleanGenerateSQLDB).isChecked());
    assertEquals(pref.getBoolean(CreaterepoPreferenceConstants.PREF_IGNORE_SYMLINKS, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_IGNORE_SYMLINKS)), bot.checkBox(Messages.CreaterepoPreferencePage_booleanIgnoreSymlinks).isChecked());
    assertEquals(pref.getBoolean(CreaterepoPreferenceConstants.PREF_PRETTY_XML, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_PRETTY_XML)), bot.checkBox(Messages.CreaterepoPreferencePage_booleanPrettyXML).isChecked());
    assertEquals(pref.getInt(CreaterepoPreferenceConstants.PREF_WORKERS, prefStore.getInt(CreaterepoPreferenceConstants.PREF_WORKERS)), Integer.parseInt(bot.textWithLabel(Messages.CreaterepoPreferencePage_numWorkers).getText()));
    assertEquals(pref.getInt(CreaterepoPreferenceConstants.PREF_CHANGELOG_LIMIT, prefStore.getInt(CreaterepoPreferenceConstants.PREF_CHANGELOG_LIMIT)), Integer.parseInt(bot.textWithLabel(Messages.CreaterepoPreferencePage_numChangelogLimit).getText()));
    assertEquals(pref.getBoolean(CreaterepoPreferenceConstants.PREF_CHECK_TS, prefStore.getDefaultBoolean(CreaterepoPreferenceConstants.PREF_CHECK_TS)), bot.checkBox(Messages.CreaterepoPreferencePage_booleanCheckTS).isChecked());
    assertTrue(bot.radio(pref.get(CreaterepoPreferenceConstants.PREF_CHECKSUM, prefStore.getDefaultString(CreaterepoPreferenceConstants.PREF_CHECKSUM))).isSelected());
    assertTrue(bot.radio(pref.get(CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE, prefStore.getDefaultString(CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE))).isSelected());
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) Test(org.junit.Test)

Example 29 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project linuxtools by eclipse.

the class CreaterepoPreferenceInitializer method initializeDefaultPreferences.

@Override
public void initializeDefaultPreferences() {
    // initial preferences
    IEclipsePreferences node = DefaultScope.INSTANCE.getNode(Activator.PLUGIN_ID);
    // CreaterepoPreferencePage
    node.putBoolean(CreaterepoPreferenceConstants.PREF_UNIQUE_MD_NAME, CreaterepoPreferenceConstants.DEFAULT_UNIQUE_MD_NAME);
    node.putBoolean(CreaterepoPreferenceConstants.PREF_GENERATE_DB, CreaterepoPreferenceConstants.DEFAULT_GENERATE_DB);
    node.putBoolean(CreaterepoPreferenceConstants.PREF_IGNORE_SYMLINKS, CreaterepoPreferenceConstants.DEFAULT_IGNORE_SYMLINKS);
    node.putBoolean(CreaterepoPreferenceConstants.PREF_PRETTY_XML, CreaterepoPreferenceConstants.DEFAULT_PRETTY);
    node.putInt(CreaterepoPreferenceConstants.PREF_WORKERS, CreaterepoPreferenceConstants.DEFAULT_NUM_WORKERS);
    node.putBoolean(CreaterepoPreferenceConstants.PREF_CHECK_TS, CreaterepoPreferenceConstants.DEFAULT_CHECK_TS);
    node.putInt(CreaterepoPreferenceConstants.PREF_CHANGELOG_LIMIT, CreaterepoPreferenceConstants.DEFAULT_CHANGELOG_LIMIT);
    node.put(CreaterepoPreferenceConstants.PREF_CHECKSUM, CreaterepoPreferenceConstants.DEFAULT_CHECKSUM);
    node.put(CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE, CreaterepoPreferenceConstants.DEFAULT_COMPRESS_TYPE);
    // default preferences
    IPreferenceStore prefStore = Activator.getDefault().getPreferenceStore();
    // CreaterepoPreferencePage
    prefStore.setDefault(CreaterepoPreferenceConstants.PREF_UNIQUE_MD_NAME, CreaterepoPreferenceConstants.DEFAULT_UNIQUE_MD_NAME);
    prefStore.setDefault(CreaterepoPreferenceConstants.PREF_GENERATE_DB, CreaterepoPreferenceConstants.DEFAULT_GENERATE_DB);
    prefStore.setDefault(CreaterepoPreferenceConstants.PREF_IGNORE_SYMLINKS, CreaterepoPreferenceConstants.DEFAULT_IGNORE_SYMLINKS);
    prefStore.setDefault(CreaterepoPreferenceConstants.PREF_PRETTY_XML, CreaterepoPreferenceConstants.DEFAULT_PRETTY);
    prefStore.setDefault(CreaterepoPreferenceConstants.PREF_WORKERS, CreaterepoPreferenceConstants.DEFAULT_NUM_WORKERS);
    prefStore.setDefault(CreaterepoPreferenceConstants.PREF_CHECK_TS, CreaterepoPreferenceConstants.DEFAULT_CHECK_TS);
    prefStore.setDefault(CreaterepoPreferenceConstants.PREF_CHANGELOG_LIMIT, CreaterepoPreferenceConstants.DEFAULT_CHANGELOG_LIMIT);
    prefStore.setDefault(CreaterepoPreferenceConstants.PREF_CHECKSUM, CreaterepoPreferenceConstants.DEFAULT_CHECKSUM);
    prefStore.setDefault(CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE, CreaterepoPreferenceConstants.DEFAULT_COMPRESS_TYPE);
    // CreaterepoGeneralPropertyPage
    prefStore.setDefault(CreaterepoPreferenceConstants.PREF_GENERAL_ENABLED, CreaterepoPreferenceConstants.DEFAULT_GENERAL_ENABLED);
    // CreaterepoDeltaPropertyPage
    prefStore.setDefault(CreaterepoPreferenceConstants.PREF_DELTA_ENABLE, CreaterepoPreferenceConstants.DEFAULT_DELTA_ENABLE);
    prefStore.setDefault(CreaterepoPreferenceConstants.PREF_NUM_DELTAS, CreaterepoPreferenceConstants.DEFAULT_NUM_DELTAS);
    prefStore.setDefault(CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE, CreaterepoPreferenceConstants.DEFAULT_MAX_DELTA_SIZE);
    prefStore.setDefault(CreaterepoPreferenceConstants.PREF_OLD_PACKAGE_DIRS, CreaterepoPreferenceConstants.DEFAULT_OLD_PACKAGE_DIR_LIST);
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore)

Example 30 with IEclipsePreferences

use of org.eclipse.core.runtime.preferences.IEclipsePreferences in project linuxtools by eclipse.

the class DockerContainersView method showContainersWithLabels.

/**
 * Activates {@link ContainersWithLabelsViewerFilter} if the given
 * {@code enabled} argument is <code>false</code>, deactivates the filter
 * otherwise.
 *
 * @param enabled
 *            the argument to enable/disable the filter.
 */
public void showContainersWithLabels(boolean enabled) {
    if (DockerContainersView.this.viewer == null) {
        return;
    }
    if (enabled) {
        this.viewer.addFilter(containersWithLabelsViewerFilter);
    } else {
        final List<ViewerFilter> filters = new ArrayList<>(Arrays.asList(this.viewer.getFilters()));
        // filters
        for (Iterator<ViewerFilter> iterator = filters.iterator(); iterator.hasNext(); ) {
            ViewerFilter viewerFilter = iterator.next();
            if (viewerFilter.equals(containersWithLabelsViewerFilter)) {
                iterator.remove();
            }
        }
        this.viewer.setFilters(filters.toArray(new ViewerFilter[0]));
    }
    // Save enablement across sessions using a preference variable.
    IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
    preferences.putBoolean(FILTER_WITH_LABELS_PREFERENCE, enabled);
    refreshViewTitle();
}
Also used : ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ArrayList(java.util.ArrayList)

Aggregations

IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)79 BackingStoreException (org.osgi.service.prefs.BackingStoreException)15 Test (org.junit.Test)11 InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)9 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)9 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)6 ProjectScope (org.eclipse.core.resources.ProjectScope)6 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)6 After (org.junit.After)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 IOException (java.io.IOException)5 ArrayList (java.util.ArrayList)5 UnsupportedEncodingException (java.io.UnsupportedEncodingException)4 HashMap (java.util.HashMap)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 Map (java.util.Map)4 XMLMemento (com.cubrid.cubridmanager.core.common.xml.XMLMemento)3 ISourceViewer (org.eclipse.jface.text.source.ISourceViewer)3 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2