Example #1
0
  /** {@inheritDoc} */
  public boolean accept(Object element) {
    boolean passes = true;

    if (element instanceof IFile) {

      IFile file = (IFile) element;
      IProject project = file.getProject();

      if (RepositoryProvider.isShared(project)) {

        RepositoryProvider provider = RepositoryProvider.getProvider(project);

        if (provider != null) {

          Subscriber subscriber = provider.getSubscriber();

          if (subscriber != null) {

            try {
              SyncInfo synchInfo = subscriber.getSyncInfo(file);

              if (synchInfo != null) {
                int kind = synchInfo.getKind();
                passes = (SyncInfo.getDirection(kind) & SyncInfo.OUTGOING) == SyncInfo.OUTGOING;
              }
            } catch (TeamException e) {
              CheckstyleLog.log(e);
            }
          }
        }
      }
    }
    return passes;
  }
  @Before
  public void setUp() throws Exception {

    IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();

    FileUtils.mkdir(new File(root.getLocation().toFile(), "Sub"), true);
    gitDir = new File(new File(root.getLocation().toFile(), "Sub"), Constants.DOT_GIT);

    repository = FileRepositoryBuilder.create(gitDir);
    repository.create();

    project = root.getProject(TEST_PROJECT);
    project.create(null);
    project.open(null);
    IProjectDescription description = project.getDescription();
    description.setLocation(root.getLocation().append(TEST_PROJECT_LOC));
    project.move(description, IResource.FORCE, null);

    project2 = root.getProject(TEST_PROJECT2);
    project2.create(null);
    project2.open(null);
    gitDir2 = new File(project2.getLocation().toFile().getAbsoluteFile(), Constants.DOT_GIT);
    repository2 = FileRepositoryBuilder.create(gitDir2);
    repository2.create();

    RepositoryMapping mapping = RepositoryMapping.create(project, gitDir);
    RepositoryMapping mapping2 = RepositoryMapping.create(project2, gitDir2);

    GitProjectData projectData = new GitProjectData(project);
    GitProjectData projectData2 = new GitProjectData(project2);
    projectData.setRepositoryMappings(Collections.singletonList(mapping));
    projectData.store();
    projectData2.setRepositoryMappings(Collections.singletonList(mapping2));
    projectData2.store();
    GitProjectData.add(project, projectData);
    GitProjectData.add(project2, projectData2);

    RepositoryProvider.map(project, GitProvider.class.getName());
    RepositoryProvider.map(project2, GitProvider.class.getName());

    JGitTestUtil.write(
        new File(repository.getWorkTree(), TEST_PROJECT + "/" + TEST_FILE), "Some data");
    JGitTestUtil.write(new File(repository2.getWorkTree(), TEST_FILE2), "Some other data");
    project.refreshLocal(IResource.DEPTH_INFINITE, null);
    project2.refreshLocal(IResource.DEPTH_INFINITE, null);
    git = new Git(repository);
    git.add().addFilepattern(".").call();
    git.commit().setMessage("Initial commit").call();

    git = new Git(repository2);
    git.add().addFilepattern(".").call();
    git.commit().setMessage("Initial commit").call();
    git.branchRename().setNewName("main").call();
  }
 private static List<IProject> getAllProjects() {
   List<IProject> projects = new ArrayList<IProject>();
   IProject[] iProjects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
   for (IProject project : iProjects) {
     if (RepositoryProvider.isShared(project)) {
       projects.add(project);
     }
   }
   return projects;
 }
  /* (non-Javadoc)
   * @see org.eclipse.egit.core.op.IEGitOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
   */
  public void execute(IProgressMonitor m) throws CoreException {
    if (m == null) {
      m = new NullProgressMonitor();
    }

    m.beginTask(CoreText.ConnectProviderOperation_connecting, 100 * projects.size());
    try {

      for (Iterator iterator = projects.keySet().iterator(); iterator.hasNext(); ) {
        IProject project = (IProject) iterator.next();
        m.setTaskName(
            NLS.bind(CoreText.ConnectProviderOperation_ConnectingProject, project.getName()));
        // TODO is this the right location?
        if (GitTraceLocation.CORE.isActive())
          GitTraceLocation.getTrace()
              .trace(
                  GitTraceLocation.CORE.getLocation(),
                  "Locating repository for " + project); // $NON-NLS-1$

        Collection<RepositoryMapping> repos =
            new RepositoryFinder(project).find(new SubProgressMonitor(m, 40));
        File suggestedRepo = projects.get(project);
        RepositoryMapping actualMapping = findActualRepository(repos, suggestedRepo);
        if (actualMapping != null) {
          GitProjectData projectData = new GitProjectData(project);
          try {
            projectData.setRepositoryMappings(Arrays.asList(actualMapping));
            projectData.store();
          } catch (CoreException ce) {
            GitProjectData.delete(project);
            throw ce;
          } catch (RuntimeException ce) {
            GitProjectData.delete(project);
            throw ce;
          }
          RepositoryProvider.map(project, GitProvider.class.getName());
          projectData = GitProjectData.get(project);
          project.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(m, 50));
          m.worked(10);
        } else {
          // TODO is this the right location?
          if (GitTraceLocation.CORE.isActive())
            GitTraceLocation.getTrace()
                .trace(
                    GitTraceLocation.CORE.getLocation(),
                    "Attempted to share project without repository ignored :" //$NON-NLS-1$
                        + project);
          m.worked(60);
        }
      }
    } finally {
      m.done();
    }
  }
  @After
  public void tearDown() throws Exception {

    Thread.sleep(1000); // FIXME: We need a good way to wait for things to settle

    RepositoryProvider.unmap(project);
    RepositoryProvider.unmap(project2);

    GitProjectData.delete(project);
    GitProjectData.delete(project2);

    project.delete(true, true, null);
    project2.delete(true, true, null);

    repository.close();
    repository2.close();

    org.eclipse.egit.core.Activator.getDefault().getRepositoryCache().clear();

    FileUtils.delete(gitDir, FileUtils.RECURSIVE);
    // gitDir2 is inside project, already gone
  }
 public IFileHistory getFileHistoryFor(IResource resource, int flags, IProgressMonitor monitor) {
   RepositoryProvider provider = RepositoryProvider.getProvider(((IFile) resource).getProject());
   if (provider instanceof MercurialTeamProvider) {
     MercurialHistory history = new MercurialHistory(resource);
     try {
       history.load(monitor, Integer.MAX_VALUE);
     } catch (CoreException e) {
       MercurialEclipsePlugin.logError(e);
     }
     return history;
   }
   return null;
 }
Example #7
0
 @Override
 protected IStatus run(IProgressMonitor monitor) {
   try {
     RepositoryProvider.unmap(project);
     return Status.OK_STATUS;
   } catch (TeamException e) {
     return new Status(
         IStatus.ERROR,
         Activator.getPluginId(),
         MessageFormat.format(
             CoreText.GitProjectData_UnmappingGoneResourceFailed, project.getName()),
         e);
   }
 }
 /** Split the resources into sets associated with their project/provider */
 protected Map getRepositoryProviderMapping() {
   HashMap result = new HashMap();
   IResource[] resources = getSelectedResources();
   for (IResource element : resources) {
     RepositoryProvider provider = RepositoryProvider.getProvider(element.getProject());
     List list = (List) result.get(provider);
     if (list == null) {
       list = new ArrayList();
       result.put(provider, list);
     }
     list.add(new SimpleResourceMapping(element));
   }
   return result;
 }
  /* (non-Javadoc)
   * @see org.eclipse.egit.core.op.IEGitOperation#execute(org.eclipse.core.runtime.IProgressMonitor)
   */
  public void execute(IProgressMonitor m) throws CoreException {
    IProgressMonitor monitor;
    if (m == null) monitor = new NullProgressMonitor();
    else monitor = m;

    monitor.beginTask(CoreText.DisconnectProviderOperation_disconnecting, projectList.size() * 200);
    try {
      for (IProject p : projectList) {
        // TODO is this the right location?
        if (GitTraceLocation.CORE.isActive())
          GitTraceLocation.getTrace()
              .trace(
                  GitTraceLocation.CORE.getLocation(), "disconnect " + p.getName()); // $NON-NLS-1$
        unmarkTeamPrivate(p);
        RepositoryProvider.unmap(p);
        monitor.worked(100);

        p.refreshLocal(IResource.DEPTH_INFINITE, new SubProgressMonitor(monitor, 100));
      }
    } finally {
      monitor.done();
    }
  }
 /** @see IProjectNature#setProject(IProject) */
 public void setProject(IProject project) {
   super.setProject(project);
   this.workspaceRoot = new SVNWorkspaceRoot(project);
 }
Example #11
0
  /**
   * Process the EGit history associated with a given project.
   *
   * @param selectedProject selected project, presumably an object contribution selection
   * @throws CoreException
   * @throws IOException
   */
  public void processHistory(IProject selectedProject, IProgressMonitor monitor)
      throws CoreException, IOException {

    // find the repository mapping for the project
    // if none found, return
    RepositoryMapping repositoryMapping = RepositoryMapping.getMapping((IResource) selectedProject);
    if (repositoryMapping == null) {
      CertWareLog.logWarning(
          String.format("%s %s", "Missing repository for project", selectedProject.getName()));
      return;
    }

    // build the commit history model, load it from the tree walk
    final CommitHistory commitHistory = ScoFactory.eINSTANCE.createCommitHistory();
    Repository repo = repositoryMapping.getRepository();
    RevWalk revWalk = new RevWalk(repo);
    ObjectId headObject = repo.resolve("HEAD");
    revWalk.markStart(revWalk.parseCommit(headObject));

    final Set<String> repositoryPaths =
        Collections.singleton(repositoryMapping.getRepoRelativePath(selectedProject));
    revWalk.setTreeFilter(PathFilterGroup.createFromStrings(repositoryPaths));

    for (RevCommit commit : revWalk) {
      String commitName = commit.getName();
      ArtifactCommit artifactCommit = ScoFactory.eINSTANCE.createArtifactCommit();
      artifactCommit.setCommitIdentifier(commitName);
      commitHistory.getCommitRecord().add(artifactCommit);
    }

    revWalk.dispose();

    // use the Git provider to find the file history, then converge into the model
    GitProvider provider = (GitProvider) RepositoryProvider.getProvider(selectedProject);
    IFileHistoryProvider fileHistoryProvider = provider.getFileHistoryProvider();
    IResource[] projectMembers = selectedProject.members();

    monitor.beginTask("Processing project resources", projectMembers.length);
    for (IResource resource : projectMembers) {
      processResource(resource, fileHistoryProvider, commitHistory, monitor);
      monitor.worked(1);
      if (monitor.isCanceled()) {
        return;
      }
    }

    // model complete with commit history and associated file sizes
    // write the resulting model to an SCO file
    // expecting preference to have no extension, so add it if necessary
    IPreferenceStore store = Activator.getDefault().getPreferenceStore();
    String fileName = store.getString(PreferenceConstants.P_FILENAME_SCO);
    if (fileName.endsWith(ICertWareConstants.SCO_EXTENSION) == false) {
      fileName = fileName + '.' + ICertWareConstants.SCO_EXTENSION;
    }

    // fully specify the path to the new file given the container project
    final String modelFile =
        selectedProject.getFullPath().toPortableString() + IPath.SEPARATOR + fileName;

    // create the resource in a workspace modify operation
    WorkspaceModifyOperation operation =
        new WorkspaceModifyOperation() {
          @Override
          protected void execute(IProgressMonitor progressMonitor) {
            try {
              // create a resource set and resource for a new file
              ResourceSet resourceSet = new ResourceSetImpl();
              URI fileURI = URI.createPlatformResourceURI(modelFile, true);
              Resource resource = resourceSet.createResource(fileURI);
              resource.getContents().add(commitHistory);

              // save the contents of the resource to the file system
              Map<Object, Object> options = new HashMap<Object, Object>();
              options.put(XMLResource.OPTION_ENCODING, FILE_ENCODING);
              resource.save(options);
            } catch (Exception e) {
              CertWareLog.logError(String.format("%s %s", "Saving SCO file", modelFile), e);
            }
          }
        };

    // modify the workspace
    try {
      operation.run(monitor);
    } catch (Exception e) {
      CertWareLog.logError(
          String.format("%s %s", "Modifying workspace for", selectedProject.getName()), e);
    }

    monitor.done();
  }
 /**
  * Returns <code>true</code> if the given project is associated to any team provider (git, svn,
  * cvs, etc.). Returns <code>false</code> otherwise.
  *
  * @param project the project to check
  * @return <code>true</code> if the project is associated with any team provider.
  */
 public static boolean isShared(IProject project) {
   return RepositoryProvider.getProvider(project) != null;
 }
  /**
   * Returns a team project set for <code>projects</code>.
   *
   * @param projects the projects to include
   * @return an XML document
   * @throws CoreException indicates that the team project set could not be created
   */
  public static ByteArrayOutputStream exportProjectSet(List<IProject> projects)
      throws CoreException {
    Map<String, Set<IProject>> map = new HashMap<String, Set<IProject>>();
    for (IProject project : projects) {
      RepositoryProvider provider = RepositoryProvider.getProvider(project);
      if (provider != null) {
        String id = provider.getID();
        Set<IProject> list = map.get(id);
        if (list == null) {
          list =
              new TreeSet<IProject>(
                  new Comparator<IProject>() {
                    public int compare(IProject o1, IProject o2) {
                      return o1.getName().toLowerCase().compareTo(o2.getName().toLowerCase());
                    }
                  });
          map.put(id, list);
        }
        list.add(project);
      }
    }

    BufferedWriter writer = null;
    ByteArrayOutputStream output = new ByteArrayOutputStream();
    try {
      writer = new BufferedWriter(new OutputStreamWriter(output, "UTF-8")); // $NON-NLS-1$

      XmlMemento xmlMemento = getXMLMementoRoot();
      Iterator<String> it = map.keySet().iterator();
      while (it.hasNext()) {
        String id = it.next();
        XmlMemento memento = xmlMemento.createChild("provider"); // $NON-NLS-1$
        memento.putString("id", id); // $NON-NLS-1$
        Set<IProject> list = map.get(id);
        IProject[] projectArray = list.toArray(new IProject[list.size()]);
        RepositoryProviderType providerType = RepositoryProviderType.getProviderType(id);
        ProjectSetCapability serializer = providerType.getProjectSetCapability();
        ProjectSetCapability.ensureBackwardsCompatible(providerType, serializer);
        if (serializer != null) {
          String[] references = serializer.asReference(projectArray, null, null);
          for (String reference : references) {
            XmlMemento proj = memento.createChild("project"); // $NON-NLS-1$
            proj.putString("reference", reference); // $NON-NLS-1$
          }
        }
      }

      xmlMemento.save(writer);
      return output;
    } catch (Exception e) {
      throw new CoreException(
          new Status(
              IStatus.ERROR,
              ScmInternal.ID_PLUGIN,
              "Unexpected error exporting project sets.",
              e)); //$NON-NLS-1$
    } finally {
      if (writer != null) {
        try {
          writer.close();
        } catch (IOException e) {
          // ignore
        }
      }
    }
  }
  /**
   * The action is enabled for the appropriate resources. This method checks that:
   *
   * <ol>
   *   <li>there is no overlap between a selected file and folder (overlapping folders is allowed
   *       because of logical vs. physical mapping problem in views)
   *   <li>the state of the resources match the conditions provided by:
   *       <ul>
   *         <li>isEnabledForIgnoredResources()
   *         <li>isEnabledForManagedResources()
   *         <li>isEnabledForUnManagedResources() (i.e. not ignored and not managed)
   *       </ul>
   * </ol>
   *
   * @see TeamAction#isEnabled()
   */
  public boolean isEnabled() {

    // allow the super to decide enablement. if the super doesn't know it will return false.
    boolean enabled = super.isEnabled();
    if (enabled) return true;

    // invoke the inherited method so that overlaps are maintained
    IResource[] resources = getSelectedResourcesWithOverlap();

    // disable if no resources are selected
    if (resources.length == 0) return false;

    // disable properly for single resource enablement
    if (!isEnabledForMultipleResources() && resources.length != 1) return false;

    // validate enabled for each resource in the selection
    List folderPaths = new ArrayList();
    List filePaths = new ArrayList();
    for (int i = 0; i < resources.length; i++) {
      IResource resource = resources[i];

      // only enable for accessible resources
      if (resource.getType() == IResource.PROJECT) {
        if (!resource.isAccessible()) return false;
      }

      // no CVS actions are enabled if the selection contains a linked resource
      if (CVSWorkspaceRoot.isLinkedResource(resource)) return false;

      // only enable for resources in a project shared with CVS
      if (RepositoryProvider.getProvider(resource.getProject(), CVSProviderPlugin.getTypeId())
          == null) {
        return false;
      }

      // collect files and folders separately to check for overlap later
      IPath resourceFullPath = resource.getFullPath();
      if (resource.getType() == IResource.FILE) {
        filePaths.add(resourceFullPath);
      } else {
        folderPaths.add(resourceFullPath);
      }

      // ensure that resource management state matches what the action requires
      ICVSResource cvsResource = getCVSResourceFor(resource);
      try {
        if (!isEnabledForCVSResource(cvsResource)) {
          return false;
        }
      } catch (CVSException e) {
        if (!isEnabledForException(e)) return false;
      }
    }
    // Ensure that there is no overlap between files and folders
    // NOTE: folder overlap must be allowed because of logical vs. physical
    if (!folderPaths.isEmpty()) {
      for (Iterator fileIter = filePaths.iterator(); fileIter.hasNext(); ) {
        IPath resourcePath = (IPath) fileIter.next();
        for (Iterator it = folderPaths.iterator(); it.hasNext(); ) {
          IPath folderPath = (IPath) it.next();
          if (folderPath.isPrefixOf(resourcePath)) {
            return false;
          }
        }
      }
    }
    return true;
  }
  private void prepareChangeLog(IProgressMonitor monitor) {

    Object element = selected.getFirstElement();

    IResource resource = null;
    Vector<PatchFile> newList = new Vector<PatchFile>();
    Vector<PatchFile> removeList = new Vector<PatchFile>();
    Vector<PatchFile> changeList = new Vector<PatchFile>();
    int totalChanges = 0;

    if (element instanceof IResource) {
      resource = (IResource) element;
    } else if (element instanceof ISynchronizeModelElement) {
      ISynchronizeModelElement sme = (ISynchronizeModelElement) element;
      resource = sme.getResource();
    } else if (element instanceof IAdaptable) {
      resource = (IResource) ((IAdaptable) element).getAdapter(IResource.class);
    }

    if (resource == null) return;

    IProject project = resource.getProject();
    // Get the repository provider so we can support multiple types of
    // code repositories without knowing exactly which (e.g. CVS, SVN, etc..).
    RepositoryProvider r = RepositoryProvider.getProvider(project);
    if (r == null) return;
    SyncInfoSet set = new SyncInfoSet();
    Subscriber s = r.getSubscriber();
    if (s == null) return;
    if (element instanceof ISynchronizeModelElement) {
      // We can extract the ChangeLog list from the synchronize view which
      // allows us to skip items removed from the view
      ISynchronizeModelElement d = (ISynchronizeModelElement) element;
      while (d.getParent() != null) d = (ISynchronizeModelElement) d.getParent();
      extractSynchronizeModelInfo(d, new Path(""), newList, removeList, changeList);
      totalChanges = newList.size() + removeList.size() + changeList.size();
    } else {
      // We can then get a list of all out-of-sync resources.
      s.collectOutOfSync(new IResource[] {project}, IResource.DEPTH_INFINITE, set, monitor);
      SyncInfo[] infos = set.getSyncInfos();
      totalChanges = infos.length;
      // Iterate through the list of changed resources and categorize them into
      // New, Removed, and Changed lists.
      for (SyncInfo info : infos) {
        int kind = SyncInfo.getChange(info.getKind());
        PatchFile p = new PatchFile(info.getLocal());

        // Check the type of entry and sort into lists.  Do not add an entry
        // for ChangeLog files.
        if (!(p.getPath().lastSegment().equals("ChangeLog"))) { // $NON-NLS-1$
          if (kind == SyncInfo.ADDITION) {
            p.setNewfile(true);
            newList.add(p);
          } else if (kind == SyncInfo.DELETION) {
            p.setRemovedFile(true);
            removeList.add(p);
          } else if (kind == SyncInfo.CHANGE) {
            if (info.getLocal().getType() == IResource.FILE) {
              changeList.add(p);
            }
          }
        } else {
          this.changeLogModified = true;
        }
      }
    }

    if (totalChanges == 0) return; // nothing to parse

    PatchFile[] patchFileInfoList = new PatchFile[totalChanges];

    // Group like changes together and sort them by path name.
    // We want removed files, then new files, then changed files.
    // To get this, we put them in the array in reverse order.
    int index = 0;
    if (changeList.size() > 0) {
      // Get the repository provider so we can support multiple types of
      // code repositories without knowing exactly which (e.g. CVS, SVN, etc..).
      Collections.sort(changeList, new PatchFileComparator());
      int size = changeList.size();
      for (int i = 0; i < size; ++i) {
        PatchFile p = changeList.get(i);
        getChangedLines(s, p, monitor);
        patchFileInfoList[index + (size - i - 1)] = p;
      }
      index += size;
    }

    if (newList.size() > 0) {
      Collections.sort(newList, new PatchFileComparator());
      int size = newList.size();
      for (int i = 0; i < size; ++i) patchFileInfoList[index + (size - i - 1)] = newList.get(i);
      index += size;
    }

    if (removeList.size() > 0) {
      Collections.sort(removeList, new PatchFileComparator());
      int size = removeList.size();
      for (int i = 0; i < size; ++i) patchFileInfoList[index + (size - i - 1)] = removeList.get(i);
    }

    // now, find out modified functions/classes.
    // try to use the the extension point. so it can be extended easily
    // for all files in patch file info list, get function guesses of each
    // file.
    monitor.subTask(Messages.getString("ChangeLog.WritingMessage")); // $NON-NLS-1$
    int unitwork = 250 / patchFileInfoList.length;
    for (PatchFile pf : patchFileInfoList) {
      // for each file
      if (pf != null) { // any ChangeLog changes will have null entries for them
        String[] funcGuessList = guessFunctionNames(pf);
        outputMultipleEntryChangeLog(pf, funcGuessList);
      }
      monitor.worked(unitwork);
    }
  }
Example #16
0
 private void compare(CommitItem commitItem) {
   IFile file = findFile(commitItem.path);
   if (file == null || RepositoryProvider.getProvider(file.getProject()) == null)
     CompareUtils.compareHeadWithWorkingTree(repository, commitItem.path);
   else CompareUtils.compareHeadWithWorkspace(repository, file);
 }
 /**
  * Returns <code>true</code> if the given project is associated to the egit team provider. Returns
  * <code>false</code> otherwise.
  *
  * @param project the project to check
  * @return <code>true</code> if the project is associated with the git team provider.
  */
 public static boolean isSharedWithGit(IProject project) {
   RepositoryProvider provider = RepositoryProvider.getProvider(project);
   return provider != null && EGIT_TEAM_PROVIDER_ID.equals(provider.getID());
 }
Example #18
0
 public boolean isEnabled() {
   return resource != null
       && RepositoryProvider.getProvider(resource.getProject(), GitProvider.ID) != null;
 }
  private void createProject(IFeatureModel model, IProgressMonitor monitor) throws CoreException {
    String name = model.getFeature().getId();

    IFeaturePlugin[] plugins = model.getFeature().getPlugins();
    for (int i = 0; i < plugins.length; i++) {
      if (name.equals(plugins[i].getId())) {
        name += "-feature"; // $NON-NLS-1$
        break;
      }
    }

    String task = NLS.bind(MDEUIMessages.FeatureImportWizard_operation_creating2, name);
    monitor.beginTask(task, 9);
    try {
      IProject project = fRoot.getProject(name);

      if (project.exists() || new File(project.getParent().getLocation().toFile(), name).exists()) {
        if (queryReplace(project)) {
          if (!project.exists()) project.create(new SubProgressMonitor(monitor, 1));
          project.delete(true, true, new SubProgressMonitor(monitor, 1));
          try {
            RepositoryProvider.unmap(project);
          } catch (TeamException e) {
          }
        } else {
          return;
        }
      } else {
        monitor.worked(1);
      }

      IProjectDescription description = MDEPlugin.getWorkspace().newProjectDescription(name);
      if (fTargetPath != null) description.setLocation(fTargetPath.append(name));

      project.create(description, new SubProgressMonitor(monitor, 1));
      if (!project.isOpen()) {
        project.open(null);
      }
      File featureDir = new File(model.getInstallLocation());

      importContent(
          featureDir,
          project.getFullPath(),
          FileSystemStructureProvider.INSTANCE,
          null,
          new SubProgressMonitor(monitor, 1));
      IFolder folder = project.getFolder("META-INF"); // $NON-NLS-1$
      if (folder.exists()) {
        folder.delete(true, null);
      }
      if (fBinary) {
        // Mark this project so that we can show image overlay
        // using the label decorator
        project.setPersistentProperty(
            MDECore.EXTERNAL_PROJECT_PROPERTY, MDECore.BINARY_PROJECT_VALUE);
      }
      createBuildProperties(project);
      setProjectNatures(project, model, monitor);
      if (project.hasNature(JavaCore.NATURE_ID)) setClasspath(project, model, monitor);

    } finally {
      monitor.done();
    }
  }