KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > core > sourcelookup > containers > WorkspaceSourceContainerType


1 /*******************************************************************************
2  * Copyright (c) 2003, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.debug.internal.core.sourcelookup.containers;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.debug.core.sourcelookup.ISourceContainer;
15 import org.eclipse.debug.core.sourcelookup.containers.AbstractSourceContainerTypeDelegate;
16 import org.eclipse.debug.core.sourcelookup.containers.WorkspaceSourceContainer;
17 import org.eclipse.debug.internal.core.sourcelookup.SourceLookupMessages;
18 import org.w3c.dom.Document JavaDoc;
19 import org.w3c.dom.Element JavaDoc;
20 import org.w3c.dom.Node JavaDoc;
21
22 /**
23  * The type for creating/restoring workspace source containers.
24  *
25  * @since 3.0
26  */

27 public class WorkspaceSourceContainerType extends AbstractSourceContainerTypeDelegate {
28
29     /* (non-Javadoc)
30      * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerTypeDelegate#createSourceContainer(java.lang.String)
31      */

32     public ISourceContainer createSourceContainer(String JavaDoc memento) throws CoreException {
33         Node JavaDoc node = parseDocument(memento);
34         if (node.getNodeType() == Node.ELEMENT_NODE) {
35             Element JavaDoc element = (Element JavaDoc)node;
36             if ("workspace".equals(element.getNodeName())) { //$NON-NLS-1$
37
return new WorkspaceSourceContainer();
38             }
39             abort(SourceLookupMessages.WorkspaceSourceContainerType_3, null);
40         }
41         abort(SourceLookupMessages.WorkspaceSourceContainerType_4, null);
42         return null;
43     }
44     /* (non-Javadoc)
45      * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerTypeDelegate#getMemento(org.eclipse.debug.internal.core.sourcelookup.ISourceContainer)
46      */

47     public String JavaDoc getMemento(ISourceContainer container) throws CoreException {
48         Document JavaDoc document = newDocument();
49         Element JavaDoc element = document.createElement("workspace"); //$NON-NLS-1$
50
document.appendChild(element);
51         return serializeDocument(document);
52     }
53 }
54
Popular Tags