当前位置: 首页>>代码示例>>Java>>正文


Java Preferences.node方法代码示例

本文整理汇总了Java中java.util.prefs.Preferences.node方法的典型用法代码示例。如果您正苦于以下问题:Java Preferences.node方法的具体用法?Java Preferences.node怎么用?Java Preferences.node使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.prefs.Preferences的用法示例。


在下文中一共展示了Preferences.node方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: load

import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void load() throws IOException {
    filters.clear();
    active = -1;
    Preferences prefs = NbPreferences.forModule(FilterRepository.class);
    prefs = prefs.node("Filters"); //NOI18N
    active = prefs.getInt("active", -1);

    int count = prefs.getInt("count", 0); //NOI18N
    for (int i = 0; i < count; i++) {
        NotificationFilter filter = new NotificationFilter();
        try {
            filter.load(prefs, "Filter_" + i); //NOI18N
        } catch (BackingStoreException bsE) {
            throw new IOException("Cannot load filter repository", bsE);
        }
        filters.add(filter);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:FilterRepository.java

示例2: checkEquals

import java.util.prefs.Preferences; //导入方法依赖的package包/类
private void checkEquals(String msg, Preferences expected, Preferences test) throws BackingStoreException {
    assertEquals("Won't compare two Preferences with different absolutePath", expected.absolutePath(), test.absolutePath());
    
    // check the keys and their values
    for(String key : expected.keys()) {
        String expectedValue = expected.get(key, null);
        assertNotNull(msg + "; Expected:" + expected.absolutePath() + " has no '" + key + "'", expectedValue);
        
        String value = test.get(key, null);
        assertNotNull(msg + "; Test:" + test.absolutePath() + " has no '" + key + "'", value);
        assertEquals(msg + "; Test:" + test.absolutePath() + "/" + key + " has wrong value", expectedValue, value);
    }

    // check the children
    for(String child : expected.childrenNames()) {
        assertTrue(msg + "; Expected:" + expected.absolutePath() + " has no '" + child + "' subnode", expected.nodeExists(child));
        Preferences expectedChild = expected.node(child);

        assertTrue(msg + "; Test:" + test.absolutePath() + " has no '" + child + "' subnode", test.nodeExists(child));
        Preferences testChild = test.node(child);

        checkEquals(msg, expectedChild, testChild);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ProxyPreferencesTest.java

示例3: checkNotContains

import java.util.prefs.Preferences; //导入方法依赖的package包/类
private void checkNotContains(Preferences prefs, String[] tree, String prefsId) throws BackingStoreException {
    for(String s : tree) {
        int equalIdx = s.lastIndexOf('=');
        assertTrue(equalIdx != -1);
        String value = s.substring(equalIdx + 1);

        String key;
        String nodePath;
        int slashIdx = s.lastIndexOf('/', equalIdx);
        if (slashIdx != -1) {
            key = s.substring(slashIdx + 1, equalIdx);
            nodePath = s.substring(0, slashIdx);
        } else {
            key = s.substring(0, equalIdx);
            nodePath = "";
        }

        if (prefs.nodeExists(nodePath)) {
            Preferences node = prefs.node(nodePath);
            String realValue = node.get(key, null);
            if (realValue != null && realValue.equals(value)) {
                fail(prefsId + ", '" + nodePath + "' node contains key '" + key + "' = '" + realValue + "'");
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ProxyPreferencesTest.java

示例4: write

import java.util.prefs.Preferences; //导入方法依赖的package包/类
private void write(Preferences prefs, String[] tree) {
    for(String s : tree) {
        int equalIdx = s.lastIndexOf('=');
        assertTrue(equalIdx != -1);
        String value = s.substring(equalIdx + 1);

        String key;
        String nodePath;
        int slashIdx = s.lastIndexOf('/', equalIdx);
        if (slashIdx != -1) {
            key = s.substring(slashIdx + 1, equalIdx);
            nodePath = s.substring(0, slashIdx);
        } else {
            key = s.substring(0, equalIdx);
            nodePath = "";
        }

        Preferences node = prefs.node(nodePath);
        node.put(key, value);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:ProxyPreferencesTest.java

示例5: saveDividerPositions

import java.util.prefs.Preferences; //导入方法依赖的package包/类
private void saveDividerPositions(String name, SplitPane pane) {
    // Pref path is UserNode/Class/name/0 (or 1 or 2)
    Preferences p0 = Preferences.userNodeForPackage(getClass());
    Preferences p1 = p0.node(name);
    double[] pos = pane.getDividerPositions();
    for (int i = 0; i < pos.length; i++) {
        p1.putDouble(i+ "", pos[i]);
    }
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:10,代码来源:ControlsPaneController.java

示例6: findPreferences

import java.util.prefs.Preferences; //导入方法依赖的package包/类
private Optional<Preferences> findPreferences() {
    Preferences prefs = null;
    User user = toolBox.getData().getUser();
    if (user != null) {
        Preferences userPreferences = toolBox.getServices()
                .getPreferencesFactory()
                .remoteUserRoot(user.getUsername());
        prefs = userPreferences.node(PREF_AP_NODE);
        log.debug("Using ");
    }
    return Optional.ofNullable(prefs);
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:13,代码来源:AssocButtonPaneController.java

示例7: getInputMethodSelectionKeyStroke

import java.util.prefs.Preferences; //导入方法依赖的package包/类
private AWTKeyStroke getInputMethodSelectionKeyStroke(Preferences root) {
    try {
        if (root.nodeExists(inputMethodSelectionKeyPath)) {
            Preferences node = root.node(inputMethodSelectionKeyPath);
            int keyCode = node.getInt(inputMethodSelectionKeyCodeName, KeyEvent.VK_UNDEFINED);
            if (keyCode != KeyEvent.VK_UNDEFINED) {
                int modifiers = node.getInt(inputMethodSelectionKeyModifiersName, 0);
                return AWTKeyStroke.getAWTKeyStroke(keyCode, modifiers);
            }
        }
    } catch (BackingStoreException bse) {
    }

    return null;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:InputContext.java

示例8: loadAll

import java.util.prefs.Preferences; //导入方法依赖的package包/类
/**
 * Loads all instances from persistent storage.
 * @return list of {@link ResizeOption}s
 */
public synchronized List<ResizeOption> loadAll() {
    Preferences prefs = getPreferences();
    int count = prefs.getInt("count", 0); // NOI18N
    List<ResizeOption> res = new ArrayList<ResizeOption>(count);
    if (count == 0) {
        res.add(ResizeOption.create(ResizeOption.Type.DESKTOP, NbBundle.getMessage(ResizeOption.class, "Lbl_DESKTOP"),
                1280, 1024, true, true));
        res.add(ResizeOption.create(ResizeOption.Type.TABLET_LANDSCAPE, NbBundle.getMessage(ResizeOption.class, "Lbl_TABLET_LANDSCAPE"),
                1024, 768, true, true));
        res.add(ResizeOption.create(ResizeOption.Type.TABLET_PORTRAIT, NbBundle.getMessage(ResizeOption.class, "Lbl_TABLET_PORTRAIT"),
                768, 1024, true, true));
        res.add(ResizeOption.create(ResizeOption.Type.SMARTPHONE_LANDSCAPE, NbBundle.getMessage(ResizeOption.class, "Lbl_SMARTPHONE_LANDSCAPE"),
                480, 320, true, true));
        res.add(ResizeOption.create(ResizeOption.Type.SMARTPHONE_PORTRAIT, NbBundle.getMessage(ResizeOption.class, "Lbl_SMARTPHONE_PORTRAIT"),
                320, 480, true, true));
        res.add(ResizeOption.create(ResizeOption.Type.WIDESCREEN, NbBundle.getMessage(ResizeOption.class, "Lbl_WIDESCREEN"),
                1680, 1050, false, true));
        res.add(ResizeOption.create(ResizeOption.Type.NETBOOK, NbBundle.getMessage(ResizeOption.class, "Lbl_NETBOOK"),
                1024, 600, false, true));
    } else {
        for (int i = 0; i < count; i++) {
            Preferences node = prefs.node("option" + i); // NOI18N
            ResizeOption option = load(node);
            if (option != null) {
                res.add(option);
            }
        }
    }
    return res;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:35,代码来源:ResizeOptions.java

示例9: loadDividerPositions

import java.util.prefs.Preferences; //导入方法依赖的package包/类
private void loadDividerPositions(String name, SplitPane pane) {
    Preferences p0 = Preferences.userNodeForPackage(getClass());
    Preferences p1 = p0.node(name);
    double[] positions = pane.getDividerPositions();
    for (int i = 0; i < positions.length; i++) {
        try {
            double v = p1.getDouble(i + "", positions[i]);
            pane.setDividerPosition(i, v);
        }
        catch (Exception e) {
            // TODO log it
        }
    }
}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:15,代码来源:ControlsPaneController.java

示例10: checkPreferencesAction

import java.util.prefs.Preferences; //导入方法依赖的package包/类
private void checkPreferencesAction(String actionFileName, String preferencesNodePrefix, Preferences prefsRoot) throws Exception {
    Action a = readAction(actionFileName);
    Preferences prefsNode = prefsRoot.node("myNode");
    checkPreferencesAction(a, prefsNode);
    a = Actions.checkbox(preferencesNodePrefix + "/myNode", "myKey", null, null, false);
    checkPreferencesAction(a, prefsNode);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:AlwaysEnabledActionTest.java

示例11: main

import java.util.prefs.Preferences; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception
{
    String filename = (args.length > 0) ? args[0] : FILENAME;
    Preferences prefs = new IniPreferences(new Ini(new File(filename)));
    Preferences dopey = prefs.node("dopey");
    int age = dopey.getInt("age", 0);
    float weight = dopey.getFloat("weight", 0);

    System.out.println("dopey/age: " + age);
    System.out.println("dopey/weight: " + weight);
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:12,代码来源:ReadPrimitiveSample.java

示例12: testRemoveHierarchy

import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void testRemoveHierarchy() throws BackingStoreException {
    String [] origTree = new String [] {
        "R.CodeStyle.project.expand-tabs=true",
        "R.CodeStyle.project.indent-shift-width=6",
        "R.CodeStyle.project.spaces-per-tab=6",
        "R.CodeStyle.project.tab-size=7",
        "R.CodeStyle.project.text-limit-width=88",
        "R.CodeStyle.usedProfile=project",
        "R.text.x-ruby.CodeStyle.project.indent-shift-width=2",
        "R.text.x-ruby.CodeStyle.project.spaces-per-tab=2",
        "R.text.x-ruby.CodeStyle.project.tab-size=2",
    };
    String [] newTree = new String [] {
        "R.CodeStyle.project.expand-tabs=true",
        "R.CodeStyle.project.indent-shift-width=3",
        "R.CodeStyle.project.spaces-per-tab=3",
        "R.CodeStyle.project.tab-size=5",
        "R.CodeStyle.project.text-limit-width=77",
        "R.CodeStyle.usedProfile=project",
        "R.text.x-ruby.CodeStyle.project.indent-shift-width=2",
        "R.text.x-ruby.CodeStyle.project.spaces-per-tab=2",
        "R.text.x-ruby.CodeStyle.project.tab-size=2",
    };

    Preferences orig = Preferences.userRoot().node(getName());
    write(orig, origTree);

    checkContains(orig, origTree, "Orig");

    Preferences test = ProxyPreferencesImpl.getProxyPreferences(this, orig);
    checkEquals("Test should be the same as Orig", orig, test);

    Preferences testRoot = test.node("R");
    removeAllKidsAndKeys(testRoot);
    
    write(test, newTree);
    checkContains(test, newTree, "Test");

    test.flush();
    checkEquals("Test didn't flush to Orig", test, orig);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:42,代码来源:ProxyPreferencesImplTest.java

示例13: loadRoots

import java.util.prefs.Preferences; //导入方法依赖的package包/类
@NonNull
private Map<URL,T> loadRoots() {
    synchronized(lck) {
       if (cache == null) {
           Map<URL,T> result = new HashMap<URL, T>();
           final Preferences root = NbPreferences.forModule(QueriesCache.class);
           final String folder = clazz.getSimpleName();
           try {
               if (root.nodeExists(folder)) {
                   final Preferences node = root.node(folder);
                   Map<URL,List<URL>> bindings = new HashMap<URL, List<URL>>();
                   for (String key : node.keys()) {
                       final String value = node.get(key, null);
                       if (value != null) {
                           final URL binUrl = getURL(key);
                           List<URL> binding = bindings.get(binUrl);
                           if(binding == null) {
                               binding = new ArrayList<URL>();
                               bindings.put(binUrl,binding);
                           }
                           binding.add(new URL(value));
                       }
                   }
                   for (Map.Entry<URL,List<URL>> e : bindings.entrySet()) {
                       final T instance = clazz.newInstance();
                       instance.update(e.getValue());
                       result.put(e.getKey(), instance);
                   }
               }
           } catch (BackingStoreException bse) {
               Exceptions.printStackTrace(bse);
           } catch (MalformedURLException mue) {
               Exceptions.printStackTrace(mue);
           } catch (InstantiationException ie) {
               Exceptions.printStackTrace(ie);
           } catch (IllegalAccessException iae) {
               Exceptions.printStackTrace(iae);
           }
           cache = result;
       }
       return cache;
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:44,代码来源:QueriesCache.java

示例14: testRemoveHierarchy

import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void testRemoveHierarchy() throws BackingStoreException {
    String [] origTree = new String [] {
        "R.CodeStyle.project.expand-tabs=true",
        "R.CodeStyle.project.indent-shift-width=6",
        "R.CodeStyle.project.spaces-per-tab=6",
        "R.CodeStyle.project.tab-size=7",
        "R.CodeStyle.project.text-limit-width=88",
        "R.CodeStyle.usedProfile=project",
        "R.text.x-ruby.CodeStyle.project.indent-shift-width=2",
        "R.text.x-ruby.CodeStyle.project.spaces-per-tab=2",
        "R.text.x-ruby.CodeStyle.project.tab-size=2",
    };
    String [] newTree = new String [] {
        "R.CodeStyle.project.expand-tabs=true",
        "R.CodeStyle.project.indent-shift-width=3",
        "R.CodeStyle.project.spaces-per-tab=3",
        "R.CodeStyle.project.tab-size=5",
        "R.CodeStyle.project.text-limit-width=77",
        "R.CodeStyle.usedProfile=project",
        "R.text.x-ruby.CodeStyle.project.indent-shift-width=2",
        "R.text.x-ruby.CodeStyle.project.spaces-per-tab=2",
        "R.text.x-ruby.CodeStyle.project.tab-size=2",
    };

    Preferences orig = Preferences.userRoot().node(getName());
    write(orig, origTree);

    checkContains(orig, origTree, "Orig");

    Preferences test = ProxyPreferences.getProxyPreferences(this, orig);
    checkEquals("Test should be the same as Orig", orig, test);

    Preferences testRoot = test.node("R");
    removeAllKidsAndKeys(testRoot);
    
    write(test, newTree);
    checkContains(test, newTree, "Test");

    test.flush();
    checkEquals("Test didn't flush to Orig", test, orig);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:42,代码来源:ProxyPreferencesTest.java

示例15: getHighlightingNode

import java.util.prefs.Preferences; //导入方法依赖的package包/类
@NonNull
private Preferences getHighlightingNode() {
    final Preferences prefs = NbPreferences.forModule(GoToSettings.class);
    return prefs.node(NODE_HIGHLIGHTING);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:GoToSettings.java


注:本文中的java.util.prefs.Preferences.node方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。