Search in sources :

Example 6 with IMemento

use of org.eclipse.ui.IMemento in project tdi-studio-se by Talend.

the class SaveChartSetAsAction method performSave.

/**
     * Performs saving chart set.
     * 
     * @param newChartSet The specified new chart set
     * @param chartSets The changed chart sets
     * @throws WorkbenchException
     * @throws IOException
     */
private void performSave(String newChartSet, List<String> chartSets) throws WorkbenchException, IOException {
    IMemento oldChartSetsMemento = getChartSetsMemento();
    IMemento[] oldMementos;
    if (oldChartSetsMemento == null) {
        oldMementos = new IMemento[0];
    } else {
        oldMementos = oldChartSetsMemento.getChildren(CHART_SET);
    }
    XMLMemento chartSetsMemento = XMLMemento.createWriteRoot(CHART_SETS);
    for (String chartSet : chartSets) {
        for (IMemento memento : oldMementos) {
            if (chartSet.equals(memento.getID()) && !chartSet.equals(newChartSet)) {
                chartSetsMemento.createChild(CHART_SET).putMemento(memento);
                break;
            }
        }
    }
    addNewChartSet(chartSetsMemento, newChartSet);
    StringWriter writer = new StringWriter();
    chartSetsMemento.save(writer);
    Activator.getDefault().getPreferenceStore().setValue(CHART_SETS, writer.getBuffer().toString());
}
Also used : XMLMemento(org.eclipse.ui.XMLMemento) StringWriter(java.io.StringWriter) IMemento(org.eclipse.ui.IMemento)

Example 7 with IMemento

use of org.eclipse.ui.IMemento in project eclipse.platform.text by eclipse.

the class SearchView method saveState.

// Methods related to saving page state. -------------------------------------------
@Override
public void saveState(IMemento memento) {
    for (Entry<ISearchResultPage, DummyPart> entry : fPagesToParts.entrySet()) {
        ISearchResultPage page = entry.getKey();
        DummyPart part = entry.getValue();
        IMemento child = memento.createChild(MEMENTO_TYPE, page.getID());
        page.saveState(child);
        child.putInteger(MEMENTO_KEY_LAST_ACTIVATION, part.getLastActivation());
    }
    memento.putString(MEMENTO_KEY_IS_PINNED, String.valueOf(isPinned()));
}
Also used : ISearchResultPage(org.eclipse.search.ui.ISearchResultPage) IMemento(org.eclipse.ui.IMemento)

Example 8 with IMemento

use of org.eclipse.ui.IMemento in project linuxtools by eclipse.

the class TreeSettings method readTree.

/**
 * Opposite action as writeTree. Reconstruct a tree from a previously-saved {@link IMemento}.
 * @param data The {@link IMemento} to read the tree out of.
 * @return The reconstructed {@link TreeNode}.
 */
private static TreeNode readTree(IMemento data) {
    String disp = data.getString(M_DISP);
    String def = data.getString(M_DEFINITON);
    boolean c = data.getBoolean(M_CLICKABLE);
    Object d = StapTreeDataFactory.createObjectFromString(data.getString(M_DATA), data.getString(M_DATATYPE));
    TreeNode parent;
    if (def == null) {
        parent = new TreeNode(d, disp, c);
    } else {
        parent = new TreeDefinitionNode(d, disp, getValueFromString(def), c);
    }
    for (IMemento child : data.getChildren()) {
        parent.add(readTree(child));
    }
    return parent;
}
Also used : TreeNode(org.eclipse.linuxtools.systemtap.structures.TreeNode) TreeDefinitionNode(org.eclipse.linuxtools.systemtap.structures.TreeDefinitionNode) IMemento(org.eclipse.ui.IMemento)

Example 9 with IMemento

use of org.eclipse.ui.IMemento in project knime-core by knime.

the class NodeUsageRegistry method saveLastUsedNodes.

/**
 * Saves last used nodes to XML memento. Called from
 * FavoriteNodesManager#saveFavoriteNodes.
 *
 * @see #loadLastUsedNodes(IMemento)
 * @param lastUsedNodes XML memento to save last used nodes to
 */
public static void saveLastUsedNodes(final IMemento lastUsedNodes) {
    for (NodeTemplate node : LAST_USED) {
        IMemento item = lastUsedNodes.createChild(TAG_FAVORITE);
        item.putString(TAG_NODE_ID, node.getID());
    }
}
Also used : NodeTemplate(org.knime.workbench.repository.model.NodeTemplate) IMemento(org.eclipse.ui.IMemento)

Example 10 with IMemento

use of org.eclipse.ui.IMemento in project knime-core by knime.

the class NodeUsageRegistry method loadFrequentNodes.

/**
 * Loads the most frequently used nodes from XML memento. Called from
 * FavoriteNodesManager#loadFavoriteNodes.
 *
 * @see #saveFrequentNodes(IMemento)
 * @param freqNodes the XML memento containing the most frequently used
 *            nodes
 */
public static void loadFrequentNodes(final IMemento freqNodes) {
    for (IMemento freqNode : freqNodes.getChildren(TAG_FAVORITE)) {
        String id = freqNode.getString(TAG_NODE_ID);
        int frequency = freqNode.getInteger(TAG_FREQUENCY);
        NodeTemplate node = RepositoryManager.INSTANCE.getNodeTemplate(id);
        if (node != null) {
            NodeTemplateFrequency nodeFreq = new NodeTemplateFrequency(node);
            nodeFreq.m_frequency = frequency;
            FREQUENCIES.put(nodeFreq, nodeFreq);
        }
    }
}
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