new version with WorkingCopy Management
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / core / JavaModelInfo.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.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 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[] nonJavaResources;
28
29 /**
30  * Constructs a new Java Model Info 
31  */
32 protected JavaModelInfo() {
33 }
34 /**
35  * Compute the non-java resources contained in this java project.
36  */
37 private Object[] computeNonJavaResources() {
38         IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
39         int length = projects.length;
40         Object[] nonJavaResources = null;
41         int index = 0;
42         for (int i = 0; i < length; i++) {
43                 IProject project = projects[i];
44                 if (!JavaProject.hasJavaNature(project)) {
45                         if (nonJavaResources == null) {
46                                 nonJavaResources = new Object[length];
47                         }
48                         nonJavaResources[index++] = project;
49                 }
50         }
51         if (index == 0) return NO_NON_JAVA_RESOURCES;
52         if (index < length) {
53                 System.arraycopy(nonJavaResources, 0, nonJavaResources = new Object[index], 0, index);
54         }
55         return nonJavaResources;
56 }
57
58 /**
59  * Returns an array of non-java resources contained in the receiver.
60  */
61 Object[] getNonJavaResources() {
62
63         Object[] nonJavaResources = this.nonJavaResources;
64         if (nonJavaResources == null) {
65                 nonJavaResources = computeNonJavaResources();
66                 this.nonJavaResources = nonJavaResources;
67         }
68         return nonJavaResources;
69 }
70 }