Search in sources :

Example 51 with InstanceScope

use of org.eclipse.core.runtime.preferences.InstanceScope in project xtext-xtend by eclipse.

the class XtendPreferenceStoreAccess method getPreferenceStore.

@SuppressWarnings("all")
@Override
public IPreferenceStore getPreferenceStore() {
    IPreferenceStore store = super.getPreferenceStore();
    FixedScopedPreferenceStore jdtStore = new FixedScopedPreferenceStore(new InstanceScope(), JavaCore.PLUGIN_ID);
    jdtStore.setSearchContexts(new IScopeContext[] { new InstanceScope(), new ConfigurationScope() });
    return new ChainedPreferenceStore(new IPreferenceStore[] { store, jdtStore, PreferenceConstants.getPreferenceStore() });
}
Also used : InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) ChainedPreferenceStore(org.eclipse.ui.texteditor.ChainedPreferenceStore) IPreferenceStore(org.eclipse.jface.preference.IPreferenceStore) FixedScopedPreferenceStore(org.eclipse.xtext.ui.editor.preferences.FixedScopedPreferenceStore) ConfigurationScope(org.eclipse.core.runtime.preferences.ConfigurationScope)

Example 52 with InstanceScope

use of org.eclipse.core.runtime.preferences.InstanceScope in project ecf by eclipse.

the class AccountStart method saveConnectionDetailsToPreferenceStore.

public void saveConnectionDetailsToPreferenceStore() {
    Preferences preferences = new InstanceScope().getNode(ClientPlugin.PLUGIN_ID);
    Preferences connections = preferences.node(SAVED);
    for (Iterator i = connectionDetails.keySet().iterator(); i.hasNext(); ) {
        String target = (String) i.next();
        ConnectionDetails details = (ConnectionDetails) connectionDetails.get(target);
        Preferences p = connections.node(target);
        p.put(ConnectionDetails.CONTAINER_TYPE, details.getContainerType());
        p.put(ConnectionDetails.TARGET_URI, details.getTargetURI());
        p.put(ConnectionDetails.NICKNAME, details.getNickname());
        p.put(ConnectionDetails.PASSWORD, details.getPassword());
    }
    try {
        connections.flush();
    } catch (BackingStoreException e) {
        ClientPlugin.getDefault().getLog().log(new Status(IStatus.ERROR, ClientPlugin.PLUGIN_ID, BACKING_STORE_SAVE_ERROR, Messages.AccountStart_EXCEPTION_SAVING_CONNECTION_DETAILS, e));
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) Status(org.eclipse.core.runtime.Status) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) Iterator(java.util.Iterator) BackingStoreException(org.osgi.service.prefs.BackingStoreException) Preferences(org.osgi.service.prefs.Preferences)

Example 53 with InstanceScope

use of org.eclipse.core.runtime.preferences.InstanceScope in project xtext-eclipse by eclipse.

the class PreferenceStoreAccessTest method testChainedPreferenceStore.

@SuppressWarnings("deprecation")
@Test
public void testChainedPreferenceStore() {
    ScopedPreferenceStore configurationStore = new ScopedPreferenceStore(new ConfigurationScope(), LANGUAGE_ID);
    configurationStore.setValue("someInt", 12);
    configurationStore.setValue("anotherInt", 12);
    configurationStore.setDefault("thirdInt", 12);
    ScopedPreferenceStore instanceStore = new ScopedPreferenceStore(new InstanceScope(), LANGUAGE_ID);
    instanceStore.setValue("someInt", 13);
    instanceStore.setDefault("anotherInt", 13);
    ChainedPreferenceStore chainedStore = new ChainedPreferenceStore(new IPreferenceStore[] { instanceStore, configurationStore });
    assertEquals(13, chainedStore.getInt("someInt"));
    assertEquals(13, chainedStore.getInt("anotherInt"));
    assertEquals(12, chainedStore.getInt("thirdInt"));
}
Also used : InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) ChainedPreferenceStore(org.eclipse.ui.texteditor.ChainedPreferenceStore) ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore) ConfigurationScope(org.eclipse.core.runtime.preferences.ConfigurationScope) Test(org.junit.Test)

Example 54 with InstanceScope

use of org.eclipse.core.runtime.preferences.InstanceScope in project xtext-eclipse by eclipse.

the class AbstractOutlineWorkbenchTest method setUp.

@SuppressWarnings("deprecation")
@Override
public void setUp() throws Exception {
    super.setUp();
    preferenceStore = new ScopedPreferenceStore(new InstanceScope(), getEditorId());
    comparer = new IOutlineNodeComparer.Default();
    modelAsText = "one { two {} three {} } four {}";
    file = IResourcesSetupUtil.createFile("test/test.outlinetestlanguage", modelAsText);
    editor = openEditor(file);
    document = editor.getDocument();
    outlineView = editor.getEditorSite().getPage().showView("org.eclipse.ui.views.ContentOutline");
    executeAsyncDisplayJobs();
    Object adapter = editor.getAdapter(IContentOutlinePage.class);
    assertTrue(adapter instanceof SyncableOutlinePage);
    outlinePage = (SyncableOutlinePage) adapter;
    outlinePage.resetSyncer();
    try {
        outlinePage.waitForUpdate(EXPECTED_TIMEOUT);
    } catch (TimeoutException e) {
        // timeout is OK here
        System.out.println("Expected timeout exceeded: " + EXPECTED_TIMEOUT);
    }
    treeViewer = outlinePage.getTreeViewer();
    assertSelected(treeViewer);
    assertExpanded(treeViewer);
    assertTrue(treeViewer.getInput() instanceof IOutlineNode);
    IOutlineNode rootNode = (IOutlineNode) treeViewer.getInput();
    List<IOutlineNode> children = rootNode.getChildren();
    assertEquals(1, children.size());
    modelNode = children.get(0);
    assertEquals(2, modelNode.getChildren().size());
    oneNode = modelNode.getChildren().get(0);
    assertEquals(2, oneNode.getChildren().size());
    twoNode = oneNode.getChildren().get(0);
    threeNode = oneNode.getChildren().get(1);
    fourNode = modelNode.getChildren().get(1);
}
Also used : IOutlineNodeComparer(org.eclipse.xtext.ui.editor.outline.impl.IOutlineNodeComparer) InstanceScope(org.eclipse.core.runtime.preferences.InstanceScope) ScopedPreferenceStore(org.eclipse.ui.preferences.ScopedPreferenceStore) IOutlineNode(org.eclipse.xtext.ui.editor.outline.IOutlineNode) TimeoutException(java.util.concurrent.TimeoutException)

Aggregations

InstanceScope (org.eclipse.core.runtime.preferences.InstanceScope)54 ProjectScope (org.eclipse.core.resources.ProjectScope)30 DefaultScope (org.eclipse.core.runtime.preferences.DefaultScope)16 IEclipsePreferences (org.eclipse.core.runtime.preferences.IEclipsePreferences)16 IScopeContext (org.eclipse.core.runtime.preferences.IScopeContext)15 IProject (org.eclipse.core.resources.IProject)11 BackingStoreException (org.osgi.service.prefs.BackingStoreException)9 IFile (org.eclipse.core.resources.IFile)7 ConfigurationScope (org.eclipse.core.runtime.preferences.ConfigurationScope)7 IXMLMemento (com.cubrid.cubridmanager.core.common.xml.IXMLMemento)6 IResource (org.eclipse.core.resources.IResource)5 Preferences (org.osgi.service.prefs.Preferences)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 Iterator (java.util.Iterator)4 Set (java.util.Set)4 IAdaptable (org.eclipse.core.runtime.IAdaptable)4 XMLMemento (com.cubrid.cubridmanager.core.common.xml.XMLMemento)3 List (java.util.List)3