mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
[mac] "compare with clipboard" actions is always enabled
This commit is contained in:
+6
@@ -20,6 +20,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.diff.*;
|
||||
import com.intellij.openapi.ide.CopyPasteManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
|
||||
import java.awt.datatransfer.DataFlavor;
|
||||
import java.awt.datatransfer.Transferable;
|
||||
@@ -50,6 +51,11 @@ public class CompareValueWithClipboardAction extends BaseValueAction {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSafeToCallFromUpdate() {
|
||||
return !SystemInfo.isMac;
|
||||
}
|
||||
|
||||
public DiffContent[] getContents() {
|
||||
if (myContents != null) return myContents;
|
||||
DiffContent clipboardContent = createClipboardContent();
|
||||
|
||||
@@ -51,6 +51,10 @@ public abstract class DiffRequest {
|
||||
public void setGroupKey(@NonNls String groupKey) { myGroupKey = groupKey; }
|
||||
public Project getProject() { return myProject; }
|
||||
|
||||
public boolean isSafeToCallFromUpdate() {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return contents to compare
|
||||
*/
|
||||
|
||||
@@ -49,9 +49,10 @@ abstract class BaseDiffAction extends AnAction implements PreloadableAction, Dum
|
||||
|
||||
public void update(AnActionEvent e) {
|
||||
DiffRequest diffData = getDiffData(e.getDataContext());
|
||||
boolean enabled;
|
||||
if (diffData == null || diffData.getContents() == null) enabled = false;
|
||||
else enabled = DiffManager.getInstance().getDiffTool().canShow(diffData);
|
||||
|
||||
boolean enabled = diffData != null &&
|
||||
(!diffData.isSafeToCallFromUpdate() || (diffData.getContents() != null && DiffManager.getInstance().getDiffTool().canShow(diffData)));
|
||||
|
||||
Presentation presentation = e.getPresentation();
|
||||
presentation.setEnabled(enabled);
|
||||
if (enabled) presentation.setVisible(true);
|
||||
|
||||
+6
@@ -24,6 +24,7 @@ import com.intellij.openapi.editor.SelectionModel;
|
||||
import com.intellij.openapi.fileEditor.FileEditorManager;
|
||||
import com.intellij.openapi.ide.CopyPasteManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -59,6 +60,11 @@ public class CompareClipboardWithSelection extends BaseDiffAction {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSafeToCallFromUpdate() {
|
||||
return !SystemInfo.isMac;
|
||||
}
|
||||
|
||||
public DiffContent[] getContents() {
|
||||
if (myContents != null) return myContents;
|
||||
DiffContent clipboardContent = createClipboardContent();
|
||||
|
||||
@@ -44,7 +44,7 @@ public class CompareFiles extends BaseDiffAction {
|
||||
presentation.setVisible(false);
|
||||
return;
|
||||
}
|
||||
final boolean canShow = DiffManager.getInstance().getDiffTool().canShow(diffRequest);
|
||||
final boolean canShow = !diffRequest.isSafeToCallFromUpdate() || DiffManager.getInstance().getDiffTool().canShow(diffRequest);
|
||||
if (ActionPlaces.isPopupPlace(e.getPlace())) {
|
||||
presentation.setVisible(canShow);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user