mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
cleanup, lambdify, use proper invokeLater
This commit is contained in:
@@ -15,12 +15,14 @@
|
||||
*/
|
||||
package git4idea.vfs;
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.progress.ProgressIndicator;
|
||||
import com.intellij.openapi.progress.ProgressManager;
|
||||
import com.intellij.openapi.progress.Task;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.vcs.FilePath;
|
||||
import com.intellij.openapi.vcs.ObjectsConvertor;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
@@ -30,7 +32,6 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileEvent;
|
||||
import com.intellij.ui.AppUIUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.vcsUtil.VcsFileUtil;
|
||||
import com.intellij.vcsUtil.VcsUtil;
|
||||
import git4idea.GitUtil;
|
||||
@@ -97,7 +98,7 @@ public class GitVFSListener extends VcsVFSListener {
|
||||
@Override
|
||||
protected void executeAdd(final List<VirtualFile> addedFiles, final Map<VirtualFile, VirtualFile> copiedFiles) {
|
||||
// Filter added files before further processing
|
||||
final Map<VirtualFile, List<VirtualFile>> sortedFiles;
|
||||
Map<VirtualFile, List<VirtualFile>> sortedFiles;
|
||||
try {
|
||||
sortedFiles = GitUtil.sortFilesByGitRoot(addedFiles, true);
|
||||
}
|
||||
@@ -111,27 +112,18 @@ public class GitVFSListener extends VcsVFSListener {
|
||||
public void run(@NotNull ProgressIndicator pi) {
|
||||
for (Map.Entry<VirtualFile, List<VirtualFile>> e : sortedFiles.entrySet()) {
|
||||
VirtualFile root = e.getKey();
|
||||
final List<VirtualFile> files = e.getValue();
|
||||
List<VirtualFile> files = e.getValue();
|
||||
pi.setText(root.getPresentableUrl());
|
||||
try {
|
||||
retainedFiles.addAll(myGit.untrackedFiles(myProject, root, files));
|
||||
}
|
||||
catch (final VcsException ex) {
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
public void run() {
|
||||
gitVcs().showMessages(ex.getMessage());
|
||||
}
|
||||
});
|
||||
catch (VcsException ex) {
|
||||
ApplicationManager.getApplication().invokeLater(() -> gitVcs().showMessages(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
addedFiles.retainAll(retainedFiles);
|
||||
|
||||
AppUIUtil.invokeLaterIfProjectAlive(myProject, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
originalExecuteAdd(addedFiles, copiedFiles);
|
||||
}
|
||||
});
|
||||
AppUIUtil.invokeLaterIfProjectAlive(myProject, () -> originalExecuteAdd(addedFiles, copiedFiles));
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -188,13 +180,13 @@ public class GitVFSListener extends VcsVFSListener {
|
||||
HashSet<File> filesToRefresh = new HashSet<>();
|
||||
|
||||
public void execute(@NotNull VirtualFile root, @NotNull List<FilePath> files) throws VcsException {
|
||||
final File rootFile = new File(root.getPath());
|
||||
GitFileUtils.delete(myProject, root, files, "--ignore-unmatch");
|
||||
if (myProject != null && !myProject.isDisposed()) {
|
||||
if (!myProject.isDisposed()) {
|
||||
VcsFileUtil.markFilesDirty(myProject, files);
|
||||
}
|
||||
File rootFile = new File(root.getPath());
|
||||
for (FilePath p : files) {
|
||||
for (File f = p.getIOFile(); f != null && !f.equals(rootFile); f = f.getParentFile()) {
|
||||
for (File f = p.getIOFile(); f != null && !FileUtil.filesEqual(f, rootFile); f = f.getParentFile()) {
|
||||
filesToRefresh.add(f);
|
||||
}
|
||||
}
|
||||
@@ -259,9 +251,10 @@ public class GitVFSListener extends VcsVFSListener {
|
||||
return deletedFiles;
|
||||
}
|
||||
|
||||
private void performBackgroundOperation(@NotNull Collection<FilePath> files, @NotNull String operationTitle,
|
||||
@NotNull final LongOperationPerRootExecutor executor) {
|
||||
final Map<VirtualFile, List<FilePath>> sortedFiles;
|
||||
private void performBackgroundOperation(@NotNull Collection<FilePath> files,
|
||||
@NotNull String operationTitle,
|
||||
@NotNull LongOperationPerRootExecutor executor) {
|
||||
Map<VirtualFile, List<FilePath>> sortedFiles;
|
||||
try {
|
||||
sortedFiles = GitUtil.sortFilePathsByGitRoot(files, true);
|
||||
}
|
||||
@@ -277,11 +270,7 @@ public class GitVFSListener extends VcsVFSListener {
|
||||
executor.execute(e.getKey(), e.getValue());
|
||||
}
|
||||
catch (final VcsException ex) {
|
||||
UIUtil.invokeLaterIfNeeded(new Runnable() {
|
||||
public void run() {
|
||||
gitVcs().showMessages(ex.getMessage());
|
||||
}
|
||||
});
|
||||
ApplicationManager.getApplication().invokeLater(() -> gitVcs().showMessages(ex.getMessage()));
|
||||
}
|
||||
}
|
||||
RefreshVFsSynchronously.refreshFiles(executor.getFilesToRefresh());
|
||||
|
||||
Reference in New Issue
Block a user