Package org.eclipse.core.resources

Examples of org.eclipse.core.resources.IFile


            _selectedFodler = folder;
            action.setEnabled(true);
          }
        }
        if (selectedElement instanceof IFile) {
          IFile file = (IFile)selectedElement;
          if(file.getParent() instanceof IFolder){ 
          IFolder folder = (IFolder)file.getParent();
            if(WGADesignStructureHelper.isDirlinkFolder(folder)){
              _selectedFodler = folder;
              action.setEnabled(true);
            }
        }
View Full Code Here


    try {
      FileUtils.unzip(designTemplate.getContent(), folder.getLocation().toFile());
     
      // remove properties from project
      folder.refreshLocal(IResource.DEPTH_ONE, new NullProgressMonitor());
      IFile props = folder.getFile(DesignTemplate.PROPERTIES_FILENAME);
      if (props.exists()) {
        props.delete(true, new NullProgressMonitor());
      }     
     
      DesignDefinition syncinfo = new DesignDefinition();   
      syncinfo.setDesignKey(designKey);
      syncinfo.setFileEncoding(DesignDefinition.FILEENCODING_CSCONFIG_DEFINED);     
View Full Code Here

      return true;
    }
    if (local != null && remote != null && local instanceof IFile) {
      WGAFSDesignResourceVariant variant = (WGAFSDesignResourceVariant)remote;
     
      IFile localFile = (IFile) local;
      String md5Local = null;
      try {
        md5Local = WGUtils.createMD5HEX(localFile.getContents());
      } catch (Exception e) {
        WGADesignerPlugin.getDefault().logError("Unable to create md5 sum of resource '" + localFile.getLocation().toString() + "'.", e);
      }
      String md5Variant = variant.getState().getMd5sum();
     
      if (md5Local != null && md5Variant != null) {
        return md5Local.equals(md5Variant);
View Full Code Here

        IResourceDeltaVisitor visitor = new IResourceDeltaVisitor() {

          public boolean visit(IResourceDelta delta) throws CoreException {
            if (delta.getResource() != null) {
              if (delta.getResource() instanceof IFile) {
                IFile file = (IFile)delta.getResource();
                String absolutePath = file.getLocation().toString();
                // make path relative to WebContent folder
                int pos = absolutePath.lastIndexOf("WebContent/");
                if (pos != -1) {                 
                  String relativePathToFile = absolutePath.substring(pos + "WebContent/".length());
                  File targetFile = new File(getDeployDir(), relativePathToFile);
                  File sourceFile = file.getLocation().toFile();               
                  if (delta.getKind() == IResourceDelta.ADDED || delta.getKind() == IResourceDelta.CHANGED) {                                                                                   
                    try {
                      if (WGADesignerPlugin.getDefault().isDebugging()) {
                        System.out.println("Updating resource '" + targetFile.getAbsolutePath() + "' of deployment '" + getName() + "'.");
                      }
View Full Code Here

     * @return the transformed editor input
     */
    protected IClassFileEditorInput transformEditorInput(Object input) {

        if (input instanceof IFileEditorInput) {
            IFile file = ((IFileEditorInput) input).getFile();
            Constructor cons;
            try {
                cons = ExternalClassFileEditorInput.class
                    .getDeclaredConstructor(new Class[]{IFile.class});
                cons.setAccessible(true);
View Full Code Here

   
    private void createRulesProject(IJavaProject project)
            throws CoreException {
        String fileName = "org/drools/ide/resource/Rules.java.drl.template";
        IFolder folder = project.getProject().getFolder("src/rules");
        IFile file = folder.getFile("Rules.java.drl");
        InputStream inputstream = getClass().getClassLoader().getResourceAsStream(fileName);
        file.create(inputstream, true, null);
    }
View Full Code Here

      int rootPathSegmentCounts,
      ArrayList collector) {
    for (int i = 0, max = nonJavaResources.length; i < max; i++) {
      Object nonJavaResource = nonJavaResources[i];
      if (nonJavaResource instanceof IFile) {
        IFile file = (IFile) nonJavaResource;
        IPath path = file.getFullPath().removeFirstSegments(rootPathSegmentCounts);
        IResource member = container.findMember(path);
        if (member != null && member.exists()) {
          collector.add(member);
        }
      } else if (nonJavaResource instanceof IFolder) {
View Full Code Here

   * @throws CoreException
   */
  public String getSharedProperty(String key) throws CoreException {

    String property = null;
    IFile rscFile = this.project.getFile(key);
    if (rscFile.exists()) {
      byte[] bytes = Util.getResourceContentsAsByteArray(rscFile);
      try {
        property = new String(bytes, org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.UTF_8); // .classpath always encoded with UTF-8
      } catch (UnsupportedEncodingException e) {
        Util.log(e, "Could not read .classpath with UTF-8 encoding"); //$NON-NLS-1$
        // fallback to default
        property = new String(bytes);
      }
    } else {
      // when a project is imported, we get a first delta for the addition of the .project, but the .classpath is not accessible
      // so default to using java.io.File
      // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=96258
      URI location = rscFile.getLocationURI();
      if (location != null) {
        File file = Util.toLocalFile(location, null/*no progress monitor available*/);
        if (file != null && file.exists()) {
          byte[] bytes;
          try {
View Full Code Here

   * As a side effect, unknown elements are stored in the given map (if not null)
   * Throws exceptions if the file cannot be accessed or is malformed.
   */
  public IClasspathEntry[] readFileEntriesWithException(Map unknownElements) throws CoreException, IOException, AssertionFailedException {
    String xmlClasspath;
    IFile rscFile = this.project.getFile(JavaProject.CLASSPATH_FILENAME);
    if (rscFile.exists()) {
      byte[] bytes = Util.getResourceContentsAsByteArray(rscFile);
      try {
        xmlClasspath = new String(bytes, org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.UTF_8); // .classpath always encoded with UTF-8
      } catch (UnsupportedEncodingException e) {
        Util.log(e, "Could not read .classpath with UTF-8 encoding"); //$NON-NLS-1$
        // fallback to default
        xmlClasspath = new String(bytes);
      }
    } else {
      // when a project is imported, we get a first delta for the addition of the .project, but the .classpath is not accessible
      // so default to using java.io.File
      // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=96258
      URI location = rscFile.getLocationURI();
      if (location == null)
        throw new IOException("Cannot obtain a location URI for " + rscFile); //$NON-NLS-1$
      File file = Util.toLocalFile(location, null/*no progress monitor available*/);
      if (file == null)
        throw new IOException("Unable to fetch file from " + location); //$NON-NLS-1$
View Full Code Here

   * @see JavaProject#getSharedProperty(String key)
   * @throws CoreException
   */
  public void setSharedProperty(String key, String value) throws CoreException {

    IFile rscFile = this.project.getFile(key);
    byte[] bytes = null;
    try {
      bytes = value.getBytes(org.aspectj.org.eclipse.jdt.internal.compiler.util.Util.UTF_8); // .classpath always encoded with UTF-8
    } catch (UnsupportedEncodingException e) {
      Util.log(e, "Could not write .classpath with UTF-8 encoding "); //$NON-NLS-1$
      // fallback to default
      bytes = value.getBytes();
    }
    InputStream inputStream = new ByteArrayInputStream(bytes);
    // update the resource content
    if (rscFile.exists()) {
      if (rscFile.isReadOnly()) {
        // provide opportunity to checkout read-only .classpath file (23984)
        ResourcesPlugin.getWorkspace().validateEdit(new IFile[]{rscFile}, null);
      }
      rscFile.setContents(inputStream, IResource.FORCE, null);
    } else {
      rscFile.create(inputStream, IResource.FORCE, null);
    }
  }
View Full Code Here

TOP

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

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.