KickJava   Java API By Example, From Geeks To Geeks.

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


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.resources.IProject;
14 import org.eclipse.core.resources.ResourcesPlugin;
15 import org.eclipse.core.runtime.CoreException;
16 import org.eclipse.debug.core.DebugPlugin;
17 import org.eclipse.debug.core.sourcelookup.ISourceContainer;
18 import org.eclipse.debug.core.sourcelookup.ISourceContainerType;
19 import org.eclipse.debug.internal.core.sourcelookup.SourceLookupMessages;
20
21 /**
22  * All projects in the workspace.
23  * <p>
24  * Clients may instantiate this class. This class is not intended to
25  * be subclassed.
26  * </p>
27  * @since 3.0
28  */

29 public class WorkspaceSourceContainer extends CompositeSourceContainer {
30     
31     /**
32      * Unique identifier for the workspace source container type
33      * (value <code>org.eclipse.debug.core.containerType.workspace</code>).
34      */

35     public static final String JavaDoc TYPE_ID = DebugPlugin.getUniqueIdentifier() + ".containerType.workspace"; //$NON-NLS-1$
36

37     public WorkspaceSourceContainer() {
38     }
39
40     /* (non-Javadoc)
41      * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getName()
42      */

43     public String JavaDoc getName() {
44         return SourceLookupMessages.WorkspaceSourceContainer_0;
45     }
46         
47     /* (non-Javadoc)
48      * @see java.lang.Object#equals(java.lang.Object)
49      */

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

57     public int hashCode() {
58         return ResourcesPlugin.getWorkspace().hashCode();
59     }
60             
61     /* (non-Javadoc)
62      * @see org.eclipse.debug.core.sourcelookup.ISourceContainer#getType()
63      */

64     public ISourceContainerType getType() {
65         return getSourceContainerType(TYPE_ID);
66     }
67     
68     /* (non-Javadoc)
69      * @see org.eclipse.debug.core.sourcelookup.containers.CompositeSourceContainer#createSourceContainers()
70      */

71     protected ISourceContainer[] createSourceContainers() throws CoreException {
72         IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
73         ISourceContainer[] containers = new ISourceContainer[projects.length];
74         for (int i = 0; i < projects.length; i++) {
75             ISourceContainer container = new ProjectSourceContainer(projects[i], false);
76             container.init(getDirector());
77             containers[i] = container;
78         }
79         return containers;
80     }
81
82 }
83
Popular Tags