use of org.eclipse.ui.IMemento in project linuxtools by eclipse.
the class TreeSettings method writeTree.
/**
* Writes the tree passed in to the {@link IMemento} argument.
* @param data The {@link IMemento} to store the tree to.
* @param name The name to give to the <code>parent</code> node.
* @param tree The {@link TreeNode} to store.
*/
private static void writeTree(IMemento data, String name, TreeNode tree) {
IMemento child = data.createChild(name);
child.putString(M_DISP, tree.toString());
Object treeData = tree.getData();
if (treeData != null) {
child.putString(M_DATA, treeData.toString());
child.putString(M_DATATYPE, StapTreeDataFactory.getDataObjectID(treeData));
}
if (tree instanceof TreeDefinitionNode) {
child.putString(M_DEFINITON, getStringFromValue(((TreeDefinitionNode) tree).getDefinition()));
}
child.putBoolean(M_CLICKABLE, tree.isClickable());
for (int i = 0, n = tree.getChildCount(); i < n; i++) {
writeTree(child, M_ITEM, tree.getChildAt(i));
}
}
use of org.eclipse.ui.IMemento in project linuxtools by eclipse.
the class TreeSettings method getTreeFileMemento.
private static IMemento getTreeFileMemento() {
if (!isTreeFileAvailable()) {
return null;
}
try (FileReader reader = new FileReader(settingsFile)) {
IMemento data = XMLMemento.createReadRoot(reader, FILE_NAME);
IMemento versionChild = data.getChild(T_VERSION);
if (versionChild != null && versionChild.getTextData().equals(VERSION_NUMBER)) {
return data;
}
return null;
} catch (IOException | WorkbenchException fnfe) {
return null;
}
}
use of org.eclipse.ui.IMemento in project knime-core by knime.
the class FavoriteNodesManager method loadFavoriteNodes.
private void loadFavoriteNodes(final XMLMemento favoriteNodes) {
IMemento favNodes = favoriteNodes.getChild(TAG_PERSONAL_FAVS);
for (IMemento favNode : favNodes.getChildren(TAG_FAVORITE)) {
String id = favNode.getString(TAG_NODE_ID);
NodeTemplate node = RepositoryManager.INSTANCE.getNodeTemplate(id);
if (node != null) {
addFavoriteNode(node);
}
}
IMemento freqNodes = favoriteNodes.getChild(TAG_MOST_FREQUENT);
NodeUsageRegistry.loadFrequentNodes(freqNodes);
IMemento lastNodes = favoriteNodes.getChild(TAG_LAST_USED);
NodeUsageRegistry.loadLastUsedNodes(lastNodes);
updateNodes();
}
use of org.eclipse.ui.IMemento in project knime-core by knime.
the class NodeUsageRegistry method loadLastUsedNodes.
/**
* Loads the last used nodes from XML memento. Called from
* FavoriteNodesManager#loadFavoriteNodes.
*
* @see #saveLastUsedNodes(IMemento)
* @param lastUsedNodes the XML memento to load the last used nodes from
*/
public static void loadLastUsedNodes(final IMemento lastUsedNodes) {
for (IMemento lastNode : lastUsedNodes.getChildren(TAG_FAVORITE)) {
String id = lastNode.getString(TAG_NODE_ID);
NodeTemplate node = RepositoryManager.INSTANCE.getNodeTemplate(id);
if (node != null) {
addToLastUsedNodes(node);
}
}
}
Aggregations