/**
   * @param project
   * @param destinationPath
   * @param classpathToMigrate
   */
  private void migrateSourceFiles(
      IProject project, IPath destinationPath, IClasspathEntry[] classpathToMigrate) {
    IPath relativeDestinationPath =
        ((IPath) destinationPath.clone()).makeRelativeTo(newProject.getFullPath());
    System.out.println(
        "migrate source destination: " + destinationPath + " relative: " + relativeDestinationPath);
    IFolder destination = newProject.getFolder(relativeDestinationPath);

    for (IClasspathEntry entry : classpathToMigrate) {
      if (entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
        try {
          IPath relativeSourcePath = entry.getPath().makeRelativeTo(project.getFullPath());
          IFolder source = project.getFolder(relativeSourcePath);

          SPLMigrationUtils.recursiveCopyFiles(source, destination);

          newProject.refreshLocal(IProject.DEPTH_INFINITE, null);

        } catch (CoreException e) {
          CorePlugin.getDefault().logError(e);
          e.printStackTrace();
        }
      }
    }
  }
  @Override
  public boolean performFinish() {
    try {
      // TODO Auto-generated method stub
      // See http://www.programcreek.com/2011/05/eclipse-jdt-tutorial-java-model/
      //

      IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
      // Crea un nuevo projecto
      final IProject project = root.getProject(page.getProjectName());
      project.create(null);
      project.open(null);

      // Map props = project.getPersistentProperties();

      /*			//Crear el proyecto Java
      			IProjectDescription description = project.getDescription();
      			//description.setLocation(page.getLocationPath());
      			//Associate nature
      			description.setNatureIds(new String[]{JavaCore.NATURE_ID});
      			project.setDescription(description, null);
      			IJavaProject javaProject = JavaCore.create(project);
      */
      IFolder folder = project.getFolder("models");
      folder.create(true, true, null);
      folder = project.getFolder("src-gen");
      folder.create(true, true, null);

      return true;
    } catch (CoreException e) {
      // TODO Auto-generated catch block
      MessageDialog.openError(getShell(), "Error", e.getMessage());
      return false;
    }
  }
  /**
   * The default implementation recursively traverses the folders of the imported projects and
   * copies all contents into a feature folder with the imported projects name in {@code
   * newProject}. Can be overwritten by extending classes to accomodate {@link
   * IComposerExtensionBase Composers} needs.
   */
  protected void migrateProjects() {
    for (IProject project : projects) {
      IPath destinationPath = new Path(configurationData.sourcePath);

      assert newProject.getFolder(destinationPath).isAccessible()
          : DESTINATIONFOLDER_NOT_ACCESSIBLE_OR_WRONG_PATH;
      assert project.isOpen() : PROJECT + project.getName() + IS_NOT_OPEN_;

      IPath featureFolderPath =
          SPLMigrationUtils.setupFolder(
              newProject.getFolder(destinationPath).getFolder(project.getName()));

      try {
        migrateClassPathDependentContent(project, featureFolderPath);
      } catch (JavaModelException e) {
        e.printStackTrace();
      }

      //			try
      //			{
      //				if(project.hasNature(ANDROID_NATURE))
      //					copyProjectProperties(project, featureFolderPath);
      //			} catch (CoreException e)
      //			{
      //				e.printStackTrace();
      //			}
    }
  }
  /**
   * Creates an NL fragment project along with the locale specific properties files.
   *
   * @throws CoreException
   * @throws IOException
   * @throws InvocationTargetException
   * @throws InterruptedException
   */
  private void internationalizePlugins(List plugins, List locales, Map overwrites)
      throws CoreException, IOException, InvocationTargetException, InterruptedException {

    Set created = new HashSet();

    for (Iterator it = plugins.iterator(); it.hasNext(); ) {
      IPluginModelBase plugin = (IPluginModelBase) it.next();

      for (Iterator iter = locales.iterator(); iter.hasNext(); ) {
        Locale locale = (Locale) iter.next();

        IProject project = getNLProject(plugin, locale);
        if (created.contains(project)
            || overwriteWithoutAsking
            || !project.exists()
            || OVERWRITE == overwrites.get(project.getName())) {
          if (!created.contains(project) && project.exists()) {
            project.delete(true, getProgressMonitor());
          }

          if (!created.contains(project)) {
            createNLFragment(plugin, project, locale);
            created.add(project);
            project.getFolder(RESOURCE_FOLDER_PARENT).create(false, true, getProgressMonitor());
          }

          project
              .getFolder(RESOURCE_FOLDER_PARENT)
              .getFolder(locale.toString())
              .create(true, true, getProgressMonitor());
          createLocaleSpecificPropertiesFile(project, plugin, locale);
        }
      }
    }
  }
  /**
   * Adds a source container to a IJavaProject.
   *
   * @param jproject The parent project
   * @param containerName The name of the new source container
   * @param inclusionFilters Inclusion filters to set
   * @param exclusionFilters Exclusion filters to set
   * @param outputLocation The location where class files are written to, <b>null</b> for project
   *     output folder
   * @return The handle to the new source container
   * @throws CoreException Creation failed
   */
  public static IPackageFragmentRoot addSourceContainer(
      IJavaProject jproject,
      String containerName,
      IPath[] inclusionFilters,
      IPath[] exclusionFilters,
      String outputLocation)
      throws CoreException {
    IProject project = jproject.getProject();
    IContainer container = null;
    if (containerName == null || containerName.length() == 0) {
      container = project;
    } else {
      IFolder folder = project.getFolder(containerName);
      if (!folder.exists()) {
        CoreUtility.createFolder(folder, false, true, null);
      }
      container = folder;
    }
    IPackageFragmentRoot root = jproject.getPackageFragmentRoot(container);

    IPath outputPath = null;
    if (outputLocation != null) {
      IFolder folder = project.getFolder(outputLocation);
      if (!folder.exists()) {
        CoreUtility.createFolder(folder, false, true, null);
      }
      outputPath = folder.getFullPath();
    }
    IClasspathEntry cpe =
        JavaCore.newSourceEntry(root.getPath(), inclusionFilters, exclusionFilters, outputPath);
    addToClasspath(jproject, cpe);
    return root;
  }
Example #6
0
  /**
   * This operation scans the default project area for SerializedItems and loads them into the Core.
   * It returns false if it encounters and error and true if it is successful.
   *
   * @return True if the SerializedItems stored in the default project area were loaded
   *     successfully, false otherwise.
   */
  private boolean loadDefaultAreaItems() {

    // Local Declarations
    boolean status = false;
    ArrayList<String> serializedItemNames = new ArrayList<String>();
    SerializedItemBuilder builder = null;
    IProject project;
    IResource[] resources = null;
    IResource currentResource = null;
    IFile file = null;
    String filename = null;

    // Get the default project and grab its contents
    project = projectTable.get("defaultUser");
    if (project == null) {
      return status;
    }
    try {
      // Update the status
      status = true;
      // If the "jobProfiles" folder exists, loop over the resources and
      // get the serialized items
      if (project.getFolder("jobProfiles").exists()) {
        // Get the list of resources in the project
        resources = project.getFolder("jobProfiles").members();
        for (int i = 0; i < resources.length; i++) {
          currentResource = resources[i];
          filename = currentResource.getFullPath().toOSString();
          // Grab PSF or XML file
          if (filename.endsWith(".psf") | filename.endsWith(".xml")) {
            // Get the file
            file = project.getFile(currentResource.getProjectRelativePath());
            try {
              // Load the SerializedItemBuilder
              builder = new SerializedItemBuilder(file.getContents());
              // Register the builder
              itemManager.registerBuilder(builder);
            } catch (IOException e) {
              // TODO Auto-generated catch block
              logger.error(getClass().getName() + " Exception!", e);
              status = false;
            }
          }
        }
      } else {
        // Otherwise create the folder and return since there is nothing
        // to load
        project.getFolder("jobProfiles").create(true, true, null);
      }
    } catch (CoreException e) {
      logger.error(getClass().getName() + " Exception!", e);
    }

    return status;
  }
Example #7
0
  private List<MavenProjectProblem> generateProblems() {
    List<MavenProjectProblem> result = new ArrayList<>();

    result.addAll(info.problems);
    result.addAll(
        info.modulesNameToPath
            .entrySet()
            .stream()
            .filter(entry -> !project.getFolder(entry.getKey()).exists())
            .map(
                entry ->
                    new MavenProjectProblem(
                        getPomPath(),
                        "Can't find module: " + entry.getKey(),
                        MavenProblemType.DEPENDENCY))
            .collect(Collectors.toList()));

    result.addAll(
        getDependencies()
            .stream()
            .filter(artifact -> !artifact.isResolved())
            .map(
                artifact ->
                    new MavenProjectProblem(
                        getPomPath(),
                        "Can't find dependency: " + artifact.getDisplayString(),
                        MavenProblemType.DEPENDENCY))
            .collect(Collectors.toList()));

    // TODO add unresolved plugins and extensions
    return result;
  }
  private void addLayoutFileChanges(IProject project, CompositeChange result) {
    try {
      // Update references in XML resource files
      IFolder resFolder = project.getFolder(SdkConstants.FD_RESOURCES);

      IResource[] folders = resFolder.members();
      for (IResource folder : folders) {
        String folderName = folder.getName();
        ResourceFolderType folderType = ResourceFolderType.getFolderType(folderName);
        if (folderType != ResourceFolderType.LAYOUT) {
          continue;
        }
        if (!(folder instanceof IFolder)) {
          continue;
        }
        IResource[] files = ((IFolder) folder).members();
        for (int i = 0; i < files.length; i++) {
          IResource member = files[i];
          if ((member instanceof IFile) && member.exists()) {
            IFile file = (IFile) member;
            String fileName = member.getName();

            if (SdkUtils.endsWith(fileName, DOT_XML)) {
              addXmlFileChanges(file, result, false);
            }
          }
        }
      }
    } catch (CoreException e) {
      RefactoringUtil.log(e);
    }
  }
  @Before
  public void setUp() throws Exception {
    System.setProperty("disableStartupRunner", "true");
    PHPCoreTests.waitForIndexer();
    PHPCoreTests.waitForAutoBuild();

    project1 = FileUtils.createProject("project1", PHPVersion.PHP5_3);

    IFolder folder = project1.getFolder("src");

    if (!folder.exists()) {
      folder.create(true, true, new NullProgressMonitor());
    }
    file = folder.getFile("test00294081.php");

    InputStream source =
        new ByteArrayInputStream(
            "<?php class MyClass{const constant = 'constant value';function showCons1tant() {echo self::constant;}}$class = new MyClass ();$class->showConstant ();echo $class::constant;?>"
                .getBytes());

    if (!file.exists()) {
      file.create(source, true, new NullProgressMonitor());
    } else {
      file.setContents(source, IFile.FORCE, new NullProgressMonitor());
    }

    PHPCoreTests.waitForIndexer();
    PHPCoreTests.waitForAutoBuild();
  }
Example #10
0
 public Object[] getChildren(final Object parentElement) {
   List<IFolder> list = new ArrayList<IFolder>();
   /*if( parentElement instanceof IHaskellProject ) {
     IHaskellProject hsProject = ( IHaskellProject )parentElement;
     Set<IPath> sourcePaths = hsProject.getSourcePaths();
     for( IPath sourcePath: sourcePaths ) {
       IProject project = hsProject.getResource();
       if( !sourcePath.equals( project.getProjectRelativePath() ) ) {
         list.add( project.getFolder( sourcePath ) );
       }
     }
   }*/
   if (parentElement instanceof IProject) {
     IProject project = (IProject) parentElement;
     IFile f = BuildWrapperPlugin.getCabalFile(project);
     try {
       PackageDescription pd = PackageDescriptionLoader.load(f);
       for (String sourcePath : pd.getStanzasBySourceDir().keySet()) {
         if (sourcePath.length() > 0) {
           list.add(project.getFolder(sourcePath));
         }
       }
     } catch (CoreException ex) {
       HaskellUIPlugin.log(ex);
     }
   }
   return list.toArray();
 }
Example #11
0
 public Collection<IPath> getIncludeDirs(
     final IProject project, final Collection<IPath> includeDirs) {
   final IErlProject erlProject = ErlModelManager.getErlangModel().getErlangProject(project);
   if (erlProject == null) {
     return includeDirs;
   }
   final Collection<IPath> projectIncludeDirs = erlProject.getIncludeDirs();
   final IPathVariableManager pvm = ResourcesPlugin.getWorkspace().getPathVariableManager();
   for (IPath inc : projectIncludeDirs) {
     inc = PluginUtils.resolvePVMPath(pvm, inc);
     if (inc.isAbsolute()) {
       includeDirs.add(inc);
     } else {
       final IFolder folder = project.getFolder(inc);
       if (folder != null) {
         final IPath location = folder.getLocation();
         if (location != null) {
           includeDirs.add(location);
         } else {
           ErlLogger.warn("No location for %s", folder);
         }
       }
     }
   }
   return includeDirs;
 }
  /**
   * This method obtains the children of this Experiment Results folder.
   *
   * <p>TODO: Define what the experiment results folder contains to be able to finish this method
   * correctly, right now it only accepts .xml files as children
   *
   * @param iProject The project that contains this Experiment Results folder
   * @return ArrayList<Object> The children of this Experiment Results folder
   */
  @Override
  protected ArrayList<Object> initializeChildren(IProject iProject) {
    ArrayList<Object> children = new ArrayList<Object>();

    // get the Experiment Results folder from the project
    IProject project = getProject();
    IFolder folder = project.getFolder(name);
    // attempt to get the resources inside this Experiment Results folder
    IResource[] members = {};
    try {
      members = folder.members();
    } catch (CoreException e) {
      e.printStackTrace();
    }
    // check for .xml files and add them to the children ArrayList
    for (IResource r : members) {
      System.out.println(r.toString());
      if (r instanceof IFile) {
        if (r.getFileExtension() != null) {
          if (r.getFileExtension().equalsIgnoreCase("xml")
              || r.getFileExtension().equalsIgnoreCase("tlv")) children.add(r);
        }
      }
    }
    System.out.println();
    return children;
  }
  @Before
  public void setUp() throws Exception {
    PHPCoreTests.waitForIndexer();
    PHPCoreTests.waitForAutoBuild();

    project1 = FileUtils.createProject("project1");

    IFolder folder = project1.getFolder("src");

    if (!folder.exists()) {
      folder.create(true, true, new NullProgressMonitor());
    }
    file = folder.getFile("test23.php");

    InputStream source =
        new ByteArrayInputStream(
            "<?php class Item { public $title;} class ItemEx extends Item{public $title;} $a=new ItemEx(); $a->title;?>"
                .getBytes());

    if (!file.exists()) {
      file.create(source, true, new NullProgressMonitor());
    } else {
      file.setContents(source, IFile.FORCE, new NullProgressMonitor());
    }

    PHPCoreTests.waitForIndexer();
    PHPCoreTests.waitForAutoBuild();
  }
  /**
   * Add a Java Nature to a project when creating
   *
   * @param project
   * @throws CoreException
   */
  private static void addJavaNature(final IProject project) throws CoreException {
    if (!project.hasNature(JavaCore.NATURE_ID)) {
      final IProjectDescription description = project.getDescription();
      final String[] prevNatures = description.getNatureIds();
      final String[] newNatures = new String[prevNatures.length + 1];
      System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
      newNatures[prevNatures.length] = JavaCore.NATURE_ID;
      description.setNatureIds(newNatures);
      project.setDescription(description, null);
      IFolder sourceFolder = project.getFolder("/src");
      sourceFolder.create(true, true, null);

      IJavaProject javaProject = JavaCore.create(project);
      javaProject.setRawClasspath(
          new IClasspathEntry[] {
            JavaCore.newSourceEntry(sourceFolder.getFullPath()),
            JavaCore.newContainerEntry(new Path("org.eclipse.jdt.launching.JRE_CONTAINER"))
          },
          null);

      @SuppressWarnings("unchecked")
      Hashtable<String, String> javaOptions = JavaCore.getOptions();
      javaOptions.put(JavaCore.COMPILER_COMPLIANCE, JavaCore.VERSION_1_5);
      javaOptions.put(JavaCore.COMPILER_CODEGEN_TARGET_PLATFORM, JavaCore.VERSION_1_5);
      javaOptions.put(JavaCore.COMPILER_SOURCE, JavaCore.VERSION_1_5);
      javaProject.setOptions(javaOptions);
    }
  }
  @Override
  protected void execute(IProgressMonitor monitor)
      throws CoreException, InvocationTargetException, InterruptedException {
    int numUnits = fWebLocation == null ? 3 : 4;

    monitor.beginTask(PDEUIMessages.NewSiteWizard_creatingProject, numUnits);

    CoreUtility.createProject(fProject, fPath, monitor);
    fProject.open(monitor);
    CoreUtility.addNatureToProject(fProject, PDE.SITE_NATURE, monitor);
    monitor.worked(1);

    if (fWebLocation != null) {
      CoreUtility.createFolder(fProject.getFolder(fWebLocation));
      createXSLFile();
      createCSSFile();
      createHTMLFile();
      monitor.worked(1);
    }

    monitor.subTask(PDEUIMessages.NewSiteWizard_creatingManifest);
    IFile file = createSiteManifest();
    monitor.worked(1);

    openFile(file);
    monitor.worked(1);
  }
  // test that after a source folder is deleted, all
  // class files nd resources are removed from the
  // output folder
  public void testDeleteSourceFolder() throws Exception {
    IProject proj = createPredefinedProject("CopyDerived1");
    getWorkspace().build(IncrementalProjectBuilder.FULL_BUILD, null);

    IJavaProject jProj = JavaCore.create(proj);
    IClasspathEntry[] classpath = jProj.getRawClasspath();
    IClasspathEntry[] newClasspath = new IClasspathEntry[classpath.length - 1];

    // remove the classpath entry corresponding to src
    for (int i = 0, j = 0; i < classpath.length; i++, j++) {
      if (classpath[i].getPath().lastSegment().toString().equals("src")) {
        j--;
        continue;
      }
      newClasspath[j] = classpath[i];
    }

    jProj.setRawClasspath(newClasspath, true, null);

    proj.build(IncrementalProjectBuilder.FULL_BUILD, null);

    IFolder out = proj.getFolder("bin");
    checkFolderIsNotDerived(out, "");
    checkFileNoExist(out, "file.txt");
    checkFileNoExist(out, "Nothing.class");
    checkFileNoExist(out, "Nothing2.class");
    checkFolderNoExist(out, "package1");
    checkFileNoExist(out, "package1/file.txt");
    checkFileNoExist(out, "package1/Nothing.class");
    checkFileNoExist(out, "package1/Nothing2.class");
  }
Example #17
0
  protected void checkIfPathValid() {
    fFolder = null;
    IContainer folder = null;
    if (fUseFolderButton.isSelected()) {
      String pathStr = fContainerDialogField.getText();
      if (pathStr.length() == 0) {
        fContainerFieldStatus.setError(NewWizardMessages.NewSourceFolderDialog_error_enterpath);
        return;
      }
      IPath path = fCurrProject.getFullPath().append(pathStr);
      IWorkspace workspace = fCurrProject.getWorkspace();

      IStatus pathValidation = workspace.validatePath(path.toString(), IResource.FOLDER);
      if (!pathValidation.isOK()) {
        fContainerFieldStatus.setError(
            Messages.format(
                NewWizardMessages.NewSourceFolderDialog_error_invalidpath,
                pathValidation.getMessage()));
        return;
      }
      folder = fCurrProject.getFolder(pathStr);
    } else {
      folder = fCurrProject;
    }
    if (isExisting(folder)) {
      fContainerFieldStatus.setError(NewWizardMessages.NewSourceFolderDialog_error_pathexists);
      return;
    }
    fContainerFieldStatus.setOK();
    fFolder = folder;
  }
 /**
  * Gets the output location for the given project, creates it if needed
  *
  * @param project
  * @return the path of the output location for the given project
  * @throws CoreException
  */
 public static IPath getDefaultProjectOutputLocation(IProject project) throws CoreException {
   IFolder binFolder = project.getFolder(BIN_FOLDER);
   if (!binFolder.exists()) {
     binFolder.create(false, true, null);
   }
   return binFolder.getFullPath();
 }
  @Parameters
  public static Collection<Object[]> params() throws Exception {
    project =
        ProjectUtils.copyProjectIntoWorkspace(
            X10DTUIPlugin.getInstance().getBundle(), new Path("data/X10DocProvider"));

    IFolder folder = project.getFolder("src");

    final List<Object[]> list = new ArrayList<Object[]>();

    folder.accept(
        new IResourceVisitor() {
          public boolean visit(IResource resource) throws CoreException {
            if (resource instanceof IFile) {
              if (!resource.toString().contains(".svn/")) {
                list.add(new Object[] {resource});
              }

              return false;
            }

            return true;
          }
        });

    return list;
  }
 protected void setUp() throws Exception {
   super.setUp();
   existingProject = getWorkspace().getRoot().getProject("ExistingProject");
   existingVirtualFolderInExistingProject =
       existingProject.getFolder("existingVirtualFolderInExistingProject");
   doCleanup();
 }
  /**
   * Initializes the resource set using the repository content ; if the repository content is empty,
   * creates all the declared indexes.
   *
   * @throws CoreException it the resourceSet cannot be initialized
   */
  private void initializeResourceSet() throws CoreException {

    // We first get the project on which the repository is defined
    IProject project = workspaceConfig.getProject();
    if (!project.exists()) {
      project.create(null);
    }
    if (!project.isOpen()) {
      project.open(null);
    }
    IFolder folder = project.getFolder(workspaceConfig.getRepositoryRelativePath());
    // We created a WorkspaceRepositoryLoader using the indexPathList
    WorkspaceRepositoryLoader loader =
        new WorkspaceRepositoryLoader(this, this.getWorkspaceConfig().getIndexesPathList());
    // If the repository folder exists
    if (folder.exists()) {
      // We load the resourceSet
      loader.loadResourceSet();
    } else {
      // If the repository folder doesn't exist
      // We create it
      folder.create(IResource.NONE, true, null);
      // And use the RepositoryLoader to initialize the resource set with empty content
      loader.loadResourceSet();
    }
    isResourceSetLoaded = true;
  }
Example #22
0
  /**
   * Creates new symbolic file system link from file or folder on project root to another file
   * system file. The filename can include relative path as a part of the name but the the path has
   * to be present on disk.
   *
   * @param project - project where to create the file.
   * @param linkName - name of the link being created.
   * @param realPath - file or folder on the file system, the target of the link.
   * @return file handle.
   * @throws UnsupportedOperationException on Windows where links are not supported.
   * @throws IOException...
   * @throws CoreException...
   */
  public static IResource createSymbolicLink(IProject project, String linkName, IPath realPath)
      throws IOException, CoreException, UnsupportedOperationException {

    if (!isSymbolicLinkSupported()) {
      throw new UnsupportedOperationException("Windows links .lnk are not supported.");
    }

    Assert.assertTrue(
        "Path for symbolic link does not exist: [" + realPath.toOSString() + "]",
        new File(realPath.toOSString()).exists());

    IPath linkedPath = project.getLocation().append(linkName);
    createSymbolicLink(linkedPath, realPath);

    IResource resource = project.getFile(linkName);
    resource.refreshLocal(IResource.DEPTH_ZERO, null);

    if (!resource.exists()) {
      resource = project.getFolder(linkName);
      resource.refreshLocal(IResource.DEPTH_ZERO, null);
    }
    Assert.assertTrue("Failed to create resource form symbolic link", resource.exists());

    externalFilesCreated.add(linkedPath.toOSString());
    ResourcesPlugin.getWorkspace().getRoot().refreshLocal(IResource.DEPTH_INFINITE, NULL_MONITOR);
    return resource;
  }
  private void initialiseProjectFiles(
      IProject project, IContainer container, IProgressMonitor monitor) throws CoreException {

    // create a config Dir
    IFolder configFolder = project.getFolder("config");
    configFolder.create(false, true, null);
    File configDir = configFolder.getLocation().toFile();

    monitor.beginTask("Creating config file ", 1);

    XMLOutputFactory factory = XMLOutputFactory.newInstance();

    try {
      XMLStreamWriter writer =
          factory.createXMLStreamWriter(
              new FileWriter(configDir.getAbsolutePath() + "\\config.xml"));

      writer.writeStartDocument();
      writer.writeStartElement("document");
      writer.writeStartElement("data");
      writer.writeAttribute("name", "value");
      writer.writeEndElement();
      writer.writeEndElement();
      writer.writeEndDocument();

      writer.flush();
      writer.close();

    } catch (XMLStreamException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
    }
  }
  private void importExcelAndGenerateFiles(
      IProject project, String filePath, String fileName, String importMode) throws Exception {
    IFolder srcGenFolder = project.getFolder(GEN_FOLDER);

    if (!srcGenFolder.exists()) {
      srcGenFolder.create(true, true, new NullProgressMonitor());
    }

    IFolder docsFolder = srcGenFolder.getFolder(DOCS_FOLDER);

    if (!docsFolder.exists()) {
      docsFolder.create(true, true, new NullProgressMonitor());
    }

    importExcelFile(docsFolder, filePath, fileName);

    // Remove file extension
    if (fileName.endsWith(".xlsx")) {
      fileName = fileName.split(".xlsx")[0];
    } else if (fileName.endsWith(".xls")) {
      fileName = fileName.split(".xls")[0];
    }

    if (importMode.equals(ImportWindow.SINGLE)) {
      generateSingleFile(srcGenFolder, filePath, fileName);
    } else {
      generateMainFile(srcGenFolder, filePath, fileName);
      generateStatementsFile(srcGenFolder, filePath, fileName);
      generatePrivateDataFile(srcGenFolder, filePath, fileName);
      generateServicesFile(srcGenFolder, filePath, fileName);
      generateEnforcementsFile(srcGenFolder, filePath, fileName);
      generateRecipientsFile(srcGenFolder, filePath, fileName);
    }
  }
 private IFolder addSourceArchive(
     IPath externalSourceArchivePath,
     IProject externalSourceArchivesProject,
     boolean scheduleForCreation) {
   Map<IPath, IResource> knownSourceArchives = getSourceArchives();
   Object existing = knownSourceArchives.get(externalSourceArchivePath);
   if (existing != null) {
     return (IFolder) existing;
   }
   IFolder result;
   int counter = 0;
   do {
     StringBuilder folderName = new StringBuilder(LINKED_FOLDER_NAME);
     if (counter > 0) {
       folderName.append(counter).append('-');
     }
     folderName.append(externalSourceArchivePath.lastSegment());
     result = externalSourceArchivesProject.getFolder(folderName.toString());
     counter++;
   } while (result.exists());
   if (scheduleForCreation) {
     synchronized (this) {
       if (pendingSourceArchives == null)
         pendingSourceArchives = Collections.synchronizedSet(new HashSet<IPath>());
     }
     pendingSourceArchives.add(externalSourceArchivePath);
   }
   knownSourceArchives.put(externalSourceArchivePath, result);
   return result;
 }
  private void importFile(File file, IProject project, List<IBuildpathEntry> entries) {

    try {

      level++;

      // handle windows path separators
      String path = file.getAbsolutePath().replace("\\", "/").replace(symfonyPath, "");

      // import the directory
      if (file.isDirectory() && !file.isHidden()) {

        IFolder folder = project.getFolder(path);

        if (!folder.exists()) {
          folder.create(true, true, null);
        }

        // add root folders to buildpath
        if (level == 1 && !folder.getFullPath().toString().endsWith("bin")) {

          IPath[] exclusion = {};

          if (folder.getName().equals(SymfonyCoreConstants.APP_PATH)) {
            exclusion =
                new IPath[] {
                  new Path(SymfonyCoreConstants.CACHE_PATH), new Path(SymfonyCoreConstants.LOG_PATH)
                };
          } else if (folder.getName().equals(SymfonyCoreConstants.VENDOR_PATH)) {
            exclusion = new IPath[] {new Path(SymfonyCoreConstants.SKELETON_PATH)};
          }

          IBuildpathEntry entry = DLTKCore.newSourceEntry(folder.getFullPath(), exclusion);
          entries.add(entry);
        }

        // now import recursively
        for (File f : file.listFiles()) {
          importFile(f, project, entries);
        }

        // create the project file
      } else if (file.isFile() && ".gitkeep".equals(file.getName()) == false) {

        FileInputStream fis = new FileInputStream(file);
        IFile iFile = project.getFile(path);
        iFile.create(fis, true, null);
      }

      level--;

    } catch (CoreException e) {
      e.printStackTrace();
      Logger.logException(e);
    } catch (FileNotFoundException e) {
      e.printStackTrace();
      Logger.logException(e);
    }
  }
 public static List<IFolder> decodeSrcPath(String srcPath, IProject project) {
   String[] paths = srcPath.split(";");
   List<IFolder> l = new ArrayList<IFolder>(paths.length);
   for (int i = 0; i < paths.length; i++) {
     l.add(project.getFolder(new Path(paths[i])));
   }
   return l;
 }
Example #28
0
 /**
  * Creates new eclipse folder-link from project root to file system folder. The folder name can
  * include relative path as a part of the name but the the path has to be present on disk.
  *
  * @param project - project where to create the file.
  * @param folderLink - name of the link being created.
  * @param realFolder - folder on the file system, the target of the link.
  * @return file handle.
  * @throws CoreException if something goes wrong.
  */
 public static IFolder createLinkedFolder(IProject project, String folderLink, IPath realFolder)
     throws CoreException {
   IFolder folder = project.getFolder(folderLink);
   folder.createLink(realFolder, IResource.REPLACE, null);
   Assert.assertTrue(folder.exists());
   resourcesCreated.add(folder);
   return folder;
 }
 private IFile createManifest(IProject project, IProgressMonitor monitor, PomParser bizPom) {
   String manifestTemplate = ResourceHelper.content(templateRoot + "MANIFEST.MF");
   String bizClientJar = "lib/" + bizPom.getArtifactId() + "-client.jar";
   String manifest =
       String.format(manifestTemplate, pi.getProjectName(), pi.getProjectId(), bizClientJar);
   IFolder metaInf = project.getFolder("META-INF");
   return EclipseHelper.createFile("MANIFEST.MF", metaInf, manifest, monitor);
 }
Example #30
0
 /**
  * Crude way to determine it... basically check for a folder called 'grails-app'. The reason we
  * need to know is because of the extra transform that will run if it is a grails-app (tagging
  * domain classes).
  */
 private static boolean isProbablyGrailsProject(IProject project) {
   try {
     IFolder folder = project.getFolder("grails-app");
     return folder.exists();
   } catch (Exception e) {
     return false;
   }
 }