Package org.eclipse.core.resources

Examples of org.eclipse.core.resources.IFolder


    if (resource==null) {
      return null;
    }
    final IContainer resourceParent = resource.getParent();
    if (resource instanceof IFolder) {
      IFolder container = (IFolder)resource;
      IPath syncDirFullPath = ProjectUtil.getSyncDirectoryFullPath(resource.getProject());
      if (syncDirFullPath.equals(container.getFullPath())) {
        // then we've reached the syncdir
        return new SyncDir(container);
      }
    } else if (!(resource instanceof IFile)) {
      return null;
View Full Code Here


    }

    public static String validateContentPackageStructure(IContainer base) {
       
        IFile filterXml = base.getFile(Path.fromPortableString("META-INF/vault/filter.xml"));
        IFolder jcrRoot = base.getFolder(Path.fromPortableString("jcr_root"));

        if (!filterXml.exists()) {
            return String.format("Could not find FileVault filter at '%s'", filterXml.getRawLocationURI());
        }

        if (!jcrRoot.exists()) {
            return String.format("Could not find JCR root at '%s'", jcrRoot.getRawLocationURI());
        }

        return null;
    }
View Full Code Here

    private void convertSource(ISigilProjectModel sigil, IClasspathEntry cp,
        List<File> files) throws JavaModelException
    {
        IPath path = cp.getOutputLocation() == null ? sigil.getJavaModel().getOutputLocation()
            : cp.getOutputLocation();
        IFolder buildFolder = sigil.getProject().getFolder(path.removeFirstSegments(1));
        if (buildFolder.exists())
        {
            files.add(buildFolder.getLocation().toFile());
        }
    }
View Full Code Here

     */
    public static IPath findFilterPath(final IProject project) {

        FilterLocator filterLocator = Activator.getDefault().getFilterLocator();

        IFolder syncFolder = ProjectUtil.getSyncDirectory(project);
        if (syncFolder == null) {
            return null;
        }
        File filterLocation = filterLocator.findFilterLocation(syncFolder.getLocation().toFile());
        if (filterLocation == null) {
            return null;
        }
        return Path.fromOSString(filterLocation.getAbsolutePath());
    }
View Full Code Here

        if (resource == null) {
            return false;
        }

        IFolder syncRoot = getSyncDirectory(resource.getProject());
        if (syncRoot == null) {
            return false;
        }

        return syncRoot.getFullPath().isPrefixOf(resource.getFullPath());
    }
View Full Code Here

                JcrNode node = it.next();
        childrenNames.add(node.getName());
      }
     
      if (resource!=null && resource instanceof IFolder) {
        IFolder folder = (IFolder)resource;
        IResource[] members = folder.members();
                List<IResource> membersList = new LinkedList<IResource>(Arrays.asList(members));
        outerLoop: while(membersList.size()>0) {
                    for (Iterator<IResource> it = membersList.iterator(); it.hasNext();) {
                        IResource iResource = it.next();
                        if (isDotVltFile(iResource)) {
View Full Code Here

            root = thisParent;
        }
        if (!(root instanceof SyncDir)) {
            return null;
        }
        IFolder folder = ((SyncDir)root).getFolder();
        while(st.hasMoreTokens()) {
            String nodeStr = st.nextToken();
            IResource child = folder.findMember(nodeStr);
            if (child==null || !(child instanceof IFolder)) {
                break;
            } else {
                folder = (IFolder) child;
            }
View Full Code Here

      } else if (childSk==SerializationKind.FOLDER) {
            IWorkspaceRunnable r = new IWorkspaceRunnable() {

                @Override
                public void run(IProgressMonitor monitor) throws CoreException {
                    IFolder newFolder = prepareCreateFolderChild(childNodeName);
                    if (parentSk==SerializationKind.METADATA_PARTIAL) {
                        // when the parent is partial and we're creating a folder here,
                        // then we're running into a SLING-3639 type of problem
                        // the way around this is to make a 'pointer' in the 'root'
                        // .content.xml, and have a directory structure leaving to
                        // the new node, together with a .content.xml describing
                        // the type (unless it's a nt:folder that is)
                       
                        // 1) 'pointer' in the 'root .content.xml'
                        createDomChild(childNodeName, null);
                       
                        // 2) directory structure is created above already
                        // 3) new .content.xml is done below
                    }
                    if (!childNodeType.equals("nt:folder")) {
                        createVaultFile(newFolder, ".content.xml", childNodeType);
                    }
                }
            };
         
          try {
              ResourcesPlugin.getWorkspace().run(r, null);
              if (childNodeType.equals("nt:folder") && parentSk==SerializationKind.FOLDER) {
                  // trigger a publish, as folder creation is not propagated to
                  // the SlingLaunchpadBehavior otherwise
                  //TODO: make configurable? Fix in Eclipse/WST?
                  ServerUtil.triggerIncrementalBuild((IFolder)resource, null);
              }
          } catch (CoreException e) {
              Activator.getDefault().getPluginLogger().error("Error creating child "+childNodeName+": "+e, e);
              e.printStackTrace();
              MessageDialog.openError(Display.getDefault().getActiveShell(), "Error creating node", "Error creating child of "+thisNodeType+" with type "+childNodeType+": "+e);
              return;
          }
        } else if ((parentSk == SerializationKind.FOLDER || parentSk == SerializationKind.METADATA_PARTIAL)
                && childSk == SerializationKind.METADATA_FULL) {
            createVaultFile((IFolder) resource, serializationManager.getOsPath(childNodeName) + ".xml", childNodeType);
      } else if (parentSk==SerializationKind.FOLDER && childSk==SerializationKind.METADATA_PARTIAL) {
//          createVaultFile((IFolder)resource, childNodeName+".xml", childNodeType);

            IWorkspaceRunnable r = new IWorkspaceRunnable() {

                @Override
                public void run(IProgressMonitor monitor) throws CoreException {
                    IFolder f = (IFolder)resource;
                    IFolder newFolder = null;
                    newFolder = f.getFolder(serializationManager.getOsPath(childNodeName));
                    newFolder.create(true, true, new NullProgressMonitor());
                    createVaultFile(newFolder, ".content.xml", childNodeType);
                }
            };
           
            try {
                ResourcesPlugin.getWorkspace().run(r, null);
            } catch (CoreException e) {
                Activator.getDefault().getPluginLogger().error("Error creating child "+childNodeName+": "+e, e);
                e.printStackTrace();
                MessageDialog.openError(Display.getDefault().getActiveShell(), "Error creating node", "Error creating child of "+thisNodeType+" with type "+childNodeType+": "+e);
                return;
            }
           
      } else if (parentSk!=SerializationKind.FOLDER && childSk==SerializationKind.METADATA_PARTIAL) {
            createDomChild(childNodeName, childNodeType);
      } else {
          if (childNodeType.equals("nt:file")) {
              IFolder f = (IFolder)resource;
              createNtFile(f, childNodeName, childNodeType);
              return;
          }
          //TODO: FILE not yet supported
View Full Code Here

        }

        @Override
        public IModuleResource[] members() throws CoreException {
            final List<IModuleResource> resources = new ArrayList<IModuleResource>();
            final IFolder syncFolder = ProjectUtil.getSyncDirectory(getProject());

            if (syncFolder == null || !syncFolder.exists()) {
                return EMPTY_MODULE_RESOURCES;
            }

            syncFolder.accept(new IResourceVisitor() {
                @Override
                public boolean visit(IResource resource) throws CoreException {

                    IPath relativePath = resource.getProjectRelativePath();

                    IPath modulePath = relativePath.removeFirstSegments(syncFolder.getProjectRelativePath()
                            .segmentCount()); // remove sync dir

                    IModuleResource moduleFile = null;

                    if (resource.getType() == IResource.FILE) {
View Full Code Here

                    if (!(resource instanceof IFolder)) {
                        MessageDialog.openWarning(null, "Unable to change primaryType", "Unable to change jcr:primaryType to nt:folder"
                                + " as there is no underlying folder");
                        return;
                    }
                    IFolder folder = (IFolder)resource;
                    // 3) delete the .content.xml
                    IFile contentXml = folder.getFile(".content.xml");
                    if (contentXml.exists()) {
                        try {
                            contentXml.delete(true, new NullProgressMonitor());
                        } catch (CoreException e) {
                            Logger logger = Activator.getDefault().getPluginLogger();
                            logger.error("Could not delete "+contentXml.getFullPath()+", e="+e, e);
                            MessageDialog.openError(null, "Could not delete file",
                                    "Could not delete "+contentXml.getFullPath()+", "+e);
                        }
                    }
                } else {
                    properties.doSetPropertyValue("jcr:primaryType", newPrimaryType);
                }
            }
            return;
        }
       
        if (newSk==SerializationKind.FOLDER) {
            // switching to a folder
            if (currentSk==SerializationKind.FILE) {
                MessageDialog.openWarning(null, "Unable to change primary type",
                        "Changing from a file to a folder type is currently not supported");
                return;
            }
            if (newPrimaryType.equals("nt:folder")) {
                // verify
                if (!verifyNodeTypeChange(ntManager, newPrimaryType)) {
                    return;
                }
            }
            try {
                // create the new directory structure pointing to 'this'
                IFolder newFolder = getParent().prepareCreateFolderChild(getJcrPathName());
               
                if (!newPrimaryType.equals("nt:folder")) {
                    // move any children from the existing 'this' to a new vault file
                    createVaultFileWithContent(newFolder, ".content.xml", newPrimaryType, domElement);
                }
View Full Code Here

TOP

Related Classes of org.eclipse.core.resources.IFolder

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.