當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。