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());
}
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()));
}
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;
}
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());
}
}
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);
}
}
}
Aggregations