use of org.eclipse.ui.IMemento in project knime-core by knime.
the class NodeUsageRegistry method saveFrequentNodes.
/**
* Saves most frequent nodes to XML memento. Called from
* FavoriteNodesManager#saveFavoriteNodes.
*
* @see #loadFrequentNodes(IMemento)
* @param freqNodes XML memento to save most frequently used nodes to
*/
public static void saveFrequentNodes(final IMemento freqNodes) {
for (NodeTemplateFrequency nodeFreq : FREQUENCIES.values()) {
IMemento item = freqNodes.createChild(TAG_FAVORITE);
item.putString(TAG_NODE_ID, nodeFreq.getNode().getID());
item.putInteger(TAG_FREQUENCY, nodeFreq.m_frequency);
}
}
use of org.eclipse.ui.IMemento in project knime-core by knime.
the class FavoriteNodesManager method saveFavoriteNodes.
private void saveFavoriteNodes(final XMLMemento memento) {
// personal favorites
IMemento favNodes = memento.createChild(TAG_PERSONAL_FAVS);
for (IRepositoryObject reposObj : m_favNodes.getChildren()) {
IMemento item = favNodes.createChild(TAG_FAVORITE);
item.putString(TAG_NODE_ID, ((NodeTemplate) reposObj).getID());
}
// most frequent
IMemento freqNodes = memento.createChild(TAG_MOST_FREQUENT);
NodeUsageRegistry.saveFrequentNodes(freqNodes);
// last used
IMemento lastUsedNodes = memento.createChild(TAG_LAST_USED);
NodeUsageRegistry.saveLastUsedNodes(lastUsedNodes);
}
use of org.eclipse.ui.IMemento in project yamcs-studio by yamcs.
the class OPIView method init.
@Override
public void init(final IViewSite site, IMemento memento) throws PartInitException {
super.init(site, memento);
this.site = site;
if (debug)
System.out.println(site.getId() + ":" + site.getSecondaryId() + " opened " + (memento == null ? ", no memento" : "with memento"));
if (memento == null) {
memento = findMementoFromPlaceholder();
}
if (memento == null) {
return;
}
// Load previously displayed input from memento
final String factoryID = memento.getString(TAG_FACTORY_ID);
if (factoryID == null) {
OPIBuilderPlugin.getLogger().log(Level.WARNING, toString() + " has memento with empty factory ID");
return;
}
final IMemento inputMem = memento.getChild(TAG_INPUT);
final IElementFactory factory = PlatformUI.getWorkbench().getElementFactory(factoryID);
if (factory == null)
throw new PartInitException(NLS.bind("Cannot instantiate input element factory {0} for OPIView", factoryID));
final IAdaptable element = factory.createElement(inputMem);
if (!(element instanceof IEditorInput))
throw new PartInitException("Instead of IEditorInput, " + factoryID + " returned " + element);
// Set input, but don't persist to memento because we just read it from memento
setOPIInput((IEditorInput) element, false);
}
use of org.eclipse.ui.IMemento in project yamcs-studio by yamcs.
the class OPIView method findMementoFromPlaceholder.
/**
* Retrieve memento persisted in MPlaceholder if present.
*
* @return memento persisted in the placeholder.
*/
private IMemento findMementoFromPlaceholder() {
IMemento memento = null;
MPlaceholder placeholder = findPlaceholder();
if (placeholder != null) {
if (placeholder.getPersistedState().containsKey(TAG_MEMENTO)) {
String mementoString = placeholder.getPersistedState().get(TAG_MEMENTO);
memento = loadMemento(mementoString);
}
}
return memento;
}
use of org.eclipse.ui.IMemento in project yamcs-studio by yamcs.
the class OPIView method saveState.
@Override
public void saveState(IMemento memento) {
super.saveState(memento);
if (input == null)
return;
IPersistableElement persistable = input.getPersistable();
if (persistable != null) {
/*
* Store IPersistable of the IEditorInput in a separate section since it could potentially use a tag already
* used in the parent memento and thus overwrite data.
*/
IMemento persistableMemento = memento.createChild(TAG_INPUT);
persistable.saveState(persistableMemento);
memento.putString(TAG_FACTORY_ID, persistable.getFactoryId());
// input.getToolTipText());
if (debug)
System.out.println(this + " saved to memento");
}
}
Aggregations