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


Java Preferences类代码示例

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


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

示例1: storeProfilingSettings

import java.util.prefs.Preferences; //导入依赖的package包/类
private void storeProfilingSettings(ProfilingSettings settings) {
    Preferences pref = getPreferences();
    
    pref.putInt(ProfilingSettings.PROP_SAMPLING_FREQUENCY, settings.getSamplingFrequency());
    pref.putInt(ProfilingSettings.PROP_CPU_PROFILING_TYPE, settings.getCPUProfilingType());
    pref.putInt(ProfilingSettings.PROP_SAMPLING_INTERVAL, settings.getSamplingInterval());
    pref.putBoolean(ProfilingSettings.PROP_EXCLUDE_WAIT_TIME, settings.getExcludeWaitTime());
    pref.putBoolean(ProfilingSettings.PROP_INSTRUMENT_SPAWNED_THREADS, settings.getInstrumentSpawnedThreads());
    pref.putInt(ProfilingSettings.PROP_N_PROFILED_THREADS_LIMIT, settings.getNProfiledThreadsLimit());
    pref.putInt(ProfilingSettings.PROP_INSTR_SCHEME, settings.getInstrScheme());
    pref.putBoolean(ProfilingSettings.PROP_INSTRUMENT_METHOD_INVOKE, settings.getInstrumentMethodInvoke());
    pref.putBoolean(ProfilingSettings.PROP_INSTRUMENT_GETTER_SETTER_METHODS, settings.getInstrumentGetterSetterMethods());
    pref.putBoolean(ProfilingSettings.PROP_INSTRUMENT_EMPTY_METHODS, settings.getInstrumentEmptyMethods());
    
    pref.putInt(ProfilingSettings.PROP_OBJ_ALLOC_STACK_SAMPLING_INTERVAL, settings.getAllocTrackEvery());
    pref.putBoolean(ProfilingSettings.PROP_RUN_GC_ON_GET_RESULTS_IN_MEMORY_PROFILING, settings.getRunGCOnGetResultsInMemoryProfiling());
    
    pref.putBoolean(ProfilingSettings.PROP_THREADS_SAMPLING_ENABLED, settings.getThreadsSamplingEnabled());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:ProfilerIDESettings.java

示例2: checkContains

import java.util.prefs.Preferences; //导入依赖的package包/类
private void checkContains(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 = "";
        }

        assertTrue(prefsId + " doesn't contain node '" + nodePath + "'", prefs.nodeExists(nodePath));
        Preferences node = prefs.node(nodePath);

        String realValue = node.get(key, null);
        assertNotNull(prefsId + ", '" + nodePath + "' node doesn't contain key '" + key + "'", realValue);
        assertEquals(prefsId + ", '" + nodePath + "' node, '" + key + "' contains wrong value", value, realValue);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:ProxyPreferencesImplTest.java

示例3: setImages

import java.util.prefs.Preferences; //导入依赖的package包/类
private void setImages() {
    Preferences preferences = Preferences.userNodeForPackage(Player.class);

    volDown.setGraphic(volDownImage);
    volUp.setGraphic(volUpImage);
    previous.setGraphic(previousImage);
    play.setGraphic(playImage);
    next.setGraphic(nextImage);

    final boolean isShuffleMode = preferences.getBoolean("ShuffleMode", false);
    shuffle.setGraphic(isShuffleMode ? shufflePressedImage : shuffleImage);

    final boolean isLoopMode = preferences.getBoolean("LoopMode", false);
    loop.setGraphic(isLoopMode ? loopPressedImage: loopImage);

    volSlider.valueChangingProperty().addListener(rootController.volumeUpdated(volSlider));
}
 
开发者ID:jakemanning,项目名称:boomer-tuner,代码行数:18,代码来源:RootView.java

示例4: promptToDelete

import java.util.prefs.Preferences; //导入依赖的package包/类
private boolean promptToDelete(Preferences prefs) {
    Object result = DialogDisplayer.getDefault().notify(new NotifyDescriptor.Confirmation(
            NbBundle.getMessage(FallbackProvider.class, "FallbackProvider.msg_clear_keys"),
            NbBundle.getMessage(FallbackProvider.class, "FallbackProvider.title_clear_keys"),
            NotifyDescriptor.OK_CANCEL_OPTION));
    if (result == NotifyDescriptor.OK_OPTION) {
        try {
            LOG.log(Level.FINE, "agreed to delete stored passwords: {0}", Arrays.asList(prefs.keys()));
            prefs.clear();
            return testSampleKey(prefs);
        } catch (BackingStoreException x) {
            LOG.log(Level.INFO, null, x);
        }
    } else {
        LOG.fine("refused to delete stored passwords");
    }
    return false;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:FallbackProvider.java

示例5: storeListData

import java.util.prefs.Preferences; //导入依赖的package包/类
@Override
protected void storeListData(final JList list, final String optionID, final Preferences node) {
    StringBuilder sb = null;
    for (int i = 0; i < list.getModel().getSize(); i++) {
        if (sb == null) {
            sb = new StringBuilder();
        } else {
            sb.append(';');
        }
        if (classMembersOrder.equals(optionID)) {
            Element e = (Element) list.getModel().getElementAt(i);
            if (e.isStatic)
                sb.append("STATIC "); //NOI18N
            sb.append(e.kind.name());
        } else {
            Visibility v = (Visibility) list.getModel().getElementAt(i);
            sb.append(v.kind);
        }
    }
    String value = sb != null ? sb.toString() : ""; //NOI18N
    if (getDefaultAsString(optionID).equals(value))
        node.remove(optionID);
    else
        node.put(optionID, value);            
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:FmtCodeGeneration.java

示例6: generateRow

import java.util.prefs.Preferences; //导入依赖的package包/类
private void generateRow(int rowIndex) {
    Preferences prefs = userRoot().node("General");
    if (!prefs.getBoolean("generate", true))
        return;
    assert (rowIndex < proofData.size());
    ProofRow row = proofData.getRow(rowIndex);
    Rule rule = row.getRule();
    if (rule == null || rule.hasCompleteInfo() == false || row.getFormula() != null) {
        return;
    }
    Formula generated = null;
    try {
        generated = rule.generateFormula(proofData, rowIndex);
    } catch (VerificationInputException e) {
        return;
    }
    if (generated == null)
        return;
    row.setFormula(generated);
    for (ProofListener listener : this.listeners) {
        listener.rowUpdated(generated.toString(), true, rowIndex + 1);
    }
}
 
开发者ID:nonilole,项目名称:Conan,代码行数:24,代码来源:Proof.java

示例7: initProjectPreferences

import java.util.prefs.Preferences; //导入依赖的package包/类
private void initProjectPreferences(final FileObject file) {
    ProjectManager.mutex().postReadRequest(new Runnable() {
        public @Override void run() {
            Preferences projectRoot = findProjectPreferences(file);
            if (projectRoot != null) {
                synchronized (Csp.this) {
                    Preferences allLangCodeStyle = projectRoot.node(NODE_CODE_STYLE);
                    Preferences p = allLangCodeStyle.node(PROJECT_PROFILE);

                    // determine if we are using code style preferences from the project
                    String usedProfile = allLangCodeStyle.get(PROP_USED_PROFILE, DEFAULT_PROFILE);
                    useProject = PROJECT_PROFILE.equals(usedProfile);
                    projectPrefs = Csp.this.mimeType == null ?
                        p :
                        new ProxyPreferences(projectRoot.node(Csp.this.mimeType).node(NODE_CODE_STYLE).node(PROJECT_PROFILE), p);

                    // listen on changes
                    allLangCodeStyle.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, switchTrakcer, allLangCodeStyle));
                }
            }
        }
    });
    LOG.fine("file '" + filePath + "' (" + mimeType + ") is using " + (useProject ? "project" : "global") + " Preferences; doc=" + s2s(refDoc == null ? null : refDoc.get())); //NOI18N
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ProjectAwareCodeStylePreferences.java

示例8: testInheritedEventsMasked

import java.util.prefs.Preferences; //导入依赖的package包/类
/** 
 * Checks that modifications to the ihnerited store are not fired if
 * the local store overrides
 */
public void testInheritedEventsMasked() throws Exception {
    Preferences stored = new MapPreferences();
    Preferences inherited = new MapPreferences();
    
    inherited.putInt("intValue", 100);
    stored.putInt("intValue", 10);

    MemoryPreferences mem = MemoryPreferences.getWithInherited(this, inherited, stored);
    Preferences test = mem.getPreferences();
    
    PL pl = new PL();
    test.addPreferenceChangeListener(pl);
    
    // change
    pl.arm();
    inherited.putInt("intValue", 3);
    pl.waitEvent();
    assertEquals(0, pl.changeCount);
    
    // remove not inherited
    pl.arm();
    inherited.remove("intValue");
    pl.waitEvent();
    assertEquals(0, pl.changeCount);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:ProxyPreferencesImplTest.java

示例9: createBooleanOption

import java.util.prefs.Preferences; //导入依赖的package包/类
private JComponent createBooleanOption(OptionDescriptor option, Preferences prefs)  {
    JCheckBox checkBox = new JCheckBox();

    org.openide.awt.Mnemonics.setLocalizedText(checkBox, option.displayName);
    checkBox.setToolTipText(option.tooltip);
    checkBox.addActionListener(new ActionListenerImpl(option.preferencesKey, prefs));

    checkBox.setSelected(prefs.getBoolean(option.preferencesKey, 
            Boolean.TRUE == option.defaultValue));
    prefs.putBoolean(option.preferencesKey, checkBox.isSelected());
    GridBagConstraints constraints = new GridBagConstraints();

    constraints.anchor = GridBagConstraints.WEST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridheight = 1;
    constraints.gridwidth = 2;
    constraints.gridx = 0;
    constraints.gridy = row++;
    constraints.weightx = 0;
    constraints.weighty = 0;

    add(checkBox, constraints);
    return checkBox;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:25,代码来源:ReflectiveCustomizerProvider.java

示例10: indexerProfileNode

import java.util.prefs.Preferences; //导入依赖的package包/类
private Preferences indexerProfileNode(SourceIndexerFactory srcFactory) {
    String nn = srcFactory.getIndexerName();
    if (nn.length() >= Preferences.MAX_NAME_LENGTH) {
        // such long nodes are constructer e.g. from class names
        int i = nn.lastIndexOf('.');
        if (i >= 0) {
            nn = nn.substring(i + 1);
        }
        if (nn.length() < 3 || nn.length() >= Preferences.MAX_NAME_LENGTH) {
            String hashCode = Integer.toHexString(nn.hashCode());
            // attempt to derive +- unique node name
            nn = srcFactory.getClass().getSimpleName() + "_" + hashCode; // NOI18N
        }
    }
    return NbPreferences.forModule(srcFactory.getClass()).node("RepositoryUpdater"). // NOI18N
            node(nn);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:RepositoryUpdater.java

示例11: getStoredProperties

import java.util.prefs.Preferences; //导入依赖的package包/类
private Properties getStoredProperties() {
    return AccessController
            .doPrivileged((PrivilegedAction<Properties>) () -> {
                Properties p = new Properties();
                String notePath = "/com/sun/media/sound/softsynthesizer";
                try {
                    Preferences prefroot = Preferences.userRoot();
                    if (prefroot.nodeExists(notePath)) {
                        Preferences prefs = prefroot.node(notePath);
                        String[] prefs_keys = prefs.keys();
                        for (String prefs_key : prefs_keys) {
                            String val = prefs.get(prefs_key, null);
                            if (val != null) {
                                p.setProperty(prefs_key, val);
                            }
                        }
                    }
                } catch (final BackingStoreException ignored) {
                }
                return p;
            });
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:23,代码来源:SoftSynthesizer.java

示例12: testFlushTree1

import java.util.prefs.Preferences; //导入依赖的package包/类
public void testFlushTree1() throws BackingStoreException {
    String [] origTree = new String [] {
        "CodeStyle/profile=GLOBAL",
    };
    String [] newTree = new String [] {
        "CodeStyle/text/x-java/tab-size=2",
        "CodeStyle/text/x-java/override-global-settings=true",
        "CodeStyle/text/x-java/expand-tabs=true",
        "CodeStyle/profile=PROJECT",
    };

    Preferences orig = Preferences.userRoot().node(getName());
    write(orig, origTree);
    checkContains(orig, origTree, "Orig");
    checkNotContains(orig, newTree, "Orig");
    
    Preferences test = ProxyPreferencesImpl.getProxyPreferences(this, orig);
    checkEquals("Test should be the same as Orig", orig, test);
    
    write(test, newTree);
    checkContains(test, newTree, "Test");

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

示例13: SideBar

import java.util.prefs.Preferences; //导入依赖的package包/类
public SideBar(Document forDocument) {
    super(new BorderLayout());
    this.forDocument = forDocument;
    add(new BreadCrumbComponent(), BorderLayout.CENTER);

    JButton closeButton = CloseButtonFactory.createBigCloseButton();

    add(closeButton, BorderLayout.EAST);
    
    prefs = MimeLookup.getLookup(MimePath.EMPTY).lookup(Preferences.class);
    prefs.addPreferenceChangeListener(WeakListeners.create(PreferenceChangeListener.class, this, prefs));
    
    closeButton.addActionListener(new ActionListener() {
        @Override public void actionPerformed(ActionEvent e) {
            prefs.putBoolean(KEY_BREADCRUMBS, false);
        }
    });
    
    setBorder(new SeparatorBorder());
    preferenceChange(null);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:SideBarFactoryImpl.java

示例14: CategorySupport

import java.util.prefs.Preferences; //导入依赖的package包/类
protected CategorySupport(Preferences preferences, String id, JPanel panel, String previewText, String[]... forcedOptions) {
    this.preferences = preferences;
    this.id = id;
    this.panel = panel;
    this.previewText = previewText != null ? previewText : NbBundle.getMessage(CategorySupport.class, "SAMPLE_Default"); //NOI18N

    // Scan the panel for its components
    scan(panel, components);

    // Initialize the preview preferences
    Preferences forcedPrefs = new PreviewPreferences();
    for (String[] option : forcedOptions) {
        forcedPrefs.put( option[0], option[1]);
    }
    this.previewPrefs = new ProxyPreferences(forcedPrefs, preferences);

    // Load and hook up all the components
    loadFrom(preferences);
    addListeners();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:CategorySupport.java

示例15: testFieldFix208072d

import java.util.prefs.Preferences; //导入依赖的package包/类
public void testFieldFix208072d() 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" +
                   "     static {\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" +
                   "     private static int ZZ = 1 + 2 * 3;\n" +
                   "     static {\n" +
                   "         int ii = ZZ;\n" +
                   "     }\n" +
                   "     private static final int II = 0;\n" +
                    "}\n").replaceAll("[ \t\n]+", " "),
                   new DialogDisplayerImpl2("ZZ", IntroduceFieldPanel.INIT_FIELD, false, EnumSet.<Modifier>of(Modifier.PRIVATE), false, true),
                   5, 2);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:IntroduceHintTest.java


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