~ubuntu-branches/debian/sid/eclipse-cdt/sid

« back to all changes in this revision

Viewing changes to debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/sourcelookup/CDirectorySourceContainerType.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2011-10-06 21:15:04 UTC
  • mfrom: (1.1.4)
  • Revision ID: package-import@ubuntu.com-20111006211504-8dutmljjih0zikfv
Tags: 8.0.1-1
* New upstream release.
* Split the JNI packages into a separate architecture dependent
  package and made eclipse-cdt architecture independent.
* Install JNI libraries into multiarch aware location
* Bumped Standards-Version to 3.9.2.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*******************************************************************************
 
2
 * Copyright (c) 2004, 2006 QNX Software Systems 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
 *     QNX Software Systems - Initial API and implementation
 
10
 *******************************************************************************/
 
11
package org.eclipse.cdt.debug.internal.core.sourcelookup; 
 
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.debug.core.sourcelookup.containers.DirectorySourceContainer;
 
18
import org.w3c.dom.Document;
 
19
import org.w3c.dom.Element;
 
20
import org.w3c.dom.Node;
 
21
 
 
22
/**
 
23
 * See <code>CDirectorySourceContainer</code>.
 
24
 */
 
25
public class CDirectorySourceContainerType extends AbstractSourceContainerTypeDelegate {
 
26
 
 
27
        /* (non-Javadoc)
 
28
         * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#createSourceContainer(java.lang.String)
 
29
         */
 
30
        public ISourceContainer createSourceContainer(String memento) throws CoreException {
 
31
                Node node = parseDocument(memento);
 
32
                if (node.getNodeType() == Node.ELEMENT_NODE) {
 
33
                        Element element = (Element) node;
 
34
                        if ("directory".equals(element.getNodeName())) { //$NON-NLS-1$
 
35
                                String string = element.getAttribute("path"); //$NON-NLS-1$
 
36
                                if (string == null || string.length() == 0) {
 
37
                                        abort(InternalSourceLookupMessages.CDirectorySourceContainerType_0, null);
 
38
                                }
 
39
                                String nest = element.getAttribute("nest"); //$NON-NLS-1$
 
40
                                boolean nested = "true".equals(nest); //$NON-NLS-1$
 
41
                                return new DirectorySourceContainer(new Path(string), nested);
 
42
                        }
 
43
                        abort(InternalSourceLookupMessages.CDirectorySourceContainerType_1, null);
 
44
                }
 
45
                abort(InternalSourceLookupMessages.CDirectorySourceContainerType_2, null);
 
46
                return null;
 
47
        }
 
48
        
 
49
        /* (non-Javadoc)
 
50
         * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#getMemento(org.eclipse.debug.internal.core.sourcelookup.ISourceContainer)
 
51
         */
 
52
        public String getMemento(ISourceContainer container) throws CoreException {
 
53
                DirectorySourceContainer folder = (DirectorySourceContainer) container;
 
54
                Document document = newDocument();
 
55
                Element element = document.createElement("directory"); //$NON-NLS-1$
 
56
                element.setAttribute("path", folder.getDirectory().getAbsolutePath()); //$NON-NLS-1$
 
57
                String nest = "false"; //$NON-NLS-1$
 
58
                if (folder.isComposite()) {
 
59
                        nest = "true"; //$NON-NLS-1$
 
60
                }
 
61
                element.setAttribute("nest", nest); //$NON-NLS-1$
 
62
                document.appendChild(element);
 
63
                return serializeDocument(document);
 
64
        }
 
65
}