@NotNull public Change[] getSelectedChanges() { Set<Change> changes = new LinkedHashSet<Change>(); final TreePath[] paths = getSelectionPaths(); if (paths == null) { return new Change[0]; } for (TreePath path : paths) { ChangesBrowserNode<?> node = (ChangesBrowserNode) path.getLastPathComponent(); changes.addAll(node.getAllChangesUnder()); } if (changes.isEmpty()) { final List<VirtualFile> selectedModifiedWithoutEditing = getSelectedModifiedWithoutEditing(); if (selectedModifiedWithoutEditing != null && !selectedModifiedWithoutEditing.isEmpty()) { for (VirtualFile file : selectedModifiedWithoutEditing) { AbstractVcs vcs = ProjectLevelVcsManager.getInstance(myProject).getVcsFor(file); if (vcs == null) continue; final VcsCurrentRevisionProxy before = VcsCurrentRevisionProxy.create(file, myProject, vcs.getKeyInstanceMethod()); if (before != null) { ContentRevision afterRevision = new CurrentContentRevision(new FilePathImpl(file)); changes.add(new Change(before, afterRevision, FileStatus.HIJACKED)); } } } } return changes.toArray(new Change[changes.size()]); }
private List<FilePath> getSelectedFilePaths(final Object tag) { Set<FilePath> files = new HashSet<FilePath>(); final TreePath[] paths = getSelectionPaths(); if (paths != null) { for (TreePath path : paths) { if (path.getPathCount() > 1) { ChangesBrowserNode firstNode = (ChangesBrowserNode) path.getPathComponent(1); if (tag == null || firstNode.getUserObject() == tag) { ChangesBrowserNode<?> node = (ChangesBrowserNode) path.getLastPathComponent(); files.addAll(node.getAllFilePathsUnder()); } } } } return new ArrayList<FilePath>(files); }
private List<LocallyDeletedChange> getSelectedLocallyDeletedChanges() { Set<LocallyDeletedChange> files = new HashSet<LocallyDeletedChange>(); final TreePath[] paths = getSelectionPaths(); if (paths != null) { for (TreePath path : paths) { if (path.getPathCount() > 1) { ChangesBrowserNode firstNode = (ChangesBrowserNode) path.getPathComponent(1); if (firstNode.getUserObject() == TreeModelBuilder.LOCALLY_DELETED_NODE) { ChangesBrowserNode<?> node = (ChangesBrowserNode) path.getLastPathComponent(); final List<LocallyDeletedChange> objectsUnder = node.getAllObjectsUnder(LocallyDeletedChange.class); files.addAll(objectsUnder); } } } } return new ArrayList<LocallyDeletedChange>(files); }