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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.core;
13 import net.sourceforge.phpdt.core.IJavaModel;
15 import org.eclipse.core.resources.IProject;
16 import org.eclipse.core.resources.ResourcesPlugin;
19 * Implementation of IJavaModel. A Java Model is specific to a
24 public class JavaModelInfo extends OpenableElementInfo {
27 * A array with all the non-java projects contained by this model
29 Object[] nonJavaResources;
32 * Constructs a new Java Model Info
34 protected JavaModelInfo() {
37 * Compute the non-java resources contained in this java project.
39 private Object[] computeNonJavaResources() {
40 IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
41 int length = projects.length;
42 Object[] nonJavaResources = null;
44 for (int i = 0; i < length; i++) {
45 IProject project = projects[i];
46 if (!JavaProject.hasJavaNature(project)) {
47 if (nonJavaResources == null) {
48 nonJavaResources = new Object[length];
50 nonJavaResources[index++] = project;
53 if (index == 0) return NO_NON_JAVA_RESOURCES;
55 System.arraycopy(nonJavaResources, 0, nonJavaResources = new Object[index], 0, index);
57 return nonJavaResources;
61 * Returns an array of non-java resources contained in the receiver.
63 Object[] getNonJavaResources() {
65 Object[] nonJavaResources = this.nonJavaResources;
66 if (nonJavaResources == null) {
67 nonJavaResources = computeNonJavaResources();
68 this.nonJavaResources = nonJavaResources;
70 return nonJavaResources;