KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > internal > core > sourcelookup > SourceContainerType


1 /*******************************************************************************
2  * Copyright (c) 2000, 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;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.core.runtime.IConfigurationElement;
15 import org.eclipse.core.runtime.IStatus;
16 import org.eclipse.core.runtime.Status;
17 import org.eclipse.debug.core.DebugPlugin;
18 import org.eclipse.debug.core.sourcelookup.ISourceContainer;
19 import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
20 import org.eclipse.debug.core.sourcelookup.ISourceContainerTypeDelegate;
21
22 /**
23  * Proxy to contributed source container type extension.
24  *
25  * @since 3.0
26  */

27 public class SourceContainerType implements ISourceContainerType {
28     
29     // lazily instantiated delegate
30
private ISourceContainerTypeDelegate fDelegate = null;
31     
32     // extension definition
33
private IConfigurationElement fElement = null;
34     
35     /**
36      * Constructs a source container type on the given extension.
37      *
38      * @param element extension definition
39      */

40     public SourceContainerType(IConfigurationElement element) {
41         fElement = element;
42     }
43     
44     /* (non-Javadoc)
45      * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#createSourceContainer(java.lang.String)
46      */

47     public ISourceContainer createSourceContainer(String JavaDoc memento) throws CoreException {
48         return getDelegate().createSourceContainer(memento);
49     }
50     /* (non-Javadoc)
51      * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#getMemento(org.eclipse.debug.internal.core.sourcelookup.ISourceContainer)
52      */

53     public String JavaDoc getMemento(ISourceContainer container) throws CoreException {
54         if (this.equals(container.getType())) {
55             return getDelegate().getMemento(container);
56         }
57         IStatus status = new Status(IStatus.ERROR, DebugPlugin.getUniqueIdentifier(), DebugPlugin.INTERNAL_ERROR, SourceLookupMessages.SourceContainerType_3, null);
58         throw new CoreException(status);
59     }
60     /* (non-Javadoc)
61      * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#getName()
62      */

63     public String JavaDoc getName() {
64         return fElement.getAttribute("name"); //$NON-NLS-1$
65
}
66     /* (non-Javadoc)
67      * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#getId()
68      */

69     public String JavaDoc getId() {
70         return fElement.getAttribute("id"); //$NON-NLS-1$
71
}
72     
73     /**
74      * Lazily instantiates and returns the underlying source container type.
75      *
76      * @exception CoreException if unable to instantiate
77      */

78     private ISourceContainerTypeDelegate getDelegate() throws CoreException {
79         if (fDelegate == null) {
80             fDelegate = (ISourceContainerTypeDelegate) fElement.createExecutableExtension("class"); //$NON-NLS-1$
81
}
82         return fDelegate;
83     }
84     /* (non-Javadoc)
85      * @see org.eclipse.debug.internal.core.sourcelookup.ISourceContainerType#getDescription()
86      */

87     public String JavaDoc getDescription() {
88         return fElement.getAttribute("description"); //$NON-NLS-1$
89
}
90 }
91
Popular Tags