go to action: compare actions with each other earlier

This commit is contained in:
Sergey Ignatov
2015-10-28 16:53:00 +03:00
parent 2ca8307bc7
commit 3dc65ccf2f
@@ -187,11 +187,16 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
public int compareTo(@NotNull MatchedValue o) {
boolean edt = ApplicationManager.getApplication().isDispatchThread();
if (value instanceof ActionWrapper && o.value instanceof ActionWrapper && edt) {
boolean p1Enable = ((ActionWrapper)value).isAvailable();
boolean p2enable = ((ActionWrapper)o.value).isAvailable();
if (p1Enable && !p2enable) return -1;
if (!p1Enable && p2enable) return 1;
if (value instanceof ActionWrapper && o.value instanceof ActionWrapper) {
if (edt) {
boolean p1Enable = ((ActionWrapper)value).isAvailable();
boolean p2enable = ((ActionWrapper)o.value).isAvailable();
if (p1Enable && !p2enable) return -1;
if (!p1Enable && p2enable) return 1;
}
//noinspection unchecked
int compared = value.compareTo(o.value);
if (compared != 0) return compared;
}
if (value instanceof ActionWrapper && o.value instanceof BooleanOptionDescription) {
@@ -563,14 +568,14 @@ public class GotoActionModel implements ChooseByNameModel, CustomMatcherModel, C
return myMatcher.get();
}
public static class ActionWrapper implements Comparable<ActionWrapper>{
public static class ActionWrapper implements Comparable<ActionWrapper> {
@NotNull private final AnAction myAction;
@NotNull private final MatchMode myMode;
@Nullable private final String myGroupName;
private final DataContext myDataContext;
private Presentation myPresentation;
public ActionWrapper(@NotNull AnAction action, @Nullable String groupName, @NotNull MatchMode mode, DataContext dataContext) {
public ActionWrapper(@NotNull AnAction action, @Nullable String groupName, @NotNull MatchMode mode, DataContext dataContext) {
myAction = action;
myMode = mode;
myGroupName = groupName;