public UpdateInfoTree(
      @NotNull ContentManager contentManager,
      @NotNull Project project,
      UpdatedFiles updatedFiles,
      String rootName,
      ActionInfo actionInfo) {
    super(contentManager, "reference.toolWindows.versionControl");
    myActionInfo = actionInfo;

    myFileStatusListener =
        new FileStatusListener() {
          public void fileStatusesChanged() {
            myTree.repaint();
          }

          public void fileStatusChanged(@NotNull VirtualFile virtualFile) {
            myTree.repaint();
          }
        };

    myProject = project;
    myUpdatedFiles = updatedFiles;
    myRootName = rootName;

    myFileStatusManager = FileStatusManager.getInstance(myProject);
    myFileStatusManager.addFileStatusListener(myFileStatusListener);
    createTree();
    init();
    myTreeExpander = new DefaultTreeExpander(myTree);
    myTreeIterable = new MyTreeIterable();
  }
  public static boolean fileInVcsByFileStatus(@NotNull Project project, @NotNull VirtualFile file) {
    FileStatus status = FileStatusManager.getInstance(project).getStatus(file);

    return status != FileStatus.UNKNOWN
        && status != FileStatus.ADDED
        && status != FileStatus.IGNORED;
  }
 /**
  * Returns true if the specified file path represents a file which exists in the VCS repository
  * (is neither unversioned nor scheduled for addition). This method is called only for directories
  * which are mapped to this VCS in the project configuration.
  *
  * @param path the path to check.
  * @return true if the corresponding file exists in the repository, false otherwise.
  */
 public boolean fileExistsInVcs(FilePath path) {
   final VirtualFile virtualFile = path.getVirtualFile();
   if (virtualFile != null) {
     final FileStatus fileStatus = FileStatusManager.getInstance(myProject).getStatus(virtualFile);
     return fileStatus != FileStatus.UNKNOWN && fileStatus != FileStatus.ADDED;
   }
   return true;
 }
Example #4
0
  protected boolean isEnabled(
      @NotNull Project project,
      @NotNull com.assembla.git.GitVcs vcs,
      @NotNull VirtualFile... vFiles) {
    for (VirtualFile file : vFiles) {
      if (FileStatusManager.getInstance(project).getStatus(file) == FileStatus.UNKNOWN)
        return false;
    }

    return true;
  }
 @Override
 protected boolean approximatelyHasRoots(final VcsContext dataContext) {
   final FilePath[] paths = dataContext.getSelectedFilePaths();
   if (paths.length == 0) return false;
   final FileStatusManager fsm = FileStatusManager.getInstance(dataContext.getProject());
   for (final FilePath path : paths) {
     VirtualFile file = path.getVirtualFile();
     if (file == null) {
       continue;
     }
     FileStatus status = fsm.getStatus(file);
     if (isApplicableRoot(file, status, dataContext)) {
       return true;
     }
   }
   return false;
 }
  private void checkForMultipleCopiesNotMove(boolean somethingChanged) {
    final MultiMap<FilePath, Pair<Change, String>> moves =
        new MultiMap<FilePath, Pair<Change, String>>() {
          @NotNull
          protected Collection<Pair<Change, String>> createCollection() {
            return new LinkedList<Pair<Change, String>>();
          }
        };

    for (LocalChangeList changeList : myMap.values()) {
      final Collection<Change> changes = changeList.getChanges();
      for (Change change : changes) {
        if (change.isMoved() || change.isRenamed()) {
          moves.putValue(
              change.getBeforeRevision().getFile(), Pair.create(change, changeList.getName()));
        }
      }
    }
    for (FilePath filePath : moves.keySet()) {
      final List<Pair<Change, String>> copies = (List<Pair<Change, String>>) moves.get(filePath);
      if (copies.size() == 1) continue;
      Collections.sort(copies, MyChangesAfterRevisionComparator.getInstance());
      for (int i = 0; i < (copies.size() - 1); i++) {
        somethingChanged = true;
        final Pair<Change, String> item = copies.get(i);
        final Change oldChange = item.getFirst();
        final Change newChange = new Change(null, oldChange.getAfterRevision());

        final LocalChangeListImpl list = (LocalChangeListImpl) myMap.get(item.getSecond());
        list.removeChange(oldChange);
        list.addChange(newChange);

        final VcsKey key = myIdx.getVcsFor(oldChange);
        myIdx.changeRemoved(oldChange);
        myIdx.changeAdded(newChange, key);
      }
    }
    if (somethingChanged) {
      FileStatusManager.getInstance(myProject).fileStatusesChanged();
    }
  }