use of org.phoebus.framework.persistence.XMLMementoTree in project phoebus by ControlSystemStudio.
the class MementoHelper method saveState.
/**
* Write all the current stages to a memento file.
* @param memento_file The file the memento xml is stored in.
* @param last_opened_file The last opened file.
* @param default_application The default application name.
* @param show_menu Show menu?
* @param show_toolbar Show toolbar?
* @param show_statusbar Show status bar?
*/
public static void saveState(final File memento_file, final File last_opened_file, final String default_application, final boolean show_menu, final boolean show_toolbar, final boolean show_statusbar) {
logger.log(Level.INFO, "Persisting state to " + memento_file);
try {
final XMLMementoTree memento = XMLMementoTree.create();
// Persist global settings
if (last_opened_file != null)
memento.setString(PhoebusApplication.LAST_OPENED_FILE, last_opened_file.toString());
if (default_application != null)
memento.setString(PhoebusApplication.DEFAULT_APPLICATION, default_application);
memento.setBoolean(PhoebusApplication.SHOW_TABS, DockPane.isAlwaysShowingTabs());
memento.setBoolean(PhoebusApplication.SHOW_MENU, show_menu);
memento.setBoolean(PhoebusApplication.SHOW_TOOLBAR, show_toolbar);
memento.setBoolean(PhoebusApplication.SHOW_STATUSBAR, show_statusbar);
// Persist each stage (window) and its tabs
saveStages(memento);
// Write the memento file
if (!memento_file.getParentFile().exists())
memento_file.getParentFile().mkdirs();
memento.write(new FileOutputStream(memento_file));
} catch (Exception ex) {
logger.log(Level.WARNING, "Error writing saved state to " + memento_file, ex);
}
}
Aggregations