當前位置: 首頁>>代碼示例>>Java>>正文


Java Project.getProjectDirectory方法代碼示例

本文整理匯總了Java中org.netbeans.api.project.Project.getProjectDirectory方法的典型用法代碼示例。如果您正苦於以下問題:Java Project.getProjectDirectory方法的具體用法?Java Project.getProjectDirectory怎麽用?Java Project.getProjectDirectory使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.netbeans.api.project.Project的用法示例。


在下文中一共展示了Project.getProjectDirectory方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: updateProjectProperties

import org.netbeans.api.project.Project; //導入方法依賴的package包/類
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);
            }
        }
    });
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:JUnitProjectOpenedHook.java

示例2: getIndex

import org.netbeans.api.project.Project; //導入方法依賴的package包/類
private int getIndex( Project p ) {
    if (p == null || p.getProjectDirectory() == null) {
        return -1;
    }
    URL pURL = p.getProjectDirectory().toURL();
    
    int i = 0;
    
    for (ProjectReference pRef : recentProjects) {
        URL p2URL = pRef.getURL();
        if ( pURL.equals( p2URL ) ) {
            return i;
        } else {
            i++;
        }
    }
    
    return -1;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:20,代碼來源:OpenProjectList.java

示例3: findProjectCacheRelative

import org.netbeans.api.project.Project; //導入方法依賴的package包/類
private static String findProjectCacheRelative(Project p) throws IOException {
    FileObject projectDirFO = p.getProjectDirectory();
    CacheDirectoryProvider cdp = p.getLookup().lookup(CacheDirectoryProvider.class);
    FileObject cacheFO = null;
    
    if (cdp == null || (cacheFO = cdp.getCacheDirectory()) == null) {
        return null;
    }
    if (FileUtil.isParentOf(projectDirFO, cacheFO)) {
        return FileUtil.getRelativePath(projectDirFO, cacheFO);
    } else {
        String s = cacheFO.toURI().toString();
        // strip the trailing / marking a directory
        return s.substring(0, s.length() - 1);
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:Util.java

示例4: testFirstGenSrcAddedDynamically

import org.netbeans.api.project.Project; //導入方法依賴的package包/類
public void testFirstGenSrcAddedDynamically() throws Exception {
    Project p = createTestProject(false);
    FileObject d = p.getProjectDirectory();
    FileObject src = d.getFileObject("src");
    URL classes = new URL(d.toURL(), "build/classes/");
    URL distJar = FileUtil.getArchiveRoot(BaseUtilities.toURI(FileUtil.normalizeFile(
            new File(FileUtil.toFile(d), "dist/x.jar".replace('/', File.separatorChar)))).toURL()); //NOI18N
    ClassPath sourcePath = ClassPath.getClassPath(src, ClassPath.SOURCE);
    assertEquals(Arrays.asList(src), Arrays.asList(sourcePath.getRoots()));
    assertEquals(Arrays.asList(src), Arrays.asList(SourceForBinaryQuery.findSourceRoots(classes).getRoots()));
    // now add the first gensrc root:
    FileObject stuff = FileUtil.createFolder(d, "build/generated-sources/stuff");
    FileObject xgen = FileUtil.createData(stuff, "net/nowhere/XGen.java");
    assertEquals(Arrays.asList(src, stuff), Arrays.asList(sourcePath.getRoots()));
    assertEquals(ClassPath.getClassPath(src, ClassPath.COMPILE), ClassPath.getClassPath(stuff, ClassPath.COMPILE));
    assertEquals(Arrays.asList(src, stuff), Arrays.asList(SourceForBinaryQuery.findSourceRoots(classes).getRoots()));
    assertEquals(Arrays.asList(classes, distJar), Arrays.asList(BinaryForSourceQuery.findBinaryRoots(stuff.toURL()).getRoots()));
    FileBuiltQuery.Status status = FileBuiltQuery.getStatus(xgen);
    assertNotNull(status);
    assertFalse(status.isBuilt());
    FileUtil.createData(d, "build/classes/net/nowhere/XGen.class");
    assertTrue(status.isBuilt());
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:GeneratedSourceRootTest.java

示例5: testSourceRoots

import org.netbeans.api.project.Project; //導入方法依賴的package包/類
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()));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:26,代碼來源:GeneratedSourceRootTest.java

示例6: testProjectPropertiesSetUp

import org.netbeans.api.project.Project; //導入方法依賴的package包/類
public void testProjectPropertiesSetUp() throws Exception {
    assertNotNull(project);
    jfxprops = JFXProjectProperties.getInstance(project.getLookup());
    assertNotNull(jfxprops);
    Project verify = jfxprops.getProject();
    assertNotNull(verify);
    FileObject projectDir = verify.getProjectDirectory();
    assertNotNull(projectDir);
    CONFIGS = jfxprops.getConfigs();
    assertNotNull(CONFIGS);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:12,代碼來源:JFXConfigsTest.java

示例7: getOpenProjectsDirectories

import org.netbeans.api.project.Project; //導入方法依賴的package包/類
@Override
public FileObject[] getOpenProjectsDirectories() {
    Project[] openProjects = OpenProjects.getDefault().getOpenProjects();
    if (openProjects.length == 0) {
        return null;
    }
    FileObject[] directories = new FileObject[openProjects.length];
    for (int i = 0; i < openProjects.length; i++) {
        Project project = openProjects[i];
        directories[i] = project.getProjectDirectory();
    }
    return directories;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:ProjectServicesImpl.java

示例8: getProjectDirectory

import org.netbeans.api.project.Project; //導入方法依賴的package包/類
/**
 * Get the project directory of the given project.
 *
 * @param project
 * @return
 */
private String getProjectDirectory(final Project project) {
    try {
        FileObject projectDirectory = project.getProjectDirectory();
        return getNativePath(projectDirectory);
    } catch (Exception e) {
        Logger.getLogger(CopyPathToClipboardAction.class.getName()).log(
                Level.FINE, null, e);
        return null;
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:17,代碼來源:CopyPathToClipboardAction.java

示例9: getProjectFile

import org.netbeans.api.project.Project; //導入方法依賴的package包/類
/**
 * Returns the {@link Project} {@link File} for the given {@link Project}
 * 
 * @param project
 * @return 
 */
public static File getProjectFile(Project project){
    if (project == null) return null;

    FileObject fo = project.getProjectDirectory();
    return  FileUtil.toFile(fo);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:13,代碼來源:Utils.java

示例10: copyBuildScript

import org.netbeans.api.project.Project; //導入方法依賴的package包/類
@NonNull
static FileObject copyBuildScript (@NonNull final Project project) throws IOException {
    final FileObject projDir = project.getProjectDirectory();
    FileObject rpBuildScript = projDir.getFileObject(BUILD_SCRIPT_PATH);
    if (rpBuildScript != null && !isBuildScriptUpToDate(project)) {
        // try to close the file just in case the file is already opened in editor
        DataObject dobj = DataObject.find(rpBuildScript);
        CloseCookie closeCookie = dobj.getLookup().lookup(CloseCookie.class);
        if (closeCookie != null) {
            closeCookie.close();
        }
        final FileObject nbproject = projDir.getFileObject("nbproject");                    //NOI18N
        final FileObject backupFile = nbproject.getFileObject(BUILD_SCRIPT_BACK_UP, "xml"); //NOI18N
        if (backupFile != null) {
            backupFile.delete();
        }
        FileUtil.moveFile(rpBuildScript, nbproject, BUILD_SCRIPT_BACK_UP);
        rpBuildScript = null;
    }
    if (rpBuildScript == null) {
        if (LOG.isLoggable(Level.FINE)) {
            LOG.log(
                Level.FINE,
                "Updating remote build script in project {0} ({1})", //NOI18N
                new Object[]{
                    ProjectUtils.getInformation(project).getDisplayName(),
                    FileUtil.getFileDisplayName(projDir)
                });
        }
        rpBuildScript = FileUtil.createData(project.getProjectDirectory(), BUILD_SCRIPT_PATH);
        try(
            final InputStream in = new BufferedInputStream(RemotePlatformProjectSaver.class.getResourceAsStream(BUILD_SCRIPT_PROTOTYPE));
            final OutputStream out = new BufferedOutputStream(rpBuildScript.getOutputStream())) {
            FileUtil.copy(in, out);
        }
    }
    return rpBuildScript;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:39,代碼來源:Utilities.java

示例11: createDefaultProjectSearchInfo

import org.netbeans.api.project.Project; //導入方法依賴的package包/類
/**
 * Create default search info for a project.
 */
static SearchInfo createDefaultProjectSearchInfo(Project project) {
    Sources sources = ProjectUtils.getSources(project);
    SourceGroup[] sourceGroups = sources.getSourceGroups(
            Sources.TYPE_GENERIC);

    FileObject base = project.getProjectDirectory();
    List<FileObject> roots = new ArrayList<FileObject>();
    if (base != null) {
        roots.add(base);
    }
    for (SourceGroup sg : sourceGroups) {
        FileObject dir = sg.getRootFolder();
        if (dir != null && (base == null || !isUnderBase(base, dir))) {
            roots.add(dir);
        }
    }
    FileObject[] rootArray = new FileObject[roots.size()];
    for (int i = 0; i < roots.size(); i++) {
        rootArray[i] = roots.get(i);
    }
    SubTreeSearchOptions stso =
            project.getLookup().lookup(SubTreeSearchOptions.class);
    if (stso == null) {
        return SearchInfoUtils.createSearchInfoForRoots(rootArray);
    } else {
        return SearchInfoUtils.createSearchInfoForRoots(rootArray, false,
                SearchInfoHelper.subTreeFilters(stso));
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:33,代碼來源:AbstractProjectSearchScope.java

示例12: createConfigurationFiles

import org.netbeans.api.project.Project; //導入方法依賴的package包/類
/**
 * Creates property files for run configuration and writes passed properties.
 * Shared properties are written to nbproject/configs folder and private properties
 * are written to nbproject/private/configs folder. The property file is not created
 * if null is passed for either shared or private properties.
 * 
 * @param prj project under which property files will be created
 * @param configName name of the config file, '.properties' is apended
 * @param sharedProps properties to be written to shared file; is allowed to
 *        contain special purpose properties starting with $ (e.g. $label)
 * @param privateProps properties to be written to private file
 * @since 1.29
 */
public static void createConfigurationFiles(Project prj, String configName, 
        final EditableProperties sharedProps, final EditableProperties privateProps) throws IOException, IllegalArgumentException {
    
    if (prj == null || configName == null || "".equals(configName)) {
        throw new IllegalArgumentException();
    }
    
    final String configFileName = configName + ".properties"; // NOI18N
    final FileObject prjDir = prj.getProjectDirectory();
    
    try {
        ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
            public Void run() throws IOException {
                prjDir.getFileSystem().runAtomicAction(new FileSystem.AtomicAction() {
                    public void run() throws IOException {
                        generateConfig(prjDir, "nbproject/configs/" + configFileName, sharedProps); // NOI18N
                        generateConfig(prjDir, "nbproject/private/configs/" + configFileName, privateProps); // NOI18N
                    }
                });
                return null;
            }
        });
    } catch (MutexException ex) {
        throw (IOException) ex.getException();
    }
    
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:41,代碼來源:J2SEProjectConfigurations.java

示例13: getPathNameSeparator

import org.netbeans.api.project.Project; //導入方法依賴的package包/類
private static char getPathNameSeparator(@NullAllowed Project project, @NonNull SourceGroup[] folders) {
    FileObject fo = null;
    if (folders != null && folders.length > 0) {
        fo = folders[0].getRootFolder();
    } else if (project != null) {
        fo = project.getProjectDirectory();
    }
    String separator = null;
    if (fo != null) {
        separator = (String) fo.getAttribute(FileObject.DEFAULT_PATHNAME_SEPARATOR_ATTR);
    }
    return (separator == null || separator.isEmpty()) ? File.separatorChar : separator.charAt(0);
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:14,代碼來源:SimpleTargetChooserPanelGUI.java

示例14: contains

import org.netbeans.api.project.Project; //導入方法依賴的package包/類
@Override public boolean contains(FileObject file) {
    if (file == loc) {
        return true;
    }
    String path = FileUtil.getRelativePath(loc, file);
    if (path == null) {
        return false;
    }
    if (file.isFolder()) {
        path += "/"; // NOI18N
    }
    if (!computeIncludeExcludePatterns().matches(path, true)) {
        return false;
    }
    Project p = getProject();
    if (file.isFolder() &&
            file != p.getProjectDirectory() &&
            ProjectManager.getDefault().isProject(file) &&
            !ProjectConvertors.isConvertorProject(FileOwnerQuery.getOwner(file))) {
        // #67450: avoid actually loading the nested project.
        return false;
    }
    if (!(SourceRoot.this instanceof TypedSourceRoot)) {
        // XXX disabled for typed source roots; difficult to make fast (#97215)
        Project owner = FileOwnerQuery.getOwner(file);
        if (owner != null &&
                owner != p &&
                !ProjectConvertors.isConvertorProject(owner)) {
            return false;
        }
        if (SharabilityQuery.getSharability(file) == SharabilityQuery.Sharability.NOT_SHARABLE) {
            return false;
        } // else MIXED, UNKNOWN, or SHARABLE
    }
    return true;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:37,代碼來源:SourcesHelper.java

示例15: copyJnlpImplTemplate

import org.netbeans.api.project.Project; //導入方法依賴的package包/類
public static boolean copyJnlpImplTemplate(Project proj) throws IOException {
    boolean res = false;
    final FileObject projDir = proj.getProjectDirectory();
    FileObject jnlpBuildFile = projDir.getFileObject(JNLP_BUILD_IMPL_PATH);
    if (jnlpBuildFile != null && !isJnlpImplUpToDate(proj)) {
        // try to close the file just in case the file is already opened in editor
        DataObject dobj = DataObject.find(jnlpBuildFile);
        CloseCookie closeCookie = dobj.getLookup().lookup(CloseCookie.class);
        if (closeCookie != null) {
            closeCookie.close();
        }
        final FileObject nbproject = projDir.getFileObject("nbproject");                    //NOI18N
        final FileObject backupFile = nbproject.getFileObject("jnlp-impl_backup", "xml");   //NOI18N
        if (backupFile != null) {
            backupFile.delete();
        }
        FileUtil.moveFile(jnlpBuildFile, nbproject, "jnlp-impl_backup");                    //NOI18N
        jnlpBuildFile = null;
    }
    if (jnlpBuildFile == null) {
        FileObject templateFO = FileUtil.getConfigFile(BUILD_TEMPLATE);
        if (templateFO != null) {
            FileUtil.copyFile(templateFO, projDir.getFileObject("nbproject"), "jnlp-impl"); // NOI18N
        }
        res = true;
    }
    return res;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:29,代碼來源:JWSProjectPropertiesUtils.java


注:本文中的org.netbeans.api.project.Project.getProjectDirectory方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。