KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > JavaModelInfo


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 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.jdt.internal.core;
12
13 import org.eclipse.core.resources.IProject;
14 import org.eclipse.core.resources.ResourcesPlugin;
15
16 /**
17  * Implementation of IJavaModel. A Java Model is specific to a
18  * workspace.
19  *
20  * @see org.eclipse.jdt.core.IJavaModel
21  */

22 public class JavaModelInfo extends OpenableElementInfo {
23
24     /**
25      * A array with all the non-java projects contained by this model
26      */

27     Object JavaDoc[] nonJavaResources;
28
29 /**
30  * Compute the non-java resources contained in this java project.
31  */

32 private Object JavaDoc[] computeNonJavaResources() {
33     IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
34     int length = projects.length;
35     Object JavaDoc[] resources = null;
36     int index = 0;
37     for (int i = 0; i < length; i++) {
38         IProject project = projects[i];
39         if (!JavaProject.hasJavaNature(project)) {
40             if (resources == null) {
41                 resources = new Object JavaDoc[length];
42             }
43             resources[index++] = project;
44         }
45     }
46     if (index == 0) return NO_NON_JAVA_RESOURCES;
47     if (index < length) {
48         System.arraycopy(resources, 0, resources = new Object JavaDoc[index], 0, index);
49     }
50     return resources;
51 }
52
53 /**
54  * Returns an array of non-java resources contained in the receiver.
55  */

56 Object JavaDoc[] getNonJavaResources() {
57
58     if (this.nonJavaResources == null) {
59         this.nonJavaResources = computeNonJavaResources();
60     }
61     return this.nonJavaResources;
62 }
63 }
64
Popular Tags