use of org.eclipse.e4.ui.di.Persist in project org.csstudio.display.builder by kasemir.
the class RuntimeViewPart method persist.
/**
* Persist the view's input "on demand".
*
* <p>Framework only persists to memento on exit,
* and only for the currently visible views.
*
* <p>Display info for views in other perspectives
* which are hidden on application shutdown will be lost.
* By forcing a persist for each view while the app is still running,
* each view can be restored when a perspective is later re-activated.
*
* <p>Memento is saved in the
* .metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi
* inside a "persistedState" element of the E4 model element.
*
* <p>This method places it in the model just as the framework
* does by calling saveState() on shutdown,
* but allows saving the state at any time.
*/
private void persist() {
try {
// Obtain E4 model element for E3 view,
// based on http://www.vogella.com/tutorials/EclipsePlugIn/article.html#eclipsecontext
final IEclipseContext context = getViewSite().getService(IEclipseContext.class);
final MPart part = context.get(MPart.class);
// Based on org.eclipse.ui.internal.ViewReference#persist():
//
// XML version of memento is written to E4 model.
// If compatibility layer changes its memento persistence,
// this will break...
// $NON-NLS-1$
final XMLMemento root = XMLMemento.createWriteRoot("view");
saveState(root);
final StringWriter writer = new StringWriter();
root.save(writer);
part.getPersistedState().put(TAG_MEMENTO, writer.toString());
} catch (Exception ex) {
logger.log(Level.WARNING, "Cannot persist " + display_info, ex);
}
}
use of org.eclipse.e4.ui.di.Persist in project whole by wholeplatform.
the class AbstractE4Part method save.
@Persist
public void save() {
if (modelInput != null) {
workspace.removeResourceChangeListener(resourceListener);
IPersistenceProvider pp = modelInput.getPersistenceProvider();
try {
RootFragment rootFragment = (RootFragment) viewer.getContents().getModel();
modelInput.getPersistenceKit().writeModel(rootFragment.wGetRoot(), pp);
viewer.getCommandStack().markSaveLocation();
part.setDirty(false);
} catch (Exception e) {
} finally {
workspace.addResourceChangeListener(resourceListener);
}
}
}
use of org.eclipse.e4.ui.di.Persist in project yamcs-studio by yamcs.
the class OPIView method persist.
/**
* Persist the view's input "on demand".
*
* <p>
* To allow saving the memento at any time.
*
* <p>
* Memento is saved in the .metadata/.plugins/org.eclipse.e4.workbench/workbench.xmi inside a "persistedState"
* element of the E4 model element.
*
* <p>
* This method places it in the model just as the framework does by calling saveState() on shutdown, but allows
* saving the state at any time.
*/
private void persist() {
// Obtain E4 model element for E3 view,
// based on http://www.vogella.com/tutorials/EclipsePlugIn/article.html#eclipsecontext
final IEclipseContext context = (IEclipseContext) getViewSite().getService(IEclipseContext.class);
final MPart model = context.get(MPart.class);
// Based on org.eclipse.ui.internal.ViewReference#persist():
//
// XML version of memento is written to E4 model.
// If compatibility layer changes its memento persistence,
// this will break...
// $NON-NLS-1$
final XMLMemento root = XMLMemento.createWriteRoot("view");
saveState(root);
final StringWriter writer = new StringWriter();
try {
root.save(writer);
model.getPersistedState().put(TAG_MEMENTO, writer.toString());
} catch (Exception ex) {
OPIBuilderPlugin.getLogger().log(Level.WARNING, toString() + " failed to persist input", ex);
}
}
Aggregations