1 11 package org.eclipse.jdt.internal.launching; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.runtime.Path; 15 import org.eclipse.debug.core.sourcelookup.ISourceContainer; 16 import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainerTypeDelegate; 17 import org.eclipse.jdt.launching.sourcelookup.containers.ClasspathVariableSourceContainer; 18 import org.w3c.dom.Document ; 19 import org.w3c.dom.Element ; 20 import org.w3c.dom.Node ; 21 22 27 public class ClasspathVariableSourceContainerTypeDelegate extends AbstractSourceContainerTypeDelegate { 28 29 32 public ISourceContainer createSourceContainer(String memento) throws CoreException { 33 Node node = parseDocument(memento); 34 if (node.getNodeType() == Node.ELEMENT_NODE) { 35 Element element = (Element )node; 36 if ("classpathVariable".equals(element.getNodeName())) { String string = element.getAttribute("path"); if (string == null || string.length() == 0) { 39 abort(LaunchingMessages.ClasspathVariableSourceContainerTypeDelegate_5, null); 40 } 41 return new ClasspathVariableSourceContainer(new Path(string)); 42 } 43 abort(LaunchingMessages.ClasspathVariableSourceContainerTypeDelegate_6, null); 44 } 45 abort(LaunchingMessages.ClasspathVariableSourceContainerTypeDelegate_7, null); 46 return null; 47 } 48 51 public String getMemento(ISourceContainer container) throws CoreException { 52 ClasspathVariableSourceContainer var = (ClasspathVariableSourceContainer) container; 53 Document document = newDocument(); 54 Element element = document.createElement("classpathVariable"); element.setAttribute("path", var.getPath().toString()); document.appendChild(element); 57 return serializeDocument(document); 58 } 59 } 60 | Popular Tags |