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 workspace.
23 public class JavaModelInfo extends OpenableElementInfo {
26 * A array with all the non-java projects contained by this model
28 Object[] nonJavaResources;
31 * Constructs a new Java Model Info
33 protected JavaModelInfo() {
37 * Compute the non-java resources contained in this java project.
39 private Object[] computeNonJavaResources() {
40 IProject[] projects = ResourcesPlugin.getWorkspace().getRoot()
42 int length = projects.length;
43 Object[] nonJavaResources = null;
45 for (int i = 0; i < length; i++) {
46 IProject project = projects[i];
47 if (!JavaProject.hasJavaNature(project)) {
48 if (nonJavaResources == null) {
49 nonJavaResources = new Object[length];
51 nonJavaResources[index++] = project;
55 return NO_NON_JAVA_RESOURCES;
57 System.arraycopy(nonJavaResources, 0,
58 nonJavaResources = new Object[index], 0, index);
60 return nonJavaResources;
64 * Returns an array of non-java resources contained in the receiver.
66 Object[] getNonJavaResources() {
68 Object[] nonJavaResources = this.nonJavaResources;
69 if (nonJavaResources == null) {
70 nonJavaResources = computeNonJavaResources();
71 this.nonJavaResources = nonJavaResources;
73 return nonJavaResources;