當前位置: 首頁>>代碼示例>>Java>>正文


Java Preferences.userNodeForPackage方法代碼示例

本文整理匯總了Java中java.util.prefs.Preferences.userNodeForPackage方法的典型用法代碼示例。如果您正苦於以下問題:Java Preferences.userNodeForPackage方法的具體用法?Java Preferences.userNodeForPackage怎麽用?Java Preferences.userNodeForPackage使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.prefs.Preferences的用法示例。


在下文中一共展示了Preferences.userNodeForPackage方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: removeFromPreferences

import java.util.prefs.Preferences; //導入方法依賴的package包/類
private void removeFromPreferences(ProjectInfo selectedItem) {
    Preferences p = Preferences.userNodeForPackage(this.getClass());
    String[] keys;
    try {
        keys = p.keys();
        for (int i = 0; i < keys.length; i++) {
            String key = keys[i];
            String fName = p.get(key, null);
            if (fName.equals(selectedItem.getFolder())) {
                p.remove(key);
                break;
            }
        }
    } catch (BackingStoreException e) {
        return;
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:18,代碼來源:ProjectSelection.java

示例2: storeFileNames

import java.util.prefs.Preferences; //導入方法依賴的package包/類
private void storeFileNames() {
    Preferences p = Preferences.userNodeForPackage(this.getClass());
    try {
        p.clear();
        p.flush();
        p = Preferences.userNodeForPackage(this.getClass());
        int itemCount = projectInfotable.getItems().size();
        int selected = projectInfotable.getSelectionModel().getSelectedIndex();
        if (selected == -1)
            selected = 0;
        ProjectInfo pi = projectInfotable.getItems().get(selected);
        p.put("dirName0", pi.getFolder());
        for (int i = 0, j = 1; i < itemCount; i++) {
            if (i != selected) {
                p.put("dirName" + j++, projectInfotable.getItems().get(i).getFolder());
            }
        }
    } catch (BackingStoreException e) {
        return;
    }
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:22,代碼來源:ProjectSelection.java

示例3: saveConfig

import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void saveConfig() {
    // Registry path on Windows Xp:
    // HKEY_CURRENT_USER/Software/JavaSoft/Prefs/us/deathmarine/luyten
    try {
        Preferences prefs = Preferences.userNodeForPackage(ConfigSaver.class);

        prefs.putBoolean(FLATTEN_SWITCH_BLOCKS_ID, decompilerSettings.getFlattenSwitchBlocks());
        prefs.putBoolean(FORCE_EXPLICIT_IMPORTS_ID, decompilerSettings.getForceExplicitImports());
        prefs.putBoolean(SHOW_SYNTHETIC_MEMBERS_ID, decompilerSettings.getShowSyntheticMembers());
        prefs.putBoolean(EXCLUDE_NESTED_TYPES_ID, decompilerSettings.getExcludeNestedTypes());
        prefs.putBoolean(FORCE_EXPLICIT_TYPE_ARGUMENTS_ID, decompilerSettings.getForceExplicitTypeArguments());
        prefs.putBoolean(RETAIN_REDUNDANT_CASTS_ID, decompilerSettings.getRetainRedundantCasts());
        prefs.putBoolean(INCLUDE_ERROR_DIAGNOSTICS_ID, decompilerSettings.getIncludeErrorDiagnostics());
        prefs.putBoolean(UNICODE_REPLACE_ENABLED_ID, decompilerSettings.isUnicodeOutputEnabled());
        prefs.put(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName());

        saveWindowPosition(prefs, MAIN_WINDOW_ID_PREFIX, mainWindowPosition);
        saveWindowPosition(prefs, FIND_WINDOW_ID_PREFIX, findWindowPosition);
        saveLuytenPreferences(prefs);
    } catch (Exception e) {
        Luyten.showExceptionDialog("Exception!", e);
    }
}
 
開發者ID:hsswx7,項目名稱:CS4500GroupProject,代碼行數:24,代碼來源:ConfigSaver.java

示例4: testNotPersistentPreferences

import java.util.prefs.Preferences; //導入方法依賴的package包/類
public void testNotPersistentPreferences() throws Exception {
    Preferences pref = Preferences.userNodeForPackage(getClass());
    assertNotNull(pref);
    pref.put(getName(), "value");
    assertEquals("value", pref.get(getName(), null));
    pref.sync();
    assertEquals(null, pref.get(getName(), null));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:NbTestCasePreferencesTest.java

示例5: main

import java.util.prefs.Preferences; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
    Preferences prefs = Preferences.userNodeForPackage(CheckUserPrefFirst.class);
    String result = prefs.get("Check", null);
    if ((result == null) || !(result.equals("Success")))
        throw new RuntimeException("User pref not stored!");
    prefs.remove("Check");
    prefs.flush();
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:9,代碼來源:CheckUserPrefLater.java

示例6: getPortNumbers

import java.util.prefs.Preferences; //導入方法依賴的package包/類
/**
 *
 * @return Pair with Sharkopoda control port (key) and Framecapture port (value)
 */
public static Pair<Integer, Integer> getPortNumbers() {
    Preferences prefs = Preferences.userNodeForPackage(SharktopodaSettingsPaneController.class);
    int dSharkPort = Initializer.getConfig().getInt("sharktopoda.defaults.control.port");
    int dFgPort = Initializer.getConfig().getInt("sharktopoda.defaults.framegrab.port");

    try {
        int cport = prefs.getInt(CONTROL_PORT_KEY, dSharkPort);
        int fport = prefs.getInt(FRAMEGRAB_PORT_KEY, dFgPort);
        return new Pair<>(cport, fport);
    }
    catch (Exception e) {
        return null;
    }
}
 
開發者ID:mbari-media-management,項目名稱:vars-annotation,代碼行數:19,代碼來源:SharktopodaSettingsPaneController.java

示例7: setLogLevel

import java.util.prefs.Preferences; //導入方法依賴的package包/類
@Override public void setLogLevel(int level) {
    Preferences p = Preferences.userNodeForPackage(LogViewLogger.class);
    p.putInt("loglevel", level);
    try {
        p.flush();
    } catch (BackingStoreException e) {
    }
    this.level = level;
}
 
開發者ID:jalian-systems,項目名稱:marathonv5,代碼行數:10,代碼來源:LogViewLogger.java

示例8: ParameterContainer

import java.util.prefs.Preferences; //導入方法依賴的package包/類
public ParameterContainer(String name, Preferences prefs) {
//	public ParameterContainer(String name, Preferences parentPrefs, String nodeName) {
		this.name = name;
		this.prefs = prefs;
		if (prefs == null) {
			this.prefs = Preferences.userNodeForPackage(this.getClass());
		}
//		this.prefs = parentPrefs.node(nodeName);
		addExcludedProperty("controlsExpanded");
		support.addPropertyChangeListener(this);
		discoverParameters();
	}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:13,代碼來源:ParameterContainer.java

示例9: loadConfig

import java.util.prefs.Preferences; //導入方法依賴的package包/類
/**
 * Do not load, get the loaded instance
 */
private void loadConfig() {
	decompilerSettings = new DecompilerSettings();
	if (decompilerSettings.getJavaFormattingOptions() == null) {
		decompilerSettings.setJavaFormattingOptions(JavaFormattingOptions.createDefault());
	}
	luytenPreferences = new LuytenPreferences();
	mainWindowPosition = new WindowPosition();
	findWindowPosition = new WindowPosition();
	try {
		Preferences prefs = Preferences.userNodeForPackage(ConfigSaver.class);
		if (!prefs.get(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName())
				.equals(decompilerSettings.getLanguage().getName()))
			prefs.put(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName());

		decompilerSettings.setFlattenSwitchBlocks(
				prefs.getBoolean(FLATTEN_SWITCH_BLOCKS_ID, decompilerSettings.getFlattenSwitchBlocks()));
		decompilerSettings.setForceExplicitImports(
				prefs.getBoolean(FORCE_EXPLICIT_IMPORTS_ID, decompilerSettings.getForceExplicitImports()));
		decompilerSettings.setShowSyntheticMembers(
				prefs.getBoolean(SHOW_SYNTHETIC_MEMBERS_ID, decompilerSettings.getShowSyntheticMembers()));
		decompilerSettings.setExcludeNestedTypes(
				prefs.getBoolean(EXCLUDE_NESTED_TYPES_ID, decompilerSettings.getExcludeNestedTypes()));
		decompilerSettings.setForceExplicitTypeArguments(prefs.getBoolean(FORCE_EXPLICIT_TYPE_ARGUMENTS_ID,
				decompilerSettings.getForceExplicitTypeArguments()));
		decompilerSettings.setRetainRedundantCasts(
				prefs.getBoolean(RETAIN_REDUNDANT_CASTS_ID, decompilerSettings.getRetainRedundantCasts()));
		decompilerSettings.setIncludeErrorDiagnostics(
				prefs.getBoolean(INCLUDE_ERROR_DIAGNOSTICS_ID, decompilerSettings.getIncludeErrorDiagnostics()));
		decompilerSettings.setLanguage(
				findLanguageByName(prefs.get(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName())));
		decompilerSettings.setUnicodeOutputEnabled(prefs.getBoolean(UNICODE_REPLACE_ENABLED_ID, false));

		mainWindowPosition = loadWindowPosition(prefs, MAIN_WINDOW_ID_PREFIX);
		findWindowPosition = loadWindowPosition(prefs, FIND_WINDOW_ID_PREFIX);
		luytenPreferences = loadLuytenPreferences(prefs);
	} catch (Exception e) {
		Luyten.showExceptionDialog("Exception!", e);
	}
}
 
開發者ID:KevinPriv,項目名稱:Luyten4Forge,代碼行數:43,代碼來源:ConfigSaver.java

示例10: createFromUserPreferences

import java.util.prefs.Preferences; //導入方法依賴的package包/類
/**
 * Charge les paramètres depuis les préférences utilisateur.
 * @return Parameters
 * @throws BackingStoreException e
 */
public static Parameters createFromUserPreferences() throws BackingStoreException {
	final Properties properties = new Properties();
	final Preferences prefs = Preferences.userNodeForPackage(Parameters.class);
	for (final String key : prefs.keys()) {
		final String value = prefs.get(key, null);
		if (value != null && !value.isEmpty()) {
			properties.put(key, value);
		}
	}
	return new Parameters(properties);
}
 
開發者ID:evernat,項目名稱:dead-code-detector,代碼行數:17,代碼來源:Parameters.java

示例11: SiLabsC8051F320_LibUsb_PAER

import java.util.prefs.Preferences; //導入方法依賴的package包/類
public SiLabsC8051F320_LibUsb_PAER(Device dev) {
    LibUsb.setDebug(null, 1);
    this.retina = dev;
    this.prefs = Preferences.userNodeForPackage(this.getClass());
    this.aeReader = null;


}
 
開發者ID:SensorsINI,項目名稱:jaer,代碼行數:9,代碼來源:SiLabsC8051F320_LibUsb_PAER.java

示例12: start

import java.util.prefs.Preferences; //導入方法依賴的package包/類
@Override
public void start(final Stage primaryStage) throws Exception
{
    primaryStage.initStyle(StageStyle.UNDECORATED);
    primaryStage.getIcons().add(new Image("/com/matthieu42/steamtradertools/bundles/images/Icon_STTBluepng.png"));
    Preferences prefs = Preferences.userNodeForPackage(com.matthieu42.steamtradertools.model.Main.class);
    String language = prefs.get(PreferencesKeys.LANGUAGE.toString(),Locale.ENGLISH.getDisplayLanguage());
    Locale locale;
    if(language.equals(Locale.FRENCH.getDisplayLanguage()))
    {
        locale = Locale.FRENCH;
    }
    else
        locale = Locale.ENGLISH;
    I18n.setLocale(locale);
    I18n.setBundle("com/matthieu42/steamtradertools/bundles/lang",locale);
    final AllAppList allAppList = new AllAppList();
    final UserAppList userAppList = new UserAppList();

    File steamAppList = new File("steamAppList.xml");
    if (!steamAppList.exists())
    {
        FXMLLoader splashLoader = new FXMLLoader(getClass().getResource("/com/matthieu42/steamtradertools/view/loadview.fxml"),I18n.getResourceBundle());
        AnchorPane pane = splashLoader.load();
        primaryStage.setScene(new Scene(pane));
        primaryStage.show();
        Task<Void> syncApp = allAppList.init();
        syncApp.setOnSucceeded(t ->
        {
            allAppList.saveToXml();
            continueLaunch(allAppList,userAppList,primaryStage);
        });

        syncApp.setOnFailed(t ->
        {
            return;
        });
        new Thread(syncApp).start();
    } else
    {
        allAppList.loadFromXml();
        continueLaunch(allAppList,userAppList,primaryStage);
    }
}
 
開發者ID:Matthieu42,項目名稱:Steam-trader-tools,代碼行數:45,代碼來源:Main.java

示例13: loadConfig

import java.util.prefs.Preferences; //導入方法依賴的package包/類
/**
 * Do not load, get the loaded instance
 */
private void loadConfig() {
    decompilerSettings = new DecompilerSettings();
    if (decompilerSettings.getJavaFormattingOptions() == null) {
        decompilerSettings.setJavaFormattingOptions(JavaFormattingOptions.createDefault());
    }
    luytenPreferences = new LuytenPreferences();
    mainWindowPosition = new WindowPosition();
    findWindowPosition = new WindowPosition();
    try {
        Preferences prefs = Preferences.userNodeForPackage(ConfigSaver.class);
        if (!prefs.get(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName())
                .equals(decompilerSettings.getLanguage().getName()))
            prefs.put(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName());

        decompilerSettings.setFlattenSwitchBlocks(
                prefs.getBoolean(FLATTEN_SWITCH_BLOCKS_ID, decompilerSettings.getFlattenSwitchBlocks()));
        decompilerSettings.setForceExplicitImports(
                prefs.getBoolean(FORCE_EXPLICIT_IMPORTS_ID, decompilerSettings.getForceExplicitImports()));
        decompilerSettings.setShowSyntheticMembers(
                prefs.getBoolean(SHOW_SYNTHETIC_MEMBERS_ID, decompilerSettings.getShowSyntheticMembers()));
        decompilerSettings.setExcludeNestedTypes(
                prefs.getBoolean(EXCLUDE_NESTED_TYPES_ID, decompilerSettings.getExcludeNestedTypes()));
        decompilerSettings.setForceExplicitTypeArguments(prefs.getBoolean(FORCE_EXPLICIT_TYPE_ARGUMENTS_ID,
                decompilerSettings.getForceExplicitTypeArguments()));
        decompilerSettings.setRetainRedundantCasts(
                prefs.getBoolean(RETAIN_REDUNDANT_CASTS_ID, decompilerSettings.getRetainRedundantCasts()));
        decompilerSettings.setIncludeErrorDiagnostics(
                prefs.getBoolean(INCLUDE_ERROR_DIAGNOSTICS_ID, decompilerSettings.getIncludeErrorDiagnostics()));
        decompilerSettings.setLanguage(
                findLanguageByName(prefs.get(LANGUAGE_NAME_ID, decompilerSettings.getLanguage().getName())));
        decompilerSettings.setUnicodeOutputEnabled(prefs.getBoolean(UNICODE_REPLACE_ENABLED_ID, false));

        mainWindowPosition = loadWindowPosition(prefs, MAIN_WINDOW_ID_PREFIX);
        findWindowPosition = loadWindowPosition(prefs, FIND_WINDOW_ID_PREFIX);
        luytenPreferences = loadLuytenPreferences(prefs);
    } catch (Exception e) {
        Luyten.showExceptionDialog("Exception!", e);
    }
}
 
開發者ID:hsswx7,項目名稱:CS4500GroupProject,代碼行數:43,代碼來源:ConfigSaver.java

示例14: 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

示例15: save

import java.util.prefs.Preferences; //導入方法依賴的package包/類
/**
 * Save these settings.
 */
@FromAnyThread
public synchronized void save() {

    final Preferences prefs = Preferences.userNodeForPackage(Editor.class);
    prefs.putInt(PREF_GRAPHIC_ANISOTROPY, getAnisotropy());
    prefs.putBoolean(PREF_GRAPHIC_FXAA, isFXAA());
    prefs.putBoolean(PREF_GRAPHIC_GAMA_CORRECTION, isGammaCorrection());
    prefs.putBoolean(PREF_GRAPHIC_STOP_RENDER_ON_LOST_FOCUS, isStopRenderOnLostFocus());
    prefs.putBoolean(PREF_GRAPHIC_TONEMAP_FILTER, isToneMapFilter());
    prefs.putInt(PREF_SCREEN_HEIGHT, getScreenHeight());
    prefs.putInt(PREF_SCREEN_WIDTH, getScreenWidth());
    prefs.putBoolean(PREF_SCREEN_MAXIMIZED, isMaximized());
    prefs.putInt(PREF_OTHER_GLOBAL_LEFT_TOOL_WIDTH, getGlobalLeftToolWidth());
    prefs.putBoolean(PREF_OTHER_GLOBAL_LEFT_TOOL_COLLAPSED, isGlobalLeftToolCollapsed());
    prefs.putInt(PREF_OTHER_GLOBAL_BOTTOM_TOOL_WIDTH, getGlobalBottomToolHeight());
    prefs.putBoolean(PREF_OTHER_GLOBAL_BOTTOM_TOOL_COLLAPSED, isGlobalBottomToolCollapsed());
    prefs.putBoolean(PREF_OTHER_ANALYTICS, isAnalytics());
    prefs.putBoolean(PREF_OTHER_NATIVE_FILE_CHOOSER, isNativeFileChooser());
    prefs.putInt(PREF_GRAPHIC_FRAME_RATE, getFrameRate());
    prefs.putInt(PREF_GRAPHIC_CAMERA_ANGLE, getCameraAngle());
    prefs.putBoolean(PREF_EDITING_AUTO_TANGENT_GENERATING, isAutoTangentGenerating());
    prefs.putBoolean(PREF_EDITING_DEFAULT_USE_FLIPPED_TEXTURE, isDefaultUseFlippedTexture());
    prefs.putBoolean(PREF_EDITING_CAMERA_LAMP_ENABLED, isDefaultEditorCameraEnabled());
    prefs.putBoolean(PREF_OTHER_ANALYTICS_QUESTION, isAnalyticsQuestion());
    prefs.putInt(PREF_OTHER_THEME, getTheme().ordinal());
    prefs.putInt(PREF_GRAPHIC_OPEN_GL, getOpenGLVersion().ordinal());

    final Vector3f whitePoint = getToneMapFilterWhitePoint();

    prefs.put(PREF_GRAPHIC_TONEMAP_FILTER_WHITE_POINT, whitePoint.getX() + "," + whitePoint.getY() + "," + whitePoint.getZ());

    if (currentAsset != null && !Files.exists(currentAsset)) {
        currentAsset = null;
    }

    if (librariesPath != null && !Files.exists(librariesPath)) {
        librariesPath = null;
    }

    if (currentAsset != null) {
        prefs.put(PREF_ASSET_CURRENT_ASSET, currentAsset.toUri().toString());
    } else {
        prefs.remove(PREF_ASSET_CURRENT_ASSET);
    }

    if (librariesPath != null) {
        prefs.put(PREF_OTHER_LIBRARIES_FOLDER, librariesPath.toUri().toString());
    } else {
        prefs.remove(PREF_OTHER_LIBRARIES_FOLDER);
    }

    if (classesPath != null) {
        prefs.put(PREF_OTHER_CLASSES_FOLDER, classesPath.toUri().toString());
    } else {
        prefs.remove(PREF_OTHER_CLASSES_FOLDER);
    }

    if (additionalEnvs != null) {
        prefs.put(PREF_OTHER_ADDITIONAL_ENVS, additionalEnvs.toUri().toString());
    } else {
        prefs.remove(PREF_OTHER_ADDITIONAL_ENVS);
    }

    final List<String> lastOpenedAssets = getLastOpenedAssets();

    prefs.putByteArray(PREF_ASSET_LAST_OPENED_ASSETS, EditorUtil.serialize((Serializable) lastOpenedAssets));
    try {
        prefs.flush();
    } catch (final BackingStoreException e) {
        throw new RuntimeException(e);
    }

    System.setProperty("jfx.frame.transfer.camera.angle", String.valueOf(getCameraAngle()));
}
 
開發者ID:JavaSaBr,項目名稱:jmonkeybuilder,代碼行數:78,代碼來源:EditorConfig.java


注:本文中的java.util.prefs.Preferences.userNodeForPackage方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。