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.eclipse.dltk.internal.mylyn.DLTKUiBridgePlugin.java

License:Open Source License

/**
 * Startup order is critical.//  ww  w  .  j  a  va 2  s.c  o m
 */
@Override
public void start(BundleContext context) throws Exception {
    super.start(context);
    INSTANCE = this;

    IPreferenceStore dltkPrefs = DLTKUIPlugin.getDefault().getPreferenceStore();
    // NOTE: moved out of wizard and first task activation to avoid bug
    // 194766
    int count = getPreferenceStore().getInt(MYLYN_RUN_COUNT);
    if (count < 1) {
        getPreferenceStore().setValue(MYLYN_RUN_COUNT, count + 1);

        // Mylyn 3.1 removes 2 computers, migrate JDT setting on first run
        // to avoid prevent JDT from displaying a warning dialog
        if (count == 0 && getPreferenceStore().contains(MYLYN_PREVIOUS_RUN)) {
            if (dltkPrefs.contains(NUM_COMPUTERS_PREF_KEY)) {
                int lastNumberOfComputers = dltkPrefs.getInt(NUM_COMPUTERS_PREF_KEY);
                if (lastNumberOfComputers > 0) {
                    dltkPrefs.putValue(NUM_COMPUTERS_PREF_KEY, Integer.toString(lastNumberOfComputers - 2));
                }
            }
        }

        // try installing Task-Focused content assist twice
        new UIJob("Initialize Content Assist") { //$NON-NLS-1$
            @Override
            public IStatus runInUIThread(IProgressMonitor monitor) {
                IPreferenceStore store = DLTKUIPlugin.getDefault().getPreferenceStore();
                DLTKUiUtil.installContentAssist(store, false);
                return Status.OK_STATUS;
            }
        }.schedule();
    }

    // the Task-Focused category should be disabled if the user reverts to
    // the default
    String defaultValue = dltkPrefs.getDefaultString(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES);
    dltkPrefs.setDefault(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES,
            defaultValue + DLTKUiUtil.ASSIST_MYLYN_ALL + DLTKUiUtil.SEPARATOR_CODEASSIST);
}

From source file:org.eclipse.edt.ide.ui.internal.contentassist.EGLCompletionProposalComputerRegistry.java

License:Open Source License

private void updateUninstalledComputerCount() {
    IPreferenceStore preferenceStore = EDTUIPreferenceConstants.getPreferenceStore();
    int lastNumberOfComputers = preferenceStore.getInt(NUM_COMPUTERS_PREF_KEY);
    int currNumber = fDescriptors.size();
    fHasUninstalledComputers = lastNumberOfComputers > currNumber;
    preferenceStore.putValue(NUM_COMPUTERS_PREF_KEY, Integer.toString(currNumber));
    EDTUIPlugin.getDefault().savePluginPreferences();
}

From source file:org.eclipse.edt.ide.ui.internal.contentassist.EGLCompletionProposalComputerRegistry.java

License:Open Source License

private void preventDuplicateCategories(IPreferenceStore store, Set disabled,
        EGLCompletionProposalCategory allProposals) {
    if (allProposals == null || !allProposals.isIncluded())
        return;//from   w  ww.j a va  2  s . c o  m
    StringBuffer buf = new StringBuffer(50 * disabled.size());
    Iterator iter = disabled.iterator();
    while (iter.hasNext()) {
        buf.append(iter.next());
        buf.append('\0');
    }
    store.putValue(PreferenceConstants.CODEASSIST_EXCLUDED_CATEGORIES, buf.toString());
}

From source file:org.eclipse.edt.ide.ui.internal.project.wizards.NewEGLProjectWizard.java

License:Open Source License

public boolean performFinish() {
    try {/*from   www  . j  a v a2 s.c  o  m*/
        ISchedulingRule rule = getCurrentSchedulingRule();
        model.setProjectName(mainPage.getModel().getProjectName());
        // If a page of the dynamically embedded template wizard is not
        // currently being displayed, the performFinish() on this wizard will
        // not get displayed. This code ensures this happens.      

        IProjectTemplate template = model.getSelectedProjectTemplate();

        IWizardNode node = mainPage.getSelectedNode();
        ProjectTemplateWizardNode twn = null;
        if (node != null && node instanceof ProjectTemplateWizardNode) {
            twn = (ProjectTemplateWizardNode) node;
            if (twn.getTemplate().hasWizard()) {
                if (!twn.getWizard().performFinish()) {
                    return false;
                }
            }
        }

        final List ops = ProjectFinishUtility.getCreateProjectFinishOperations(
                (IProjectTemplateClass) template.getProjectTemplateClass(), model, 0, rule);

        //         ops.addAll(opsImport);
        getContainer().run(true, true, new WorkspaceModifyOperation() {
            @Override
            protected void execute(IProgressMonitor monitor)
                    throws CoreException, InvocationTargetException, InterruptedException {

                for (Iterator it = ops.iterator(); it.hasNext();) {
                    Object obj = it.next();
                    if (obj instanceof WorkspaceModifyOperation) {
                        IRunnableWithProgress runnable = (IRunnableWithProgress) obj;
                        try {
                            runnable.run(monitor);
                        } catch (Exception e) {
                            e.printStackTrace();
                        }

                        if (monitor.isCanceled()) {
                            break;
                        }
                    }
                }
            }
        });

        List opsImport = ProjectFinishUtility.getImportProjectOperations(
                (IProjectTemplateClass) template.getProjectTemplateClass(), model, 0, rule);
        for (Iterator it = opsImport.iterator(); it.hasNext();) {
            Object obj = it.next();
            if (obj instanceof WorkspaceModifyOperation) {
                WorkspaceModifyOperation op = (WorkspaceModifyOperation) obj;
                getContainer().run(false, true, op);
            }
        }

        if (twn != null && twn.getTemplate().hasWizard()) {
            if (twn.getWizard() instanceof BasicProjectTemplateWizard) {
                if (!((BasicProjectTemplateWizard) twn.getWizard()).proecssGenerationDirectorySetting()) {
                    return false;
                }
            }
        }

        // Remember base package name
        IPreferenceStore store = EDTUIPlugin.getDefault().getPreferenceStore();
        if (template.getProjectTemplateClass().needPreserveBasePackage()) {
            store.putValue(EDTUIPreferenceConstants.NEWPROJECTWIZARD_BASEPACKAGE, model.getBasePackageName());
        }
        store.putValue(EDTUIPreferenceConstants.NEWPROJECTWIZARD_SELECTEDTEMPLATE, template.getId());
    } catch (InterruptedException e) {
        e.printStackTrace();
        return false;
    } catch (InvocationTargetException e) {
        if (e.getTargetException() instanceof CoreException) {
            ErrorDialog.openError(getContainer().getShell(), null, null,
                    ((CoreException) e.getTargetException()).getStatus());
        } else {
            e.printStackTrace();
            EDTUIPlugin.log(e);
        }
        return false;
    } finally {
        postPerformFinish();
    }
    return true;
}

From source file:org.eclipse.epsilon.ewl.emf.WizardsExtensionPreference.java

License:Open Source License

public static void storePreferences(List<WizardsExtensionPreference> preferences) {
    IPreferenceStore preferenceStore = EwlEmfPlugin.getDefault().getPreferenceStore();
    String preferenceValue = "";

    //Set the new value
    for (WizardsExtensionPreference preference : preferences) {
        preferenceValue = preferenceValue + preference.toString() + ";";
    }//from  w  ww . j  a va  2 s .c  o  m

    preferenceStore.putValue(preferenceKey, preferenceValue);

    try {
        ((IPersistentPreferenceStore) preferenceStore).save();
    } catch (IOException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}

From source file:org.eclipse.jdt.text.tests.performance.ScrollVerticalRulerTest.java

License:Open Source License

protected void setUp() throws Exception {
    super.setUp();

    PreferenceConstants.getPreferenceStore().putValue(PreferenceConstants.SPELLING_PROBLEMS_THRESHOLD,
            new Integer(100000).toString());

    boolean isInstalled = EditorsUI.getSpellingService().getSpellingEngineDescriptors().length > 0;
    assertTrue("No spelling engine installed", isInstalled);

    IPreferenceStore store = EditorsUI.getPreferenceStore();
    store.putValue(SpellingService.PREFERENCE_SPELLING_ENABLED, IPreferenceStore.TRUE);

    IEclipsePreferences editorsNode = InstanceScope.INSTANCE.getNode(EditorsUI.PLUGIN_ID);

    MarkerAnnotationPreferences markerAnnotationPreferences = EditorsPlugin.getDefault()
            .getMarkerAnnotationPreferences();
    Iterator iterator = markerAnnotationPreferences.getAnnotationPreferences().iterator();
    while (iterator.hasNext()) {
        AnnotationPreference pref = (AnnotationPreference) iterator.next();
        String preferenceKey = pref.getVerticalRulerPreferenceKey();
        if ("spellingIndicationInVerticalRuler".equals(preferenceKey)) {
            editorsNode.putBoolean(preferenceKey, true);
            String textPreferenceKey = pref.getTextPreferenceKey();
            editorsNode.putBoolean(textPreferenceKey, false);
        }/*w  ww .  ja v  a 2  s  .com*/
    }
}

From source file:org.eclipse.jpt.jpadiagrameditor.ui.tests.internal.modelintegration.util.ModelIntegrationUtilTest.java

License:Open Source License

@Test
public void copyExistingXMIContentAndDeleteFileTest() throws Exception {
    Bundle b = EasyMock.createMock(Bundle.class);
    BundleContext bc = EasyMock.createMock(BundleContext.class);
    EasyMock.expect(bc.getBundle()).andStubReturn(b);
    EasyMock.expect(b.getSymbolicName()).andStubReturn("jpa_editor");
    bc.addBundleListener(EasyMock.isA(BundleListener.class));
    EasyMock.replay(bc, b);/*from  w w  w  .  jav a2 s  .com*/

    JPADiagramEditorPlugin p = new JPADiagramEditorPlugin();
    p.start(bc);

    IPreferenceStore store = JPADiagramEditorPlugin.getDefault().getPreferenceStore();
    store.putValue(JPAEditorPreferenceInitializer.PROPERTY_DIAGRAM_FOLDER, "diagrams");
    store.getString(JPAEditorPreferenceInitializer.PROPERTY_DIAGRAM_FOLDER);

    JPACreateFactory factory = JPACreateFactory.instance();
    JpaProject jpaProject = factory.createJPAProject("Test_" + System.currentTimeMillis());
    assertNotNull(jpaProject);
    ModelIntegrationUtil.copyExistingXMIContentAndDeleteFile(jpaProject.getProject(), "diagram_name", null);
}

From source file:org.eclipse.m2e.internal.discovery.startup.UpdateConfigurationStartup.java

License:Open Source License

private static void setEarlyActivationPreference(String[] disabledPlugins) {// Add ourself to disabled
    StringBuffer preference = new StringBuffer();
    for (String item : disabledPlugins) {
        preference.append(item).append(IPreferenceConstants.SEPARATOR);
    }// w w w  . j a  va2 s .com

    IPreferenceStore store = PrefUtil.getInternalPreferenceStore();
    store.putValue(IPreferenceConstants.PLUGINS_NOT_ACTIVATED_ON_STARTUP, preference.toString());
    PrefUtil.savePrefs();
}

From source file:org.eclipse.mylyn.internal.java.ui.JavaUiBridgePlugin.java

License:Open Source License

public void changeProcessorCount(IPreferenceStore javaPrefs, int delta) {
    if (javaPrefs.contains(NUM_COMPUTERS_PREF_KEY)) {
        int lastNumberOfComputers = javaPrefs.getInt(NUM_COMPUTERS_PREF_KEY);
        if (lastNumberOfComputers > 0) {
            javaPrefs.putValue(NUM_COMPUTERS_PREF_KEY, Integer.toString(lastNumberOfComputers + delta));
        }//from   www  .j ava 2s . co  m
    }
}

From source file:org.eclipse.osee.ote.ui.test.manager.preferences.environment.EnvironmentPreferencePage.java

License:Open Source License

public void storeVariables() {
    IPreferenceStore prefStore = TestManagerPlugin.getInstance().getPreferenceStore();
    prefStore.setValue(PAGE_KEY + "." + NUMBER_OF_VALUES, treeInputList.size());
    int index = 0;
    for (EnvironmentPreferenceNode node : treeInputList) {
        index = treeInputList.indexOf(node);
        String name = node.getEnvName();
        if (name != null && name != "") {
            prefStore.putValue(PAGE_KEY + "." + NAME + "_" + index, name);
            String value = node.getValue();
            prefStore.putValue(PAGE_KEY + "." + VALUE + "_" + index, (value != null ? value : ""));
            prefStore.putValue(PAGE_KEY + "." + CHECKED + "_" + index, Boolean.toString(node.isChecked()));
        }/* w w  w .  ja  va  2 s. c o  m*/
    }
}