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

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

Introduction

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

Prototype

void putValue(String name, String value);

Source Link

Document

Sets the current value of the preference with the given name to the given string value without sending a property change.

Usage

From source file:org.guvnor.tools.preferences.GuvnorPreferencePage.java

License:Apache License

public static boolean shouldShowChangeIndicator() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    boolean res = true;
    if (!store.contains(IGuvnorPreferenceConstants.SHOW_CHANGE_INDICATOR_PREF)) {
        store.putValue(IGuvnorPreferenceConstants.SHOW_CHANGE_INDICATOR_PREF, String.valueOf(true));
    } else {//from  w  ww.  j av  a 2  s  . c  o m
        res = store.getBoolean(IGuvnorPreferenceConstants.SHOW_CHANGE_INDICATOR_PREF);
    }
    return res;
}

From source file:org.guvnor.tools.preferences.GuvnorPreferencePage.java

License:Apache License

public static boolean shouldShowRevision() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    boolean res = true;
    if (!store.contains(IGuvnorPreferenceConstants.SHOW_REVISION_PREF)) {
        store.putValue(IGuvnorPreferenceConstants.SHOW_REVISION_PREF, String.valueOf(true));
    } else {/*from   www  .j  ava2  s. c o  m*/
        res = store.getBoolean(IGuvnorPreferenceConstants.SHOW_REVISION_PREF);
    }
    return res;
}

From source file:org.guvnor.tools.preferences.GuvnorPreferencePage.java

License:Apache License

public static boolean shouldShowTimeDateStamp() {
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    boolean res = true;
    if (!store.contains(IGuvnorPreferenceConstants.SHOW_DATETIME_PREF)) {
        store.putValue(IGuvnorPreferenceConstants.SHOW_DATETIME_PREF, String.valueOf(true));
    } else {/*from w  w  w. ja v a 2s  .c o  m*/
        res = store.getBoolean(IGuvnorPreferenceConstants.SHOW_DATETIME_PREF);
    }
    return res;
}

From source file:org.jboss.tools.cdi.core.test.tck.validation.SuppressWarningsTests.java

License:Open Source License

private void modifyPreferences(String preference) throws Exception {
    IPreferenceStore store = CDICorePlugin.getDefault().getPreferenceStore();
    store.putValue(preference, CDIPreferences.WARNING);
    ((IPersistentPreferenceStore) store).save();
}

From source file:org.jboss.tools.cdi.core.test.tck.validation.SuppressWarningsTests.java

License:Open Source License

private void restorePreferences(String preference, IFile file) throws Exception {
    IPreferenceStore store = CDICorePlugin.getDefault().getPreferenceStore();
    store.putValue(preference, CDIPreferences.ERROR);
    ((IPersistentPreferenceStore) store).save();
    TestUtil.validate(file);/* ww  w  . ja v a2  s  . c o m*/
}

From source file:org.jboss.tools.project.examples.test.CheatSheetTest.java

License:Open Source License

private void testActionInNonUIThread(IFile file) {
    boolean delete = false;
    CheatSheetView view = null;//  www.j a  va  2s . co  m
    try {
        if (!file.exists()) {
            IPreferenceStore store = ProjectExamplesActivator.getDefault().getPreferenceStore();
            String oldValue = ProjectExamplesActivator.getDefault().getShowCheatsheets();
            try {
                store.putValue(ProjectExamplesActivator.SHOW_CHEATSHEETS,
                        ProjectExamplesActivator.SHOW_CHEATSHEETS_NEVER);
                createCheatSheet(file);
            } finally {
                store.putValue(ProjectExamplesActivator.SHOW_CHEATSHEETS, oldValue);
            }
            delete = true;
        }
        view = openCheatSheet(file);
        testCommand();
    } catch (Exception e) {
        ProjectExamplesActivator.log(e);
        fail(e.getMessage());
    } finally {
        getActivePage().hideView(view);
        if (delete) {
            try {
                file.delete(true, null);
            } catch (CoreException e) {
                // ignore
            }
        }
    }
}

From source file:org.jboss.tools.project.examples.test.CheatSheetTest.java

License:Open Source License

@Test
public void testOpenNonMavenProject() throws Exception {

    Display.getDefault().syncExec(new Runnable() {

        @Override/* w w w  .j ava  2s .co  m*/
        public void run() {

            CheatSheetView view = (CheatSheetView) getActivePage()
                    .findView(ICheatSheetResource.CHEAT_SHEET_VIEW_ID);
            if (view != null) {
                getActivePage().hideView(view);
            }
            IPreferenceStore store = ProjectExamplesActivator.getDefault().getPreferenceStore();
            IProject project = null;
            String oldValue = ProjectExamplesActivator.getDefault().getShowCheatsheets();
            IWorkspace workspace = ResourcesPlugin.getWorkspace();
            try {
                store.putValue(ProjectExamplesActivator.SHOW_CHEATSHEETS,
                        ProjectExamplesActivator.SHOW_CHEATSHEETS_ALWAYS);

                String projectName = CHEATSHEET_HELLOWORLD_PROJECT;
                IProjectDescription description = workspace.newProjectDescription(projectName);
                Bundle bundle = Platform.getBundle(TEST_PLUGIN_ID);
                String zipLocation = FileLocator.resolve(bundle.getEntry(CHEATSHEET_HELLOWORLD_ZIP)).getFile();

                File file = new File(zipLocation);

                String dest = Platform.getConfigurationLocation().getURL().getFile();
                File destination = new File(dest);
                ProjectExamplesActivator.extractZipFile(file, destination, new NullProgressMonitor());
                description.setName(projectName);
                description.setLocation(new Path(dest).append(projectName));
                project = workspace.getRoot().getProject(projectName);
                project.create(description, null);
                JobUtils.waitForIdle(1000);
                project.open(null);
                JobUtils.waitForIdle(1000);
                view = (CheatSheetView) getActivePage().findView(ICheatSheetResource.CHEAT_SHEET_VIEW_ID);
                assertTrue("A cheatsheet is not opened.", view != null);
            } catch (Exception e) {
                e.printStackTrace();
                fail(e.getMessage());
            } finally {
                if (project != null) {
                    try {
                        project.delete(true, true, null);
                    } catch (CoreException e) {
                        e.printStackTrace();
                    }
                }
                store.putValue(ProjectExamplesActivator.SHOW_CHEATSHEETS, oldValue);
            }

        }
    });

}

From source file:org.jboss.tools.project.examples.tests.CheatSheetTest.java

License:Open Source License

@Test
public void testOpenNonMavenProject() throws Exception {

    Display.getDefault().syncExec(new Runnable() {

        @Override//from  w  w  w .  j  av a  2 s  .  co m
        public void run() {

            CheatSheetView view = (CheatSheetView) getActivePage()
                    .findView(ICheatSheetResource.CHEAT_SHEET_VIEW_ID);
            if (view != null) {
                getActivePage().hideView(view);
            }
            IPreferenceStore store = ProjectExamplesActivator.getDefault().getPreferenceStore();
            IProject project = null;
            String oldValue = ProjectExamplesActivator.getDefault().getShowCheatsheets();
            IWorkspace workspace = ResourcesPlugin.getWorkspace();
            try {
                store.putValue(ProjectExamplesActivator.SHOW_CHEATSHEETS,
                        ProjectExamplesActivator.SHOW_CHEATSHEETS_ALWAYS);

                String projectName = CHEATSHEET_HELLOWORLD_PROJECT;
                IProjectDescription description = workspace.newProjectDescription(projectName);
                Bundle bundle = Platform.getBundle(TEST_PLUGIN_ID);
                String zipLocation = FileLocator.resolve(bundle.getEntry(CHEATSHEET_HELLOWORLD_ZIP)).getFile();

                File file = new File(zipLocation);

                String dest = Platform.getConfigurationLocation().getURL().getFile();
                File destination = new File(dest);
                UnArchiver unarchiver = UnArchiver.create(file, destination);
                unarchiver.extract(new NullProgressMonitor());
                description.setName(projectName);
                description.setLocation(new Path(dest).append(projectName));
                project = workspace.getRoot().getProject(projectName);
                project.create(description, null);
                JobUtils.waitForIdle();
                project.open(null);
                JobUtils.waitForIdle();
                view = (CheatSheetView) getActivePage().findView(ICheatSheetResource.CHEAT_SHEET_VIEW_ID);
                assertTrue("A cheatsheet is not opened.", view != null);
            } catch (Exception e) {
                e.printStackTrace();
                fail(e.getMessage());
            } finally {
                if (project != null) {
                    try {
                        project.delete(true, true, null);
                    } catch (CoreException e) {
                        e.printStackTrace();
                    }
                }
                store.putValue(ProjectExamplesActivator.SHOW_CHEATSHEETS, oldValue);
            }

        }
    });

}

From source file:org.jboss.tools.seam.core.test.SeamValidatorsTest.java

License:Open Source License

private void enableUnpairGetterOrSetterValidation(boolean enable) {
    IPreferenceStore store = WebKbPlugin.getDefault().getPreferenceStore();
    store.putValue(ELSeverityPreferences.UNPAIRED_GETTER_OR_SETTER,
            enable ? SeamPreferences.ERROR : SeamPreferences.IGNORE);
    if (store instanceof IPersistentPreferenceStore) {
        try {/*from   www  .  j  ava2  s.c o  m*/
            ((IPersistentPreferenceStore) store).save();
        } catch (IOException e) {
            SeamCorePlugin.getPluginLog().logError(e);
        }
    }
}

From source file:org.jboss.tools.seam.core.test.SeamValidatorsTest.java

License:Open Source License

private void modifyPreferences() {
    IPreferenceStore store = SeamCorePlugin.getDefault().getPreferenceStore();
    store.putValue(SeamPreferences.UNKNOWN_VARIABLE_NAME, SeamPreferences.ERROR);

    if (store instanceof IPersistentPreferenceStore) {
        try {//from   www .j a va2s .co m
            ((IPersistentPreferenceStore) store).save();
        } catch (IOException e) {
            SeamCorePlugin.getPluginLog().logError(e);
        }
    }

    store = WebKbPlugin.getDefault().getPreferenceStore();
    store.putValue(ELSeverityPreferences.UNKNOWN_EL_VARIABLE_NAME, SeamPreferences.ERROR);
    store.putValue(ELSeverityPreferences.UNKNOWN_EL_VARIABLE_PROPERTY_NAME, SeamPreferences.ERROR);
    //store.putValue(ELSeverityPreferences.UNPAIRED_GETTER_OR_SETTER, SeamPreferences.ERROR);
    store.putValue(ELSeverityPreferences.RE_VALIDATE_UNRESOLVED_EL, SeamPreferences.ENABLE);

    if (store instanceof IPersistentPreferenceStore) {
        try {
            ((IPersistentPreferenceStore) store).save();
        } catch (IOException e) {
            SeamCorePlugin.getPluginLog().logError(e);
        }
    }
}