diff --git a/platform/lang-impl/src/com/intellij/find/EditorSearchSession.java b/platform/lang-impl/src/com/intellij/find/EditorSearchSession.java index 2614b9d108d2..8774531f7367 100644 --- a/platform/lang-impl/src/com/intellij/find/EditorSearchSession.java +++ b/platform/lang-impl/src/com/intellij/find/EditorSearchSession.java @@ -41,6 +41,7 @@ import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; import com.intellij.util.ui.update.Activatable; import com.intellij.util.ui.update.UiNotifyConnector; +import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.NonNls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -103,8 +104,6 @@ public class EditorSearchSession implements SearchSession, myComponent = SearchReplaceComponent .buildFor(project, myEditor.getContentComponent()) .addPrimarySearchActions(createPrimarySearchActions()) - .addSecondarySearchActions(createSecondarySearchActions()) - .addPrimarySearchActions(new ToggleSelectionOnlyAction()) .addExtraSearchActions(new ToggleMatchCase(), new ToggleWholeWordsOnlyAction(), new ToggleRegex(), @@ -119,7 +118,6 @@ public class EditorSearchSession implements SearchSession, .withDataProvider(this) .withCloseAction(this::close) .withReplaceAction(this::replaceCurrent) - .withSecondarySearchActionsIsModifiedGetter(() -> myFindModel.getSearchContext() != FindModel.SearchContext.ANY) .build(); myComponent.addListener(this); @@ -211,20 +209,20 @@ public class EditorSearchSession implements SearchSession, new AddOccurrenceAction(), new RemoveOccurrenceAction(), new SelectAllAction(), - new Separator() + new Separator(), + new ToggleSelectionOnlyAction(), + new ShowFilterPopupGroup() }; } + /** + * @deprecated Won't be used anymore + */ + @ApiStatus.ScheduledForRemoval(inVersion = "2020.3") + @Deprecated @NotNull protected AnAction[] createSecondarySearchActions() { - return new AnAction[] { - new ToggleAnywhereAction(), - new ToggleInCommentsAction(), - new ToggleInLiteralsOnlyAction(), - new ToggleExceptCommentsAction(), - new ToggleExceptLiteralsAction(), - new ToggleExceptCommentsAndLiteralsAction() - }; + return AnAction.EMPTY_ARRAY; } private void saveInitialSelection() { diff --git a/platform/lang-impl/src/com/intellij/find/SearchReplaceComponent.java b/platform/lang-impl/src/com/intellij/find/SearchReplaceComponent.java index dd8845ee3676..434bfaf13bfe 100644 --- a/platform/lang-impl/src/com/intellij/find/SearchReplaceComponent.java +++ b/platform/lang-impl/src/com/intellij/find/SearchReplaceComponent.java @@ -1,7 +1,6 @@ // 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.find; -import com.intellij.execution.runners.ExecutionUtil; import com.intellij.find.editorHeaderActions.*; import com.intellij.icons.AllIcons; import com.intellij.ide.DataManager; @@ -16,7 +15,6 @@ import com.intellij.openapi.project.DumbAwareAction; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.Splitter; import com.intellij.openapi.ui.VerticalFlowLayout; -import com.intellij.openapi.util.BooleanGetter; import com.intellij.openapi.util.NlsContexts; import com.intellij.openapi.util.SystemInfo; import com.intellij.openapi.util.registry.Registry; @@ -66,7 +64,6 @@ public final class SearchReplaceComponent extends EditorHeaderComponent implemen private final ActionToolbarImpl mySearchActionsToolbar; private final List myEmbeddedSearchActions = new ArrayList<>(); private final List myExtraSearchButtons = new ArrayList<>(); - private final BooleanGetter mySearchToolbarModifiedFlagGetter; private final DefaultActionGroup myReplaceFieldActions; private final ActionToolbarImpl myReplaceActionsToolbar; @@ -101,7 +98,6 @@ public final class SearchReplaceComponent extends EditorHeaderComponent implemen private SearchReplaceComponent(@Nullable Project project, @NotNull JComponent targetComponent, @NotNull DefaultActionGroup searchToolbar1Actions, - @NotNull final BooleanGetter searchToolbar1ModifiedFlagGetter, @NotNull DefaultActionGroup searchToolbar2Actions, @NotNull DefaultActionGroup searchFieldActions, @NotNull DefaultActionGroup replaceToolbar1Actions, @@ -117,7 +113,6 @@ public final class SearchReplaceComponent extends EditorHeaderComponent implemen boolean useSearchField) { myProject = project; myTargetComponent = targetComponent; - mySearchToolbarModifiedFlagGetter = searchToolbar1ModifiedFlagGetter; mySearchFieldActions = searchFieldActions; myReplaceFieldActions = replaceFieldActions; myReplaceAction = replaceAction; @@ -180,7 +175,7 @@ public final class SearchReplaceComponent extends EditorHeaderComponent implemen searchToolbar1Actions.addAll(searchToolbar2Actions.getChildren(null)); replaceToolbar1Actions.addAll(replaceToolbar2Actions.getChildren(null)); - mySearchActionsToolbar = createSearchToolbar1(searchToolbar1Actions); + mySearchActionsToolbar = createToolbar(searchToolbar1Actions); mySearchActionsToolbar.setForceShowFirstComponent(true); JPanel searchPair = new NonOpaquePanel(new BorderLayout()); searchPair.add(mySearchActionsToolbar, BorderLayout.CENTER); @@ -630,31 +625,6 @@ public final class SearchReplaceComponent extends EditorHeaderComponent implemen } - @NotNull - private ActionToolbarImpl createSearchToolbar1(@NotNull DefaultActionGroup group) { - ActionToolbarImpl toolbar = createToolbar(group); - toolbar.setSecondaryActionsTooltip(FindBundle.message("find.popup.show.filter.popup")); - toolbar.setSecondaryActionsIcon(AllIcons.General.Filter, true); - toolbar.setNoGapMode(); - toolbar.setSecondaryButtonPopupStateModifier(new ActionToolbarImpl.SecondaryGroupUpdater() { - @Override - public void update(@NotNull AnActionEvent e) { - Icon icon = e.getPresentation().getIcon(); - if (icon != null && mySearchToolbarModifiedFlagGetter.get()) { - e.getPresentation().setIcon(ExecutionUtil.getLiveIndicator(icon)); - } - } - }); - - KeyboardShortcut keyboardShortcut = ActionManager.getInstance().getKeyboardShortcut("ShowFilterPopup"); - if (keyboardShortcut != null) { - toolbar.setSecondaryActionsShortcut(KeymapUtil.getShortcutText(keyboardShortcut)); - } - - new ShowMoreOptions(toolbar, mySearchFieldWrapper); - return toolbar; - } - @NotNull private ActionToolbarImpl createReplaceToolbar1(@NotNull DefaultActionGroup group) { ActionToolbarImpl toolbar = createToolbar(group); @@ -694,7 +664,6 @@ public final class SearchReplaceComponent extends EditorHeaderComponent implemen private final DefaultActionGroup mySearchActions = DefaultActionGroup.createFlatGroup(() -> "search bar 1"); private final DefaultActionGroup myExtraSearchActions = DefaultActionGroup.createFlatGroup(() -> "search bar 2"); private final DefaultActionGroup mySearchFieldActions = DefaultActionGroup.createFlatGroup(() -> "search field actions"); - private BooleanGetter mySearchToolbarModifiedFlagGetter = BooleanGetter.FALSE; private final DefaultActionGroup myReplaceActions = DefaultActionGroup.createFlatGroup(() -> "replace bar 1"); private final DefaultActionGroup myExtraReplaceActions = DefaultActionGroup.createFlatGroup(() -> "replace bar 1"); @@ -755,12 +724,6 @@ public final class SearchReplaceComponent extends EditorHeaderComponent implemen return this; } - @NotNull - public Builder withSecondarySearchActionsIsModifiedGetter(@NotNull BooleanGetter getter) { - mySearchToolbarModifiedFlagGetter = getter; - return this; - } - @NotNull public Builder addExtraSearchActions(AnAction @NotNull ... actions) { myExtraSearchActions.addAll(actions); @@ -796,7 +759,6 @@ public final class SearchReplaceComponent extends EditorHeaderComponent implemen return new SearchReplaceComponent(myProject, myTargetComponent, mySearchActions, - mySearchToolbarModifiedFlagGetter, myExtraSearchActions, mySearchFieldActions, myReplaceActions, diff --git a/platform/lang-impl/src/com/intellij/find/editorHeaderActions/ShowFilterPopupGroup.java b/platform/lang-impl/src/com/intellij/find/editorHeaderActions/ShowFilterPopupGroup.java new file mode 100644 index 000000000000..fb7dd2794e7e --- /dev/null +++ b/platform/lang-impl/src/com/intellij/find/editorHeaderActions/ShowFilterPopupGroup.java @@ -0,0 +1,53 @@ +// Copyright 2000-2021 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.find.editorHeaderActions; + +import com.intellij.execution.runners.ExecutionUtil; +import com.intellij.find.FindBundle; +import com.intellij.find.FindModel; +import com.intellij.find.SearchSession; +import com.intellij.icons.AllIcons; +import com.intellij.openapi.actionSystem.*; +import com.intellij.openapi.actionSystem.impl.ActionButton; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import javax.swing.*; + +public class ShowFilterPopupGroup extends DefaultActionGroup implements ShortcutProvider { + public ShowFilterPopupGroup() { + super(new ToggleAnywhereAction(), + new ToggleInCommentsAction(), + new ToggleInLiteralsOnlyAction(), + new ToggleExceptCommentsAction(), + new ToggleExceptLiteralsAction(), + new ToggleExceptCommentsAndLiteralsAction()); + setPopup(true); + getTemplatePresentation().setText(FindBundle.message("find.popup.show.filter.popup")); + getTemplatePresentation().setIcon(AllIcons.General.Filter); + getTemplatePresentation().putClientProperty(ActionButton.HIDE_DROPDOWN_ICON, Boolean.TRUE); + } + + @Override + public void update(@NotNull AnActionEvent e) { + SearchSession session = e.getData(SearchSession.KEY); + if (session == null) { + e.getPresentation().setEnabled(false); + return; + } + Icon icon = getTemplatePresentation().getIcon(); + if (icon != null && session.getFindModel().getSearchContext() != FindModel.SearchContext.ANY) { + e.getPresentation().setIcon(ExecutionUtil.getLiveIndicator(icon)); + } + else { + e.getPresentation().setIcon(icon); + } + } + + @Override + public @Nullable ShortcutSet getShortcut() { + KeyboardShortcut keyboardShortcut = ActionManager.getInstance().getKeyboardShortcut("ShowFilterPopup"); + if (keyboardShortcut != null) + return new CustomShortcutSet(keyboardShortcut); + return null; + } +} diff --git a/platform/lang-impl/src/com/intellij/find/editorHeaderActions/ShowMoreOptions.java b/platform/lang-impl/src/com/intellij/find/editorHeaderActions/ShowMoreOptions.java deleted file mode 100644 index 772ce01a3bb5..000000000000 --- a/platform/lang-impl/src/com/intellij/find/editorHeaderActions/ShowMoreOptions.java +++ /dev/null @@ -1,45 +0,0 @@ -// 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. -package com.intellij.find.editorHeaderActions; - -import com.intellij.ide.lightEdit.LightEditCompatible; -import com.intellij.openapi.actionSystem.ActionManager; -import com.intellij.openapi.actionSystem.AnActionEvent; -import com.intellij.openapi.actionSystem.CustomShortcutSet; -import com.intellij.openapi.actionSystem.KeyboardShortcut; -import com.intellij.openapi.actionSystem.impl.ActionButton; -import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl; -import com.intellij.openapi.project.DumbAwareAction; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; - -public class ShowMoreOptions extends DumbAwareAction implements LightEditCompatible { - - private final ActionToolbarImpl myToolbarComponent; - - //placeholder for keymap - public ShowMoreOptions() { - myToolbarComponent = null; - } - - public ShowMoreOptions(ActionToolbarImpl toolbarComponent, JComponent shortcutHolder) { - this.myToolbarComponent = toolbarComponent; - KeyboardShortcut keyboardShortcut = ActionManager.getInstance().getKeyboardShortcut("ShowFilterPopup"); - if (keyboardShortcut != null) { - registerCustomShortcutSet(new CustomShortcutSet(keyboardShortcut), shortcutHolder); - } - } - - @Override - public void actionPerformed(@NotNull AnActionEvent e) { - final ActionButton secondaryActions = myToolbarComponent.getSecondaryActionsButton(); - if (secondaryActions != null) { - secondaryActions.click(); - } - } - - @Override - public void update(@NotNull AnActionEvent e) { - e.getPresentation().setEnabled(myToolbarComponent != null && myToolbarComponent.getSecondaryActionsButton() != null); - } -} diff --git a/platform/platform-resources/src/idea/PlatformActions.xml b/platform/platform-resources/src/idea/PlatformActions.xml index 26225aebde0e..0997570d59bc 100644 --- a/platform/platform-resources/src/idea/PlatformActions.xml +++ b/platform/platform-resources/src/idea/PlatformActions.xml @@ -1289,7 +1289,7 @@ - +