Package org.openide.filesystems

Examples of org.openide.filesystems.FileObject


  }
    }

    private String getProjectDirectory(final Project project) {
  try {
      FileObject projectDirectory = project.getProjectDirectory();
      return projectDirectory.getPath();
  } catch (Exception e) {
      //ignore the exception
      return null;
  }
    }
View Full Code Here


        return (packageLookup.allInstances().isEmpty()) ? null : packageLookup.allInstances().iterator().next();
    }

    public static boolean containsPackage(ClassPath classPath, String fullPackageName) {
        for (FileObject cpRoot : classPath.getRoots()) {
            FileObject fo = FileObjectUtils.getPackageFileObject(cpRoot, fullPackageName);
            if (fo != null) {
                return true;
            }
        }
        return false;
View Full Code Here

        return false;
    }

    public static FileObject getPackageFileObject(final ClassPath classPath, final String fullPackageName) {
        for (FileObject root : classPath.getRoots()) {
            FileObject fo = getPackageFileObject(root, fullPackageName);
            if (fo != null) {
                return fo;
            }
        }
        return null;
View Full Code Here

    public static Collection<FileObject> getFiles(final FileObject rootDir, final boolean recursive, final FileType... types) {
        assert rootDir != null && rootDir.isFolder() && !ArrayUtils.contains(types, FileType.OTHER);
        Collection<FileObject> fileObjects = new ArrayList<FileObject>();
        Enumeration<FileObject> entries = (Enumeration<FileObject>) rootDir.getChildren(recursive);
        while (entries.hasMoreElements()) {
            FileObject curr = entries.nextElement();
            if (curr.isData()) {
                FileType t = FileType.parse(curr.getExt());
                if (ArrayUtils.isEmpty(types) || ArrayUtils.contains(types, t)) {
                    fileObjects.add(curr);
                }
            }
        }
View Full Code Here

        BasicPomInfo basicPomInfo = getBasicPomInfo(getShortProjectKey());
        Model model = new MvnModelFactory().createModel(parentProject);
        if (model.getGroupId().equals(basicPomInfo.getGroupId()) && model.getArtifactId().equals(basicPomInfo.getArtifactId())) {
            return parentProject;
        }
        FileObject mavenDir = findMvnDir(model, basicPomInfo, model.getGroupId());
        if (mavenDir != null) {
            return FileOwnerQuery.getOwner(mavenDir);
        } else {
            return null;
        }
View Full Code Here

    }
   
    private static FileObject findMvnDir(Model model, BasicPomInfo basicPomInfo, String groupId)throws MvnModelInputException {
        MvnModelFactory factory = new MvnModelFactory();
        for (String module : model.getModules()) {
            FileObject moduleFile = FileUtil.toFileObject(new File(model.getProjectDirectory(), module));
            Model m = factory.createModel(moduleFile);
            String tmpGroupId = m.getGroupId() == null ? groupId : m.getGroupId();
            if (tmpGroupId.equals(basicPomInfo.getGroupId()) && m.getArtifactId().equals(basicPomInfo.getArtifactId())) {
                return moduleFile;
            } else {
                FileObject o = findMvnDir(m, basicPomInfo, tmpGroupId);
                if (o != null) {
                    return o;
                }
            }
        }
View Full Code Here

    }

    private void openIssueLocation(IssueLocation issueLocation) throws MvnModelInputException {
        int lineNumber = issueLocation.getLineNumber() <= 0 ? 1 : issueLocation.getLineNumber();
        File file = issueLocation.getFile(projectContext.getProject());
        FileObject fobj = FileUtil.toFileObject(file);
        if (fobj == null) {
            String messageTitle = org.openide.util.NbBundle.getMessage(SonarIssuesTopComponent.class, "SonarIssuesTopComponent.unexistentFile.title");
            String message = MessageFormat.format(org.openide.util.NbBundle.getMessage(SonarIssuesTopComponent.class, "SonarIssuesTopComponent.unexistentFile.text"), file.getPath());
            JOptionPane.showMessageDialog(WindowManager.getDefault().getMainWindow(), message, messageTitle, JOptionPane.WARNING_MESSAGE);
            return;
View Full Code Here

    public Model createModel(Project project) throws MvnModelInputException{
        return createModel(project.getProjectDirectory());
    }
   
    public Model createModel(FileObject projectDir) throws MvnModelInputException {
        FileObject pomFile = projectDir.getFileObject("pom.xml");
        MavenXpp3Reader mavenreader = new MavenXpp3Reader();
        try(Reader reader=new InputStreamReader(pomFile.getInputStream())){
            Model model = mavenreader.read(reader);
            model.setPomFile(new File(pomFile.getPath()));
            return model;
        }catch(XmlPullParserException | IOException ex) {
            throw new MvnModelInputException(ex);
        }
    }
View Full Code Here

            String s = f.getPath();
            if (s == null || s.equalsIgnoreCase("") || f.isDirectory() || !f.isFile()) {
                throw new IOException();
            }
        } catch (IOException ex) {
            FileObject tmpFo = FileUtil.toFileObject(new JFileChooser().getCurrentDirectory());
            int i = 0;
            StringBuilder s = new StringBuilder();
            FileObject sqlFo = null;
            for (;;) {
                //String nameFmt = NbBundle.getMessage(SQLEditorProviderImpl.class, "LBL_SQLCommandFileName");
                //String name = MessageFormat.format(nameFmt, new Object[]{new Integer(i)});
                try {
                    s.setLength(0);
View Full Code Here

    public void edit() {
        File selFile = returnLocalFile();
        if (selFile == null) {
            return;
        }
        FileObject file;
        DataObject dob;
        try {
            FileWriter fw = new FileWriter(selFile);
            OracleConnection conn = ou.getConn();
            this.LoadObjectSource(conn);
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.