private SourceGroup getPreselectedGroup(SourceGroup[] groups, FileObject folder) { for (int i = 0; folder != null && i < groups.length; i++) { if (FileUtil.isParentOf(groups[i].getRootFolder(), folder) || groups[i].getRootFolder().equals(folder)) { return groups[i]; } } if (groups.length > 0) { return groups[0]; } return null; }
public FileObject getLocation() { SourceGroup[] sourceGroups = SourceGroups.getJavaSourceGroups(project); if (sourceGroups.length > 0) { return sourceGroups[0].getRootFolder(); } return null; } }
public String getShortDescription() { FileObject gdir = group.getRootFolder(); String dir = FileUtil.getFileDisplayName(gdir); return NbBundle.getMessage(PhysicalView.class, isProjectDir ? "HINT_project" : "HINT_group", // NOI18N dir); }
private boolean existsFolder(List<SourceGroup> groups, String folderName) { for (SourceGroup group : groups) { final String groupPath = group.getRootFolder().getPath(); // Two check because of issue #221727 if (groupPath.endsWith("/" + folderName) || groupPath.contains("/" + folderName + "/")) { // NOI18N return true; } } return false; }
public static FileObject showDialog(SourceGroup[] folders) { List<FileObject> roots = new LinkedList<FileObject>(); for (SourceGroup sourceGroup : folders) { roots.add(sourceGroup.getRootFolder()); } return showDialog(roots.toArray(new FileObject[roots.size()])); }
private FileObject findTestRootFolder(FileObject targetFolder) { for (int i = 0; i < testSrcGroups.length; i++) { FileObject rootFolder = testSrcGroups[i].getRootFolder(); if (rootFolder == targetFolder || FileUtil.isParentOf(rootFolder, targetFolder)) { return rootFolder; } } return null; }
@Override public String getShortDescription() { FileObject gdir = group.getRootFolder(); String dir = FileUtil.getFileDisplayName(gdir); return NbBundle.getMessage(PhysicalView.class, isProjectDir ? "HINT_project" : "HINT_group", // NOI18N dir); }
public PackageItem(SourceGroup group, FileObject pkg, boolean empty) { this.pkg = pkg; this.empty = empty; String path = FileUtil.getRelativePath(group.getRootFolder(), pkg); assert path != null : "No " + pkg + " in " + group; pkgname = path.replace('/', '.'); }
public final List<SourceGroup> moveAsFirst(List<SourceGroup> groups, String folderName) { List<SourceGroup> reorderedGroup = new ArrayList<SourceGroup>(); for (SourceGroup group : groups) { if (group.getRootFolder().getPath().contains(folderName)) { // NOI18N reorderedGroup.add(0, group); } else { reorderedGroup.add(group); } } return reorderedGroup; }
private String getPackageName(FileObject targetFolder) { List<SourceGroup> groups = retrieveGroups(); String packageName = null; for (int i = 0; i < groups.size() && packageName == null; i++) { packageName = FileUtil.getRelativePath(groups.get(i).getRootFolder(), targetFolder); } if (packageName != null) { packageName = packageName.replaceAll("/", "."); // NOI18N } return packageName; }
private static FileObject getSourceRoot(Project project) { Sources sources = ProjectUtils.getSources(project); for (SourceGroup g : sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)) { return g.getRootFolder(); } return null; }
public String getClassPathProperty(SourceGroup sg, String type) { assert sg != null : "SourceGroup cannot be null"; //NOI18N assert type != null : "Type cannot be null"; //NOI18N final String[] classPathProperty = getClassPathProvider().getPropertyName (sg, type); if (classPathProperty == null || classPathProperty.length == 0) { throw new UnsupportedOperationException ("Modification of [" + sg.getRootFolder().getPath() +", " + type + "] is not supported"); //NOI18N } assert !classPathProperty[0].equals(WebProjectProperties.J2EE_PLATFORM_CLASSPATH); return classPathProperty[0]; }
private FileObject getFileObjectOfClass(String className) { Sources sources = ProjectUtils.getSources(project); SourceGroup[] sourceGroups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA); for (int i = 0; i < sourceGroups.length; i++) { FileObject rootFolder = sourceGroups[i].getRootFolder(); FileObject classFileObject = rootFolder.getFileObject(className.replaceAll("\\.", "/") + ".java"); if (classFileObject != null) { return classFileObject; } } return null; }
public String getClassPathProperty(SourceGroup sg, String type) { assert sg != null : "SourceGroup cannot be null"; //NOI18N assert type != null : "Type cannot be null"; //NOI18N final String classPathProperty[] = getClassPathProvider().getPropertyName (sg, type); if (classPathProperty == null || classPathProperty.length == 0) { throw new UnsupportedOperationException ("Modification of [" + sg.getRootFolder().getPath() +", " + type + "] is not supported"); //NOI18N } return classPathProperty[0]; }
@Override public String getClassPathProperty(SourceGroup sg, String type) { assert sg != null : "SourceGroup cannot be null"; //NOI18N assert type != null : "Type cannot be null"; //NOI18N final String[] classPathProperty = getClassPathProvider().getPropertyName (sg, type); if (classPathProperty == null || classPathProperty.length == 0) { throw new UnsupportedOperationException ("Modification of [" + sg.getRootFolder().getPath() +", " + type + "] is not supported"); //NOI18N } return classPathProperty[0]; }
private static Lookup createLookup( SourceGroup group ) { // XXX Remove DataFolder when paste, find and refresh are reimplemented FileObject rootFolder = group.getRootFolder(); DataFolder dataFolder = DataFolder.findFolder( rootFolder ); return Lookups.fixed(dataFolder, new PathFinder(group)); }
private static ClassPath getCompileClasspath(Project project) { ClassPathProvider cpp = project.getLookup().lookup(ClassPathProvider.class); Sources sources = ProjectUtils.getSources(project); if (sources == null) { return null; } SourceGroup[] sourceGroups = sources.getSourceGroups("java"); //NOII18N if (sourceGroups.length > 0) { return cpp.findClassPath(sourceGroups[0].getRootFolder(), ClassPath.COMPILE); } return null; }
public void initValues( TargetChooserPanel<T> panel, TargetChooserPanelGUI<T> uiPanel ) { if (panel.getSourceGroups()!=null && panel.getSourceGroups().length>0) { myWebModule = WebModule.getWebModule(panel.getSourceGroups()[0]. getRootFolder()); } }
boolean hasTests(Project project) { for (SourceGroup g : ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)) { FileObject root = g.getRootFolder(); if (UnitTestForSourceQuery.findSources(root).length > 0 && containsSources(root)) { return true; } } return false; } boolean containsSources(FileObject f) {
@Override protected Node[] createNodes(SourceGroup g) { try{ FileObject folder = g.getRootFolder(); FilterNode fn = new FilterNode( new PhysicalView.GroupNode(project, g, folder.equals(project.getProjectDirectory()), DataFolder.findFolder(folder)), new SourceGroupChildren(folder, g)); return new Node[] { fn }; }catch (Exception ex){ return null; } }