use of org.phoebus.framework.spi.AppInstance in project phoebus by ControlSystemStudio.
the class MementoHelper method saveDockItem.
/**
* Save state of a DockItem
*
* <p>Store the application name, optionally the resource (input),
* and then allow the application itself to store details.
*
* @param memento
* @param item
*/
private static void saveDockItem(final MementoTree memento, final DockItem item) {
final AppInstance application = item.getApplication();
if (application == null || application.isTransient())
return;
final MementoTree item_memento = memento.getChild(item.getID());
item_memento.setString(DockItem.KEY_APPLICATION, application.getAppDescriptor().getName());
if (item instanceof DockItemWithInput) {
final URI input = ((DockItemWithInput) item).getInput();
if (input != null)
item_memento.setString(INPUT_URI, input.toString());
}
try {
application.save(item_memento);
} catch (Throwable ex) {
logger.log(Level.SEVERE, "Application " + application.getAppDescriptor().getDisplayName() + " memento error", ex);
}
}
use of org.phoebus.framework.spi.AppInstance in project phoebus by ControlSystemStudio.
the class MementoHelper method restoreApplication.
private static void restoreApplication(final MementoTree item_memento, final DockPane pane, final AppDescriptor app) {
DockPane.setActiveDockPane(pane);
final AppInstance instance;
if (app instanceof AppResourceDescriptor) {
final AppResourceDescriptor app_res = (AppResourceDescriptor) app;
final String input = item_memento.getString(INPUT_URI).orElse(null);
instance = input == null ? app_res.create() : app_res.create(URI.create(input));
} else
instance = app.create();
instance.restore(item_memento);
}
Aggregations