Search in sources :

Example 71 with IEclipsePreferences

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

the class CreaterepoPreferenceInitializerTest method testPreferenceInitialization.

/**
 * Test for the initial preferences to be set for the plugin. Test
 * that if the default value is what the return is, then it failed.
 * The defaults are intentionally wrong to test if correct values are
 * stored incorrectly on initialization.
 */
@Test
public void testPreferenceInitialization() {
    IEclipsePreferences node = DefaultScope.INSTANCE.getNode(Activator.PLUGIN_ID);
    assertNotEquals(!CreaterepoPreferenceConstants.DEFAULT_UNIQUE_MD_NAME, node.getBoolean(CreaterepoPreferenceConstants.PREF_UNIQUE_MD_NAME, !CreaterepoPreferenceConstants.DEFAULT_UNIQUE_MD_NAME));
    assertNotEquals(!CreaterepoPreferenceConstants.DEFAULT_GENERATE_DB, node.getBoolean(CreaterepoPreferenceConstants.PREF_GENERATE_DB, !CreaterepoPreferenceConstants.DEFAULT_GENERATE_DB));
    assertNotEquals(!CreaterepoPreferenceConstants.DEFAULT_IGNORE_SYMLINKS, node.getBoolean(CreaterepoPreferenceConstants.PREF_IGNORE_SYMLINKS, !CreaterepoPreferenceConstants.DEFAULT_IGNORE_SYMLINKS));
    assertNotEquals(!CreaterepoPreferenceConstants.DEFAULT_PRETTY, node.getBoolean(CreaterepoPreferenceConstants.PREF_PRETTY_XML, !CreaterepoPreferenceConstants.DEFAULT_PRETTY));
    assertNotEquals(-1309, node.getInt(CreaterepoPreferenceConstants.PREF_WORKERS, -1309));
    assertNotEquals(!CreaterepoPreferenceConstants.DEFAULT_CHECK_TS, node.getBoolean(CreaterepoPreferenceConstants.PREF_CHECK_TS, !CreaterepoPreferenceConstants.DEFAULT_CHECK_TS));
    assertNotEquals(-1309, node.getInt(CreaterepoPreferenceConstants.PREF_CHANGELOG_LIMIT, -1309));
    assertNotEquals(CreaterepoPreferenceConstants.DEFAULT_CHECKSUM.concat("test"), // $NON-NLS-1$
    node.get(// $NON-NLS-1$
    CreaterepoPreferenceConstants.PREF_CHECKSUM, // $NON-NLS-1$
    CreaterepoPreferenceConstants.DEFAULT_CHECKSUM.concat("test")));
    assertNotEquals(CreaterepoPreferenceConstants.DEFAULT_COMPRESS_TYPE.concat("test"), // $NON-NLS-1$
    node.get(// $NON-NLS-1$
    CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE, // $NON-NLS-1$
    CreaterepoPreferenceConstants.DEFAULT_COMPRESS_TYPE.concat("test")));
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) Test(org.junit.Test)

Example 72 with IEclipsePreferences

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

the class CreaterepoCommandCreatorTest method setProjectPreferences.

/**
 * Set test project preferences.
 *
 * @throws BackingStoreException
 */
private void setProjectPreferences() throws BackingStoreException {
    // enable use of project preferences
    IPreferenceStore prefStore = new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.PLUGIN_ID);
    prefStore.setValue(CreaterepoPreferenceConstants.PREF_GENERAL_ENABLED, true);
    // --simple-md-filenames should not be used because project properties are enabled
    prefStore.setValue(CreaterepoPreferenceConstants.PREF_UNIQUE_MD_NAME, false);
    // set the project preferences
    IEclipsePreferences pref = project.getEclipsePreferences();
    // --unique-md-filenames
    pref.putBoolean(CreaterepoPreferenceConstants.PREF_UNIQUE_MD_NAME, true);
    // --no-database
    pref.putBoolean(CreaterepoPreferenceConstants.PREF_GENERATE_DB, false);
    // --skip-symlinks
    pref.putBoolean(CreaterepoPreferenceConstants.PREF_IGNORE_SYMLINKS, true);
    // --pretty
    pref.putBoolean(CreaterepoPreferenceConstants.PREF_PRETTY_XML, false);
    // --workers 13
    pref.putInt(CreaterepoPreferenceConstants.PREF_WORKERS, 13);
    // --checkts
    pref.putBoolean(CreaterepoPreferenceConstants.PREF_CHECK_TS, true);
    // --changelog-limit 37
    pref.putInt(CreaterepoPreferenceConstants.PREF_CHANGELOG_LIMIT, 37);
    // --checksum sha512
    pref.put(CreaterepoPreferenceConstants.PREF_CHECKSUM, ICreaterepoChecksums.SHA512);
    // --compress-type xz
    pref.put(CreaterepoPreferenceConstants.PREF_COMPRESSION_TYPE, ICreaterepoCompressionTypes.XZ);
    // enable deltas
    // --deltas
    prefStore.setValue(CreaterepoPreferenceConstants.PREF_DELTA_ENABLE, true);
    // --num-deltas 13
    pref.putInt(CreaterepoPreferenceConstants.PREF_NUM_DELTAS, 13);
    // --max-delta-rpm-size 37
    pref.putInt(CreaterepoPreferenceConstants.PREF_MAX_DELTA_SIZE, 37);
    // --oldpackagedirs /tmp --oldpackagedirs /home
    // $NON-NLS-1$
    pref.put(CreaterepoPreferenceConstants.PREF_OLD_PACKAGE_DIRS, "/tmp;/home");
    // --distro cpeid,distrotag --distro tag2 --distro tag3 --distro tag4
    // $NON-NLS-1$
    pref.put(CreaterepoPreferenceConstants.PREF_DISTRO_TAG, "cpeid,distrotag;tag2;tag3;tag4");
    // $NON-NLS-1$
    pref.put(CreaterepoPreferenceConstants.PREF_CONTENT_TAG, "");
    pref.flush();
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore)

Example 73 with IEclipsePreferences

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

the class CreaterepoCommandCreatorTest method tearDown.

/**
 * Clear the preferences after each test.
 *
 * @throws BackingStoreException
 */
@After
public void tearDown() throws Exception {
    IEclipsePreferences pref = project.getEclipsePreferences();
    pref.clear();
    pref.flush();
    testProject.restoreDefaults();
    assertEquals(0, pref.keys().length);
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) After(org.junit.After)

Example 74 with IEclipsePreferences

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

the class CreaterepoTest method tearDown.

/**
 * Clear the preferences after each test and destroy the console.
 *
 * @throws BackingStoreException
 */
@After
public void tearDown() throws BackingStoreException {
    IEclipsePreferences pref = project.getEclipsePreferences();
    pref.clear();
    pref.flush();
    assertEquals(0, pref.keys().length);
    console.destroy();
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) After(org.junit.After)

Example 75 with IEclipsePreferences

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

the class ConfigureLabelsCommandHandler method execute.

@SuppressWarnings("unused")
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final ConfigureLabels wizard = new ConfigureLabels();
    final boolean configureLabels = CommandUtils.openWizard(wizard, HandlerUtil.getActiveShell(event));
    if (configureLabels) {
        Map<String, String> labels = wizard.getConfigureLabels();
        StringBuffer buffer = new StringBuffer();
        for (Entry<String, String> entry : labels.entrySet()) {
            buffer.append(entry.getKey());
            // $NON-NLS-1$
            buffer.append('=');
            buffer.append(entry.getValue());
            buffer.append('\u00a0');
        }
        IEclipsePreferences preferences = InstanceScope.INSTANCE.getNode(Activator.PLUGIN_ID);
        preferences.put(CONTAINER_FILTER_LABELS, buffer.toString());
        IDockerConnection connection = CommandUtils.getCurrentConnection(null);
        // force refresh
        connection.getContainers(true);
    }
    return null;
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ConfigureLabels(org.eclipse.linuxtools.internal.docker.ui.wizards.ConfigureLabels) IDockerConnection(org.eclipse.linuxtools.docker.core.IDockerConnection)

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