mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Possibility to mark groups as excluded from action search (IDEA-241815)
GitOrigin-RevId: 6d84498ff14f7e4cd2f8926e8d9a6301d5b4141a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
b3a471390c
commit
c4b40f7b61
@@ -59,7 +59,7 @@
|
||||
<action id="NewElement" class="com.intellij.ide.actions.NewElementAction"/>
|
||||
|
||||
<group id="OpenProjectGroup">
|
||||
<group id="NewElementInMenuGroup" class="com.intellij.ide.actions.NewActionGroup" popup="true"/>
|
||||
<group id="NewElementInMenuGroup" class="com.intellij.ide.actions.NewActionGroup" popup="true" searchable="false"/>
|
||||
<add-to-group group-id="FileOpenGroup" anchor="first"/>
|
||||
</group>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// Copyright 2000-2019 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.openapi.actionSystem;
|
||||
|
||||
import com.intellij.util.ReflectionUtil;
|
||||
@@ -26,6 +26,7 @@ import static com.intellij.openapi.util.NlsActions.ActionText;
|
||||
*/
|
||||
public abstract class ActionGroup extends AnAction {
|
||||
private boolean myPopup;
|
||||
private boolean mySearchable = true;
|
||||
private final PropertyChangeSupport myChangeSupport = new PropertyChangeSupport(this);
|
||||
public static final ActionGroup EMPTY_GROUP = new ActionGroup() {
|
||||
@Override
|
||||
@@ -119,6 +120,14 @@ public abstract class ActionGroup extends AnAction {
|
||||
firePropertyChange(PROP_POPUP, oldPopup, myPopup);
|
||||
}
|
||||
|
||||
public boolean isSearchable() {
|
||||
return mySearchable;
|
||||
}
|
||||
|
||||
public void setSearchable(boolean searchable) {
|
||||
mySearchable = searchable;
|
||||
}
|
||||
|
||||
public final void addPropertyChangeListener(@NotNull PropertyChangeListener l){
|
||||
myChangeSupport.addPropertyChangeListener(l);
|
||||
}
|
||||
|
||||
@@ -232,6 +232,7 @@ public final class GotoActionItemProvider implements ChooseByNameWeightedItemPro
|
||||
}
|
||||
|
||||
JBIterable<ActionWrapper> actionWrappers = actions.unique().filterMap(action -> {
|
||||
if (action instanceof ActionGroup && !((ActionGroup) action).isSearchable()) return null;
|
||||
MatchMode mode = myModel.actionMatches(pattern, matcher, action);
|
||||
if (mode == MatchMode.NONE) return null;
|
||||
return new ActionWrapper(action, myModel.getGroupMapping(action), mode, dataContext, myModel);
|
||||
|
||||
@@ -53,5 +53,6 @@ class ActionGroupStub(override val id: String, val actionClass: String, override
|
||||
if (popupDefinedInXml) {
|
||||
target.isPopup = isPopup
|
||||
}
|
||||
target.isSearchable = isSearchable
|
||||
}
|
||||
}
|
||||
|
||||
+7
@@ -103,6 +103,7 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
private static final String KEY_ATTR_NAME = "key";
|
||||
private static final String POPUP_ATTR_NAME = "popup";
|
||||
private static final String COMPACT_ATTR_NAME = "compact";
|
||||
private static final String SEARCHABLE_ATTR_NAME = "searchable";
|
||||
private static final String SEPARATOR_ELEMENT_NAME = "separator";
|
||||
private static final String REFERENCE_ELEMENT_NAME = "reference";
|
||||
private static final String ABBREVIATION_ELEMENT_NAME = "abbreviation";
|
||||
@@ -818,6 +819,12 @@ public final class ActionManagerImpl extends ActionManagerEx implements Disposab
|
||||
((ActionGroupStub)group).setPopupDefinedInXml(true);
|
||||
}
|
||||
}
|
||||
|
||||
String searchable = element.getAttributeValue(SEARCHABLE_ATTR_NAME);
|
||||
if (searchable != null) {
|
||||
group.setSearchable(Boolean.parseBoolean(searchable));
|
||||
}
|
||||
|
||||
String shortcutOfActionId = element.getAttributeValue(USE_SHORTCUT_OF_ATTR_NAME);
|
||||
if (customClass && shortcutOfActionId != null) {
|
||||
KeymapManagerEx.getInstanceEx().bindShortcuts(shortcutOfActionId, id);
|
||||
|
||||
@@ -451,7 +451,7 @@
|
||||
</group>
|
||||
|
||||
|
||||
<group id="NewGroup" popup="true">
|
||||
<group id="NewGroup" popup="true" searchable="false">
|
||||
<action id="NewFile" class="com.intellij.ide.actions.CreateFileAction"/>
|
||||
<action id="NewScratchFile" class="com.intellij.ide.scratch.ScratchFileActions$NewFileAction" />
|
||||
<action id="NewDir" class="com.intellij.ide.actions.CreateDirectoryOrPackageAction"/>
|
||||
@@ -459,7 +459,7 @@
|
||||
<action id="NewFromTemplate" class="com.intellij.ide.fileTemplates.actions.CreateFromTemplateGroup"/>
|
||||
</group>
|
||||
|
||||
<group id="WeighingNewGroup" class="com.intellij.ide.actions.WeighingNewActionGroup"/>
|
||||
<group id="WeighingNewGroup" class="com.intellij.ide.actions.WeighingNewActionGroup" searchable="false"/>
|
||||
<reference ref="AssociateWithFileType"/>
|
||||
|
||||
<group id="RevealGroup">
|
||||
|
||||
@@ -17,6 +17,9 @@ public interface Group extends ActionContainer, ActionOrGroup {
|
||||
@NotNull
|
||||
GenericAttributeValue<Boolean> getCompact();
|
||||
|
||||
@NotNull
|
||||
GenericAttributeValue<Boolean> getSearchable();
|
||||
|
||||
@NotNull
|
||||
@Attribute("class")
|
||||
@ExtendClass(value = "com.intellij.openapi.actionSystem.ActionGroup",
|
||||
|
||||
Reference in New Issue
Block a user