# HG changeset patch # User Alex Kotchnev # Date 1244305248 14400 # Node ID e8b98a82534cfc019c904cc9ea16a6df439bb599 # Parent 4a57328293dc88a9c84a09a8577229f2d0940011 switched to package view to a number of the grails folders diff --git a/groovy.grailsproject/nbproject/project.xml b/groovy.grailsproject/nbproject/project.xml --- a/groovy.grailsproject/nbproject/project.xml +++ b/groovy.grailsproject/nbproject/project.xml @@ -20,7 +20,16 @@ 1 - + 1.18 + + + + org.netbeans.api.debugger.jpda + + + + 2 + 2.20 @@ -69,12 +78,21 @@ + org.netbeans.modules.editor.lib + + + + 1 + 1.39 + + + org.netbeans.modules.editor.lib2 1 - + 1.12 diff --git a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/SourceNodeFactory.java b/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/SourceNodeFactory.java --- a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/SourceNodeFactory.java +++ b/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/SourceNodeFactory.java @@ -38,12 +38,13 @@ * Version 2 license, then the option applies only if the new code is * made subject to such option by the copyright holder. */ - package org.netbeans.modules.groovy.grailsproject.ui; import java.util.ArrayList; import java.util.Collections; +import java.util.HashSet; import java.util.List; +import java.util.Set; import javax.swing.SwingUtilities; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; @@ -53,6 +54,7 @@ import org.netbeans.api.project.Sources; import org.netbeans.modules.groovy.grailsproject.GrailsProject; import org.netbeans.modules.groovy.support.api.GroovySources; +import org.netbeans.spi.java.project.support.ui.PackageView; import org.netbeans.spi.project.ui.support.NodeFactory; import org.netbeans.spi.project.ui.support.NodeList; import org.openide.filesystems.FileObject; @@ -64,128 +66,151 @@ * * @author Martin Adamek */ -@NodeFactory.Registration(projectType="org-netbeans-modules-groovy-grailsproject") +@NodeFactory.Registration(projectType = "org-netbeans-modules-groovy-grailsproject") public class SourceNodeFactory implements NodeFactory { - public SourceNodeFactory() { - } + public SourceNodeFactory() { + } - public NodeList createNodes(Project p) { + public NodeList createNodes(Project p) { - GrailsProject project = p.getLookup().lookup(GrailsProject.class); - assert project != null; - return new SourcesNodeList(project); + GrailsProject project = p.getLookup().lookup(GrailsProject.class); + assert project != null; + return new SourcesNodeList(project); - } + } - private static class SourcesNodeList implements NodeList, ChangeListener { + private static class SourcesNodeList implements NodeList, ChangeListener { - private GrailsProject project; + private GrailsProject project; + private final ChangeSupport changeSupport = new ChangeSupport(this); - private final ChangeSupport changeSupport = new ChangeSupport(this); + public SourcesNodeList(GrailsProject proj) { + this.project = proj; + } - public SourcesNodeList(GrailsProject proj) { - this.project = proj; - } + public List keys() { + FileObject projectDir = project.getProjectDirectory(); + if (projectDir == null || !projectDir.isValid()) { + return Collections.emptyList(); + } + Sources sources = getSources(); + List sourceGroups = GroovySources.getGroovySourceGroups(sources); + List result = new ArrayList(); + Set treeSources = new HashSet() { + { + add("conf"); + add("i18n"); + add("views"); + add("web-app"); + add("libraries"); + } + }; + for (SourceGroup sourceGroup : sourceGroups) { + if (sourceGroup.getRootFolder() != null) { + String style = "packages"; + for (String treeSource : treeSources) { + if (sourceGroup.getName().endsWith(treeSource)) { + style = "tree"; + break; + } + } + result.add(new SourceGroupKey(sourceGroup, projectDir,style)); + } + } - public List keys() { - FileObject projectDir = project.getProjectDirectory(); - if (projectDir == null || !projectDir.isValid()) { - return Collections.emptyList(); - } - Sources sources = getSources(); - List sourceGroups = GroovySources.getGroovySourceGroups(sources); - List result = new ArrayList(); + Collections.sort(result); + return result; + } - for (SourceGroup sourceGroup : sourceGroups) { - if (sourceGroup.getRootFolder() != null) { - result.add(new SourceGroupKey(sourceGroup, projectDir)); - } - } - - Collections.sort(result); - return result; - } + public void addChangeListener(ChangeListener l) { + changeSupport.addChangeListener(l); + } - public void addChangeListener(ChangeListener l) { - changeSupport.addChangeListener(l); - } + public void removeChangeListener(ChangeListener l) { + changeSupport.removeChangeListener(l); + } - public void removeChangeListener(ChangeListener l) { - changeSupport.removeChangeListener(l); - } + public Node node(SourceGroupKey key) { + if (key.getViewStyle().equals("packages")) { + return PackageView.createPackageView(key.group); + } else { + return new TreeRootNode(key.group, project); + } + + } - public Node node(SourceGroupKey key) { - return new TreeRootNode(key.group, project); - } + public void addNotify() { + getSources().addChangeListener(this); + } - public void addNotify() { - getSources().addChangeListener(this); - } + public void removeNotify() { + getSources().removeChangeListener(this); + } - public void removeNotify() { - getSources().removeChangeListener(this); - } + public void stateChanged(ChangeEvent e) { + // setKeys(getKeys()); + // The caller holds ProjectManager.mutex() read lock + SwingUtilities.invokeLater(new Runnable() { - public void stateChanged(ChangeEvent e) { - // setKeys(getKeys()); - // The caller holds ProjectManager.mutex() read lock - SwingUtilities.invokeLater(new Runnable() { - public void run() { - changeSupport.fireChange(); - } - }); - } + public void run() { + changeSupport.fireChange(); + } + }); + } - private Sources getSources() { - return ProjectUtils.getSources(project); - } + private Sources getSources() { + return ProjectUtils.getSources(project); + } + } - } + private static class SourceGroupKey implements Comparable { - private static class SourceGroupKey implements Comparable { + public final SourceGroup group; + public final FileObject fileObject; + public final FileObject projectDir; + public final String viewStyle; - public final SourceGroup group; - public final FileObject fileObject; - public final FileObject projectDir; + SourceGroupKey(SourceGroup group, FileObject projectDir, String viewStyle) { + this.group = group; + this.fileObject = group.getRootFolder(); + this.projectDir = projectDir; + this.viewStyle = viewStyle; + } - SourceGroupKey(SourceGroup group, FileObject projectDir) { - this.group = group; - this.fileObject = group.getRootFolder(); - this.projectDir = projectDir; - } + public String getViewStyle() { + return this.viewStyle; + } - public int hashCode() { - return fileObject.hashCode(); - } + public int hashCode() { + return fileObject.hashCode(); + } + public int compareTo(SourceGroupKey o) { + String relativePath1 = FileUtil.getRelativePath(projectDir, fileObject); + String relativePath2 = FileUtil.getRelativePath(projectDir, o.fileObject); + return relativePath1.compareTo(relativePath2); + } - public int compareTo(SourceGroupKey o) { - String relativePath1 = FileUtil.getRelativePath(projectDir, fileObject); - String relativePath2 = FileUtil.getRelativePath(projectDir, o.fileObject); - return relativePath1.compareTo(relativePath2); - } + public boolean equals(Object obj) { - public boolean equals(Object obj) { + if (!(obj instanceof SourceGroupKey)) { + return false; + } else { + SourceGroupKey otherKey = (SourceGroupKey) obj; + String thisDisplayName = this.group.getDisplayName(); + String otherDisplayName = otherKey.group.getDisplayName(); +// String otherViewStyle = otherKey.viewStyle; + // XXX what is the operator binding order supposed to be here?? + return fileObject.equals(otherKey.fileObject) && + thisDisplayName == null ? otherDisplayName == null : thisDisplayName.equals(otherDisplayName); + } - if (!(obj instanceof SourceGroupKey)) { - return false; - } else { - SourceGroupKey otherKey = (SourceGroupKey) obj; - String thisDisplayName = this.group.getDisplayName(); - String otherDisplayName = otherKey.group.getDisplayName(); - // XXX what is the operator binding order supposed to be here?? - return fileObject.equals(otherKey.fileObject) && - thisDisplayName == null ? otherDisplayName == null : thisDisplayName.equals(otherDisplayName); - } + } - } - - @Override - public String toString() { - return group.toString(); - } - - } - + @Override + public String toString() { + return group.toString(); + } + } } # HG changeset patch # User Alex Kotchnev # Date 1244305387 14400 # Node ID 83b7c42c98fe64cd1388bb5dcc5aa9daba857d74 # Parent e8b98a82534cfc019c904cc9ea16a6df439bb599 added scripts to folder/non-package view diff --git a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/SourceNodeFactory.java b/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/SourceNodeFactory.java --- a/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/SourceNodeFactory.java +++ b/groovy.grailsproject/src/org/netbeans/modules/groovy/grailsproject/ui/SourceNodeFactory.java @@ -104,6 +104,7 @@ add("views"); add("web-app"); add("libraries"); + add("scripts"); } }; for (SourceGroup sourceGroup : sourceGroups) {