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


Java Preferences.put方法代码示例

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


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

示例1: saveAsLast

import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void saveAsLast() {
	if (!isValid()) return;

	Preferences root = Preferences.userRoot().node(userPrefFolder).node(userPrefKey);

	try {
		saveList(root.node(pathsAKey), pathsA);
		saveList(root.node(pathsBKey), pathsB);
		saveList(root.node(classPathAKey), classPathA);
		saveList(root.node(classPathBKey), classPathB);
		saveList(root.node(pathsSharedKey), sharedClassPath);
		root.putBoolean(inputsBeforeClassPathKey, inputsBeforeClassPath);
		if (uidHost != null) root.put("uidHost", uidHost);
		if (uidPort != 0) root.putInt("uidPort", uidPort);
		if (uidUser != null) root.put("uidUser", uidUser);
		if (uidPassword != null) root.put("uidPassword", uidPassword);
		if (uidProject != null) root.put("uidProject", uidProject);
		if (uidVersionA != null) root.put("uidVersionA", uidVersionA);
		if (uidVersionB != null) root.put("uidVersionB", uidVersionB);

		root.flush();
	} catch (BackingStoreException e) {
		throw new RuntimeException(e);
	}
}
 
开发者ID:sfPlayer1,项目名称:Matcher,代码行数:26,代码来源:ProjectConfig.java

示例2: testConstantFix208072c

import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void testConstantFix208072c() throws Exception {
    Preferences prefs = CodeStylePreferences.get((FileObject) null, JavacParser.MIME_TYPE).getPreferences();
    prefs.put("classMembersOrder", "STATIC_INIT;STATIC METHOD;INSTANCE_INIT;CONSTRUCTOR;METHOD;STATIC CLASS;CLASS;STATIC FIELD;FIELD");
    prefs.put("classMemberInsertionPoint", "LAST_IN_CATEGORY");
    performFixTest("package test;\n" +
                   "import java.util.logging.Level;\n" +
                   "import java.util.logging.Logger;\n" +
                   "public class Test {\n" +
                   "     {\n" +
                   "         int ii = |1 + 2 * 3|;\n" +
                   "     }\n" +
                   "     private static final int II = 0;\n" +
                   "}\n",
                   ("package test;\n" +
                    "import java.util.logging.Level;\n" +
                    "import java.util.logging.Logger;\n" +
                    "public class Test {\n" +
                   "     {\n" +
                   "         int ii = ZZ;\n" +
                   "     }\n" +
                   "     private static final int II = 0;\n" +
                   "     private static final int ZZ = 1 + 2 * 3;\n" +
                    "}\n").replaceAll("[ \t\n]+", " "),
                   new DialogDisplayerImpl("ZZ", true, true, true, EnumSet.of(Modifier.PRIVATE)),
                   5, 1);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:IntroduceHintTest.java

示例3: getExecutionEnvironment

import java.util.prefs.Preferences; //导入方法依赖的package包/类
public ExecutionEnvironment getExecutionEnvironment() {
    if (btnKnownHosts.isSelected()) {
        last = (ExecutionEnvironment) cbKnownHosts.getSelectedItem();
    } else {
        if (userField.getText().isEmpty() || hostField.getText().isEmpty()) {
            return null;
        }

        int port = 22;

        if (!portField.getText().isEmpty()) {
            try {
                port = Integer.parseInt(portField.getText());
            } catch (NumberFormatException ex) {
            }
        }

        last = ExecutionEnvironmentFactory.createNew(userField.getText(), hostField.getText(), port);
    }
    Preferences prefs = NbPreferences.forModule(RemoteInfoDialog.class);
    prefs.put(LAST_SELECTED_HOST, ExecutionEnvironmentFactory.toUniqueID(last));
    return last;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:RemoteInfoDialog.java

示例4: setValues

import java.util.prefs.Preferences; //导入方法依赖的package包/类
private void setValues(Preferences p, Map<String, String> values) {
    for (Entry<String, String> e : values.entrySet()) {
        if (e.getValue() != null) {
            p.put(e.getKey(), e.getValue());
        } else {
            p.remove(e.getKey());
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:10,代码来源:MethodBodyTest.java

示例5: testNewLineIndentationBeforeEmptyHalfIndentedBlockEnd

import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void testNewLineIndentationBeforeEmptyHalfIndentedBlockEnd() throws Exception {
    Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
    preferences.put("otherBracePlacement", CodeStyle.BracePlacement.NEW_LINE_HALF_INDENTED.name());
    try {
        performNewLineIndentationTest("package t;\npublic class T {\n    public void op() {\n          {|}\n    }\n}\n",
                "package t;\npublic class T {\n    public void op() {\n          {\n          }\n    }\n}\n");
    } finally {
        preferences.remove("otherBracePlacement");
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ReindenterTest.java

示例6: testNode

import java.util.prefs.Preferences; //导入方法依赖的package包/类
@Test
public void testNode() {
    Preferences userRoot = factory.remoteUserRoot("brian");
    log.debug("userRoot = " + userRoot.absolutePath());
    userRoot.put("trash", "foo");
    String s0 = userRoot.get("trash", "bar");
    assertTrue("Returned value was not what we expected", s0.equals("foo"));
    userRoot.put("trash", "bar");
    String s1 = userRoot.get("trash", "bar");
    assertTrue("Returned value was not what we expected", s1.equals("bar"));
    userRoot.remove("trash");

}
 
开发者ID:mbari-media-management,项目名称:vars-annotation,代码行数:14,代码来源:WebPreferencesTest.java

示例7: saveFontsTo

import java.util.prefs.Preferences; //导入方法依赖的package包/类
/**
 * Save font settings. Save allways, changing L&F shouldn't affect font
 * settings.
 */
private void saveFontsTo(Preferences preferences) {
    preferences.putInt(PREFIX + PROP_FONT_SIZE, getFont().getSize());
    preferences.putInt(PREFIX + PROP_FONT_STYLE, getFont().getStyle());
    preferences.putInt(PREFIX + PROP_FONT_SIZE_WRAP,
            getFontForWrappedMode().getSize());
    preferences.put(PREFIX + PROP_FONT_FAMILY, getFont().getFamily());
    preferences.put(PREFIX + PROP_STYLE_LINK, getLinkStyle().name());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:OutputOptions.java

示例8: testTooLong

import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void testTooLong() throws IOException, BackingStoreException {
    lookup.setDelegates(Lookups.fixed(new TestAuxiliaryConfigurationImpl()));

    AuxiliaryConfiguration ac = p.getLookup().lookup(AuxiliaryConfiguration.class);

    assertNotNull(ac);

    AuxiliaryConfigBasedPreferencesProvider toSync = new AuxiliaryConfigBasedPreferencesProvider(p, ac, null, true);
    Preferences pref = toSync.findModule("test");
    //test length of key
    char[] keyChars = new char[100];
    Arrays.fill(keyChars, 'X');
    String key = new String(keyChars);
    pref.put(key, "test");

    //test length of value
    char[] valChars = new char[10 * 1024];
    Arrays.fill(valChars, 'X');
    String value = new String(valChars);
    pref.put("test", value);

    pref.flush();

    assertEquals(pref.get("test", null), value);
    assertEquals(pref.get(key, null), "test");

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:AuxiliaryConfigBasedPreferencesProviderTest.java

示例9: save

import java.util.prefs.Preferences; //导入方法依赖的package包/类
private void save(Preferences prefs, ResizeOption option) {
    prefs.put("displayName", option.getDisplayName()); // NOI18N
    prefs.putInt("width", option.getWidth()); // NOI18N
    prefs.putInt("height", option.getHeight()); // NOI18N
    prefs.putBoolean("toolbar", option.isShowInToolbar()); // NOI18N
    prefs.putBoolean("default", option.isDefault()); // NOI18N
    prefs.put("type", option.getType().name()); // NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ResizeOptions.java

示例10: testEvents1

import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void testEvents1() throws Exception {
    Preferences prefsA = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
    L listenerA = new L();
    prefsA.addPreferenceChangeListener(listenerA);

    Preferences prefsB = MimeLookup.getLookup(MimePath.parse("text/x-testA")).lookup(Preferences.class);
    L listenerB = new L();
    prefsB.addPreferenceChangeListener(listenerB);
    
    assertNotNull("'simple-value-setting-A' should not be null", prefsA.get("simple-value-setting-A", null));
    assertNotNull("'simple-value-setting-A' should not be null", prefsB.get("simple-value-setting-A", null));
    assertEquals("Wrong value for 'testA-1-setting-1'", "value-of-testA-1-setting-1", prefsB.get("testA-1-setting-1", null));

    assertEquals("There should be no A events", 0, listenerA.count);
    assertEquals("There should be no B events", 0, listenerB.count);
    
    prefsA.put("simple-value-setting-A", "new-value");
    assertEquals("Wrong value for 'simple-value-setting-A'", "new-value", prefsA.get("simple-value-setting-A", null));
    assertEquals("The value for 'simple-value-setting-A' was not propagated", "new-value", prefsB.get("simple-value-setting-A", null));
    
    Thread.sleep(500);
    
    assertEquals("Wrong number of A events", 1, listenerA.count);
    assertEquals("Wrong setting name in the A event", "simple-value-setting-A", listenerA.lastEvent.getKey());
    assertEquals("Wrong setting value in the A event", "new-value", listenerA.lastEvent.getNewValue());
    assertSame("Wrong Preferences instance in the A event", prefsA, listenerA.lastEvent.getNode());
    assertEquals("Wrong number of B events", 1, listenerB.count);
    assertEquals("Wrong setting name in the B event", "simple-value-setting-A", listenerB.lastEvent.getKey());
    assertEquals("Wrong setting value in the B event", "new-value", listenerB.lastEvent.getNewValue());
    assertSame("Wrong Preferences instance in the B event", prefsB, listenerB.lastEvent.getNode());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:PreferencesTest.java

示例11: testLineIndentationBeforeHalfIndentedForEachBlock

import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void testLineIndentationBeforeHalfIndentedForEachBlock() throws Exception {
    Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
    preferences.put("otherBracePlacement", CodeStyle.BracePlacement.NEW_LINE_HALF_INDENTED.name());
    try {
        performLineIndentationTest("package t;\npublic class T {\n    public void op() {\n        for (String s : getStrings())\n|            {\n    }\n}\n",
                "package t;\npublic class T {\n    public void op() {\n        for (String s : getStrings())\n          {\n    }\n}\n");
    } finally {
        preferences.remove("otherBracePlacement");
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ReindenterTest.java

示例12: setFilePath

import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void setFilePath(File f) {
	Preferences p = Preferences.userNodeForPackage(MainApp.class);
	
	if (f != null) {
		p.put("filePath",  f.getPath());
		primaryStage.setTitle("Kanphnia2 - " + f.getName());
	}
	else {
		p.remove("filePath");
		primaryStage.setTitle("Kanphnia2");
	}
}
 
开发者ID:yc45,项目名称:kanphnia2,代码行数:13,代码来源:MainApp.java

示例13: writePreferredInputMethod

import java.util.prefs.Preferences; //导入方法依赖的package包/类
private void writePreferredInputMethod(String path, String descriptorName) {
    if (userRoot != null) {
        Preferences node = userRoot.node(path);

        // record it
        if (descriptorName != null) {
            node.put(descriptorKey, descriptorName);
        } else {
            node.remove(descriptorKey);
        }
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:ExecutableInputMethodManager.java

示例14: testLineIndentationBeforeHalfIndentedIfBlock

import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void testLineIndentationBeforeHalfIndentedIfBlock() throws Exception {
    Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
    preferences.put("otherBracePlacement", CodeStyle.BracePlacement.NEW_LINE_HALF_INDENTED.name());
    try {
        performLineIndentationTest("package t;\npublic class T {\n    public void op() {\n        if (true)\n|            {\n    }\n}\n",
                "package t;\npublic class T {\n    public void op() {\n        if (true)\n          {\n    }\n}\n");
    } finally {
        preferences.remove("otherBracePlacement");
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ReindenterTest.java

示例15: testLineIndentationInsideEmptyHalfIndentedMethodBody

import java.util.prefs.Preferences; //导入方法依赖的package包/类
public void testLineIndentationInsideEmptyHalfIndentedMethodBody() throws Exception {
    Preferences preferences = MimeLookup.getLookup(JavaTokenId.language().mimeType()).lookup(Preferences.class);
    preferences.put("methodDeclBracePlacement", CodeStyle.BracePlacement.NEW_LINE_HALF_INDENTED.name());
    try {
        performLineIndentationTest("package t;\npublic class T {\n    public void op()\n      {\n|\n      }\n}\n",
                "package t;\npublic class T {\n    public void op()\n      {\n        \n      }\n}\n");
    } finally {
        preferences.remove("methodDeclBracePlacement");
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ReindenterTest.java


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