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

The following are top voted examples for showing how to use org.netbeans.api.project.Project. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: incubator-netbeans   File: Classpaths.java   Source Code and License 6 votes vote down vote up
private List<URL> createExecuteClasspath(List<String> packageRoots, Element compilationUnitEl) {
    for (Element e : XMLUtil.findSubElements(compilationUnitEl)) {
        if (e.getLocalName().equals("classpath") && e.getAttribute("mode").equals("execute")) { // NOI18N
            return createClasspath(e, new RemoveSources(helper, sfbqImpl));
        }
    }
    // None specified; assume it is same as compile classpath plus (cf. #49113) <built-to> dirs/JARs
    // if there are any (else include the source dir(s) as a fallback for the I18N wizard to work).
    Set<URL> urls = new LinkedHashSet<>();
    urls.addAll(createCompileClasspath(compilationUnitEl));
    final Project prj = FileOwnerQuery.getOwner(helper.getProjectDirectory());
    if (prj != null) {
        for (URL src : createSourcePath(packageRoots)) {
            urls.addAll(sfbqImpl.findBinaryRoots(src));
        }
    }
    return new ArrayList<>(urls);
}
 
Example 2
Project: incubator-netbeans   File: DefaultPlugin.java   Source Code and License 6 votes vote down vote up
/**
 * Finds a Java source group the given file belongs to.
 * 
 * @param  file  {@code FileObject} to find a {@code SourceGroup} for
 * @return  the found {@code SourceGroup}, or {@code null} if the given
 *          file does not belong to any Java source group
 */
private static SourceGroup findSourceGroup(FileObject file) {
    final Project project = FileOwnerQuery.getOwner(file);
    if (project == null) {
        return null;
    }

    Sources src = ProjectUtils.getSources(project);
    SourceGroup[] srcGrps = src.getSourceGroups(SOURCES_TYPE_JAVA);
    for (SourceGroup srcGrp : srcGrps) {
        FileObject rootFolder = srcGrp.getRootFolder();
        if (((file == rootFolder) || FileUtil.isParentOf(rootFolder, file)) 
                && srcGrp.contains(file)) {
            return srcGrp;
        }
    }
    return null;
}
 
Example 3
Project: incubator-netbeans   File: LayerNode.java   Source Code and License 6 votes vote down vote up
@Messages({"LBL_this_layer=<this layer>", "LBL_this_layer_in_context=<this layer in context>"})
@Override protected boolean createKeys(List<DataObject> keys) {
    handle.setAutosave(true);
    FileObject layer = handle.getLayerFile();
    if (layer == null) { // #180872, #212541
        return true;
    }
    Project p = FileOwnerQuery.getOwner(layer);
    if (p == null) { // #175861: inside JAR etc.
        return true;
    }
    FileSystem layerfs = handle.layer(false);
    try {
        if (layerfs != null) {
            keys.add(DataObject.find(badge(layerfs, handle.getLayerFile(), LBL_this_layer(), null).getRoot()));
        }
        LayerHandle h = LayerHandle.forProject(p);
        if (layer.equals(h.getLayerFile())) {
            h.setAutosave(true); // #135376
            keys.add(DataObject.find(badge(LayerUtils.getEffectiveSystemFilesystem(p), handle.getLayerFile(), LBL_this_layer_in_context(), handle.layer(false)).getRoot()));
        }
    } catch (IOException e) {
        Util.err.notify(ErrorManager.INFORMATIONAL, e);
    }
    return true;
}
 
Example 4
Project: incubator-netbeans   File: FileChooser.java   Source Code and License 6 votes vote down vote up
/**
 * Create chooser for given AntProjectHelper. Standard file chooser is shown
 * if project is not sharable.
 * 
 * @param helper ant project helper; cannot be null
 * @param copyAllowed is file copying allowed
 */
public FileChooser(AntProjectHelper helper, boolean copyAllowed) {
    super();
    FileObject projectFolder = helper.getProjectDirectory();
    Project p = projectFolder != null ? FileOwnerQuery.getOwner(projectFolder): null;
    LibraryManager lm = p != null ? ReferenceHelper.getProjectLibraryManager(p) : null;
    if (lm != null) {
        URL u = lm.getLocation();
        if (u != null) {
            File libBase = Utilities.toFile(URI.create(u.toExternalForm())).getParentFile();
            accessory = new FileChooserAccessory(this, FileUtil.toFile(helper.getProjectDirectory()), 
                libBase, copyAllowed);
            setAccessory(accessory);
        }
    }
}
 
Example 5
Project: incubator-netbeans   File: SimpleFileOwnerQueryImplementation.java   Source Code and License 6 votes vote down vote up
/** @see FileOwnerQuery#markExternalOwner */
public static void markExternalOwnerTransient(URI root, Project owner) {
    externalRootsIncludeNonFolders |= !root.getPath().endsWith("/");
    if (owner != null) {
        FileObject fo = owner.getProjectDirectory();
        URI foUri = owner == FileOwnerQuery.UNOWNED ? UNOWNED_URI : fo.toURI();
        synchronized (cacheLock) {
            cacheInvalid = true;
            externalOwners.put(root, foUri);
            deserializedExternalOwners.remove(root);
        }
    } else {
        synchronized (cacheLock) {
            cacheInvalid = true;
            externalOwners.remove(root);
        }
    }
}
 
Example 6
Project: incubator-netbeans   File: Util.java   Source Code and License 6 votes vote down vote up
/**
 * Creates a persistence unit using the PU wizard and adds the created
 * persistence unit to the given project's <code>PUDataObject</code> and saves it.
 *
 * @param project the project to which the created persistence unit is to be created.
 * @param preselectedDB the name of the db connection that should be preselected, or null if none needs
 * to be preselected.
 * @param tableGeneration the table generation strategy for the persistence unit.
 *
 * @return true if the creation of the persistence unit was successful, false otherwise.
 *
 * @throws InvalidPersistenceXmlException if the persistence.xml file in the given
 * project is not valid.
 *
 */
public static boolean createPersistenceUnitUsingWizard(Project project,
        String preselectedDB, TableGeneration tableGeneration) throws InvalidPersistenceXmlException {

    PersistenceUnit punit = buildPersistenceUnitUsingWizard(project, preselectedDB, tableGeneration);
    if (punit == null) {
        return false;
    }
    String version = Persistence.VERSION_1_0;
    if(punit instanceof org.netbeans.modules.j2ee.persistence.dd.persistence.model_2_1.PersistenceUnit) {
        version = Persistence.VERSION_2_1;
    } else if(punit instanceof org.netbeans.modules.j2ee.persistence.dd.persistence.model_2_0.PersistenceUnit) {
        version = Persistence.VERSION_2_0;
    }
    PUDataObject pud = ProviderUtil.getPUDataObject(project, version);
    if (pud == null) {
        return false;
    }
    pud.addPersistenceUnit(punit);
    pud.save();
    return true;
}
 
Example 7
Project: incubator-netbeans   File: ProjectXMLManagerTest.java   Source Code and License 6 votes vote down vote up
private static void checkDependenciesOrder(final Project proj) throws Exception {
    FileObject projectXML = proj.getProjectDirectory().getFileObject("nbproject/project.xml");
    BufferedReader r = new BufferedReader(new InputStreamReader(projectXML.getInputStream()));
    try {
        String previousCNB = null;
        String line;
        while ((line = r.readLine()) != null) {
            line = line.trim();
            if (line.matches("<code-name-base>.+</code-name-base>")) {
                String currentCNB = line.substring(16, line.length() - 17);
                assertTrue("dependencies order, previous = \"" + previousCNB + "\", current = \"" + currentCNB + "\"",
                        previousCNB == null || previousCNB.compareTo(currentCNB) < 0);
                previousCNB = currentCNB;
            }
        }
    } finally {
        r.close();
    }
}
 
Example 8
Project: incubator-netbeans   File: JUnitProjectOpenedHook.java   Source Code and License 6 votes vote down vote up
private void updateProjectProperties(Project project) throws IOException {
    final FileObject projectDir = project.getProjectDirectory();
    ProjectManager.mutex().postWriteRequest(new Runnable() {
        @Override
        public void run() {
            try {
                FileObject projectProperties = FileUtil.createData(projectDir, AntProjectHelper.PROJECT_PROPERTIES_PATH);
                Properties props = getProjectProperties(projectDir);

                if (isJUnit3specific) {
                    String testClasspath = props.getProperty(PROP_JAVAC_TEST_CLASSPATH);
                    props.put(PROP_JAVAC_TEST_CLASSPATH, testClasspath.replace("${libs.junit.classpath}", ""));
                }
                props.put(PROP_JUNIT_SELECTED_VERSION, isJUnit3specific ? "3" : "4");
                OutputStream propertiesOS = projectProperties.getOutputStream();
                props.store(propertiesOS, null);
                propertiesOS.close();
            } catch (IOException ex) {
                Exceptions.printStackTrace(ex);
            }
        }
    });
}
 
Example 9
Project: chipKIT-importer   File: ProjectSetupStep.java   Source Code and License 6 votes vote down vote up
private void checkForExistingProject() {
    //if project already exists, enable the check box
    if ("".equalsIgnoreCase(view.projectNameField.getText().trim())) {
        view.overwriteCheckBox.setEnabled(false);
    } else {
        File projFolder = FileUtil.normalizeFile( new File( readLocationStringFromField(view.projectDirectoryField) ) );
        FileObject dirFO = FileUtil.toFileObject(projFolder);
        Project proj = null;
        if (dirFO != null) {
            try {
                proj = ProjectManager.getDefault().findProject(dirFO);
            } catch (IOException | IllegalArgumentException ex) {
                view.overwriteCheckBox.setEnabled(false);
            }
        }
        if (proj == null) {
            view.overwriteCheckBox.setEnabled(false);
        } else {
            view.overwriteCheckBox.setEnabled(true);
        }
    }
}
 
Example 10
Project: incubator-netbeans   File: PackagesPanelProvider.java   Source Code and License 6 votes vote down vote up
@Override
public Category createCategory(Lookup context) {
    Project project = context.lookup(Project.class);
    NbMavenProject watcher = project.getLookup().lookup(NbMavenProject.class);
    String effPackaging = watcher.getPackagingType();
    String[] types = PluginPropertyUtils.getPluginPropertyList(project, OSGiConstants.GROUPID_FELIX, OSGiConstants.ARTIFACTID_BUNDLE_PLUGIN, "supportedProjectTypes", "supportedProjectType", /*"bundle" would not work for GlassFish parent POM*/null);
    if (types != null) {
        for (String type : types) {
            if (effPackaging.equals(type)) {
                effPackaging = NbMavenProject.TYPE_OSGI;
            }
        }
    }
    if (NbMavenProject.TYPE_OSGI.equalsIgnoreCase(effPackaging)) {
        return ProjectCustomizer.Category.create(
                ModelHandle2.PANEL_COMPILE,
                org.openide.util.NbBundle.getMessage(PackagesPanelProvider.class, "TIT_Packages"),
                null);
    }
    return null;
}
 
Example 11
Project: incubator-netbeans   File: OpenSubprojects.java   Source Code and License 6 votes vote down vote up
private void getSubProjects() {
    try {
        if(activatedNodes != null) {
            for( int i = 0; i < activatedNodes.length; i++ ) {
                Project p = activatedNodes[i].getLookup().lookup(Project.class);
                if ( p != null ) {
                    ProjectContainerProvider pcp = p.getLookup().lookup(ProjectContainerProvider.class);
                    if (pcp != null) {
                        subProjects = pcp.getContainedProjects().getProjects();
                    } else {
                        SubprojectProvider spp = p.getLookup().lookup(SubprojectProvider.class);
                        if(spp != null) {
                            subProjects = spp.getSubprojects();
                        }
                    }
                }
            }
        }
    } finally {
        initialized = true;
    }
}
 
Example 12
Project: incubator-netbeans   File: BaseProcessor.java   Source Code and License 6 votes vote down vote up
private void processFile(Project project, FileObject fileObject, String originalName, String originalExtension) {
    assert fileObject.isData() : "File expected: " + fileObject;
    if (!isSupportedFile(fileObject)) {
        // unsupported file
        return;
    }
    if (!processedFiles.add(fileObject)) {
        // already processed
        return;
    }
    if (fileObject.isValid()) {
        fileChanged(project, fileObject);
        if (originalName != null) {
            // file renamed
            fileRenamed(project, fileObject, originalName, originalExtension);
        }
    } else {
        // deleted file
        fileDeleted(project, fileObject);
    }
}
 
Example 13
Project: incubator-netbeans   File: RetoucheUtils.java   Source Code and License 6 votes vote down vote up
public static boolean isOnSourceClasspath(FileObject fo) {
    Project p = FileOwnerQuery.getOwner(fo);
    if (p==null) return false;
    Project[] opened = OpenProjects.getDefault().getOpenProjects();
    for (int i = 0; i<opened.length; i++) {
        if (p.equals(opened[i]) || opened[i].equals(p)) {
            SourceGroup[] gr = ProjectUtils.getSources(p).getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
            for (int j = 0; j < gr.length; j++) {
                if (fo==gr[j].getRootFolder()) return true;
                if (FileUtil.isParentOf(gr[j].getRootFolder(), fo))
                    return true;
            }
            return false;
        }
    }
    return false;
}
 
Example 14
Project: incubator-netbeans   File: TestSingleMethodSupport.java   Source Code and License 6 votes vote down vote up
public static boolean isTestClass(Node activatedNode) {
    FileObject fileObject = org.netbeans.modules.gsf.testrunner.ui.api.UICommonUtils.getFileObjectFromNode(activatedNode);
    if (fileObject != null && CommonTestUtil.isJavaFile(fileObject)) {
        Project project = FileOwnerQuery.getOwner(fileObject);
        if (project != null) {
            SourceGroup[] javaSGs = new JavaUtils(project).getJavaSourceGroups();
            for (int i = 0; i < javaSGs.length; i++) {
                SourceGroup javaSG = javaSGs[i];
                FileObject rootFolder = javaSG.getRootFolder();
                URL[] testRoots = UnitTestForSourceQuery.findUnitTests(rootFolder);
                URL[] sourceRoots = UnitTestForSourceQuery.findSources(rootFolder);
                if (((fileObject == rootFolder) || FileUtil.isParentOf(rootFolder, fileObject)) && javaSG.contains(fileObject)) {
                    // activated FO is contained in the javaSG source group
                    if (testRoots.length == 0 && sourceRoots.length > 0) {
                        // javaSG has corresponding source root but no corresponding test root,
                        // thus the activated FO is a test class, so activate action
                        return true;
                    }
                }
            }
        }
    }
    return false;
}
 
Example 15
Project: incubator-netbeans   File: OpenProjectListTest.java   Source Code and License 6 votes vote down vote up
public void testListenerOpenClose () throws Exception {
    assertTrue ("No project is open.", OpenProjectList.getDefault ().getOpenProjects ().length == 0); 
    ChangeListener list = new ChangeListener();
    OpenProjectList.getDefault().addPropertyChangeListener(list);
    CharSequence log = Log.enable("org.netbeans.ui", Level.FINE);
    OpenProjectList.getDefault ().open (project1, true);
    Pattern p = Pattern.compile("Opening.*1.*TestProject", Pattern.MULTILINE | Pattern.DOTALL);
    Matcher m = p.matcher(log);
    if (!m.find()) {
        fail("There should be TestProject\n" + log.toString());
    }
    assertEquals(0, list.oldCount);
    assertEquals(1, list.newCount);
    OpenProjectList.getDefault ().open (project2, true);
    assertEquals(1, list.oldCount);
    assertEquals(2, list.newCount);
    OpenProjectList.getDefault().close(new Project[] {project1}, false);
    assertEquals(2, list.oldCount);
    assertEquals(1, list.newCount);
    OpenProjectList.getDefault().close(new Project[] {project2}, false);
    assertEquals(1, list.oldCount);
    assertEquals(0, list.newCount);
}
 
Example 16
Project: incubator-netbeans   File: ProjectUtilities.java   Source Code and License 6 votes vote down vote up
public static boolean hasAction(Project project, String actionName) {
    ActionProvider ap = project.getLookup().lookup(ActionProvider.class);

    if (ap == null) {
        return false; // return false if no ActionProvider available
    }

    String[] actions = ap.getSupportedActions();

    for (int i = 0; i < actions.length; i++) {
        if ((actions[i] != null) && actionName.equals(actions[i])) {
            return true;
        }
    }

    return false;
}
 
Example 17
Project: incubator-netbeans   File: InstallToPaletteAction.java   Source Code and License 6 votes vote down vote up
@Override
protected boolean enable(Node[] activatedNodes) {
    if (activatedNodes.length == 0) {
        return false;
    }
    for (Node n: activatedNodes) {
        FileObject fobj = n.getLookup().lookup(FileObject.class);
        if (fobj == null || JavaSource.forFileObject(fobj) == null) {
            return false;
        }
        // Issue 73641
        Project project = FileOwnerQuery.getOwner(fobj);
        if (project != null) {
            RecommendedTemplates info = project.getLookup().lookup(RecommendedTemplates.class);
            if ((info != null) && !Arrays.asList(info.getRecommendedTypes()).contains("java-forms")) { // NOI18N
                return false;
            }
        }
    }
    
    return true;
}
 
Example 18
Project: incubator-netbeans   File: WizardUtils.java   Source Code and License 6 votes vote down vote up
/**
 * Returns {@link ComboBoxModel} containing {@link LayerItemPresenter}s
 * wrapping all folders under the given <code>sfsRoot</code>.
 *
 * @param excludeAttrs {@link Map} of pairs String - Object used to filter
 *                     out folders which have one or more attribute(key)
 *                     with a corresponding value.
 */
public static ComboBoxModel createLayerPresenterComboModel(
        final Project project, final String sfsRoot, final Map<String,Object> excludeAttrs) {
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    try {
        FileSystem sfs = project.getLookup().lookup(NbModuleProvider.class).getEffectiveSystemFilesystem();
        FileObject root = sfs.getRoot().getFileObject(sfsRoot);
        if (root != null) {
            SortedSet<LayerItemPresenter> presenters = new TreeSet<LayerItemPresenter>();
            for (FileObject subFolder : getFolders(root, excludeAttrs)) {
                presenters.add(new LayerItemPresenter(subFolder, root));
            }
            for (LayerItemPresenter presenter : presenters) {
                model.addElement(presenter);
            }
        }
    } catch (IOException exc) {
        Logger.getLogger(UIUtil.class.getName()).log(Level.INFO, "Failed to create model of " + sfsRoot, exc);
    }
    return model;
}
 
Example 19
Project: incubator-netbeans   File: MavenRunOptions.java   Source Code and License 5 votes vote down vote up
/**
 * Creates new form MavenRunOptions
 */
public MavenRunOptions(Project project, Category category, ModelHandle2 handle) {
    this.project = project;
    this.category = category;
    this.handle = handle;
    
    initComponents();

    cbConfiguration.setEditable(false);
    cbConfiguration.setRenderer(new DefaultListCellRenderer() {
        @Override
        public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
            Component com = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            if (com instanceof JLabel) {
                if (value == handle.getActiveConfiguration()) {
                    com.setFont(com.getFont().deriveFont(Font.BOLD));
                }
            }
            return com;
        }
    });
    
    nestedOptions = (JShellOptions2)pOptions;
    
    setupConfigurations();
    
    loadOptions(null);
    
    nestedOptions.setConfigChangeListener(this::optionsChanged);
    cbConfiguration.addActionListener(this::loadOptions);
}
 
Example 20
Project: incubator-netbeans   File: EntityComparator.java   Source Code and License 5 votes vote down vote up
/**
 * Returns names of all projects opened in the IDE's GUI.
 * @return a collection of the names.
 */
private static Collection<String> getNamesOfOpenProjects() {
    ArrayList<String> names = new ArrayList<String>(10);
    for(Project p: OpenProjects.getDefault().getOpenProjects()) {
        String pName = ProjectUtils.getInformation(p).getDisplayName();
        names.add(pName);
    }
    return names;
}
 
Example 21
Project: incubator-netbeans   File: UpdateTrackingFileOwnerQueryTest.java   Source Code and License 5 votes vote down vote up
private void assertOwnership(String project, String file) throws Exception {
    FileObject projectFO = FileUtil.toFileObject(PropertyUtils.resolveFile(nbRootFile(), project));
    assertNotNull("have project " + project, projectFO);
    Project p = ProjectManager.getDefault().findProject(projectFO);
    assertNotNull("have a project in " + project, p);
    // This has the side effect of forcing a scan of the module universe:
    ClassPath.getClassPath(projectFO.getFileObject("src"), ClassPath.COMPILE);
    FileObject fileFO = FileUtil.toFileObject(PropertyUtils.resolveFile(nbRootFile(), file));
    if (fileFO != null) { // OK if not currently built
        assertEquals("correct owner by FileObject of " + file, p, FileOwnerQuery.getOwner(fileFO));
    }
    assertEquals("correct owner by URI of " + file, p, FileOwnerQuery.getOwner(
            Utilities.toURI(PropertyUtils.resolveFile(nbRootFile(), file))));
}
 
Example 22
Project: incubator-netbeans   File: JavaFileFilterListener.java   Source Code and License 5 votes vote down vote up
private boolean verify(final URL root) throws IOException, URISyntaxException {
    boolean result = true;
    final Project p = FileOwnerQuery.getOwner(root.toURI());
    if (p != null) {
        final ProjectConfigurationProvider cp = p.getLookup().lookup(ProjectConfigurationProvider.class);
        if (cp != null) {
            final ProjectConfiguration cfg = cp.getActiveConfiguration();
            if (cfg != null) {
                String name = cfg.getDisplayName();
                result = !JavaIndex.ensureAttributeValue(root, ATTR_FILTER_CFG, name);
            }
        }
    }
    return result;
}
 
Example 23
Project: incubator-netbeans   File: HibernateMappingWizardPanel.java   Source Code and License 5 votes vote down vote up
public String[] getConfigFilesFromProject(Project project) {
    List<String> configFiles = new ArrayList<String>();
    configFileObjects = env.getAllHibernateConfigFileObjects();
    for (FileObject fo : configFileObjects) {
        configFiles.add(fo.getNameExt());
    }
    return configFiles.toArray(new String[]{});
}
 
Example 24
Project: incubator-netbeans   File: JFXGeneratedFilesInterceptor.java   Source Code and License 5 votes vote down vote up
@Override
public void fileGenerated(
        final Project project,
        final String path) {
    if (reenter.get() == Boolean.TRUE) {
        return;
    }
    if (GeneratedFilesHelper.BUILD_IMPL_XML_PATH.equals(path)) {
        final AntBuildExtender extender = project.getLookup().lookup(AntBuildExtender.class);
        if (extender == null) {
            LOG.log(
                Level.WARNING,
                "The project {0} ({1}) does not support AntBuildExtender.",     //NOI18N
                new Object[] {
                    ProjectUtils.getInformation(project).getDisplayName(),
                    FileUtil.getFileDisplayName(project.getProjectDirectory())
                });
            return;
        }
        runDeferred(new Runnable() {
            @Override
            public void run() {
                updateIfNeeded(project, extender);
            }
        });
    }
}
 
Example 25
Project: incubator-netbeans   File: Util.java   Source Code and License 5 votes vote down vote up
public static Provider getDefaultProvider(Project project) {
    PersistenceProviderSupplier providerSupplier = project.getLookup().lookup(PersistenceProviderSupplier.class);
    if ((providerSupplier != null && providerSupplier.supportsDefaultProvider())) {
        List<Provider> providers = providerSupplier.getSupportedProviders();
        if (providers.size() > 0) {
            return providers.get(0);
        }
        Logger.getLogger(RelatedCMPWizard.class.getName()).log(Level.WARNING, "Default provider support is reported without any supported providers. See: {0}", providerSupplier);
    }
    return null;
}
 
Example 26
Project: incubator-netbeans   File: Utilities.java   Source Code and License 5 votes vote down vote up
/**
 * Open project <code>projectName</code> located in <code>dir</code>
 * directory.
 *
 * @param projectName           project name to open
 * @param dir                   project's enclosing directory
 * @return file-object          representing project
 * @throws java.io.IOException  when project cannot be opened
 */
public static FileObject openProject(String projectName, File dir) throws IOException {
    File projectsDir = FileUtil.normalizeFile(dir);
    FileObject projectsDirFO = FileUtil.toFileObject(projectsDir);
    FileObject projdir = projectsDirFO.getFileObject(projectName);
    Project p = ProjectManager.getDefault().findProject(projdir);
    OpenProjects.getDefault().open(new Project[]{p}, false);
    if (p == null) {
        throw new IOException("Project is not opened " + projectName);
    }
    return projdir;
}
 
Example 27
Project: incubator-netbeans   File: ProjectWhiteListQueryImpl.java   Source Code and License 5 votes vote down vote up
@Override
public WhiteListImplementation getWhiteList(FileObject file) {
    final Project project = FileOwnerQuery.getOwner(file);
    if (project != null) {
        final WhiteListQueryImplementation delegate = project.getLookup().lookup(WhiteListQueryImplementation.class);
        if (delegate != null) {
            return delegate.getWhiteList(file);
        }
    }
    return null;
}
 
Example 28
Project: incubator-netbeans   File: FacadeGenerator.java   Source Code and License 5 votes vote down vote up
Set<FileObject> generate(final Project project,
final Map<String, String> entityNames,
final FileObject targetFolder,
final String entityFQN,
final String idClass,
final String pkg,
final boolean hasRemote,
final boolean hasLocal,
boolean overrideExisting) throws IOException;
 
Example 29
Project: incubator-netbeans   File: BookmarkUtils.java   Source Code and License 5 votes vote down vote up
public static Project findProject(URI projectURI) {
    if (projectURI != null) {
        try {
            FileObject prjFO = URLMapper.findFileObject(projectURI.toURL());
            if (prjFO != null && prjFO.isFolder()) {
                return ProjectManager.getDefault().findProject(prjFO);
            }
        } catch (IOException ex) {
            // Cannot load project -> return null
        }
    }
    return null;
}
 
Example 30
Project: incubator-netbeans   File: JAXBBindingSupportFileNode.java   Source Code and License 5 votes vote down vote up
private static Lookup createLookup(FileObject xsdFileObject, 
                                    Project prj) {
    return Lookups.fixed( new Object[] {
        xsdFileObject,
        prj
    } );
}
 
Example 31
Project: incubator-netbeans   File: SelectorUtils.java   Source Code and License 5 votes vote down vote up
private static String getDisplayName(FileObject fo, Project owner, boolean incPrjName) {
    if (owner != null) {
        SourceGroup grp = getSourceGroup(fo, owner);
        String n = (grp!=null)?grp.getDisplayName():FileUtil.getFileDisplayName(fo);
        if (incPrjName) {
            ProjectInformation pi = ProjectUtils.getInformation(owner);
            n  += " [" + pi.getDisplayName() + "]";
        }
        return n;
    } else 
        return FileUtil.getFileDisplayName(fo);
}
 
Example 32
Project: incubator-netbeans   File: CompilerPluginVersionError.java   Source Code and License 5 votes vote down vote up
@Override
public List<ErrorDescription> getErrorsForDocument(POMModel model, Project prj) {
    assert model != null;
    List<ErrorDescription> toRet = new ArrayList<ErrorDescription>();
    
    if(prj == null) {
        return toRet;
    }
    
    if(ModuleInfoUtils.checkModuleInfoAndCompilerFit(prj)) {
        return toRet;
    }
            
    int pos = -1;
    org.netbeans.modules.maven.model.pom.Project p = model.getProject();
    Build bld = p.getBuild();
    if (bld != null) {
        Plugin plg = bld.findPluginById(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_COMPILER);
        if (plg != null) {
            pos = plg.findPosition();
        }
    }    
    
    if(pos == -1) {
        pos = p.findPosition();
    }
    
    if(pos == -1) {
        return toRet;
    }        
           
    Document baseDocument = model.getBaseDocument();        
    Line line = NbEditorUtilities.getLine(baseDocument, pos, false);
    toRet.add(ErrorDescriptionFactory.createErrorDescription(Severity.ERROR, Bundle.DESC_ModulesNotSupported(), Collections.<Fix>singletonList(new UpdatePluginVersion(model)), baseDocument, line.getLineNumber() + 1));
    
    return toRet;
}
 
Example 33
Project: incubator-netbeans   File: PaletteUtils.java   Source Code and License 5 votes vote down vote up
public static synchronized void removePaletteListener(PropertyChangeListener listener,
                                                      FileObject context)
{
    Project project = FileOwnerQuery.getOwner(context);
    ProjectPaletteInfo pInfo = palettes.get(project);
    if (pInfo != null && pInfo.paletteListeners != null) {
        pInfo.paletteListeners.remove(listener);
        pInfo.getPalette().removePropertyChangeListener(listener);
    }
}
 
Example 34
Project: NBANDROID-V2   File: GradleAndroidSources.java   Source Code and License 5 votes vote down vote up
public GradleAndroidSources(Project project, BuildVariant buildConfig) {
    this.project = Preconditions.checkNotNull(project);
    this.buildConfig = Preconditions.checkNotNull(buildConfig);
    buildConfig.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            cs.fireChange();
        }
    });
}
 
Example 35
Project: incubator-netbeans   File: JFXProjectProperties.java   Source Code and License 5 votes vote down vote up
/** Getter method */
public static JFXProjectProperties getInstanceIfExists(Project proj) {
    assert proj != null;
    String projDir = proj.getProjectDirectory().getPath();
    JFXProjectProperties prop = propInstance.get(projDir);
    if(prop != null) {
        return prop;
    }
    return null;
}
 
Example 36
Project: incubator-netbeans   File: J2SECategoryExtensionProviderTest.java   Source Code and License 5 votes vote down vote up
@Override
public JComponent createComponent(Project proj, ConfigChangeListener listener) {
    extender = new MockupComponent("MockupRunExtender2");
    extender.setState(false);
    extender.addListener(listener);
    return extender;
}
 
Example 37
Project: incubator-netbeans   File: FreeformSourcesTest.java   Source Code and License 5 votes vote down vote up
public void testNonExistentRoot() throws Exception {
    clearWorkDir();
    final File d = getWorkDir();
    final File proj = new File (d,"proj");
    final File extSrcDir = new File (d,"ext");
    proj.mkdir();
    AntProjectHelper helper = FreeformProjectGenerator.createProject(proj, proj, "prj", null);
    Project p = ProjectManager.getDefault().findProject(helper.getProjectDirectory());

    Element data = Util.getPrimaryConfigurationData(helper);
    Document doc = data.getOwnerDocument();
    Element sf = (Element) data.insertBefore(doc.createElementNS(Util.NAMESPACE, "folders"), XMLUtil.findElement(data, "view", Util.NAMESPACE)).
            appendChild(doc.createElementNS(Util.NAMESPACE, "source-folder"));
    sf.appendChild(doc.createElementNS(Util.NAMESPACE, "label")).appendChild(doc.createTextNode("Sources"));
    sf.appendChild(doc.createElementNS(Util.NAMESPACE, "location")).appendChild(doc.createTextNode("../ext"));
    Util.putPrimaryConfigurationData(helper, data);
    ProjectManager.getDefault().saveProject(p);

    final Sources src = ProjectUtils.getSources(p);
    SourceGroup[] sgs = src.getSourceGroups(Sources.TYPE_GENERIC);
    assertEquals(1,sgs.length);
    assertEquals(p.getProjectDirectory(), sgs[0].getRootFolder());
    final FileObject extFo = FileUtil.createFolder(extSrcDir);
    sgs = src.getSourceGroups(Sources.TYPE_GENERIC);
    assertSourceGroupsEquals(new FileObject[] {p.getProjectDirectory(), extFo}, sgs);
    assertEquals(p, FileOwnerQuery.getOwner(extFo));
}
 
Example 38
Project: incubator-netbeans   File: Selenium2MavenSupportImpl.java   Source Code and License 5 votes vote down vote up
@Override
public boolean isActionEnable(String action, Project project, Lookup lookup) {
    if (action.startsWith("selenium2.")) { //NOI18N
        return true;
    }
    return super.isActionEnable(action, project, lookup);
}
 
Example 39
Project: incubator-netbeans   File: WebServerTest.java   Source Code and License 5 votes vote down vote up
@Override
public Project getOwner(FileObject file) {
    if (file.getParent().equals(testProject1.getProjectDirectory())) {
        return testProject1;
    }
    if (file.getParent().equals(testProject2.getProjectDirectory())) {
        return testProject2;
    }
    return null;
}
 
Example 40
Project: incubator-netbeans   File: JWSProjectProperties.java   Source Code and License 5 votes vote down vote up
/** Factory method */
public static JWSProjectProperties getInstance(Lookup context) {
    Project proj = context.lookup(Project.class);
    String projDir = proj.getProjectDirectory().getPath();
    JWSProjectProperties prop = propInstance.get(projDir);
    if(prop == null) {
        prop = new JWSProjectProperties(context);
        propInstance.put(projDir, prop);
    }
    return prop;
}
 
Example 41
Project: incubator-netbeans   File: ProjectsRootNode.java   Source Code and License 5 votes vote down vote up
@Override
public void destroy() throws IOException {
    Project p = getLookup().lookup(Project.class);
    if (p == null) {
        return;
    }
    final ActionProvider ap = p.getLookup().lookup(ActionProvider.class);
    Mutex.EVENT.writeAccess(new Runnable() {
        @Override
        public void run() {
            ap.invokeAction(ActionProvider.COMMAND_DELETE, getLookup());
        }
    });
}
 
Example 42
Project: incubator-netbeans   File: ModuleActions.java   Source Code and License 5 votes vote down vote up
static void setRunArgsIde(Project project, PropertyEvaluator eval, String command, Properties p) {
    StringBuilder runArgsIde = new StringBuilder();
    StartupExtender.StartMode mode;
    boolean isOsgi = command.equals("profile-osgi");
    if (command.equals(COMMAND_RUN) || command.equals(COMMAND_RUN_SINGLE)) {
        mode = StartupExtender.StartMode.NORMAL;
    } else if (command.equals(COMMAND_DEBUG) || command.equals(COMMAND_DEBUG_SINGLE) || command.equals(COMMAND_DEBUG_STEP_INTO)) {
        mode = StartupExtender.StartMode.DEBUG;
    } else if (command.equals(COMMAND_PROFILE) || command.equals(COMMAND_PROFILE_SINGLE) || command.equals("profile-osgi")) {
        mode = StartupExtender.StartMode.PROFILE;
    } else if (command.equals(COMMAND_TEST) || command.equals(COMMAND_TEST_SINGLE)) {
        mode = StartupExtender.StartMode.TEST_NORMAL;
    } else if (command.equals(COMMAND_DEBUG_TEST_SINGLE)) {
        mode = StartupExtender.StartMode.TEST_DEBUG;
    } else if (command.equals(COMMAND_PROFILE_TEST_SINGLE)) {
        mode = StartupExtender.StartMode.TEST_PROFILE;
    } else {
        mode = null;
    }
    
    boolean isTest = (EnumSet.of(
                        StartupExtender.StartMode.TEST_PROFILE, 
                        StartupExtender.StartMode.TEST_NORMAL, 
                        StartupExtender.StartMode.TEST_DEBUG).contains(mode) || 
                      command.equals(COMMAND_PROFILE_SINGLE));
    if (mode != null) {
        JavaPlatform plaf = ModuleProperties.getJavaPlatform(eval);
        Lookup context = Lookups.fixed(project, plaf != null ? plaf : JavaPlatformManager.getDefault().getDefaultPlatform());
        for (StartupExtender group : StartupExtender.getExtenders(context, mode)) {
            for (String arg : group.getArguments()) {
                runArgsIde.append((isTest | isOsgi) ? "" : "-J").append(arg).append(' ');
            }
        }
    }
    if (runArgsIde.length() > 0) {
        p.setProperty(RUN_ARGS_IDE, runArgsIde.toString());
    }
}
 
Example 43
Project: incubator-netbeans   File: ActivatorIterator.java   Source Code and License 5 votes vote down vote up
@Override
public Set<DataObject> instantiate () throws IOException/*, IllegalStateException*/ {
    // Here is the default plain behavior. Simply takes the selected
    // template (you need to have included the standard second panel
    // in createPanels(), or at least set the properties targetName and
    // targetFolder correctly), instantiates it in the provided
    // position, and returns the result.
    // More advanced wizards can create multiple objects from template
    // (return them all in the result of this method), populate file
    // contents on the fly, etc.
   
    org.openide.filesystems.FileObject dir = Templates.getTargetFolder( wiz );
    DataFolder df = DataFolder.findFolder( dir );
    
    FileObject template = Templates.getTemplate( wiz );
    
    DataObject dTemplate = DataObject.find( template );                
    final DataObject dobj = dTemplate.createFromTemplate( df, Templates.getTargetName( wiz )  );

    //this part might be turned pluggable once we have also ant based osgi projects. if..
    Project project = Templates.getProject( wiz );
    ClassPath cp = ClassPath.getClassPath(dobj.getPrimaryFile(), ClassPath.SOURCE);
    final String path = cp.getResourceName(dobj.getPrimaryFile(), '.', false);

    final NbMavenProject prj = project.getLookup().lookup(NbMavenProject.class);
    if (prj != null) {
        Utilities.performPOMModelOperations(project.getProjectDirectory().getFileObject("pom.xml"),
                Collections.<ModelOperation<POMModel>>singletonList(
                    new ModelOperation<POMModel>() {
            @Override
                       public void performOperation(POMModel model) {
                           addActivator(prj, model, path);
                       }
                }
        ));
    }

    return Collections.singleton(dobj);
}
 
Example 44
Project: incubator-netbeans   File: SourcesNodeModel.java   Source Code and License 5 votes vote down vote up
private void computePathWithProject(final Object o) {
    rp.post(new Runnable() {
        @Override
        public void run() {
            String dn;
            File f = new File ((String) o);
            if (f.exists ()) {
                FileObject fo = FileUtil.toFileObject (f);
                Project p = FileOwnerQuery.getOwner (fo);
                if (p != null) {
                    ProjectInformation pi = (ProjectInformation) ProjectUtils.getInformation(p);
                    if (pi != null) {
                        dn = NbBundle.getMessage(SourcesNodeModel.class, "CTL_SourcesModel_Column_Name_ProjectSources",
                                                 f.getPath(), pi.getDisplayName());
                    } else {
                        dn = NbBundle.getMessage(SourcesNodeModel.class, "CTL_SourcesModel_Column_Name_LibrarySources",
                                                 f.getPath());
                    }
                } else {
                    dn = NbBundle.getMessage(SourcesNodeModel.class, "CTL_SourcesModel_Column_Name_LibrarySources",
                                             f.getPath());
                }
            } else {
                dn = (String) o;
            }
            synchronized (pathWithProject) {
                pathWithProject.put(o, dn);
            }
            fireNodeChanged(o);
        }
    });
}
 
Example 45
Project: incubator-netbeans   File: AntArtifactQuery.java   Source Code and License 5 votes vote down vote up
/**
 * Try to find a particular build artifact according to the Ant target producing it.
 * @param p a project (should have {@link AntArtifactProvider} in lookup
 *          in order for this query to work)
 * @param id a desired {@link AntArtifact#getID ID}
 * @return an artifact produced by that project with the specified target,
 *         or null if none such can be found
 */
public static AntArtifact findArtifactByID(Project p, String id) {
    AntArtifactProvider prov = p.getLookup().lookup(AntArtifactProvider.class);
    if (prov == null) {
        return null;
    }
    for (AntArtifact artifact : prov.getBuildArtifacts()) {
        if (artifact.getID().equals(id)) {
            return artifact;
        }
    }
    return null;
}
 
Example 46
Project: incubator-netbeans   File: ApisupportOutputProcessorFactory.java   Source Code and License 5 votes vote down vote up
@Override
public Set<OutputProcessor> createProcessorsSet(Project project) {
    Set<OutputProcessor> toReturn = new HashSet<OutputProcessor>();
    if (project != null) {
        toReturn.add(new IDEOutputListenerProvider(project));
    }
    return toReturn;
}
 
Example 47
Project: incubator-netbeans   File: SetMainProject.java   Source Code and License 5 votes vote down vote up
private void checkProjectNames() {
    for(Component componentIter : subMenu.getMenuComponents()) {
        if(componentIter instanceof JRadioButtonMenuItem) {
            JRadioButtonMenuItem menuItem = (JRadioButtonMenuItem) componentIter;
            Project projectIter = getItemProject(menuItem);
            if(projectIter != null && !ProjectUtils.getInformation(projectIter).getDisplayName().equals(menuItem.getText())) {
                menuItem.setText(ProjectUtils.getInformation(projectIter).getDisplayName());
            }
        }
    }
}
 
Example 48
Project: incubator-netbeans   File: FileProvider.java   Source Code and License 5 votes vote down vote up
/**
 * Adds a file into the result
 * When the file is under processed {@link  SourceGroup} relative path
 * is displayed in the dialog. If the file is not under
 * {@link SourceGroup} absolute path is used. Never add a file owned by
 * other {@link SourceGroup}.
 * @param file The file to be added into result
 */
public void addFile (final FileObject file) {
    Parameters.notNull("file", file);   //NOI18N
    String path = FileUtil.getRelativePath(ctx.getRoot(), file);
    if (path == null) {
        path = FileUtil.getFileDisplayName(file);
    }
    final Project prj = ctx.getProject();
    addFileDescriptor(new FileDescription(file, path, prj));
}
 
Example 49
Project: incubator-netbeans   File: NbMoveRefactoringPlugin.java   Source Code and License 5 votes vote down vote up
private void refactorProjectPropertyFiles(FileObject folder, RefactoringElementsBag refactoringElements) {
    Project project = FileOwnerQuery.getOwner(folder);
    NbModuleProvider moduleProvider = project.getLookup().lookup(NbModuleProvider.class);
    if (moduleProvider == null) {
        // take just netbeans module development into account..
        return;
    }
    
    Sources srcs = org.netbeans.api.project.ProjectUtils.getSources(project);
    SourceGroup[] srcGrps = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
    SourceGroup[] rscGrps = srcs.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_RESOURCES);
    StringBuffer relPath = new StringBuffer();
    String newName = ((RenameRefactoring)refactoring).getNewName().replace('.', '/');
    if(isProjectPropertiesFilePath(srcGrps, folder, relPath) 
        || isProjectPropertiesFilePath(rscGrps, folder, relPath)) {
        refactoringElements.add(refactoring, new ManifestMoveRefactoringElement(moduleProvider.getManifestFile(), 
        relPath.toString().replace('.', '/'), newName));
    }
    
    NbRefactoringProvider refactoringProvider = project.getLookup().lookup(NbRefactoringProvider.class);
    if(refactoringProvider == null) {
        return;
    }
    
    List<NbRefactoringProvider.ProjectFileRefactoring> projectFilesRefactoring = refactoringProvider.getProjectFilesRefactoring(
        new NbRefactoringContext(folder, newName, relPath.toString().replace('.', '/')));
    if(projectFilesRefactoring!=null) {
        for(NbRefactoringProvider.ProjectFileRefactoring projectFileRefIter : projectFilesRefactoring) {
            refactoringElements.add(refactoring, new ProjectFileMoveRefactoringElement(projectFileRefIter));
        }
    }
}
 
Example 50
Project: incubator-netbeans   File: OpenProjectCLITest.java   Source Code and License 5 votes vote down vote up
public void testOpenProjectFolder() throws Exception {
    CommandLine.getDefault().process(new String[] { "--open", dir.getPath() });
    assertNull("No explorer called", MockNodeOperation.explored);

    Project p = OpenProjects.getDefault().getMainProject();
    assertNotNull("There is a main project", p);
    if (!(p instanceof MockProject)) {
        fail("Wrong project: " + p);
    }
    MockProject mp = (MockProject)p;
    
    assertEquals("It is our dir", fo, mp.p);
}
 
Example 51
Project: incubator-netbeans   File: PlatformNode.java   Source Code and License 5 votes vote down vote up
/**
 * Creates new PlatformNode
 * @param eval the PropertyEvaluator used for obtaining the active platform name
 * and listening on the active platform change
 * @param platformPropName the name of ant property holding the platform name
 *
 */
public static PlatformNode create (
        @NonNull final Project project,
        @NonNull final PropertyEvaluator eval,
        @NonNull final Pair<Pair<String,String>, ClassPath> boot,
        @NonNull final ClassPathSupport cs) {
    PlatformProvider pp = new PlatformProvider (project, eval, boot);
    return new PlatformNode (pp, cs);
}
 
Example 52
Project: incubator-netbeans   File: CoverageAction.java   Source Code and License 5 votes vote down vote up
public ContextAction(Lookup lkp, Action configureAction, Action[] extraActions) {
    super(NbBundle.getMessage(CoverageAction.class, "LBL_CodeCoverage"));
    this.configureAction = configureAction;
    this.extraActions = extraActions;

    Collection<? extends Project> apcs = lkp.lookupAll(Project.class);

    if (apcs.size() == 1) {
        project = apcs.iterator().next();
    } else {
        project = null;
    }

    super.setEnabled(project != null);
}
 
Example 53
Project: incubator-netbeans   File: OpenProjectList.java   Source Code and License 5 votes vote down vote up
static boolean isRecommended(@NullAllowed Project project, @NonNull String[] recommendedTypes, @NonNull FileObject primaryFile) {
    if (project != null) {
        return isRecommended(recommendedTypes, primaryFile);
    }

    if (primaryFile.isFolder()) {
        // folders of templates do not require a project for display
        return true;
    }

    Object requireProject = primaryFile.getAttribute("requireProject");
    return Boolean.FALSE.equals(requireProject);
}
 
Example 54
Project: incubator-netbeans   File: NewProjectIterator.java   Source Code and License 5 votes vote down vote up
private static void createProjectZip(OutputStream target, Project source) throws IOException {
    Sources srcs = ProjectUtils.getSources(source); // #63247: don't use lookup directly
    // assuming we got 1-sized array, should be enforced by UI.
    SourceGroup[] grps = srcs.getSourceGroups(Sources.TYPE_GENERIC);
    SourceGroup group = grps[0];
    Collection<FileObject> files = new ArrayList<FileObject>();
    collectFiles(group.getRootFolder(), files,
            SharabilityQuery.getSharability(group.getRootFolder()));
    createZipFile(target, group.getRootFolder(), files);
}
 
Example 55
Project: incubator-netbeans   File: ProjectsRootNode.java   Source Code and License 5 votes vote down vote up
protected final void setProjectFiles() {
    Project prj = getLookup().lookup(Project.class);

    if (prj != null && /* #145682 */ !(prj instanceof LazyProject)) {
        setProjectFiles(prj);
    }
}
 
Example 56
Project: incubator-netbeans   File: FormI18nStringEditor.java   Source Code and License 5 votes vote down vote up
/** Constructor. */
public CustomEditor(I18nString i18nString, Project project, FileObject file) {
    i18nPanel = new I18nPanel(i18nString.getSupport().getPropertyPanel(), false, project, file);
    setLayout(new java.awt.BorderLayout());
    add(i18nPanel);

    i18nPanel.setI18nString(i18nString);

    env.setState(PropertyEnv.STATE_NEEDS_VALIDATION);
    env.addVetoableChangeListener(this);

    HelpCtx.setHelpIDString(this, I18nUtil.HELP_ID_FORMED);
}
 
Example 57
Project: incubator-netbeans   File: ClassPathProviderImpl.java   Source Code and License 5 votes vote down vote up
@CheckForNull
private ClassPath getBootClassPath(@NonNull final FileObject artefact) {
    int type = getType(artefact);
    switch (type) {
        case -1:
            //Some old code rely on the existence of BootCP on any project file, mainly project folder.
            //For compatibily reasons simulate this behavior even it's not correct.
            //Cannot be done for multi module project, but there are no compatibility reasons as it's new.
            final Project prj = getProject();
            if (prj != null && prj.equals(FileOwnerQuery.getOwner(artefact))) {
                type = 0;
                break;
            } else {
                return null;
            }
        case 0:
        case 2:
        case 4:
            type = 0;
            break;
        case 1:
        case 3:
            type = 1;
            break;
        default:
            throw new IllegalArgumentException(Integer.toString(type));
    }
    return this.getBootClassPath(type);
}
 
Example 58
Project: NBANDROID-V2   File: TestLaunchAction.java   Source Code and License 5 votes vote down vote up
public TestRunListener(final Project project) {
    Preconditions.checkNotNull(project);
    delegates = Lists.newArrayList(Iterables.concat(
            Collections.singleton(simpleLsnr),
            Iterables.transform(
                    project.getLookup().lookupAll(TestOutputConsumer.class),
                    new Function<TestOutputConsumer, ITestRunListener>() {

                @Override
                public ITestRunListener apply(TestOutputConsumer input) {
                    return input.createTestListener(project);
                }
            })));
    LOG.log(Level.FINE, "Sending test output to {0}", Iterables.toString(delegates));
}
 
Example 59
Project: incubator-netbeans   File: CoverageProviderHelper.java   Source Code and License 5 votes vote down vote up
public static boolean isEnabled(Project project) {
    AuxiliaryConfiguration config = ProjectUtils.getAuxiliaryConfiguration(project);
    Element configurationFragment = config.getConfigurationFragment("coverage", COVERAGE_NAMESPACE_URI, false); // NOI18N
    if (configurationFragment == null) {
        return false;
    }
    return configurationFragment.getAttribute("enabled").equals("true"); // NOI18N
}
 
Example 60
Project: incubator-netbeans   File: ProfilesAnalyzer.java   Source Code and License 5 votes vote down vote up
@NbBundle.Messages ({
    "MSG_ProjectHigherProfile=Project requires profile: {0}",
    "DESC_ProjectHigherProfile=The project {0} located in {1} requires profile: {2}",
})
private static void verifySubProjects(
    @NonNull final Collection<? extends Project> projectRefs,
    @NonNull final Project owner,
    @NonNull final SourceLevelQuery.Profile profile,
    @NonNull final Result result) {
    for (Project p : projectRefs) {
        final FileObject pHome = p.getProjectDirectory();
        final SourceLevelQuery.Profile pProfile = SourceLevelQuery.getSourceLevel2(pHome).getProfile();
        if (pProfile.compareTo(profile) > 0) {
            result.reportError(owner, ErrorDescriptionFactory.createErrorDescription(
                    null,
                    Severity.ERROR,
                    Bundle.MSG_ProjectHigherProfile(pProfile.getDisplayName()),
                    Bundle.DESC_ProjectHigherProfile(
                        ProjectUtils.getInformation(p).getDisplayName(),
                        FileUtil.getFileDisplayName(pHome),
                        profile.getDisplayName()),
                    ErrorDescriptionFactory.lazyListForFixes(Collections.<Fix>emptyList()),
                    p.getProjectDirectory(),
                    null));
        }
    }
}