Search in sources :

Example 1 with XMLMemento

use of org.eclipse.jst.server.core.internal.XMLMemento in project webtools.servertools by eclipse.

the class RuntimeClasspathProviderDelegate method save.

/**
 * Save source attachment info.
 */
private synchronized void save() {
    List<SourceAttachmentUpdate> srcAttachments = sourceAttachments;
    if (srcAttachments == null)
        return;
    String id = extensionId;
    String filename = JavaServerPlugin.getInstance().getStateLocation().append(id + ".xml").toOSString();
    try {
        XMLMemento memento = XMLMemento.createWriteRoot("classpath");
        Iterator iterator = srcAttachments.iterator();
        while (iterator.hasNext()) {
            SourceAttachmentUpdate sau = (SourceAttachmentUpdate) iterator.next();
            IMemento child = memento.createChild("source-attachment");
            child.putString("runtime-id", sau.runtimeId);
            if (sau.entry != null)
                child.putString("entry", sau.entry.toPortableString());
            if (sau.sourceAttachmentPath != null)
                child.putString("source-attachment-path", sau.sourceAttachmentPath.toPortableString());
            if (sau.sourceAttachmentRootPath != null)
                child.putString("source-attachment-root-path", sau.sourceAttachmentRootPath.toPortableString());
            if (sau.attributes != null) {
                for (IClasspathAttribute attr : sau.attributes) {
                    IMemento attrChild = child.createChild("attribute");
                    attrChild.putString("name", attr.getName());
                    attrChild.putString("value", attr.getValue());
                }
            }
        }
        memento.saveToFile(filename);
    } catch (Exception e) {
        if (Trace.SEVERE) {
            Trace.trace(Trace.STRING_SEVERE, "Error saving source path info", e);
        }
    }
}
Also used : IClasspathAttribute(org.eclipse.jdt.core.IClasspathAttribute) XMLMemento(org.eclipse.jst.server.core.internal.XMLMemento) IMemento(org.eclipse.jst.server.core.internal.IMemento)

Aggregations

IClasspathAttribute (org.eclipse.jdt.core.IClasspathAttribute)1 IMemento (org.eclipse.jst.server.core.internal.IMemento)1 XMLMemento (org.eclipse.jst.server.core.internal.XMLMemento)1