Search in sources :

Example 26 with IMemento

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));
    }
}
Also used : TreeDefinitionNode(org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode) IMemento(org.eclipse.ui.IMemento)

Example 27 with IMemento

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;
    }
}
Also used : FileReader(java.io.FileReader) IOException(java.io.IOException) WorkbenchException(org.eclipse.ui.WorkbenchException) IMemento(org.eclipse.ui.IMemento)

Example 28 with IMemento

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();
}
Also used : NodeTemplate(org.knime.workbench.repository.model.NodeTemplate) IMemento(org.eclipse.ui.IMemento)

Example 29 with IMemento

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);
        }
    }
}
Also used : NodeTemplate(org.knime.workbench.repository.model.NodeTemplate) IMemento(org.eclipse.ui.IMemento)

Aggregations

IMemento (org.eclipse.ui.IMemento)29 NodeTemplate (org.knime.workbench.repository.model.NodeTemplate)4 IOException (java.io.IOException)3 StringWriter (java.io.StringWriter)3 WorkbenchException (org.eclipse.ui.WorkbenchException)3 XMLMemento (org.eclipse.ui.XMLMemento)3 IMonitoredMXBeanGroup (org.talend.designer.runtime.visualization.MBean.IMonitoredMXBeanGroup)3 ArrayList (java.util.ArrayList)2 TreeDefinitionNode (org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode)2 ISearchResultPage (org.eclipse.search.ui.ISearchResultPage)2 JvmCoreException (org.talend.designer.runtime.visualization.JvmCoreException)2 IMBeanServer (org.talend.designer.runtime.visualization.MBean.IMBeanServer)2 FileReader (java.io.FileReader)1 Entry (java.util.Map.Entry)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 MPlaceholder (org.eclipse.e4.ui.model.application.ui.advanced.MPlaceholder)1 TreeNode (org.eclipse.linuxtools.systemtap.structures.TreeNode)1 IActionBars (org.eclipse.ui.IActionBars)1 IEditorInput (org.eclipse.ui.IEditorInput)1 IElementFactory (org.eclipse.ui.IElementFactory)1