Ejemplo n.º 1
0
 /**
  * Create a folder relative to the project based on aProjectRelativePathString.
  *
  * @param aProjectRelativePath
  * @return
  * @throws CoreException
  * @since 1.0.0
  */
 public IFolder createFolder(IPath aProjectRelativePath) throws CoreException {
   if (aProjectRelativePath != null && !aProjectRelativePath.isEmpty()) {
     IFolder folder =
         getWorkspace().getRoot().getFolder(getProjectPath().append(aProjectRelativePath));
     if (!folder.exists()) {
       ProjectUtilities.ensureContainerNotReadOnly(folder);
       folder.create(true, true, null);
     }
     return folder;
   }
   return null;
 }
Ejemplo n.º 2
0
  private void createFile() {
    if (result != null && result.indexOf('\\') == -1) { // NOI18N

      if (!targetFolder.getPrimaryFile().canWrite()) {
        return;
      }

      DataObject dObj = null;

      try {
        FileObject fo =
            type == TYPE_FILE
                ? FileUtil.createData(targetFolder.getPrimaryFile(), result)
                : FileUtil.createFolder(targetFolder.getPrimaryFile(), result);
        if (fo != null) {
          dObj = DataObject.find(fo);
        }
      } catch (DataObjectNotFoundException e) {
        // No data object no open
      } catch (IOException e) {
        // XXX
      }

      if (result != null) {
        // handle new template in SystemFileSystem
        DataObject rootDO = findTemplate("/Templates"); // NOI18N
        if (rootDO != null && dObj != null) {
          if (FileUtil.isParentOf(rootDO.getPrimaryFile(), dObj.getPrimaryFile())) {
            try {
              dObj.setTemplate(true);
            } catch (IOException e) {
              // can ignore
            }
          }
        }
      }
      if (dObj != null) {
        ProjectUtilities.openAndSelectNewObject(dObj);
      }
    }
  }
Ejemplo n.º 3
0
 /**
  * Add the nature id to the project.
  *
  * @param proj
  * @param natureId
  * @throws CoreException
  * @since 1.0.0
  */
 protected static void addNatureToProject(IProject proj, String natureId) throws CoreException {
   ProjectUtilities.addNatureToProject(proj, natureId);
 }