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

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

Introduction

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

Prototype

boolean contains(String name);

Source Link

Document

Returns whether the named preference is known to this preference store.

Usage

From source file:net.tourbook.common.util.Util.java

License:Open Source License

public static boolean getPrefixPrefBoolean(final IPreferenceStore prefStore, final String prefPrefix,
        final String prefKey) {

    boolean prefValue;

    if (prefStore.contains(prefPrefix + prefKey)) {
        prefValue = prefStore.getBoolean(prefPrefix + prefKey);
    } else {//  w  w w  .j  av  a  2  s.  c o m
        prefValue = prefStore.getDefaultBoolean(prefKey);
    }

    return prefValue;
}

From source file:net.tourbook.common.util.Util.java

License:Open Source License

public static int getPrefixPrefInt(final IPreferenceStore prefStore, final String prefPrefix,
        final String prefKey) {

    int prefValue;

    if (prefStore.contains(prefPrefix + prefKey)) {
        prefValue = prefStore.getInt(prefPrefix + prefKey);
    } else {/*  ww w. j a v a 2s . c om*/
        prefValue = prefStore.getDefaultInt(prefKey);
    }

    return prefValue;
}

From source file:nexcore.tool.uml.ui.core.diagram.action.PrintPreviewAction.java

License:Open Source License

/**
 * @see org.eclipse.jface.action.Action#run()
 *//*from w  w  w . j  a v  a  2  s.  c  om*/
public void run() {
    IPreferenceStore store = UiCorePlugin.getDefault().getPreferenceStore();
    if (!store.contains(ManagerConstant.PREFERENCE_CONSTANT_KEY__NEXCORE_TOOL_UML_PRINT_PREVIEW_MARGIN_TOP)) {
        store.setValue(ManagerConstant.PREFERENCE_CONSTANT_KEY__NEXCORE_TOOL_UML_PRINT_PREVIEW_HEADERFOOTER,
                UMLMessage.LABEL_PRINT_NONE);
        store.setValue(
                ManagerConstant.PREFERENCE_CONSTANT_KEY__NEXCORE_TOOL_UML_PRINT_PREVIEW_HEADERFOOTER_ONLYDIAGRAM,
                false);
        store.setValue(ManagerConstant.PREFERENCE_CONSTANT_KEY__NEXCORE_TOOL_UML_PRINT_PREVIEW_PAGE_SIZE,
                UMLMessage.LABEL_PRINT_A4);
        store.setValue(ManagerConstant.PREFERENCE_CONSTANT_KEY__NEXCORE_TOOL_UML_PRINT_PREVIEW_PAGE_ORIENTATION,
                UMLMessage.LABEL_PRINT_PORTRAIT);

        store.setValue(ManagerConstant.PREFERENCE_CONSTANT_KEY__NEXCORE_TOOL_UML_PRINT_PREVIEW_MARGIN_TOP,
                UICoreConstant.PROJECT_CONSTANTS__ZERO);
        store.setValue(ManagerConstant.PREFERENCE_CONSTANT_KEY__NEXCORE_TOOL_UML_PRINT_PREVIEW_MARGIN_LEFT,
                UICoreConstant.PROJECT_CONSTANTS__ZERO);
        store.setValue(ManagerConstant.PREFERENCE_CONSTANT_KEY__NEXCORE_TOOL_UML_PRINT_PREVIEW_MARGIN_RIGHT,
                UICoreConstant.PROJECT_CONSTANTS__ZERO);
        store.setValue(ManagerConstant.PREFERENCE_CONSTANT_KEY__NEXCORE_TOOL_UML_PRINT_PREVIEW_MARGIN_BOTTOM,
                UICoreConstant.PROJECT_CONSTANTS__ZERO);
        store.setValue(ManagerConstant.PREFERENCE_CONSTANT_KEY__NEXCORE_TOOL_UML_PRINT_PREVIEW_HEADER_TEXT,
                UICoreConstant.EMPTY_STRING);
    }

    DiagramRootEditPart rootPart = (DiagramRootEditPart) ((((AbstractDiagramEditor) getWorkbenchPart())
            .getDiagramGraphicalViewer()).getRootEditPart());

    rootPart.togglePreviewFigure();

}

From source file:org.boomslang.dsl.feature.ui.preference.BuilderPreferenceAccess.java

License:Open Source License

public boolean isAutoBuildEnabled(Object context) {
    IPreferenceStore preferenceStore = preferenceStoreAccess.getContextPreferenceStore(context);
    return preferenceStore.contains(PREF_AUTO_BUILDING) ? preferenceStore.getBoolean(PREF_AUTO_BUILDING) : true;
}

From source file:org.cheetahplatform.tdm.daily.model.Workspace.java

License:Open Source License

public static void initializeRoleFilterPreferences() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    List<Role> roles = RoleLookup.getInstance().getAllRoles();

    for (Role role : roles) {
        String key = SHOW_ROLE + role.getName();
        if (!store.contains(key)) {
            store.setValue(key, String.valueOf(true));
        }//  w w w.  j  av  a  2  s .  c  o m
    }
}

From source file:org.codehaus.groovy.eclipse.refactoring.test.formatter.TestFormatterPreferences.java

License:Apache License

/**
 * Braces preferences should come from the preferences store used by the groovy preferences page
 */// ww  w .  jav  a 2  s  .co  m
public void testBracesPrefs() throws Exception {
    FormatterPreferencesPage preferencesPage = new FormatterPreferencesPage();
    IPreferenceStore groovyPrefs = preferencesPage.getPreferenceStore();
    assertTrue("Using the wrong preferences store?", groovyPrefs.contains(BRACES_START));
    assertTrue("Using the wrong preferences store?", groovyPrefs.contains(BRACES_END));

    groovyPrefs.setValue(BRACES_START, PreferenceConstants.NEXT);
    FormatterPreferences formatPrefs = new FormatterPreferences(gunit);
    assertTrue(formatPrefs.getBracesStart() == PreferenceConstants.NEXT_LINE);

    groovyPrefs.setValue(BRACES_START, PreferenceConstants.SAME);
    formatPrefs = new FormatterPreferences(gunit);
    assertTrue(formatPrefs.getBracesStart() == PreferenceConstants.SAME_LINE);

    groovyPrefs.setValue(BRACES_END, PreferenceConstants.NEXT);
    formatPrefs = new FormatterPreferences(gunit);
    assertTrue(formatPrefs.getBracesEnd() == PreferenceConstants.NEXT_LINE);

    groovyPrefs.setValue(BRACES_END, PreferenceConstants.SAME);
    formatPrefs = new FormatterPreferences(gunit);
    assertTrue(formatPrefs.getBracesEnd() == PreferenceConstants.SAME_LINE);
}

From source file:org.codehaus.groovy.eclipse.refactoring.test.formatter.TestFormatterPreferences.java

License:Apache License

/**
 * Tab related preferences should be inherited from the Java project.
 *//*from   w  w w. j a  va  2  s .  co  m*/
public void testTabRelatedPrefs() throws Exception {
    IPreferenceStore projectPrefs = new ScopedPreferenceStore(new ProjectScope(testProject.getProject()),
            JavaCore.PLUGIN_ID);
    assertTrue("Using the wrong preferences store?", projectPrefs.contains(TAB_CHAR));
    assertTrue("Using the wrong preferences store?", projectPrefs.contains(TAB_SIZE));

    projectPrefs.setValue(TAB_CHAR, JavaCore.SPACE);
    IFormatterPreferences formatPrefs = new FormatterPreferences(gunit);
    assertTrue(formatPrefs.useTabs() == false);

    projectPrefs.setValue(TAB_CHAR, JavaCore.TAB);
    formatPrefs = new FormatterPreferences(gunit);
    assertTrue(formatPrefs.useTabs() == true);

    projectPrefs.setValue(TAB_SIZE, 13);
    formatPrefs = new FormatterPreferences(gunit);
    assertEquals(13, formatPrefs.getTabSize());

    projectPrefs.setValue(TAB_CHAR, JavaCore.TAB);
    projectPrefs.setValue(TAB_SIZE, 11);
    projectPrefs.setValue(INDENT_SIZE, 5);
    formatPrefs = new FormatterPreferences(gunit);
    assertEquals(11, formatPrefs.getIndentationSize());
    assertEquals(11, formatPrefs.getTabSize());

    projectPrefs.setValue(TAB_CHAR, DefaultCodeFormatterConstants.MIXED);
    projectPrefs.setValue(TAB_SIZE, 11);
    projectPrefs.setValue(INDENT_SIZE, 5);
    formatPrefs = new FormatterPreferences(gunit);
    assertEquals(5, formatPrefs.getIndentationSize());
    assertEquals(11, formatPrefs.getTabSize());
}

From source file:org.codehaus.groovy.eclipse.refactoring.test.formatter.TestFormatterPreferences.java

License:Apache License

/**
 * Indentation of empty lines preferences should be inherited from the Java project.
 *//*from   ww  w.j  a va 2s  .c o  m*/
public void testIndentEmptyLinesPrefs() throws Exception {
    IPreferenceStore projectPrefs = new ScopedPreferenceStore(new ProjectScope(testProject.getProject()),
            JavaCore.PLUGIN_ID);
    assertTrue("Using the wrong preferences store?", projectPrefs.contains(INDENT_EMPTY_LINES));

    projectPrefs.setValue(INDENT_EMPTY_LINES, DefaultCodeFormatterConstants.TRUE);
    IFormatterPreferences formatPrefs = new FormatterPreferences(gunit);
    assertTrue(formatPrefs.isIndentEmptyLines());

    projectPrefs.setValue(INDENT_EMPTY_LINES, DefaultCodeFormatterConstants.FALSE);
    formatPrefs = new FormatterPreferences(gunit);
    assertFalse(formatPrefs.isIndentEmptyLines());
}

From source file:org.codehaus.groovy.eclipse.refactoring.test.formatter.TestFormatterPreferences.java

License:Apache License

/**
 * Semicolon preferences should come from the preferences store used by the groovy preferences page
 *//*ww  w . jav a  2  s .  com*/
public void testSemicolonPrefs() throws Exception {
    FormatterPreferencesPage preferencesPage = new FormatterPreferencesPage();
    IPreferenceStore groovyPrefs = preferencesPage.getPreferenceStore();
    assertTrue("Using the wrong preferences store?",
            groovyPrefs.contains(PreferenceConstants.GROOVY_FORMATTER_REMOVE_UNNECESSARY_SEMICOLONS));

    groovyPrefs.setValue(PreferenceConstants.GROOVY_FORMATTER_REMOVE_UNNECESSARY_SEMICOLONS, true);
    FormatterPreferences formatPrefs = new FormatterPreferences(gunit);
    assertTrue(formatPrefs.isRemoveUnnecessarySemicolons() == true);

    groovyPrefs.setValue(PreferenceConstants.GROOVY_FORMATTER_REMOVE_UNNECESSARY_SEMICOLONS, false);
    formatPrefs = new FormatterPreferences(gunit);
    assertTrue(formatPrefs.isRemoveUnnecessarySemicolons() == false);
}

From source file:org.compiere.mfg_scm.eclipse.db.DbfLauncherPlugin.java

License:Apache License

public List readProjectsInSourcePathFromPref() {
    IPreferenceStore pref = DbfLauncherPlugin.getDefault().getPreferenceStore();
    if (!(pref.contains(DBF_PREF_PROJECTSINSOURCEPATH_KEY))) {
        // Compute source path for a new workspace
        pref.setValue(DBF_PREF_COMPUTESOURCEPATH_KEY, true);
        return computeProjectsInSourcePath();
    } else {//ww w  .  j ava2  s.co m
        return DbfLauncherPlugin.readProjectsFromPreferenceStore(DBF_PREF_PROJECTSINSOURCEPATH_KEY);
    }
}