mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
marker interface for actions that prevent popup from closing on click on them
(cherry picked from commit a7647c77df6a39a040896a61fe542263ad883282)
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.ui.popup;
|
||||
|
||||
/**
|
||||
* Marker interface for actions that prevent popup from closing when user clicks on them.
|
||||
* */
|
||||
public interface KeepingPopupOpenAction {
|
||||
}
|
||||
@@ -298,9 +298,9 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
final ActionPopupStep actionPopupStep = ObjectUtils.tryCast(getListStep(), ActionPopupStep.class);
|
||||
|
||||
if (actionPopupStep != null) {
|
||||
ToggleAction toggleAction = getToggleAction(selectedValue, actionPopupStep);
|
||||
if (toggleAction != null) {
|
||||
actionPopupStep.performAction(toggleAction, e != null ? e.getModifiers() : 0);
|
||||
KeepingPopupOpenAction dontClosePopupAction = getActionByClass(selectedValue, actionPopupStep, KeepingPopupOpenAction.class);
|
||||
if (dontClosePopupAction != null) {
|
||||
actionPopupStep.performAction((AnAction)dontClosePopupAction, e != null ? e.getModifiers() : 0);
|
||||
for (ActionItem item : actionPopupStep.myItems) {
|
||||
updateActionItem(item);
|
||||
}
|
||||
@@ -322,7 +322,7 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
List<ToggleAction> filtered = ContainerUtil.mapNotNull(selectedValues, new Function<Object, ToggleAction>() {
|
||||
@Override
|
||||
public ToggleAction fun(Object o) {
|
||||
return getToggleAction(o, actionPopupStep);
|
||||
return getActionByClass(o, actionPopupStep, ToggleAction.class);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -338,11 +338,11 @@ public class PopupFactoryImpl extends JBPopupFactory {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static ToggleAction getToggleAction(@Nullable Object value, @NotNull ActionPopupStep actionPopupStep) {
|
||||
private static <T> T getActionByClass(@Nullable Object value, @NotNull ActionPopupStep actionPopupStep, @NotNull Class<T> actionClass) {
|
||||
ActionItem item = value instanceof ActionItem ? (ActionItem)value : null;
|
||||
if (item == null) return null;
|
||||
if (!actionPopupStep.isSelectable(item)) return null;
|
||||
return item.getAction() instanceof ToggleAction ? (ToggleAction)item.getAction() : null;
|
||||
return actionClass.isInstance(item.getAction()) ? actionClass.cast(item.getAction()) : null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-1
@@ -19,6 +19,7 @@ import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.project.DumbAware;
|
||||
import com.intellij.openapi.project.DumbAwareAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.popup.KeepingPopupOpenAction;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.SizedIcon;
|
||||
@@ -223,7 +224,7 @@ class StructureFilterPopupComponent extends FilterPopupComponent<VcsLogFileFilte
|
||||
}
|
||||
}
|
||||
|
||||
private class SelectVisibleRootAction extends ToggleAction implements DumbAware {
|
||||
private class SelectVisibleRootAction extends ToggleAction implements DumbAware, KeepingPopupOpenAction {
|
||||
@NotNull private final CheckboxColorIcon myIcon;
|
||||
@NotNull private final VirtualFile myRoot;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user