/**
  * DOC smallet Comment method "afterImportAs".
  *
  * @param newName
  * @param technicalName
  * @throws InvocationTargetException
  */
 private static Project afterImportAs(String newName, String technicalName)
     throws InvocationTargetException {
   // Rename in ".project" and "talendProject" or "talend.project"
   // TODO SML Optimize
   final IWorkspace workspace = org.eclipse.core.resources.ResourcesPlugin.getWorkspace();
   IContainer containers = (IProject) workspace.getRoot().findMember(new Path(technicalName));
   IResource file2 = containers.findMember(IProjectDescription.DESCRIPTION_FILE_NAME);
   try {
     FilesUtils.replaceInFile(
         "<name>.*</name>",
         file2.getLocation().toOSString(),
         "<name>" + technicalName + "</name>"); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     // TDI-19269
     final IProject project = workspace.getRoot().getProject(technicalName);
     XmiResourceManager xmiManager = new XmiResourceManager();
     try {
       final Project loadProject = xmiManager.loadProject(project);
       loadProject.setTechnicalLabel(technicalName);
       loadProject.setLabel(newName);
       loadProject.setLocal(true);
       loadProject.setId(0);
       loadProject.setUrl(null);
       loadProject.setCreationDate(null);
       loadProject.setDescription("");
       loadProject.setType(null);
       // ADD xqliu 2012-03-12 TDQ-4771 clear the list of Folders
       if (loadProject.getFolders() != null) {
         loadProject.getFolders().clear();
       }
       // ~ TDQ-4771
       xmiManager.saveResource(loadProject.eResource());
       return loadProject;
     } catch (PersistenceException e) {
       //
     }
   } catch (IOException e) {
     throw new InvocationTargetException(e);
   }
   return null;
 }
Exemplo n.º 2
0
 /**
  * Sets the label.
  *
  * @param label the label to set
  */
 public void setLabel(String label) {
   project.setLabel(label);
 }
Exemplo n.º 3
0
 public Project(String label) {
   this.project = PropertiesFactory.eINSTANCE.createProject();
   project.setLabel(label);
 }