Package org.openide.filesystems

Examples of org.openide.filesystems.FileObject


                    final SourceGroup[] sourceGroups = sources.getSourceGroups(Sources.TYPE_GENERIC);
                    final SourceGroup[] javaGroups = sources.getSourceGroups(JavaProjectConstants.SOURCES_TYPE_JAVA);
                    final SourceGroup[] groups = new SourceGroup [sourceGroups.length + javaGroups.length];
                    System.arraycopy(sourceGroups,0,groups,0,sourceGroups.length);
                    System.arraycopy(javaGroups,0,groups,sourceGroups.length,javaGroups.length);
                    final FileObject projectDirectory = p.getProjectDirectory();
                    final FileObject fileObject = FileUtil.toFileObject(normalizedFile);
                    if (projectDirectory == null || fileObject == null) {
                        rootsFromOtherProjects.add (normalizedFile);
                        continue;
                    }
                    for (int j=0; j<groups.length; j++) {
                        final FileObject sgRoot = groups[j].getRootFolder();
                        if (fileObject.equals(sgRoot)) {
                            rootsFromOtherProjects.add (normalizedFile);
                            continue out;
                        }
                        if (!projectDirectory.equals(sgRoot) && FileUtil.isParentOf(sgRoot, fileObject)) {
View Full Code Here


    public void save() {
        try {
            if ((genFileHelper.getBuildScriptState(GeneratedFilesHelper.BUILD_IMPL_XML_PATH,J2SEProject.class.getResource("resources/build-impl.xsl")) //NOI18N
                & GeneratedFilesHelper.FLAG_MODIFIED) == GeneratedFilesHelper.FLAG_MODIFIED) {  //NOI18N
                //Back up build-impl.xml
                final FileObject projectDir = updateHelper.getAntProjectHelper().getProjectDirectory();
                final FileObject buildImpl = projectDir.getFileObject(GeneratedFilesHelper.BUILD_IMPL_XML_PATH);
                if (buildImpl  != null) {
                    final String name = buildImpl.getName();
                    final String backupext = String.format("%s~",buildImpl.getExt());   //NOI18N
                    final FileObject oldBackup = buildImpl.getParent().getFileObject(name, backupext);
                    if (oldBackup != null) {
                        oldBackup.delete();
                    }
                    FileLock lock = buildImpl.lock();
                    try {
                        buildImpl.rename(lock, name, backupext);
                    } finally {
                        lock.releaseLock();
                    }
                }
            }
            saveLibrariesLocation();
            // Store properties
            ProjectManager.mutex().writeAccess(new Mutex.ExceptionAction<Void>() {
                public Void run() throws IOException {
                    storeProperties();
                    //Delete COS mark
                    if (!COMPILE_ON_SAVE_MODEL.isSelected()) {
                        FileObject buildClasses = updateHelper.getAntProjectHelper().resolveFileObject(evaluator.getProperty(ProjectProperties.BUILD_CLASSES_DIR));
                        if (buildClasses != null) {
                            FileObject mark = buildClasses.getFileObject(COS_MARK);
                            if (mark != null) {
                                final ActionProvider ap = project.getLookup().lookup(ActionProvider.class);
                                assert ap != null;
                                ap.invokeAction(ActionProvider.COMMAND_CLEAN, Lookups.fixed(project));
                            }
View Full Code Here

            if (v != null) {
                def.put(prop, v);
            }
        }
        m.put(null, def);
        FileObject configs = project.getProjectDirectory().getFileObject("nbproject/configs");
        if (configs != null) {
            for (FileObject kid : configs.getChildren()) {
                if (!kid.hasExt("properties")) {
                    continue;
                }
                m.put(kid.getName(), new TreeMap<String,String>(updateHelper.getProperties(FileUtil.getRelativePath(project.getProjectDirectory(), kid))));
            }
        }
        configs = project.getProjectDirectory().getFileObject("nbproject/private/configs");
        if (configs != null) {
            for (FileObject kid : configs.getChildren()) {
                if (!kid.hasExt("properties")) {
                    continue;
                }
                Map<String,String> c = m.get(kid.getName());
                if (c == null) {
View Full Code Here

        sourceRoots.setModel( uiProperties.SOURCE_ROOTS_MODEL );
        testRoots.setModel( uiProperties.TEST_ROOTS_MODEL );
        sourceRoots.getTableHeader().setReorderingAllowed(false);
        testRoots.getTableHeader().setReorderingAllowed(false);                       
       
        FileObject projectFolder = uiProperties.getProject().getProjectDirectory();
        File pf = FileUtil.toFile( projectFolder );
        this.projectLocation.setText( pf == null ? "" : pf.getPath() ); // NOI18N
       
       
        J2SESourceRootsUi.EditMediator emSR = J2SESourceRootsUi.registerEditMediator(
View Full Code Here

            return null;
        }
       
        try {           
            File normProjectDir = FileUtil.normalizeFile(projectDir);
            FileObject fo = FileUtil.toFileObject(normProjectDir);
            if (fo != null) {
                return ProjectManager.getDefault().findProject(fo);
            }
        } catch (IOException e) {
            ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
View Full Code Here

        chooser.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage (AntArtifactChooser.class,"AD_AACH_SelectProject"));
        AntArtifactChooser accessory = new AntArtifactChooser( artifactTypes, chooser );
        chooser.setAccessory( accessory );
        chooser.setPreferredSize( new Dimension( 650, 380 ) );       
        File defaultFolder = null;
        FileObject defFo = master.getProjectDirectory();
        if (defFo != null) {
            defFo = defFo.getParent();
            if (defFo != null) {
                defaultFolder = FileUtil.toFile(defFo);
            }
        }
        chooser.setCurrentDirectory (FoldersListSettings.getDefault().getLastUsedArtifactFolder(defaultFolder));
View Full Code Here

        int returnFile = chooser.showOpenDialog(null);

        if (returnFile == JFileChooser.APPROVE_OPTION) {
            File file = chooser.getSelectedFile();
            file = FileUtil.normalizeFile(file);
            FileObject fileObject = FileUtil.toFileObject(file);

            //Save last path
            NbPreferences.forModule(ProjectControllerUIImpl.class).put(LAST_PATH, file.getAbsolutePath());

            if (fileObject.getExt().equalsIgnoreCase("gephi")) {
                //Project
                if (controller.getCurrentProject() != null) {
                    if (!closeCurrentProject()) {
                        return;
                    }
View Full Code Here

            presets.set(exist, preset);
        }

        try {
            //Create file if dont exist
            FileObject folder = FileUtil.getConfigFile("previewpresets");
            if (folder == null) {
                folder = FileUtil.getConfigRoot().createFolder("previewpresets");
            }
            FileObject presetFile = folder.getFileObject(preset.getName(), "xml");
            if (presetFile == null) {
                presetFile = folder.createData(preset.getName(), "xml");
            }

            //Create doc
View Full Code Here

        }
        return presets.toArray(new PreviewPreset[0]);
    }

    private void loadPresets() {
        FileObject folder = FileUtil.getConfigFile("previewpresets");
        if (folder != null) {
            for (FileObject child : folder.getChildren()) {
                if (child.isValid() && child.hasExt("xml")) {
                    try {
                        InputStream stream = child.getInputStream();
                        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
                        DocumentBuilder builder = factory.newDocumentBuilder();
View Full Code Here

  }

  DataObject dataObject = activeTC.getLookup().lookup(DataObject.class);
  Project project = activeTC.getLookup().lookup(Project.class);
  Node node = activeTC.getLookup().lookup(Node.class);
  FileObject fileObject = activeTC.getLookup().lookup(FileObject.class);
  //                showInStatusBar(project);

  String projectName = null;
  String projectDir = null;
  String fileName = null;
  if (null != project) {
      projectName = getProjectName(project);
      projectDir = getProjectDirectory(project);
  }

  if (null != dataObject || null != fileObject) {

      final FileObject primaryFile;
      if (null != dataObject) {
    primaryFile = getFileObjectWithShadowSupport(dataObject);
      } else {
    primaryFile = fileObject;
      }
      projectDir = getProjectDirectory(primaryFile);
      projectName = getProjectName(primaryFile);


      if (null != primaryFile.getPath()) {
    fileName = primaryFile.getPath();
      }

      //support selected items in jars
      if (null != FileUtil.getArchiveFile(primaryFile)) {
    String fullJARPath = FileUtil.getArchiveFile(primaryFile).getPath();
    String archiveFileName = primaryFile.getPath();
    boolean hasFileName = null != archiveFileName && !"".equals(archiveFileName);
    if (hasFileName) {
        fileName = fullJARPath + "/" + archiveFileName;
    } else {
        fileName = fullJARPath;
View Full Code Here

TOP

Related Classes of org.openide.filesystems.FileObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.