Search in sources :

Example 61 with IEclipsePreferences

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

the class CreaterepoTreeTest method addTestPreferences.

/**
 * Add some test tags in the preferences.
 *
 * @throws BackingStoreException
 */
private void addTestPreferences() throws BackingStoreException {
    IEclipsePreferences pref = project.getEclipsePreferences();
    pref.put(CreaterepoPreferenceConstants.PREF_DISTRO_TAG, preparePrefValue(DISTRO_TAGS));
    pref.put(CreaterepoPreferenceConstants.PREF_CONTENT_TAG, preparePrefValue(CONTENT_TAGS));
    pref.put(CreaterepoPreferenceConstants.PREF_REPO_TAG, preparePrefValue(REPO_TAGS));
    pref.flush();
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences)

Example 62 with IEclipsePreferences

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

the class CreaterepoTreeTest method tearDown.

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

Example 63 with IEclipsePreferences

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

the class RPMQuery method eval.

/**
 * Uses RPM to eval the given string.
 * @param project Underlying project.
 * @param toEval The string to be evaled.
 * @return The value of the evaluation.
 * @throws CoreException If there is IOException when calling.
 * @since 2.1
 */
public static String eval(IProject project, String toEval) throws CoreException {
    IEclipsePreferences node = DefaultScope.INSTANCE.getNode(IRPMConstants.RPM_CORE_ID);
    // $NON-NLS-1$
    String rpmCmd = node.get(IRPMConstants.RPM_CMD, "");
    List<String> command = new ArrayList<>();
    command.add(rpmCmd);
    // $NON-NLS-1$
    command.add("--eval");
    command.add(toEval);
    try {
        return Utils.runCommandToString(project, command.toArray(new String[command.size()]));
    } catch (IOException e) {
        throw new CoreException(new Status(IStatus.ERROR, IRPMConstants.RPM_CORE_ID, e.getMessage(), e));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) CoreException(org.eclipse.core.runtime.CoreException) IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 64 with IEclipsePreferences

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

the class RPMQuery method query.

private static String query(IFile rpmFile, String... args) {
    IEclipsePreferences node = DefaultScope.INSTANCE.getNode(IRPMConstants.RPM_CORE_ID);
    // $NON-NLS-1$
    String rpmCmd = node.get(IRPMConstants.RPM_CMD, "");
    List<String> command = new ArrayList<>();
    command.add(rpmCmd);
    command.addAll(Arrays.asList(args));
    command.add(rpmFile.getLocation().toOSString());
    try {
        return Utils.runCommandToString(command.toArray(new String[command.size()]));
    } catch (IOException e) {
    // ignore - nothing that deserves showing to the user
    }
    // $NON-NLS-1$
    return "";
}
Also used : IEclipsePreferences(org.eclipse.core.runtime.preferences.IEclipsePreferences) ArrayList(java.util.ArrayList) IOException(java.io.IOException)

Example 65 with IEclipsePreferences

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

the class MetadataPageTest method tearDown.

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

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