KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > debug > core > sourcelookup > containers > DefaultSourceContainer


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.core.sourcelookup.containers;
12
13 import org.eclipse.core.runtime.CoreException;
14 import org.eclipse.debug.core.DebugPlugin;
15 import org.eclipse.debug.core.ILaunchConfiguration;
16 import org.eclipse.debug.core.sourcelookup.ISourceContainer;
17 import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
18 import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
19 import org.eclipse.debug.core.sourcelookup.ISourcePathComputer;
20 import org.eclipse.debug.internal.core.sourcelookup.SourceLookupMessages;
21
22 /**
23  * A source container that computer the default source lookup path
24  * for a launch configuration on each launch using a launch configuration's
25  * associated source path computer.
26  * <p>
27  * Clients may instantiate this class. This class is not intended to
28  * be subclassed.
29  * </p>
30  * @since 3.0
31  */

32 public class DefaultSourceContainer extends CompositeSourceContainer {
33     
34     /**
35      * Unique identifier for the default source container type
36      * (value <code>org.eclipse.debug.core.containerType.default</code>).
37      */

38     public static final String JavaDoc TYPE_ID = DebugPlugin.getUniqueIdentifier() + ".containerType.default"; //$NON-NLS-1$
39

40     /**
41      * Constructs a default source container.
42      */

43     public DefaultSourceContainer() {
44     }
45     
46     /* (non-Javadoc)
47      * @see java.lang.Object#equals(java.lang.Object)
48      */

49     public boolean equals(Object JavaDoc obj) {
50         return obj instanceof DefaultSourceContainer;
51     }
52
53     /* (non-Javadoc)
54      * @see java.lang.Object#hashCode()
55      */

56     public int hashCode() {
57         return getClass().hashCode();
58     }
59     
60     /**
61      * Returns the launch configuration for which a default source lookup
62      * path will be computed, or <code>null</code> if none.
63      *
64      * @return the launch configuration for which a default source lookup
65      * path will be computed, or <code>null</code>
66      */

67     protected ILaunchConfiguration getLaunchConfiguration() {
68         ISourceLookupDirector director = getDirector();
69         if (director != null) {
70             return director.getLaunchConfiguration();
71         }
72         return null;
73     }
74     
75     /* (non-Javadoc)
76      * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getType()
77      */

78     public ISourceContainerType getType() {
79         return getSourceContainerType(TYPE_ID);
80     }
81     
82     /**
83      * Returns the source path computer to use, or <code>null</code>
84      * if none.
85      *
86      * @return the source path computer to use, or <code>null</code>
87      * if none
88      */

89     private ISourcePathComputer getSourcePathComputer() {
90         ISourceLookupDirector director = getDirector();
91         if (director != null) {
92             return director.getSourcePathComputer();
93         }
94         return null;
95     }
96
97     /* (non-Javadoc)
98      * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getName()
99      */

100     public String JavaDoc getName() {
101         return SourceLookupMessages.DefaultSourceContainer_0;
102     }
103
104     /* (non-Javadoc)
105      * @see org.eclipse.debug.core.sourcelookup.containers.CompositeSourceContainer#createSourceContainers()
106      */

107     protected ISourceContainer[] createSourceContainers() throws CoreException {
108         ISourcePathComputer sourcePathComputer = getSourcePathComputer();
109         if (sourcePathComputer != null) {
110             ILaunchConfiguration config= getLaunchConfiguration();
111             if (config != null) {
112                 return sourcePathComputer.computeSourceContainers(config, null);
113             }
114         }
115         
116         return new ISourceContainer[0];
117     }
118 }
Popular Tags