--- a/java.source/nbproject/project.xml
+++ a/java.source/nbproject/project.xml
@@ -191,6 +191,15 @@
1.0
+
+
+
+ org.netbeans.modules.java.project
+
+
+
+ 1
+ 1.18
--- a/java.source/src/META-INF/services/org.netbeans.spi.java.project.support.ui.PackagesProvider
+++ a/java.source/src/META-INF/services/org.netbeans.spi.java.project.support.ui.PackagesProvider
@@ -0,0 +1,1 @@
+org.netbeans.modules.java.source.usages.PackagesProviderImpl
--- a/java.source/src/org/netbeans/modules/java/source/usages/PackagesProviderImpl.java
+++ a/java.source/src/org/netbeans/modules/java/source/usages/PackagesProviderImpl.java
@@ -0,0 +1,106 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Sun in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ *
+ * Portions Copyrighted 2008 Sun Microsystems, Inc.
+ */
+
+package org.netbeans.modules.java.source.usages;
+
+import java.io.IOException;
+import org.netbeans.api.project.SourceGroup;
+import org.netbeans.spi.java.project.support.ui.PackagesProvider;
+import org.openide.filesystems.FileObject;
+import org.openide.util.Exceptions;
+
+/**
+ *
+ * @author Jan Lahoda
+ */
+public class PackagesProviderImpl implements PackagesProvider {
+
+ public void compute(Request request, Response response) {
+ try {
+ String packages = RepositoryUpdater.getAttribute(request.getSourceGroup().getRootFolder().getURL(), "contained-packages", null);
+
+ if (packages == null) {
+ return;
+ }
+
+ FileObject current = request.getSourceGroup().getRootFolder();
+
+ process(current, packages, new int[1], request.getSourceGroup(), response);
+
+ response.finish();
+ } catch (IOException ex) {
+ Exceptions.printStackTrace(ex);
+ }
+ }
+
+ private void process(FileObject current, String packages, int[] index, SourceGroup sg, Response response) {
+ StringBuilder name = new StringBuilder();
+
+ while (packages.charAt(index[0]) != '(') {
+ name.append(packages.charAt(index[0]));
+ index[0]++;
+ }
+
+ FileObject f = current.getFileObject(name.toString());
+
+ index[0]++;
+
+ boolean hasSubPackages = packages.charAt(index[0]) != ')';
+
+ while (packages.charAt(index[0]) != ')') {
+ process(f, packages, index, sg, response);
+ }
+
+ index[0]++;
+
+ boolean hasFiles = packages.charAt(index[0]) == '+';
+
+ index[0]++;
+
+ if (f == null) {
+ //XXX: warn
+ return;
+ }
+
+ if (!hasSubPackages || hasFiles) {
+ response.addPackage(sg, f, !hasFiles);
+ }
+ }
+
+}
--- a/java.source/src/org/netbeans/modules/java/source/usages/RepositoryUpdater.java
+++ a/java.source/src/org/netbeans/modules/java/source/usages/RepositoryUpdater.java
@@ -2166,6 +2166,8 @@
final Map> misplacedSource2FQNs = new HashMap>();
Map > resources = getAllClassFiles(classCache, FileObjects.getRelativePath(rootFile,folderFile),true);
final FileList children = new FileList(folderFile);
+ children.init();
+ setAttribute(root, "contained-packages", children.tree);
Set compiledFiles = new HashSet();
parseFiles(root, classCache, isInitialCompilation,
children.getJavaFiles(), children.getVirtualJavaFiles(),
@@ -2696,6 +2698,7 @@
private final List javaFiles = new LinkedList();
private final List virtualJavaFiles = new LinkedList();
private boolean initialized;
+ private String tree;
public FileList (final File root) {
assert root != null;
@@ -2714,31 +2717,41 @@
}
private synchronized void init () {
- if (!initialized) {
- collectFiles (root, javaFiles, virtualJavaFiles);
+ if (!initialized) {
+ StringBuilder tree = new StringBuilder();
+ collectFiles (root, javaFiles, virtualJavaFiles, tree);
+ this.tree = tree.toString();
initialized = true;
}
}
private static void collectFiles (final File root, final List super File> javaFiles,
- final List super File> virtualJavaFiles) {
+ final List super File> virtualJavaFiles, StringBuilder tree) {
+ tree.append('(');
final File[] content = root.listFiles();
+ boolean hasFiles = false;
if (content != null) {
for (File child : content) {
final String name = child.getName();
if (child.isDirectory() && !ignoredDirectories.contains(name)) {
- collectFiles(child, javaFiles, virtualJavaFiles);
+ tree.append(name);
+ collectFiles(child, javaFiles, virtualJavaFiles, tree);
}
- else if (name.endsWith('.'+JavaDataLoader.JAVA_EXTENSION)) { //NOI18N
- if (!PACKAGE_INFO.equals(name) && child.length()>0) {
- javaFiles.add(child);
+ else {
+ if (name.endsWith('.' + JavaDataLoader.JAVA_EXTENSION)) { //NOI18N
+ if (!PACKAGE_INFO.equals(name) && child.length() > 0) {
+ javaFiles.add(child);
+ }
+ } else if (VirtualSourceProviderQuery.hasVirtualSource(child)) {
+ virtualJavaFiles.add(child);
}
- }
- else if (VirtualSourceProviderQuery.hasVirtualSource(child)) {
- virtualJavaFiles.add(child);
+
+ hasFiles = true;
}
}
}
+ tree.append(')');
+ tree.append(hasFiles ? '+' : '-');
}
}