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 tdi-studio-se by Talend.
the class LoadChartAction method loadChartSet.
/**
* Loads the given chart set.
*
* @param chartSet The chart set
* @throws JvmCoreException
*/
private void loadChartSet(String chartSet) throws JvmCoreException {
loadPredefinedChartSet(chartSet);
IMemento chartSetsMemento;
try {
chartSetsMemento = getChartSetsMemento();
} catch (WorkbenchException e) {
throw new JvmCoreException(IStatus.ERROR, Messages.loadChartSetFailedMsg, e);
} catch (IOException e) {
throw new JvmCoreException(IStatus.ERROR, Messages.loadChartSetFailedMsg, e);
}
if (chartSetsMemento == null) {
return;
}
IMemento[] mementos = chartSetsMemento.getChildren(CHART_SET);
for (IMemento memento : mementos) {
if (chartSet.equals(memento.getID())) {
loadChartSet(memento);
return;
}
}
}
use of org.eclipse.ui.IMemento in project tdi-studio-se by Talend.
the class LoadChartSetAction method loadChartSet.
/**
* Loads the given memento of chart set.
*
* @param memento The memento
* @throws JvmCoreException
*/
private void loadChartSet(IMemento memento) throws JvmCoreException {
IMBeanServer server = section.getJvm().getMBeanServer();
server.getMonitoredAttributeGroups().clear();
StringBuffer buffer = new StringBuffer();
for (IMemento groupMemento : memento.getChildren(GROUP)) {
IMonitoredMXBeanGroup group = server.addMonitoredAttributeGroup(groupMemento.getID(), AxisUnit.valueOf(groupMemento.getString(UNIT)));
for (IMemento attributeMemento : groupMemento.getChildren(ATTRIBUTE)) {
String objectName = attributeMemento.getString(OBJECT_NAME);
String attributeName = attributeMemento.getID();
if (attributeExist(objectName, attributeName)) {
group.addAttribute(objectName, attributeName, getRGB(attributeMemento.getString(COLOR)));
} else {
buffer.append('\n');
buffer.append(objectName + ':' + attributeName);
}
}
}
if (buffer.length() > 0) {
MessageDialog.openError(Display.getDefault().getActiveShell(), Messages.errorDialogTitle, NLS.bind(Messages.attributeNotSupportedMsg, buffer.toString()));
}
}
use of org.eclipse.ui.IMemento in project tdi-studio-se by Talend.
the class LoadChartAction method saveChartSets.
/**
* Saves the given chart sets that can be subset of previous chart sets.
*
* @param chartSets The chart sets
* @throws WorkbenchException
* @throws IOException
*/
private void saveChartSets(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())) {
chartSetsMemento.createChild(CHART_SET).putMemento(memento);
break;
}
}
}
StringWriter writer = new StringWriter();
chartSetsMemento.save(writer);
Activator.getDefault().getPreferenceStore().setValue(CHART_SETS, writer.getBuffer().toString());
}
use of org.eclipse.ui.IMemento in project tdi-studio-se by Talend.
the class LoadChartSetAction method saveChartSets.
/**
* Saves the given chart sets that can be subset of previous chart sets.
*
* @param chartSets The chart sets
* @throws WorkbenchException
* @throws IOException
*/
private void saveChartSets(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())) {
chartSetsMemento.createChild(CHART_SET).putMemento(memento);
break;
}
}
}
StringWriter writer = new StringWriter();
chartSetsMemento.save(writer);
Activator.getDefault().getPreferenceStore().setValue(CHART_SETS, writer.getBuffer().toString());
}
Aggregations