Java Code Examples for org.netbeans.api.project.SourceGroup

The following examples show how to use org.netbeans.api.project.SourceGroup. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: netbeans   Source File: SrcNodeTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testSubfolderLookup() throws Exception {
    PhpProject phpProject = TestUtils.createPhpProject(getWorkDir());
    FileObject sources = ProjectPropertiesSupport.getSourcesDirectory(phpProject);
    final FileObject subfolder = sources.createFolder("emptyFolder");
    NodeList<SourceGroup> nodes = new SourcesNodeFactory().createNodes(phpProject);
    List<SourceGroup> sourceGroups = nodes.keys();
    assertFalse("Source groups should be found", sourceGroups.isEmpty());
    for (SourceGroup sourceGroup : sourceGroups) {
        Node node = nodes.node(sourceGroup);
        Lookup lookup = node.getLookup();
        assertNotNull("Fileobject should be found", lookup.lookup(FileObject.class));
        Children children = node.getChildren();
        assertTrue("Should have subnodes", children.getNodesCount(true) > 0);
        for (Node subnode : children.getNodes(true)) {
            Lookup sublookup = subnode.getLookup();
            FileObject fileObject = sublookup.lookup(FileObject.class);
            assertNotNull("Fileobject should be found", fileObject);
            assertEquals("Fileobjects should be same", subfolder, fileObject);
        }
    }
}
 
Example 2
Source Project: netbeans   Source File: SimpleTargetChooserPanelGUI.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("LeakingThisInConstructor")
@Messages("LBL_SimpleTargetChooserPanel_Name=Name and Location")
public SimpleTargetChooserPanelGUI( @NullAllowed Project project, @NonNull SourceGroup[] folders, Component bottomPanel, boolean isFolder, boolean freeFileExtension) {
    this.project = project;
    this.folders = folders.clone();
    this.isFolder = isFolder;
    this.freeFileExtension = freeFileExtension;
    this.separatorChar = getPathNameSeparator(project, folders);
    initComponents();
    
    locationComboBox.setRenderer( CELL_RENDERER );
    
    if ( bottomPanel != null ) {
        bottomPanelContainer.add( bottomPanel, java.awt.BorderLayout.CENTER );
    }
    initValues( null, null, null , true);

    setPreferredSize(PREF_DIM);

    browseButton.addActionListener( this );
    locationComboBox.addActionListener( this );
    documentNameTextField.getDocument().addDocumentListener( this );
    folderTextField.getDocument().addDocumentListener( this );
    
    setName(LBL_SimpleTargetChooserPanel_Name());
}
 
Example 3
Source Project: netbeans   Source File: MainProjectManager.java    License: Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("DMI_COLLECTION_OF_URLS")
private static Set<URL> getProjectRoots(Project p) {
    Set<URL> projectRoots = new HashSet<URL>(); // roots
    Sources sources = ProjectUtils.getSources(p);
    SourceGroup[] sgs = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    for (SourceGroup sg : sgs) {
        URL root;
        try {
            root = sg.getRootFolder().toURL();
            projectRoots.add(root);
        } catch (NullPointerException npe) {
            // http://www.netbeans.org/issues/show_bug.cgi?id=148076
            if (sg == null) {
                npe = Exceptions.attachMessage(npe, "Null source group returned from "+sources+" of class "+sources.getClass());
            } else if (sg.getRootFolder() == null) {
                npe = Exceptions.attachMessage(npe, "Null root folder returned from "+sg+" of class "+sg.getClass());
            }
            Exceptions.printStackTrace(npe);
        }
    }
    return projectRoots;
}
 
Example 4
Source Project: netbeans   Source File: JspPGPanel.java    License: Apache License 2.0 6 votes vote down vote up
private void browseButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButton3ActionPerformed
    try {
        SourceGroup[] groups = DDUtils.getDocBaseGroups(dObj);
        org.openide.filesystems.FileObject fo = BrowseFolders.showDialog(groups);
        if (fo!=null) {
            String fileName = "/"+DDUtils.getResourcePath(groups,fo,'/',true);
            String oldValue = codaTF.getText();
            if (fileName.length()>0) {
                String newValue = DDUtils.addItem(oldValue,fileName,false);
                if (!oldValue.equals(newValue)) {
                    dObj.modelUpdatedFromUI();
                    dObj.setChangedFromUI(true);
                    codaTF.setText(newValue);
                    setCodas(newValue);
                    dObj.setChangedFromUI(false);
                }
            }
        }
    } catch (java.io.IOException ex) {}
}
 
Example 5
Source Project: netbeans   Source File: CdiUtil.java    License: Apache License 2.0 6 votes vote down vote up
private static FileObject getDefaultBeansTargetFolder( SourceGroup[] sourceGroups,
        boolean create )
{
    if ( sourceGroups.length >0 ){
        FileObject metaInf = sourceGroups[0].getRootFolder().getFileObject( META_INF );
        if ( metaInf == null && create ){
            try {
                metaInf = FileUtil.createFolder(
                    sourceGroups[0].getRootFolder(), META_INF);
            }
            catch( IOException e ){
                Logger.getLogger( CdiUtil.class.getName() ).log( 
                        Level.WARNING, null, e );
            }
        }
        return metaInf;
    }
    return null;
}
 
Example 6
Source Project: netbeans   Source File: TargetEvaluator.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Used by the ObjectNameWizard panel to set the target folder
 * gotten from the system wizard initially. 
 */
void setInitialFolder(DataFolder selectedFolder, Project p) {
    if (selectedFolder == null) {
        return;
    }
    FileObject targetFolder = selectedFolder.getPrimaryFile();
    Sources sources = ProjectUtils.getSources(p);
    SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    String packageName = null;
    for (int i = 0; i < groups.length && packageName == null; i++) {
        packageName = org.openide.filesystems.FileUtil.getRelativePath(groups[i].getRootFolder(), targetFolder);
        deployData.setWebApp(DeployData.getWebAppFor(groups[i].getRootFolder()));
    }
    if (packageName == null) {
        packageName = "";
    }
    setInitialPath(packageName);
}
 
Example 7
Source Project: netbeans   Source File: ResourceHyperlinkProcessor.java    License: Apache License 2.0 6 votes vote down vote up
private static boolean openFromClasspath(FileObject fo, String value) {
    int colonOffset = value.indexOf(":");   //NOI18N
    String subPath = value.substring(colonOffset + 1);
    Project project = FileOwnerQuery.getOwner(fo);
    if (project != null) {
        List<SourceGroup> groups = new ArrayList<>();
        Sources sources = ProjectUtils.getSources(project);
        groups.addAll(Arrays.asList(sources.getSourceGroups("doc_root"))); //NOI18N
        groups.addAll(Arrays.asList(sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)));
        for (SourceGroup sourceGroup : groups) {
            FileObject fileObject = sourceGroup.getRootFolder().getFileObject(subPath);
            if (fileObject != null) {
                openFile(fileObject);
                return true;
            }
        }
    }
    return false;
}
 
Example 8
Source Project: netbeans   Source File: J2SESourcesTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testIncludesExcludes() throws Exception {
    SourceGroup g = ProjectUtils.getSources(project).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA)[0];
    assertEquals(sources, g.getRootFolder());
    FileObject objectJava = FileUtil.createData(sources, "java/lang/Object.java");
    FileObject jcJava = FileUtil.createData(sources, "javax/swing/JComponent.java");
    FileObject doc = FileUtil.createData(sources, "javax/swing/doc-files/index.html");
    assertTrue(g.contains(objectJava));
    assertTrue(g.contains(jcJava));
    assertTrue(g.contains(doc));
    Method projectOpened = ProjectOpenedHook.class.getDeclaredMethod("projectOpened");
    projectOpened.setAccessible(true);
    projectOpened.invoke(project.getLookup().lookup(ProjectOpenedHook.class));
    EditableProperties ep = helper.getProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH);
    assertEquals("includes/excludes were initialized to defaults", "**", ep.getProperty(ProjectProperties.INCLUDES));
    assertEquals("includes/excludes were initialized to defaults", "", ep.getProperty(ProjectProperties.EXCLUDES));
    ep.setProperty(ProjectProperties.INCLUDES, "javax/swing/");
    ep.setProperty(ProjectProperties.EXCLUDES, "**/doc-files/");
    helper.putProperties(AntProjectHelper.PROJECT_PROPERTIES_PATH, ep);
    pm.saveProject(project);
    assertFalse(g.contains(objectJava));
    assertTrue(g.contains(jcJava));
    assertFalse(g.contains(doc));
}
 
Example 9
Source Project: NBANDROID-V2   Source File: AndroidFileTypesImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public boolean isLayoutFile(@Nullable final FileObject fo) {
    if (fo == null || !"xml".equals(fo.getExt())) {
        return false;
    }
    Project p = FileOwnerQuery.getOwner(fo);
    if (p.getLookup().lookup(AndroidClassPathProvider.class) == null) {
        return false;
    }
    return Iterables.any(
            Arrays.asList(ProjectUtils.getSources(p).getSourceGroups(AndroidConstants.SOURCES_TYPE_ANDROID_RES)),
            new Predicate<SourceGroup>() {
        @Override
        public boolean apply(SourceGroup t) {
            FileObject folder = fo.getParent();
            if (folder == null) {
                return false;
            }
            return FileUtil.isParentOf(t.getRootFolder(), fo)
                    && "xml".equals(fo.getExt())
                    && ("layout".equals(folder.getNameExt()) || folder.getNameExt().startsWith("layout-"));
        }
    });
}
 
Example 10
Source Project: netbeans   Source File: I18nServiceImpl.java    License: Apache License 2.0 6 votes vote down vote up
private static FileObject getResourcesRoot(FileObject srcFile) {
    FileObject root = null;
    Project owner = FileOwnerQuery.getOwner(srcFile);
    if (owner != null) {
        // this is for projects that have split sources/resources folder structures.
        Sources srcs = ProjectUtils.getSources(owner);
        SourceGroup[] grps = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_RESOURCES);
        if (grps != null && grps.length > 0) {
            root = grps[0].getRootFolder();
        }
    }
    if (root == null) {
        root = ClassPath.getClassPath(srcFile, ClassPath.SOURCE).getRoots()[0];
    }
    return root;
}
 
Example 11
Source Project: netbeans   Source File: GeneratedSourceRootTest.java    License: Apache License 2.0 6 votes vote down vote up
public void testSourceRoots() throws Exception {
    Project p = createTestProject(true);
    FileObject d = p.getProjectDirectory();
    FileObject src = d.getFileObject("src");
    FileObject stuff = d.getFileObject("build/generated-sources/stuff");
    SourceGroup[] groups = ProjectUtils.getSources(p).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    assertEquals(2, groups.length);
    assertEquals(src, groups[0].getRootFolder());
    assertEquals(d.getFileObject("test"), groups[1].getRootFolder());
    ClassPath sourcePath = ClassPath.getClassPath(src, ClassPath.SOURCE);
    assertEquals(Arrays.asList(src, stuff), Arrays.asList(sourcePath.getRoots()));
    FileObject moreStuff = FileUtil.createFolder(d, "build/generated-sources/morestuff");
    final Set<FileObject> expected = new TreeSet<FileObject>(new FOComparator());
    expected.addAll(Arrays.asList(src, stuff, moreStuff));
    final Set<FileObject> result = new TreeSet<FileObject>(new FOComparator());
    result.addAll(Arrays.asList(sourcePath.getRoots()));
    assertEquals(expected, result);
    ClassPath compile = ClassPath.getClassPath(src, ClassPath.COMPILE);
    assertEquals(compile, ClassPath.getClassPath(stuff, ClassPath.COMPILE));
    assertEquals(compile, ClassPath.getClassPath(moreStuff, ClassPath.COMPILE));
    assertEquals(ClassPath.getClassPath(src, ClassPath.EXECUTE), ClassPath.getClassPath(stuff, ClassPath.EXECUTE));
    assertEquals(ClassPath.getClassPath(src, ClassPath.BOOT), ClassPath.getClassPath(stuff, ClassPath.BOOT));
    d.getFileObject("build").delete();
    assertEquals(Arrays.asList(src), Arrays.asList(sourcePath.getRoots()));
}
 
Example 12
Source Project: netbeans   Source File: ServletPanel.java    License: Apache License 2.0 6 votes vote down vote up
private void browseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseButtonActionPerformed
    try {
        SourceGroup[] groups = DDUtils.getJavaSourceGroups(dObj);
        org.openide.filesystems.FileObject fo = BrowseFolders.showDialog(groups);
        if (fo!=null) {
            String className = DDUtils.getResourcePath(groups,fo);
            if (className.length()>0 && !className.equals(servletClassTF.getText())) {
                dObj.modelUpdatedFromUI();
                servletClassTF.setText(className);
                dObj.setChangedFromUI(true);
                servlet.setServletClass(className);
                dObj.setChangedFromUI(false);
                getSectionView().checkValidity();
            }
        }
    } catch (java.io.IOException ex) {}
}
 
Example 13
Source Project: netbeans   Source File: ProjectJAXWSView.java    License: Apache License 2.0 6 votes vote down vote up
public Node createJAXWSView(Project project) {
    if (project != null) {
        JaxWsModel model = (JaxWsModel) project.getLookup().lookup(JaxWsModel.class);
        
        if (model != null) {
            Sources sources = (Sources)project.getLookup().lookup(Sources.class);
            if (sources!=null) {
                SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
                if (groups!=null) {
                    List<FileObject> roots = new ArrayList<FileObject>();
                    for (SourceGroup group: groups) {
                        roots.add(group.getRootFolder());
                    }
                    FileObject[] srcRoots = new FileObject[roots.size()];
                    roots.toArray(srcRoots);
                    return new JaxWsRootNode(project, model,srcRoots);
                }   
            }
        }
    }
    return null;
}
 
Example 14
Source Project: netbeans   Source File: RefactoringUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Is given file on any source classpath?
 *
 * @param fo
 * @return
 * @deprecated 
 */
@Deprecated
public static boolean isOnSourceClasspath(FileObject fo) {
    Project pr = FileOwnerQuery.getOwner(fo);
    if (pr == null) {
        return false;
    }

    //workaround for 143542
    for (String type : new String[]{JavaProjectConstants.SOURCES_TYPE_JAVA, JavaProjectConstants.SOURCES_TYPE_RESOURCES}) {
        for (SourceGroup sg : ProjectUtils.getSources(pr).getSourceGroups(type)) {
            if (fo == sg.getRootFolder() || (FileUtil.isParentOf(sg.getRootFolder(), fo) && sg.contains(fo))) {
                return ClassPath.getClassPath(fo, ClassPath.SOURCE) != null;
            }
        }
    }
    return false;
    //end of workaround
    //return ClassPath.getClassPath(fo, ClassPath.SOURCE)!=null;
}
 
Example 15
Source Project: netbeans   Source File: JSEApplicationClassChooser.java    License: Apache License 2.0 6 votes vote down vote up
private void initCombos() {
        Sources sources = ProjectUtils.getSources(project);
        SourceGroup[] sourceGroupsJava = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
        if (sourceGroupsJava == null) {
            throw new IllegalStateException(
                    NbBundle.getMessage(FXMLTemplateWizardIterator.class,
                    "MSG_ConfigureFXMLPanel_SGs_Error")); // NOI18N
        }
        support = new SourceGroupSupport(JavaProjectConstants.SOURCES_TYPE_JAVA);
        support.addSourceGroups(sourceGroupsJava); //must exist

        comboBoxSourceRoot.setModel(new DefaultComboBoxModel(support.getSourceGroups().toArray()));
//        SourceGroupSupport.SourceGroupProxy preselectedGroup = support.getParent().getCurrentSourceGroup();
//        ignoreRootCombo = true;
//        comboBoxSourceRoot.setSelectedItem(preselectedGroup);
//        ignoreRootCombo = false;
//        comboBoxPackage.getEditor().setItem(support.getParent().getCurrentPackageName());
        updatePackages();
        updateText();
        updateResult();
    }
 
Example 16
Source Project: netbeans   Source File: J2SEPersistenceProviderTest.java    License: Apache License 2.0 6 votes vote down vote up
public void setUp() throws Exception {
    // in an attempt to find the cause of issue 90762
    Logger.getLogger(PersistenceScopesHelper.class.getName()).setLevel(Level.FINEST);
    // setup the project
    FileObject scratch = TestUtil.makeScratchDir(this);
    final FileObject projdir = scratch.createFolder("proj");
    MockLookup.setLayersAndInstances();
    // issue 90762: prevent AntProjectHelper from firing changes in a RP thread, which interferes with tests
    // see APH.fireExternalChange
    ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
        public Void run() throws Exception{
            J2SEProjectGenerator.setDefaultSourceLevel(new SpecificationVersion ("1.6"));
            J2SEProjectGenerator.createProject(FileUtil.toFile(projdir), "proj", "foo.Main", "manifest.mf", null, false);
            J2SEProjectGenerator.setDefaultSourceLevel(null);
            return null;
        }
    });
    project = ProjectManager.getDefault().findProject(projdir);
    Sources src = project.getLookup().lookup(Sources.class);
    SourceGroup[] groups = src.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    root = groups[0].getRootFolder();
    provider = project.getLookup().lookup(J2SEPersistenceProvider.class);
    persistenceLocation = new File(FileUtil.toFile(project.getProjectDirectory().getFileObject("src")), "META-INF");
}
 
Example 17
Source Project: netbeans   Source File: ManagerUtil.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Convenience method to obtain the source root folder.
 * @param project the Project object
 * @return the FileObject of the source root folder
 */
public static FileObject getSourceRoot(Project project) {
    if (project == null) {
        return null;
    }

    // Search the ${src.dir} Source Package Folder first, use the first source group if failed.
    Sources src = ProjectUtils.getSources(project);
    SourceGroup[] grp = src.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    for (int i = 0; i < grp.length; i++) {
        if ("${src.dir}".equals(grp[i].getName())) { // NOI18N
            return grp[i].getRootFolder();
        }
    }
    if (grp.length != 0) {
        return grp[0].getRootFolder();
    }

    return null;
}
 
Example 18
Source Project: netbeans   Source File: RestClientPojoCodeGenerator.java    License: Apache License 2.0 5 votes vote down vote up
protected void createRestConnectionFile(Project project) throws IOException {
    SourceGroup[] srcGrps = SourceGroupSupport.getJavaSourceGroups(project);
    String pkg = REST_CONNECTION_PACKAGE;
    FileObject targetFolder = SourceGroupSupport.getFolderForPackage(srcGrps[0],pkg , true);
    JavaSourceHelper.createJavaSource(REST_CONNECTION_TEMPLATE, targetFolder, pkg, REST_CONNECTION);
    String restResponseTemplate = REST_RESPONSE_TEMPLATE;
    JavaSource restResponseJS = JavaSourceHelper.createJavaSource(restResponseTemplate, targetFolder, pkg, REST_RESPONSE);
}
 
Example 19
Source Project: netbeans   Source File: J2seJaxWsOpenHook.java    License: Apache License 2.0 5 votes vote down vote up
private void addJaxWsApiEndorsed(Project prj) throws IOException {
    SourceGroup[] sourceGroups = ProjectUtils.getSources(prj).getSourceGroups(
    JavaProjectConstants.SOURCES_TYPE_JAVA);
    if (sourceGroups!=null && sourceGroups.length>0) {
        WSUtils.addJaxWsApiEndorsed(prj, sourceGroups[0].getRootFolder());
    }
}
 
Example 20
Source Project: netbeans   Source File: BasicWizardIterator.java    License: Apache License 2.0 5 votes vote down vote up
public SourceGroup getSourceRootGroup() {
    if (sourceRootGroup == null) {
        FileObject tempSrcRoot = getModuleInfo().getSourceDirectory();
        assert tempSrcRoot != null;
        
        Sources sources = ProjectUtils.getSources(project);
        SourceGroup[] groups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
        for (int i = 0; sourceRootGroup == null && i < groups.length; i++) {
            if (groups[i].getRootFolder().equals(tempSrcRoot)) {
                sourceRootGroup = groups[i];
            }
        }
    }
    return sourceRootGroup;
}
 
Example 21
Source Project: netbeans   Source File: JaxRsStackSupportImpl.java    License: Apache License 2.0 5 votes vote down vote up
private FileObject getSourceRoot(Project project){
    SourceGroup[] sourceGroups = ProjectUtils.getSources(project).getSourceGroups(
            JavaProjectConstants.SOURCES_TYPE_JAVA);
    if (sourceGroups == null || sourceGroups.length < 1) {
        return null;
    }
    return sourceGroups[0].getRootFolder();
}
 
Example 22
Source Project: netbeans   Source File: BrowseFolders.java    License: Apache License 2.0 5 votes vote down vote up
public BrowseFolders(SourceGroup[] folders) {
    initComponents();
    manager = new ExplorerManager();
    AbstractNode rootNode = new AbstractNode(new SourceGroupsChildren(folders));
    manager.setRootContext(rootNode);
    createTemplateView();
}
 
Example 23
Source Project: netbeans   Source File: SourceGroups.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets the folder representing the given <code>packageName</code>.
 * 
 * @param sourceGroup the source group of the package; must not be null.
 * @param packageName the name of the package; must not be null.
 * @param create specifies whether the folder should be created if it does not exist.
 * @return the folder representing the given package or null if it was not found.
 */
public static FileObject getFolderForPackage(SourceGroup sourceGroup, String packageName, boolean create) throws IOException {
    Parameters.notNull("sourceGroup", sourceGroup); //NOI18N
    Parameters.notNull("packageName", packageName); //NOI18N
    
    String relativePkgName = packageName.replace('.', '/');
    FileObject folder = sourceGroup.getRootFolder().getFileObject(relativePkgName);
    if (folder != null) {
        return folder;
    } else if (create) {
        return FileUtil.createFolder(sourceGroup.getRootFolder(), relativePkgName);
    }
    return null;
}
 
Example 24
Source Project: netbeans   Source File: ClassPathModifier.java    License: Apache License 2.0 5 votes vote down vote up
@Override
public String[] getExtensibleClassPathTypes (SourceGroup sg) {
    return new String[] {
        ClassPath.COMPILE,
        ClassPath.EXECUTE,
        ClassPathSupport.ENDORSED,
        JavaClassPathConstants.PROCESSOR_PATH,
        JavaClassPathConstants.MODULE_COMPILE_PATH,
        JavaClassPathConstants.MODULE_EXECUTE_PATH,
    };
}
 
Example 25
Source Project: NBANDROID-V2   Source File: AndroidProjects.java    License: Apache License 2.0 5 votes vote down vote up
public static FileObject findResFolder(Project project) {
    Sources sources = ProjectUtils.getSources(project);
    SourceGroup[] resGroup = sources.getSourceGroups(AndroidConstants.SOURCES_TYPE_ANDROID_RES);
    if (resGroup.length > 0) {
        return resGroup[0].getRootFolder();
    }
    return null;
}
 
Example 26
@Override
protected boolean addAntArtifacts(AntArtifact[] artifacts, URI[] artifactElements, SourceGroup sourceGroup, String type) throws IOException, UnsupportedOperationException {
    if (JavaClassPathConstants.COMPILE_ONLY.equals(type)) {
        return compileOnlyClassPathSupport.addCompileAntArtifacts(artifacts, artifactElements);
    } else {
        return cpMod.addAntArtifacts(artifacts, artifactElements, sourceGroup, type);
    }
}
 
Example 27
Source Project: netbeans   Source File: ProjectUtilities.java    License: Apache License 2.0 5 votes vote down vote up
public static boolean isJavaProject(Project project) {
    if (project == null) return false;
    
    Sources sources = ProjectUtils.getSources(project);
    SourceGroup[] sourceGroups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);

    return sourceGroups.length > 0;
}
 
Example 28
Source Project: netbeans   Source File: JavaUtil.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Returns the SourceGroup of the passesd project which contains the
 * fully-qualified class name.
 */
public static SourceGroup getClassSourceGroup(Project project, String fqClassName) {
    String classFile = fqClassName.replace('.', '/') + "." + Constants.JAVA_EXT; // NOI18N
    SourceGroup[] sourceGroups = SourceGroupSupport.getJavaSourceGroups(project);

    for (SourceGroup sourceGroup : sourceGroups) {
        FileObject classFO = sourceGroup.getRootFolder().getFileObject(classFile);
        if (classFO != null) {
            return sourceGroup;
        }
    }
    return null;
}
 
Example 29
Source Project: netbeans   Source File: MavenSourcesImpl.java    License: Apache License 2.0 5 votes vote down vote up
public MavenSourcesImpl(Project proj) {
    this.proj = proj;
    javaGroup = new TreeMap<String, SourceGroup>();
    genSrcGroup = new TreeMap<File, SourceGroup>();
    otherMainGroups = new TreeMap<File, OtherGroup>();
    otherTestGroups = new TreeMap<File, OtherGroup>();
}
 
Example 30
Source Project: NBANDROID-V2   Source File: ResNodeFactoryProvider.java    License: Apache License 2.0 5 votes vote down vote up
public Node createNode(Project p, SourceGroup sg) {
    try {
        DataObject dobj = DataObject.find(sg.getRootFolder());
        Node node = cache.get(dobj);
        if (node == null) {
            node = new AndroidResourceNode(dobj.getNodeDelegate(), p, sg.getDisplayName());
            cache.put(dobj, node);
        }
        return node;
    } catch (DataObjectNotFoundException ex) {
        Exceptions.printStackTrace(ex);
    }
    return null;
}