mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
VCS: Don't query for revision content in AWT thread.
This commit is contained in:
+1
-1
@@ -85,7 +85,7 @@ public class ChangeDiffRequest implements ChangeRequestChain {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public DiffRequest init(final int idx) throws VcsException {
|
||||
public DiffRequest init(final int idx) {
|
||||
if (idx < 0 || idx > (mySteps.size() - 1)) return null;
|
||||
myIndex = idx - 1;
|
||||
final DiffRequest result = moveForward();
|
||||
|
||||
+50
-28
@@ -19,6 +19,7 @@ import com.intellij.idea.ActionsBundle;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.PlatformDataKeys;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.diff.*;
|
||||
import com.intellij.openapi.diff.impl.external.BinaryDiffTool;
|
||||
@@ -201,18 +202,22 @@ public class ShowDiffAction extends AnAction implements DumbAware {
|
||||
}), newIndex, context);
|
||||
}
|
||||
|
||||
public static void showDiffForChange(final Change[] changes, int index, final Project project, @NotNull ShowDiffUIContext context) {
|
||||
final Change selected = index >= 0 ? changes[index] : null;
|
||||
if (isBinaryDiff(project, changes, index)) {
|
||||
showBinaryDiff(project, changes[index]);
|
||||
return;
|
||||
}
|
||||
showDiffForChange(Arrays.asList(changes), new Condition<Change>() {
|
||||
@Override
|
||||
public boolean value(final Change change) {
|
||||
return selected == null ? false : selected.equals(change);
|
||||
}
|
||||
}, project, context);
|
||||
public static void showDiffForChange(final Change[] changes, final int index, final Project project, @NotNull final ShowDiffUIContext context) {
|
||||
ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
|
||||
public void run() {
|
||||
final Change selected = index >= 0 ? changes[index] : null;
|
||||
if (isBinaryDiff(project, changes, index)) {
|
||||
showBinaryDiff(project, changes[index]);
|
||||
return;
|
||||
}
|
||||
showDiffForChange(Arrays.asList(changes), new Condition<Change>() {
|
||||
@Override
|
||||
public boolean value(final Change change) {
|
||||
return selected == null ? false : selected.equals(change);
|
||||
}
|
||||
}, project, context);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private static FileContent createBinaryFileContent(final Project project, final ContentRevision contentRevision, final String fileName)
|
||||
@@ -260,11 +265,19 @@ public class ShowDiffAction extends AnAction implements DumbAware {
|
||||
try {
|
||||
final SimpleDiffRequest request = createBinaryDiffRequest(project, change);
|
||||
if (DiffManager.getInstance().getDiffTool().canShow(request)) {
|
||||
DiffManager.getInstance().getDiffTool().show(request);
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
DiffManager.getInstance().getDiffTool().show(request);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (VcsException e) {
|
||||
Messages.showWarningDialog(e.getMessage(), "Show Diff");
|
||||
catch (final VcsException e) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
Messages.showWarningDialog(e.getMessage(), "Show Diff");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -289,26 +302,35 @@ public class ShowDiffAction extends AnAction implements DumbAware {
|
||||
return isBinaryChange(change) && (change.getAfterRevision() == null || BinaryDiffTool.canShow(project, change.getVirtualFile()));
|
||||
}
|
||||
|
||||
public static void showDiffImpl(final Project project, List<DiffRequestPresentable> changeList, int index, @NotNull final ShowDiffUIContext context) {
|
||||
public static void showDiffImpl(final Project project, List<DiffRequestPresentable> changeList, final int index, @NotNull final ShowDiffUIContext context) {
|
||||
final ChangeDiffRequest request = new ChangeDiffRequest(project, changeList, context.getActionsFactory(), context.isShowFrame());
|
||||
final DiffTool tool = DiffManager.getInstance().getDiffTool();
|
||||
final DiffRequest simpleRequest;
|
||||
try {
|
||||
request.quickCheckHaveStuff();
|
||||
simpleRequest = request.init(index);
|
||||
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
final DiffRequest simpleRequest = request.init(index);
|
||||
|
||||
if (simpleRequest != null) {
|
||||
final DiffNavigationContext navigationContext = context.getDiffNavigationContext();
|
||||
if (navigationContext != null) {
|
||||
simpleRequest.passForDataContext(DiffTool.SCROLL_TO_LINE, navigationContext);
|
||||
}
|
||||
tool.show(simpleRequest);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (VcsException e) {
|
||||
Messages.showWarningDialog(e.getMessage(), "Show Diff");
|
||||
return;
|
||||
catch (final VcsException e) {
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
@Override public void run() {
|
||||
Messages.showWarningDialog(e.getMessage(), "Show Diff");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
if (simpleRequest != null) {
|
||||
final DiffNavigationContext navigationContext = context.getDiffNavigationContext();
|
||||
if (navigationContext != null) {
|
||||
simpleRequest.passForDataContext(DiffTool.SCROLL_TO_LINE, navigationContext);
|
||||
}
|
||||
tool.show(simpleRequest);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean directoryOrBinary(final Change change) {
|
||||
|
||||
Reference in New Issue
Block a user