Package org.openide.filesystems

Examples of org.openide.filesystems.FileObject


     * @param  webModule the web module to return the templates for.
     *
     * @return full paths to privileged templates, e.g. <samp>Templates/Other/XmlFile.xml</samp>; never null.
     */
    public String[] getPrivilegedTemplates(WebModule mod) {
        FileObject fo = mod.getWebInf();
        Project proj = FileOwnerQuery.getOwner(fo);
       
        if (sp.isInWebModule(mod)) {  // NOI18N
            return new String[] {
                "Templates/SIP_Servlet/SipServlet.java",        // NOI18N
View Full Code Here


    static final String PROJECT_CONFIGURATION_NAMESPACE = "http://www.netbeans.org/ns/web-project/3";    //NOI18N
    static final String JSPC_CLASSPATH = "jspc.classpath";

    static FileObject createProjectFromTemplate(final FileObject template, File projectLocation, final String name) throws IOException {
        assert template != null && projectLocation != null && name != null;
        FileObject prjLoc = FileUtil.createFolder(projectLocation);
        if (template.getExt().endsWith("zip")) {  //NOI18N
            unzip(template.getInputStream(), prjLoc);
            // update project.xml
            try {
                File projXml = FileUtil.toFile(prjLoc.getFileObject(AntProjectHelper.PROJECT_XML_PATH));
                Document doc = XMLUtil.parse(new InputSource(projXml.toURI().toString()), false, true, null, null);
                NodeList nlist = doc.getElementsByTagNameNS(PROJECT_CONFIGURATION_NAMESPACE, "name");       //NOI18N
                if (nlist != null) {
                    for (int i=0; i < nlist.getLength(); i++) {
                        Node n = nlist.item(i);
                        if (n.getNodeType() != Node.ELEMENT_NODE) {
                            continue;
                        }
                        Element e = (Element)n;
                       
                        replaceText(e, name);
                    }
                    saveXml(doc, prjLoc, AntProjectHelper.PROJECT_XML_PATH);
                }
                // clean up the project.properties, too.
                FileObject projPropsFO = prjLoc.getFileObject(AntProjectHelper.PROJECT_PROPERTIES_PATH);
                if (null != projPropsFO) {
                    java.util.Properties p = new java.util.Properties();
                    InputStream in = projPropsFO.getInputStream();
                    OutputStream out = null;
                    try {                       
                        p.load(in);

                        // this is a hack
                        // make sure these two keys match keys in the sip-app
                        // template's project.properties file....
                        //
                        p.setProperty("war.name", name+".war");
                        p.setProperty("war.ear.name", name+".war");
                        in.close();
                        out = projPropsFO.getOutputStream();
                        p.store(out, "Altered war.name property");
                    } catch (java.io.IOException ioe) {
                        // this might be a read or a write
                        Logger.getLogger(ProjectGenerator.class.getName()).log(Level.FINER,
                            null, ioe);
View Full Code Here

            ZipEntry ent;
            while ((ent = zip.getNextEntry()) != null) {
                if (ent.isDirectory()) {
                    FileUtil.createFolder(targetFolder, ent.getName());
                } else {
                    final FileObject destFile = FileUtil.createData(targetFolder,ent.getName());
                    final FileLock lock = destFile.lock();
                    try {
                        final OutputStream out = destFile.getOutputStream(lock);
                        try {
                            FileUtil.copy(zip, out);
                        } finally {
                            out.close();
                        }
View Full Code Here

    /**
     * Save an XML config file to a named path.
     * If the file does not yet exist, it is created.
     */
    private static void saveXml(Document doc, FileObject dir, String path) throws IOException {
        FileObject xml = FileUtil.createData(dir, path);
        FileLock lock = xml.lock();
        try {
            OutputStream os = xml.getOutputStream(lock);
            try {
                XMLUtil.write(doc, os, "UTF-8"); // NOI18N
            } finally {
                os.close();
            }
View Full Code Here

        }
        return panels;
    }

    public Set instantiate() throws IOException {
        FileObject dir = Templates.getTargetFolder( wizard );
        String targetName = Templates.getTargetName( wizard );
       
        DataFolder df = DataFolder.findFolder( dir );
        FileObject template = Templates.getTemplate( wizard );
       
        DataObject dTemplate = DataObject.find( template );               
        DataObject dobj = dTemplate.createFromTemplate( df, targetName, mapFromWizard(wizard,dTemplate,df) );
           
        FileObject createdFile = dobj.getPrimaryFile();
       
        return Collections.singleton( createdFile );
    }
View Full Code Here

   
    public java.util.Set<DataObject> instantiate (org.openide.loaders.TemplateWizard templateWizard) throws java.io.IOException {
        File projectLocation = (File) wiz.getProperty(ProjectWizardProperties.PROJECT_DIR);
        String name = (String) wiz.getProperty(ProjectWizardProperties.NAME);
                       
        FileObject prjLoc = ProjectGenerator.createProjectFromTemplate(templateWizard.getTemplate().getPrimaryFile(), projectLocation, name);
       
        FileObject webRoot = prjLoc.getFileObject("web");    //NOI18N
        FileObject index = getIndexFile(webRoot);

        Set<DataObject> hset = new HashSet<DataObject>();
        hset.add(DataObject.find(prjLoc));
        hset.add(DataObject.find(index));
       
View Full Code Here

        component.putClientProperty ("WizardPanel_contentSelectedIndex",    // NOI18N
                Integer.valueOf(currentIndex));
    }
   
    private FileObject getIndexFile(final FileObject webRoot) {
        FileObject file = webRoot.getFileObject("index", "jsp");        // NOI18N
        if (file == null) {
            file = webRoot.getFileObject("index", "html");              // NOI18N
        }
        return file;
    }
View Full Code Here

    public Set/*<FileObject>*/ instantiate(/*ProgressHandle handle*/) throws IOException {
        Set<FileObject> resultSet = new LinkedHashSet<FileObject>();
        File dirF = FileUtil.normalizeFile((File) wiz.getProperty("projdir"));
        dirF.mkdirs();

        FileObject template = Templates.getTemplate(wiz);
        FileObject dir = FileUtil.toFileObject(dirF);
        unZipFile(template.getInputStream(), dir);

        // Always open top dir as a project:
        resultSet.add(dir);
        // Look for nested projects to open as well:
        Enumeration<? extends FileObject> e = dir.getFolders(true);
        while (e.hasMoreElements()) {
            FileObject subfolder = e.nextElement();
            if (ProjectManager.getDefault().isProject(subfolder)) {
                resultSet.add(subfolder);
            }
        }

View Full Code Here

            ZipEntry entry;
            while ((entry = str.getNextEntry()) != null) {
                if (entry.isDirectory()) {
                    FileUtil.createFolder(projectRoot, entry.getName());
                } else {
                    FileObject fo = FileUtil.createData(projectRoot, entry.getName());
                    if ("nbproject/project.xml".equals(entry.getName())) {
                        // Special handling for setting name of Ant-based projects; customize as needed:
                        filterProjectXML(fo, str, projectRoot.getName());
                    } else {
                        writeFile(str, fo);
View Full Code Here

   
    @Override
    public void run() {
  try {
      // Init JSLint TaskScanner
      FileObject fileObject = nodeData.getPrimaryFile();
      JSLintTaskScanner.create().scan(fileObject);
  } catch (Exception ex) {
            ErrorManager.getDefault().notify(ErrorManager.WARNING, ex);
        }
    }
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.