diff --git a/platform/platform-impl/src/com/intellij/ui/popup/KeepingPopupOpenAction.java b/platform/platform-impl/src/com/intellij/ui/popup/KeepingPopupOpenAction.java new file mode 100644 index 000000000000..e8748921e7d8 --- /dev/null +++ b/platform/platform-impl/src/com/intellij/ui/popup/KeepingPopupOpenAction.java @@ -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 { +} diff --git a/platform/platform-impl/src/com/intellij/ui/popup/PopupFactoryImpl.java b/platform/platform-impl/src/com/intellij/ui/popup/PopupFactoryImpl.java index a10187dd5d4f..ee30c2b8288c 100644 --- a/platform/platform-impl/src/com/intellij/ui/popup/PopupFactoryImpl.java +++ b/platform/platform-impl/src/com/intellij/ui/popup/PopupFactoryImpl.java @@ -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 filtered = ContainerUtil.mapNotNull(selectedValues, new Function() { @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 getActionByClass(@Nullable Object value, @NotNull ActionPopupStep actionPopupStep, @NotNull Class 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; } } diff --git a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/StructureFilterPopupComponent.java b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/StructureFilterPopupComponent.java index 5c1370f4e3e1..13b03e28410e 100644 --- a/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/StructureFilterPopupComponent.java +++ b/platform/vcs-log/impl/src/com/intellij/vcs/log/ui/filter/StructureFilterPopupComponent.java @@ -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