java.util.prefs.BackingStoreException#printStackTrace ( )源码实例Demo

下面列出了java.util.prefs.BackingStoreException#printStackTrace ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: whyline   文件: Whyline.java
private static String loadPreferences() {

		UI.class.getName();
		
		// Load the preferences, if there are any.
		Preferences userPrefs = getPreferences();

		// If no preference is set, use the current working directory.
		String WHYLINE_HOME = userPrefs.get(WHYLINE_HOME_PATH_KEY, System.getProperty("user.dir") + File.separatorChar + "whyline" + File.separatorChar);

		// Now store the preference, in case it wasn't stored before
		userPrefs.put(WHYLINE_HOME_PATH_KEY, WHYLINE_HOME);
		try {
			userPrefs.flush();
		} catch (BackingStoreException e) {
			e.printStackTrace();
		}

		return WHYLINE_HOME;
		
	}
 
源代码2 项目: markdown-writer-fx   文件: ProjectManager.java
private static List<File> getRecentProjects() {
	Preferences state = getProjectsState();
	ArrayList<File> projects = new ArrayList<>();

	try {
		String[] childrenNames = state.childrenNames();
		for (String childName : childrenNames) {
			Preferences child = state.node(childName);
			String path = child.get(KEY_PATH, null);
			if (path != null)
				projects.add(new File(path));
		}
	} catch (BackingStoreException ex) {
		// ignore
		ex.printStackTrace();
	}

	return projects;
}
 
源代码3 项目: petscii-bbs   文件: PreferencesDialog.java
public void actionPerformed(ActionEvent e) {
 
  if (e.getActionCommand().equals("Ok")) {
    
    // Transfer the settings to the user settings only, they will
    // only take effect on the next restart
    int stdfontsize = Integer.valueOf(stdfontSpinner.getValue().toString());
    int fixedfontsize = Integer.valueOf(fixedfontSpinner.getValue().toString());
    int bgcolor = ((ColorItem) backgroundCB.getSelectedItem()).color;
    int fgcolor = ((ColorItem) foregroundCB.getSelectedItem()).color;
    boolean antialias = antialiasCB.isSelected();
    
    preferences.put("stdfontsize", String.valueOf(stdfontsize));
    preferences.put("fixedfontsize", String.valueOf(fixedfontsize));
    preferences.put("defaultbackground", String.valueOf(bgcolor));
    preferences.put("defaultforeground", String.valueOf(fgcolor));
    preferences.put("antialias", antialias ? "on" : "off");
    settings.setSettings(stdfontsize, fixedfontsize, bgcolor, fgcolor, antialias);
    try {
      preferences.flush();
    } catch (BackingStoreException ex) {
      
      ex.printStackTrace();
    }
  }
  dispose();
}
 
源代码4 项目: GIFKR   文件: GIFKRPrefs.java
public static void setShowCreditsFrame(boolean value) {
	p.putBoolean(KEY_CREDITS_FRAME, value);
	try {
		p.sync();
	} catch (BackingStoreException e) {
		e.printStackTrace();
	}
}
 
源代码5 项目: whyline   文件: Whyline.java
public static void setHome(File home) {

		Preferences userPrefs = getPreferences();
		userPrefs.put(WHYLINE_HOME_PATH_KEY, home.getAbsolutePath());
		try {
			userPrefs.flush();
		} catch (BackingStoreException e) {
			e.printStackTrace();
		}

		WHYLINE_FOLDER = home;
		WHYLINE_FOLDER.mkdir();	

		WORKING_TRACE_FOLDER = new File(WHYLINE_FOLDER, WORKING_TRACE_FOLDER_NAME);
		WORKING_CLASSIDS_FILE = new File(Whyline.WHYLINE_FOLDER, CLASSIDS_NAME);
		WORKING_IMMUTABLES_FILE = new File(WORKING_TRACE_FOLDER, IMMUTABLES_PATH);
		WORKING_META_FILE = new File(WORKING_TRACE_FOLDER, META_PATH);
		WORKING_OBJECT_TYPES_FILE = new File(Whyline.WORKING_TRACE_FOLDER, OBJECT_TYPES_PATH);
		WORKING_SERIAL_HISTORY_FOLDER = new File(Whyline.WORKING_TRACE_FOLDER, SERIAL_PATH);
		WORKING_SOURCE_FOLDER  = new File(WORKING_TRACE_FOLDER, SOURCE_PATH);
		WORKING_CLASSNAMES_FILE = new File(WORKING_TRACE_FOLDER, CLASSNAMES_PATH);

		CLASS_CACHE_FOLDER = new File(WHYLINE_FOLDER, CLASS_CACHE_PATH);	
		UNINSTRUMENTED_CLASS_CACHE_FOLDER = new File(getClassCacheFolder(), ANALYZED_CLASS_CACHE_FOLDER_NAME);	
		INSTRUMENTED_CLASS_CACHE_FOLDER = new File(getClassCacheFolder(), INSTRUMENTED_CLASS_CACHE_FOLDER_NAME);	
		SAVED_TRACES_FOLDER = new File(WHYLINE_FOLDER, SAVED_TRACES_FOLDER_NAME);
		
	}
 
源代码6 项目: Stringlate   文件: AppSettingsBaseJ.java
public synchronized void closePrefs() {
    if (_preference != null) {
        try {
            _preference.sync();
        } catch (BackingStoreException e) {
            e.printStackTrace();
        }
    }
    _preference = null;
}
 
源代码7 项目: Stringlate   文件: AppSettingsBaseJ.java
public void reset(boolean setDefaultOptions) {
    try {
        getPref().clear();
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }

    if (setDefaultOptions) {
        resetDefaultValues();
    }
}
 
源代码8 项目: tda   文件: PrefManager.java
public void flush() {
    try {
        toolPrefs.flush();
    } catch (BackingStoreException ex) {
        ex.printStackTrace();
    }
}
 
源代码9 项目: opencards   文件: Utils.java
public static void flushPreferences() {
    try {
        getPrefs().flush();
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }
}
 
源代码10 项目: opencards   文件: Utils.java
public static void resetAllSettings() {
    try {
        getPrefs().clear();
        getPrefs().flush();
    } catch (BackingStoreException e) {
        e.printStackTrace();
    }
}
 
源代码11 项目: markdown-writer-fx   文件: ProjectManager.java
private static void removeProjectState(File project) {
	Preferences projectState = getProjectState(project, false);
	if (projectState != null) {
		try {
			projectState.removeNode();
		} catch (BackingStoreException ex) {
			// ignore
			ex.printStackTrace();
		}
	}
}
 
源代码12 项目: DiskBrowser   文件: WindowState.java
void clear ()
// ---------------------------------------------------------------------------------//
{
  try
  {
    preferences.clear ();
    System.out.println ("Preferences cleared");
  }
  catch (BackingStoreException e)
  {
    e.printStackTrace ();
  }
}
 
源代码13 项目: gama   文件: GamaPreferences.java
public static void setNewPreferences(final Map<String, Object> modelValues) {
	for (final String name : modelValues.keySet()) {
		final Pref e = prefs.get(name);
		if (e == null) {
			continue;
		}
		e.set(modelValues.get(name));
		writeToStore(e);
		try {
			store.flush();
		} catch (final BackingStoreException ex) {
			ex.printStackTrace();
		}
	}
}
 
源代码14 项目: gama   文件: WorkspacePreferences.java
public static Preferences getNode() {
	try {
		if ( Preferences.userRoot().nodeExists("gama") ) { return Preferences.userRoot().node("gama"); }
	} catch (final BackingStoreException e1) {
		e1.printStackTrace();
	}
	final Preferences p = Preferences.userRoot().node("gama");
	try {
		p.flush();
	} catch (final BackingStoreException e) {
		e.printStackTrace();
	}
	return p;
}
 
源代码15 项目: gama   文件: WorkspacePreferences.java
private static void flush() {
	try {
		getNode().flush();
	} catch (final BackingStoreException e) {
		e.printStackTrace();
	}
}
 
源代码16 项目: whyline   文件: Whyline.java
public static String getJDKSourcePath() {

		Preferences userPrefs = getPreferences();

		String sourcePath = userPrefs.get(JDK_SOURCE_PATH, null);

		if(sourcePath == null) {
			
			String OSXPathToSource = "/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Home/src.jar";
			String WindowsPathToSource = "C:/jdk1.5.0/src.zip";

			String osName = System.getProperty("os.name");
			if(osName.contains("OS X")) sourcePath = OSXPathToSource;
			else if(osName.contains("Windows")) sourcePath = WindowsPathToSource;
			
			userPrefs.put(JDK_SOURCE_PATH, sourcePath);
			try { userPrefs.flush(); } catch(BackingStoreException e) { e.printStackTrace(); }
			
		}
			
		return sourcePath;
		
	}
 
源代码17 项目: pumpernickel   文件: TextInputDialog.java
/**
 * Show a QDialog prompting the user for text input. This method reads and
 * writes a value from the Preferences object provided. (If you don't want
 * to use Preferences, use another static method.)
 * 
 * @param frame
 *            the frame that will own the dialog.
 * @param dialogTitle
 *            the title of the dialog.
 * @param boldMessage
 *            the optional bold message for the content pane.
 * @param plainMessage
 *            the optional plain message for the content pane to display
 *            below the bold message.
 * @param textFieldPrompt
 *            the optional text field prompt.
 * @param textFieldToolTip
 *            the optional text field tooltip.
 * @param defaultTextFieldText
 *            the text to show in the text field if the preferences don't
 *            offer any starting text.
 * @param prefs
 *            the preferences to consult.
 * @param preferenceKey
 *            the key to consult in the Preferences argument.
 * @param handler
 *            the optional handler used to control UI elements in the
 *            dialog.
 * @return the String the user entered, or null if the user cancelled the
 *         dialog.
 */
public static String show(Frame frame, String dialogTitle,
		String boldMessage, String plainMessage, String textFieldPrompt,
		String textFieldToolTip, String defaultTextFieldText,
		Preferences prefs, String preferenceKey, StringInputHandler handler) {
	String initialText = prefs.get(preferenceKey, defaultTextFieldText);
	String returnValue = show(frame, dialogTitle, boldMessage,
			plainMessage, textFieldPrompt, textFieldToolTip, initialText,
			handler);

	if (returnValue != null) {
		prefs.put(preferenceKey, returnValue);
	}
	try {
		prefs.sync();
	} catch (BackingStoreException e) {
		e.printStackTrace();
	}
	return returnValue;

}
 
源代码18 项目: iBioSim   文件: EditPreferences.java
public void preferences() {
	Preferences biosimrc = Preferences.userRoot();
	if (biosimrc.get("biosim.check.undeclared", "").equals("false")) {
		checkUndeclared = false;
	}
	else {
		checkUndeclared = true;
	}
	if (biosimrc.get("biosim.check.units", "").equals("false")) {
		checkUnits = false;
	}
	else {
		checkUnits = true;
	}
	JPanel generalPrefs = generalPreferences(biosimrc);
	JPanel schematicPrefs = schematicPreferences(biosimrc);
	JPanel modelPrefs = modelPreferences(biosimrc);
	JPanel analysisPrefs = analysisPreferences(biosimrc);

	// create tabs
	JTabbedPane prefTabs = new JTabbedPane();
	if (async) prefTabs.addTab("General Preferences", generalPrefs);
	if (async) prefTabs.addTab("Schematic Preferences", schematicPrefs);
	if (async) prefTabs.addTab("Model Preferences", modelPrefs);
	if (async) prefTabs.addTab("Analysis Preferences", analysisPrefs);

	boolean problem;
	int value;
	do {
		problem = false;
		Object[] options = { "Save", "Cancel" };
		value = JOptionPane.showOptionDialog(frame, prefTabs, "Preferences", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE, null,
				options, options[0]);

		// if user hits "save", store and/or check new data
		if (value == JOptionPane.YES_OPTION) {
			if (async) saveGeneralPreferences(biosimrc);
			if (async) problem = saveSchematicPreferences(biosimrc);
			if (async && !problem) problem = saveModelPreferences(biosimrc);
			if (async && !problem) problem = saveAnalysisPreferences(biosimrc);
			try {
				biosimrc.sync();
			}
			catch (BackingStoreException e) {
				e.printStackTrace();
			}
		}
	} while (value == JOptionPane.YES_OPTION && problem);
}
 
源代码19 项目: gama   文件: GamaPreferences.java
private static void register(final Pref gp) {
	final IScope scope = null;
	final String key = gp.key;
	if (key == null) { return; }
	prefs.put(key, gp);
	final Object value = gp.value;
	if (storeKeys.contains(key)) {
		switch (gp.type) {
			case IType.POINT:
				gp.init(() -> asPoint(scope, store.get(key, asString(scope, value)), false));
				break;
			case IType.INT:
				gp.init(() -> store.getInt(key, asInt(scope, value)));
				break;
			case IType.FLOAT:
				gp.init(() -> store.getDouble(key, asFloat(scope, value)));
				break;
			case IType.BOOL:
				gp.init(() -> store.getBoolean(key, asBool(scope, value)));
				break;
			case IType.STRING:
				gp.init(() -> store.get(key, toJavaString(asString(scope, value))));
				break;
			case IType.FILE:
				gp.init(() -> new GenericFile(store.get(key, (String) value), false));
				break;
			case IType.COLOR:
				gp.init(() -> GamaColor.getInt(store.getInt(key, asInt(scope, value))));
				break;
			case IType.FONT:
				gp.init(() -> GamaFontType.staticCast(scope, store.get(key, asString(scope, value)), false));
				break;
			case IType.DATE:
				gp.init(() -> fromISOString(toJavaString(store.get(key, asString(scope, value)))));
				break;
			default:
				gp.init(() -> store.get(key, asString(scope, value)));
		}
	}
	try {
		store.flush();
	} catch (final BackingStoreException ex) {
		ex.printStackTrace();
	}
	// Adds the preferences to the platform species if it is already created
	final PlatformSpeciesDescription spec = GamaMetaModel.INSTANCE.getPlatformSpeciesDescription();
	if (spec != null) {
		if (!spec.hasAttribute(key)) {
			spec.addPref(key, gp);
			spec.validate();
		}
	}
	// Registers the preferences in the variable of the scope provider

}
 
源代码20 项目: whyline   文件: Whyline.java
public static void setJDKSourcePath(String sourcePath) {

		Preferences userPrefs = getPreferences();
		userPrefs.put(JDK_SOURCE_PATH, sourcePath);
		try { userPrefs.flush(); } catch(BackingStoreException e) { e.printStackTrace(); }

	}