Search in sources :

Example 21 with ScopedPreferenceStore

use of org.eclipse.ui.preferences.ScopedPreferenceStore in project linuxtools by eclipse.

the class RpmlintParser method getMixedUseOfTabsAndSpaces.

private static int getMixedUseOfTabsAndSpaces(String refferedContent) {
    int lineNbr = -1;
    if (refferedContent.indexOf("(spaces: line") > -1) {
        // $NON-NLS-1$
        String tabsAndSpacesPref = new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.PLUGIN_ID).getString(PreferenceConstants.P_RPMLINT_TABS_AND_SPACES);
        // $NON-NLS-1$
        String[] spacesAndTabs = refferedContent.split("line");
        if (tabsAndSpacesPref == PreferenceConstants.P_RPMLINT_SPACES) {
            lineNbr = Integer.parseInt(// $NON-NLS-1$
            spacesAndTabs[1].split(",")[0].trim());
        } else {
            lineNbr = Integer.parseInt(spacesAndTabs[2].replaceFirst("\\)", EMPTY_STRING).trim());
        }
    }
    return lineNbr;
}
Also used : ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore)

Example 22 with ScopedPreferenceStore

use of org.eclipse.ui.preferences.ScopedPreferenceStore in project linuxtools by eclipse.

the class PreferenceInitializer method initializeDefaultPreferences.

@Override
public void initializeDefaultPreferences() {
    IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, Activator.PLUGIN_ID);
    store.setDefault(PreferenceConstants.P_RPMLINT_PATH, PreferenceConstants.DP_RPMLINT_PATH);
    store.setDefault(PreferenceConstants.P_RPMLINT_TABS_AND_SPACES, PreferenceConstants.P_RPMLINT_SPACES);
}
Also used : IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore)

Example 23 with ScopedPreferenceStore

use of org.eclipse.ui.preferences.ScopedPreferenceStore 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 24 with ScopedPreferenceStore

use of org.eclipse.ui.preferences.ScopedPreferenceStore in project linuxtools by eclipse.

the class UiUtils method pluginSanityCheck.

public static void pluginSanityCheck() throws IOException {
    boolean exists = (new File(PreferenceConstants.RPMMACRO_FILE)).exists();
    // it with the appropriate command.
    if (!exists && Files.exists(Paths.get("/usr/bin/rpmdev-setuptree"))) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        org.eclipse.linuxtools.rpm.core.utils.Utils.runCommandToInputStream("rpmdev-setuptree");
    }
    // Check RPM tool preference.
    IPreferenceStore store = new ScopedPreferenceStore(InstanceScope.INSTANCE, FrameworkUtil.getBundle(UiUtils.class).getSymbolicName());
    String currentRpmTool = store.getString(PreferenceConstants.P_CURRENT_RPMTOOLS);
    if (!Files.exists(Paths.get("/usr/bin/yum"))) {
        // $NON-NLS-1$
        if (currentRpmTool.equals(PreferenceConstants.DP_RPMTOOLS_YUM)) {
            store.setValue(PreferenceConstants.P_CURRENT_RPMTOOLS, PreferenceConstants.DP_RPMTOOLS_RPM);
        }
    } else if (!Files.exists(Paths.get("/usr/bin/urpmq"))) {
        // $NON-NLS-1$
        if (currentRpmTool.equals(PreferenceConstants.DP_RPMTOOLS_URPM)) {
            store.setValue(PreferenceConstants.P_CURRENT_RPMTOOLS, PreferenceConstants.DP_RPMTOOLS_RPM);
        }
    }
}
Also used : IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) File(java.io.File) ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore)

Aggregations

ScopedPreferenceStore (org.eclipse.ui.preferences.ScopedPreferenceStore)24 ProjectScope (org.eclipse.core.resources.ProjectScope)9 IPreferenceStore (org.eclipse.jface.preference.IPreferenceStore)8 IOException (java.io.IOException)4 IProject (org.eclipse.core.resources.IProject)4 IResource (org.eclipse.core.resources.IResource)3 CoreException (org.eclipse.core.runtime.CoreException)3 IExtensionPoint (org.eclipse.core.runtime.IExtensionPoint)3 IConfigurationElement (org.eclipse.core.runtime.IConfigurationElement)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 ILaunch (org.eclipse.debug.core.ILaunch)2 Launch (org.eclipse.debug.core.Launch)2 Before (org.junit.Before)2 BufferedInputStream (java.io.BufferedInputStream)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 HashMap (java.util.HashMap)1 Entry (java.util.Map.Entry)1