private void updateReadOnlyPackageFragmentsForCopy(
     IContainer sourceFolder, PackageFragmentRoot root, String[] newFragName) {
   IContainer parentFolder = (IContainer) root.resource();
   for (int i = 0, length = newFragName.length; i < length; i++) {
     String subFolderName = newFragName[i];
     parentFolder = parentFolder.getFolder(new Path(subFolderName));
     sourceFolder = sourceFolder.getFolder(new Path(subFolderName));
     if (sourceFolder.exists() && Util.isReadOnly(sourceFolder)) {
       Util.setReadOnly(parentFolder, true);
     }
   }
 }
 public boolean pageExists(String wiki, String space, String page, String language) {
   IFile pageFile =
       baseFolder
           .getFolder(PAGES_DIRECTORY)
           .getFile(getFileNameForPage(wiki, space, page, language));
   return pageFile.exists();
 }
  /**
   * @param spaceSummary
   * @return
   */
  public List<XWikiEclipsePageSummary> getPageSummaries(String wiki, String space)
      throws XWikiEclipseStorageException {
    final List<XWikiEclipsePageSummary> result = new ArrayList<XWikiEclipsePageSummary>();

    try {
      final IFolder pagesFolder = StorageUtils.createFolder(baseFolder.getFolder(PAGES_DIRECTORY));

      List<IResource> pageFolderResources = getChildResources(pagesFolder, IResource.DEPTH_ONE);
      for (IResource pageFolderResource : pageFolderResources) {
        if (pageFolderResource instanceof IFile) {
          IFile file = (IFile) pageFolderResource;
          if (file.getFileExtension().equals(PAGE_SUMMARY_FILE_EXTENSION)) {
            IFile pageSummaryFile = (IFile) pageFolderResource;
            XWikiEclipsePageSummary pageSummary;
            try {
              pageSummary =
                  (XWikiEclipsePageSummary)
                      StorageUtils.readFromJSON(
                          pageSummaryFile, XWikiEclipsePageSummary.class.getCanonicalName());
              if (pageSummary.getWiki().equals(wiki) && pageSummary.getSpace().equals(space)) {
                result.add(pageSummary);
              }
            } catch (Exception e) {
              // TODO Auto-generated catch block
              e.printStackTrace();
            }
          }
        }
      }
    } catch (CoreException e) {
      throw new XWikiEclipseStorageException(e);
    }

    return result;
  }
  /**
   * @param wiki
   * @param space
   * @param page
   * @return
   * @throws Exception
   */
  public List<XWikiEclipseObjectSummary> getObjectSummaries(String wiki, String space, String page)
      throws Exception {
    List<XWikiEclipseObjectSummary> result = new ArrayList<XWikiEclipseObjectSummary>();
    final IFolder objectsFolder =
        StorageUtils.createFolder(baseFolder.getFolder(OBJECTS_DIRECTORY));

    List<IResource> objectsFolderResources = getChildResources(objectsFolder, IResource.DEPTH_ONE);
    for (IResource objectsFolderResource : objectsFolderResources) {
      if (objectsFolderResource instanceof IFile
          && ((IFile) objectsFolderResource)
              .getFileExtension()
              .equals(OBJECT_SUMMARY_FILE_EXTENSION)) {
        IFile objectSummaryFile = (IFile) objectsFolderResource;
        XWikiEclipseObjectSummary objectSummary =
            (XWikiEclipseObjectSummary)
                StorageUtils.readFromJSON(
                    objectSummaryFile, XWikiEclipseObjectSummary.class.getCanonicalName());
        if (objectSummary.getWiki().equals(wiki)
            && objectSummary.getSpace().equals(space)
            && objectSummary.getPageName().equals(page)) {
          result.add(objectSummary);
        }
      }
    }

    return result;
  }
  public List<XWikiEclipseSpaceSummary> getSpaces(String wikiId)
      throws XWikiEclipseStorageException {

    final List<XWikiEclipseSpaceSummary> result = new ArrayList<XWikiEclipseSpaceSummary>();

    try {
      final IFolder spaceFolder = StorageUtils.createFolder(baseFolder.getFolder(SPACES_DIRECTORY));

      List<IResource> spaceFolderResources = getChildResources(spaceFolder, IResource.DEPTH_ONE);
      for (IResource spaceFolderResource : spaceFolderResources) {
        if (spaceFolderResource instanceof IFile) {
          IFile wikiFile = (IFile) spaceFolderResource;
          XWikiEclipseSpaceSummary spaceSummary;
          try {
            spaceSummary =
                (XWikiEclipseSpaceSummary)
                    StorageUtils.readFromJSON(
                        wikiFile, XWikiEclipseSpaceSummary.class.getCanonicalName());
            if (spaceSummary.getWiki().equals(wikiId)) {
              result.add(spaceSummary);
            }
          } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
      }
    } catch (CoreException e) {
      throw new XWikiEclipseStorageException(e);
    }

    return result;
  }
  public List<XWikiEclipseWikiSummary> getWikiSummaries() throws XWikiEclipseStorageException {
    final List<XWikiEclipseWikiSummary> result = new ArrayList<XWikiEclipseWikiSummary>();

    try {
      final IFolder wikiFolder = StorageUtils.createFolder(baseFolder.getFolder(WIKIS_DIRECTORY));

      List<IResource> wikiFolderResources = getChildResources(wikiFolder, IResource.DEPTH_ONE);
      for (IResource wikiFolderResource : wikiFolderResources) {
        if (wikiFolderResource instanceof IFile) {
          IFile wikiFile = (IFile) wikiFolderResource;
          XWikiEclipseWikiSummary wikiSummary;
          try {
            wikiSummary =
                (XWikiEclipseWikiSummary)
                    StorageUtils.readFromJSON(
                        wikiFile, XWikiEclipseWikiSummary.class.getCanonicalName());
            result.add(wikiSummary);
          } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
          }
        }
      }
    } catch (CoreException e) {
      throw new XWikiEclipseStorageException(e);
    }

    return result;
  }
Ejemplo n.º 7
0
  /**
   * Creates the complete package path given by the user (all filled with __init__) and returns the
   * last __init__ module created.
   */
  public static IFile createPackage(
      IProgressMonitor monitor, IContainer validatedSourceFolder, String packageName)
      throws CoreException {
    IFile lastFile = null;
    if (validatedSourceFolder == null) {
      return null;
    }
    IContainer parent = validatedSourceFolder;
    for (String packagePart : StringUtils.dotSplit(packageName)) {
      IFolder folder = parent.getFolder(new Path(packagePart));
      if (!folder.exists()) {
        folder.create(true, true, monitor);
      }
      parent = folder;
      IFile file =
          parent.getFile(
              new Path("__init__" + FileTypesPreferencesPage.getDefaultDottedPythonExtension()));
      if (!file.exists()) {
        file.create(new ByteArrayInputStream(new byte[0]), true, monitor);
      }
      lastFile = file;
    }

    return lastFile;
  }
  @Override
  public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
    try {
      IFolder documentationFolder = container.getFolder(new Path(GENERATED_DOCS_FOLDER));
      if (!documentationFolder.exists()) {
        documentationFolder.create(true, true, monitor);
      }
      IFolder templateFolder =
          documentationFolder.getFolder(new Path(generatorDescriptor.getLabel()));
      if (!templateFolder.exists()) {
        templateFolder.create(true, true, monitor);
      }

      IFolder rendererFolder = templateFolder.getFolder(rendererDescriptor.getLabel());
      if (rendererFolder.exists()) {
        rendererFolder.delete(true, monitor);
      }
      rendererFolder.create(true, true, monitor);
      AbstractDocumentationGenerator generator =
          generatorDescriptor.createGenerator(rendererDescriptor.createRenderer(rendererFolder));
      // Generates semantic files
      generator.initialize(
          input, new File(rendererFolder.getLocation().toOSString()), getExtraArguments());
      generator.doGenerate(BasicMonitor.toMonitor(monitor));
      statuses = generator.getGenerationStrategy().getStatus();
      rendererFolder.refreshLocal(IFolder.DEPTH_INFINITE, monitor);
    } catch (IOException e) {
      throw new InvocationTargetException(e);
    } catch (CoreException e) {
      throw new InvocationTargetException(e);
    }
  }
 public boolean objectExists(
     String wiki, String space, String page, String className, int number) {
   IFile objectFile =
       baseFolder
           .getFolder(OBJECTS_DIRECTORY)
           .getFile(getFileNameForObject(wiki, space, page, className, number));
   return objectFile.exists();
 }
 private void updateReadOnlyPackageFragmentsForMove(
     IContainer sourceFolder,
     PackageFragmentRoot root,
     String[] newFragName,
     boolean sourceFolderIsReadOnly) {
   IContainer parentFolder = (IContainer) root.resource();
   for (int i = 0, length = newFragName.length; i < length; i++) {
     String subFolderName = newFragName[i];
     parentFolder = parentFolder.getFolder(new Path(subFolderName));
     sourceFolder = sourceFolder.getFolder(new Path(subFolderName));
     if ((sourceFolder.exists() && Util.isReadOnly(sourceFolder))
         || (i == length - 1 && sourceFolderIsReadOnly)) {
       Util.setReadOnly(parentFolder, true);
       // the source folder will be deleted anyway (move operation)
       Util.setReadOnly(sourceFolder, false);
     }
   }
 }
Ejemplo n.º 11
0
 /**
  * Creates new folder from project root. The folder name can include relative path as a part of
  * the name. Nonexistent parent directories are being created.
  *
  * @param project - project where to create the folder.
  * @param name - folder name.
  * @return folder handle.
  * @throws CoreException if something goes wrong.
  */
 public static IFolder createFolder(IProject project, String name) throws CoreException {
   final IPath p = new Path(name);
   IContainer folder = project;
   for (String seg : p.segments()) {
     folder = folder.getFolder(new Path(seg));
     if (!folder.exists()) ((IFolder) folder).create(true, true, NULL_MONITOR);
   }
   resourcesCreated.add(folder);
   return (IFolder) folder;
 }
 public void createWebInf() throws CoreException {
   if (webInfDir == null) {
     IPath webInfPath = new Path(WEB_INF_PATH);
     webInfDir = rootFolder.getFolder(webInfPath);
     if (!webInfDir.exists()) {
       webInfDir.create(true, false, null);
       refreshWebInf();
     }
   }
 }
Ejemplo n.º 13
0
 /**
  * @param wiki
  * @param space
  * @param pageName
  * @param language
  * @return
  * @throws Exception
  */
 public XWikiEclipsePageSummary getPageSummary(
     String wiki, String space, String pageName, String language) throws Exception {
   String fileName = getFileNameForPageSummary(wiki, space, pageName, language);
   IFile pageSummaryFile = baseFolder.getFolder(PAGES_DIRECTORY).getFile(fileName);
   if (pageSummaryFile.exists()) {
     return (XWikiEclipsePageSummary)
         StorageUtils.readFromJSON(
             pageSummaryFile, XWikiEclipsePageSummary.class.getCanonicalName());
   }
   return null;
 }
 /**
  * Creates any destination package fragment(s) which do not exists yet. Return true if a read-only
  * package fragment has been found among package fragments, false otherwise
  */
 private boolean createNeededPackageFragments(
     IContainer sourceFolder, PackageFragmentRoot root, String[] newFragName, boolean moveFolder)
     throws JavaModelException {
   boolean containsReadOnlyPackageFragment = false;
   IContainer parentFolder = (IContainer) root.resource();
   JavaElementDelta projectDelta = null;
   String[] sideEffectPackageName = null;
   char[][] inclusionPatterns = root.fullInclusionPatternChars();
   char[][] exclusionPatterns = root.fullExclusionPatternChars();
   for (int i = 0; i < newFragName.length; i++) {
     String subFolderName = newFragName[i];
     sideEffectPackageName = Util.arrayConcat(sideEffectPackageName, subFolderName);
     IResource subFolder = parentFolder.findMember(subFolderName);
     if (subFolder == null) {
       // create deepest folder only if not a move (folder will be moved in
       // processPackageFragmentResource)
       if (!(moveFolder && i == newFragName.length - 1)) {
         createFolder(parentFolder, subFolderName, this.force);
       }
       parentFolder = parentFolder.getFolder(new Path(subFolderName));
       sourceFolder = sourceFolder.getFolder(new Path(subFolderName));
       if (Util.isReadOnly(sourceFolder)) {
         containsReadOnlyPackageFragment = true;
       }
       IPackageFragment sideEffectPackage = root.getPackageFragment(sideEffectPackageName);
       if (i < newFragName.length - 1 // all but the last one are side effect packages
           && !Util.isExcluded(parentFolder, inclusionPatterns, exclusionPatterns)) {
         if (projectDelta == null) {
           projectDelta = getDeltaFor(root.getJavaProject());
         }
         projectDelta.added(sideEffectPackage);
       }
       this.createdElements.add(sideEffectPackage);
     } else {
       parentFolder = (IContainer) subFolder;
     }
   }
   return containsReadOnlyPackageFragment;
 }
Ejemplo n.º 15
0
 public IFolder createFolder(String name) throws CoreException {
   initializeProject();
   String[] segments = new Path(name).segments();
   IContainer container = project;
   for (String segment : segments) {
     IFolder newFolder = container.getFolder(new Path(segment));
     if (!newFolder.exists()) {
       newFolder.create(true, true, newProgressMonitor());
     }
     container = newFolder;
   }
   return project.getFolder(new Path(name));
 }
Ejemplo n.º 16
0
 /** @see IModelElement#getResource() */
 public IResource getResource() {
   ProjectFragment root = this.getProjectFragment();
   if (root.isArchive()) {
     return root.getResource();
   } else {
     if (path.segmentCount() == 0) return root.getResource();
     IContainer container = (IContainer) root.getResource();
     if (container != null) {
       return container.getFolder(path);
     }
     return null;
   }
 }
Ejemplo n.º 17
0
  /**
   * @param wiki
   * @param className
   * @return
   * @throws Exception
   */
  public XWikiEclipseClass getClass(String wiki, String className) throws Exception {
    IFolder classesFolder = StorageUtils.createFolder(baseFolder.getFolder(CLASSES_DIRECTORY));
    IFile classFile = classesFolder.getFile(getFileNameForClass(wiki, className));
    if (classFile.exists()) {
      XWikiEclipseClass result =
          (XWikiEclipseClass)
              StorageUtils.readFromJSON(classFile, XWikiEclipseClass.class.getCanonicalName());

      return result;
    }
    // TODO Auto-generated method stub
    return null;
  }
 private void copy(File src, IContainer dest) throws CoreException, FileNotFoundException {
   File[] children = src.listFiles();
   for (int i = 0; i < children.length; i++) {
     String name = children[i].getName();
     if (children[i].isDirectory()) {
       IFolder folder = dest.getFolder(new Path(name));
       folder.create(true, true, null);
       copy(children[i], folder);
     } else if (name.endsWith(".jsp")) {
       IFile file = dest.getFile(new Path(name));
       file.create(new FileInputStream(children[i]), true, null);
     }
   }
 }
  /**
   * This file created the base configuration file.
   *
   * @param container
   * @throws IOException
   * @throws TemplateException
   */
  private void createBaseConfigurationXML(IContainer container)
      throws IOException, TemplateException {
    Bundle bundle = Platform.getBundle(AsideActivator.PLUGIN_ID);
    String fileName = "resources/BaseConfiguration.ftl";
    Path originPath = new Path(fileName);

    URL bundledFileURL = FileLocator.find(bundle, originPath, null);

    String ftlLocation = null;
    try {
      bundledFileURL = FileLocator.resolve(bundledFileURL);
      System.out.println(
          "VAlue of bundledFileURL.getFile().toString() :" + bundledFileURL.getFile().toString());
      System.out.println("Value of bundledFileURL.getPath() :" + bundledFileURL.getPath());
      ftlLocation = bundledFileURL.getFile().toString();
      ftlLocation = ftlLocation.substring(1, ftlLocation.lastIndexOf("/"));
      System.out.println("Value of ftlLocation -->" + ftlLocation);
    } catch (IOException e) {
      throw new RuntimeException("Plugin Error: can't read file: " + fileName, e);
    }

    //

    Configuration cfg = new Configuration();
    cfg.setDirectoryForTemplateLoading(new File(ftlLocation));
    Template template = cfg.getTemplate("BaseConfiguration.ftl");
    final IFolder folder = container.getFolder(new Path("resources"));
    if (folder.exists()) {
      System.out.println(folder.getFullPath());
      System.out.println(folder.getLocation().toString());
      System.out.println(folder.getLocationURI());
      final IFile baseXMLFIle =
          container.getFile(new Path(folder.getFullPath() + "/" + "baseConfiguration.xml"));
      System.out.println(baseXMLFIle.getName());
      System.out.println(baseXMLFIle.getFullPath().toFile());
      System.out.println(baseXMLFIle.getLocation().toFile());
      // final File xmlFile = baseXMLFIle.getFullPath().toFile();

      // Build the data-model
      Map<String, Object> data = new HashMap<String, Object>();
      data.put("message", "Hello World!");

      // File output
      Writer baseFile =
          new FileWriter(new File(folder.getLocation().toString() + "/" + "baseConfiguration.xml"));
      template.process(data, baseFile);
      baseFile.flush();
      baseFile.close();
    }
  }
Ejemplo n.º 20
0
 /** Convenience method to create a folder. */
 protected void createFolder(IContainer parentFolder, String name, boolean forceFlag)
     throws DartModelException {
   IFolder folder = parentFolder.getFolder(new Path(name));
   try {
     // we should use true to create the file locally. Only VCM should use
     // true/false
     folder.create(
         forceFlag ? IResource.FORCE | IResource.KEEP_HISTORY : IResource.KEEP_HISTORY,
         true, // local
         getSubProgressMonitor(1));
     setAttribute(HAS_MODIFIED_RESOURCE_ATTR, TRUE);
   } catch (CoreException e) {
     throw new DartModelException(e);
   }
 }
 /**
  * Imports resources from <code>bundleSourcePath</code> inside <code>bundle</code> into <code>
  * importTarget</code>.
  *
  * @param importTarget the parent container
  * @param bundle the bundle
  * @param bundleSourcePath the path to a folder containing resources
  * @throws CoreException import failed
  * @throws IOException import failed
  */
 public static void importResources(
     IContainer importTarget, Bundle bundle, String bundleSourcePath)
     throws CoreException, IOException {
   Enumeration entryPaths = bundle.getEntryPaths(bundleSourcePath);
   while (entryPaths.hasMoreElements()) {
     String path = (String) entryPaths.nextElement();
     IPath name = new Path(path.substring(bundleSourcePath.length()));
     if (path.endsWith("/")) {
       IFolder folder = importTarget.getFolder(name);
       folder.create(false, true, null);
       importResources(folder, bundle, path);
     } else {
       URL url = bundle.getEntry(path);
       IFile file = importTarget.getFile(name);
       file.create(url.openStream(), true, null);
     }
   }
 }
Ejemplo n.º 22
0
 protected IStatus cleanUpDerivedResources(IProgressMonitor monitor, IProject project)
     throws CoreException {
   if (monitor.isCanceled()) {
     return Status.CANCEL_STATUS;
   }
   if (shouldBeProcessed(project)) {
     IContainer container = project;
     if (folderNameToClean != null) container = container.getFolder(new Path(folderNameToClean));
     for (IFile derivedFile : derivedResourceMarkers.findDerivedResources(container, null)) {
       derivedFile.delete(true, monitor);
       //				deleteEmptyParent(monitor, derivedFile.getParent());
       if (monitor.isCanceled()) {
         return Status.CANCEL_STATUS;
       }
     }
   }
   return Status.OK_STATUS;
 }
Ejemplo n.º 23
0
  public List<XWikiEclipseClass> getClasses() throws Exception {
    List<XWikiEclipseClass> result = new ArrayList<XWikiEclipseClass>();

    List<IResource> classFolderResources =
        getChildResources(baseFolder.getFolder(CLASSES_DIRECTORY), IResource.DEPTH_ONE);
    for (IResource classFolderResource : classFolderResources) {
      if (classFolderResource instanceof IFile) {
        IFile file = (IFile) classFolderResource;
        if (file.getFileExtension().equals(CLASS_FILE_EXTENSION)) {
          XWikiEclipseClass clazz =
              (XWikiEclipseClass)
                  StorageUtils.readFromJSON(file, XWikiEclipseClass.class.getCanonicalName());
          result.add(clazz);
        }
      }
    }

    return result;
  }
Ejemplo n.º 24
0
  public XWikiEclipsePage getPage(String wiki, String space, String pageName, String language)
      throws XWikiEclipseStorageException {
    try {
      IFolder pageFolder = StorageUtils.createFolder(baseFolder.getFolder(PAGES_DIRECTORY));

      IFile pageFile =
          pageFolder.getFile(getFileNameForPage(wiki, space, pageName, language)); // $NON-NLS-1$
      if (pageFile.exists()) {
        XWikiEclipsePage result =
            (XWikiEclipsePage)
                StorageUtils.readFromJSON(pageFile, XWikiEclipsePage.class.getCanonicalName());
        return result;
      }
    } catch (Exception e) {
      throw new XWikiEclipseStorageException(e);
    }

    return null;
  }
Ejemplo n.º 25
0
  public void removeSpace(String wiki, String space) throws XWikiEclipseStorageException {
    // Delete space summary file
    try {
      final IFolder spaceFolder = StorageUtils.createFolder(baseFolder.getFolder(SPACES_DIRECTORY));

      List<IResource> spacesFolderResources = getChildResources(spaceFolder, IResource.DEPTH_ONE);
      for (IResource spacesFolderResource : spacesFolderResources) {
        if (spacesFolderResource instanceof IFile) {
          IFile spaceFile = (IFile) spacesFolderResource;
          if (spaceFile.getName().equals(getFileNameForSpaceSummary(wiki, space))) {
            spaceFile.delete(true, null);
            break;
          }
        }
      }
    } catch (CoreException e) {
      throw new XWikiEclipseStorageException(e);
    }
  }
Ejemplo n.º 26
0
  public XWikiEclipseObject getObject(
      String wiki, String space, String page, String className, int number)
      throws XWikiEclipseStorageException {
    try {
      IFolder objectsFolder = StorageUtils.createFolder(baseFolder.getFolder(OBJECTS_DIRECTORY));

      IFile objectFile =
          objectsFolder.getFile(
              getFileNameForObject(wiki, space, page, className, number)); // $NON-NLS-1$
      if (objectFile.exists()) {
        XWikiEclipseObject result =
            (XWikiEclipseObject)
                StorageUtils.readFromJSON(objectFile, XWikiEclipseObject.class.getCanonicalName());
        return result;
      }
    } catch (Exception e) {
      throw new XWikiEclipseStorageException(e);
    }

    return null;
  }
 /**
  * Execute the operation - creates the new script folder and any side effect folders.
  *
  * @exception ModelException if the operation is unable to complete
  */
 @Override
 protected void executeOperation() throws ModelException {
   ModelElementDelta delta = null;
   IProjectFragment root = (IProjectFragment) getParentElement();
   beginTask(Messages.operation_createScriptFolderProgress, this.pkgName.segmentCount());
   IContainer parentFolder = (IContainer) root.getResource();
   IPath sideEffectPackageName = Path.EMPTY;
   ArrayList<IScriptFolder> results = new ArrayList<IScriptFolder>(this.pkgName.segmentCount());
   int i;
   for (i = 0; i < this.pkgName.segmentCount(); i++) {
     String subFolderName = this.pkgName.segment(i);
     sideEffectPackageName = sideEffectPackageName.append(subFolderName);
     IResource subFolder = parentFolder.findMember(subFolderName);
     if (subFolder == null) {
       createFolder(parentFolder, subFolderName, force);
       parentFolder = parentFolder.getFolder(new Path(subFolderName));
       IScriptFolder addedFrag = root.getScriptFolder(sideEffectPackageName);
       if (!Util.isExcluded(parentFolder, root)) {
         if (delta == null) {
           delta = newModelElementDelta();
         }
         delta.added(addedFrag);
       }
       results.add(addedFrag);
     } else {
       parentFolder = (IContainer) subFolder;
     }
     worked(1);
   }
   if (results.size() > 0) {
     this.resultElements = new IModelElement[results.size()];
     results.toArray(this.resultElements);
     if (delta != null) {
       addDelta(delta);
     }
   }
   done();
 }
  /**
   * This file created the base structure of the file transformation configuiration file.
   *
   * @param container
   * @throws IOException
   * @throws TemplateException
   */
  private void createTransformationTemplate(IContainer container)
      throws IOException, TemplateException {

    final Bundle bundle = Platform.getBundle(AsideActivator.PLUGIN_ID);
    final String fileName = "resources/FileToFileTemplate.ftl";
    final Path originPath = new Path(fileName);

    URL bundledFileURL = FileLocator.find(bundle, originPath, null);

    String ftlLocation = null;
    try {
      bundledFileURL = FileLocator.resolve(bundledFileURL);
      ftlLocation = bundledFileURL.getFile().toString();
      ftlLocation = ftlLocation.substring(1, ftlLocation.lastIndexOf("/"));

    } catch (IOException e) {
      throw new RuntimeException("Plugin Error: can't read file: " + fileName, e);
    }

    Configuration cfg = new Configuration();
    cfg.setDirectoryForTemplateLoading(new File(ftlLocation));
    Template template = cfg.getTemplate("FileToFileTemplate.ftl");
    final IFolder folder = container.getFolder(new Path("resources"));
    if (folder.exists()) {
      // Build the data-model
      Map<String, Object> data = new HashMap<String, Object>();
      data.put("job_name", selectFileTransformationPage.getInterfaceMaster().getInterfaceName());

      // File output
      Writer baseFile =
          new FileWriter(
              new File(folder.getLocation().toString() + "/" + "FileToFileTemplate.xml"));
      template.process(data, baseFile);
      baseFile.flush();
      baseFile.close();
    }
  }
  private void validateNewExperimentName() {

    String name = fExperimentName.getText();
    IWorkspace workspace = fExperimentFolder.getWorkspace();
    IStatus nameStatus = workspace.validateName(name, IResource.FOLDER);

    if ("".equals(name)) { // $NON-NLS-1$
      updateStatus(
          new Status(
              IStatus.ERROR,
              Activator.PLUGIN_ID,
              IStatus.ERROR,
              Messages.Dialog_EmptyNameError,
              null));
      return;
    }

    if (!nameStatus.isOK()) {
      updateStatus(nameStatus);
      return;
    }

    IPath path = new Path(name);
    if (fExperimentFolder.getFolder(path).exists() || fExperimentFolder.getFile(path).exists()) {
      updateStatus(
          new Status(
              IStatus.ERROR,
              Activator.PLUGIN_ID,
              IStatus.ERROR,
              Messages.Dialog_ExistingNameError,
              null));
      return;
    }

    updateStatus(new Status(IStatus.OK, Activator.PLUGIN_ID, "")); // $NON-NLS-1$
  }
 void checkFolderNoExist(IContainer container, String fName) {
   IFolder folder = container.getFolder(new Path(fName));
   assertFalse(folder + " should not exist", folder.exists());
 }