private ActiveComponent createPinButton( final UsageInfoToUsageConverter.TargetElementsDescriptor descriptor, final UsageViewImpl usageView, final FindUsagesOptions options, final JBPopup[] popup, DefaultActionGroup pinGroup) { final AnAction pinAction = new AnAction( "Open Find Usages Toolwindow", "Show all usages in a separate toolwindow", AllIcons.General.AutohideOff) { { AnAction action = ActionManager.getInstance().getAction(IdeActions.ACTION_FIND_USAGES); setShortcutSet(action.getShortcutSet()); } @Override public void actionPerformed(AnActionEvent e) { hideHints(); popup[0].cancel(); FindUsagesManager findUsagesManager = ((FindManagerImpl) FindManager.getInstance(usageView.getProject())) .getFindUsagesManager(); FindUsagesManager.SearchData data = new FindUsagesManager.SearchData(); data.myOptions = options; List<SmartPsiElementPointer<PsiElement>> plist = descriptor.getAllElementPointers(); data.myElements = plist.toArray(new SmartPsiElementPointer[plist.size()]); findUsagesManager.rerunAndRecallFromHistory(data); } }; pinGroup.add(pinAction); final ActionToolbar pinToolbar = ActionManager.getInstance() .createActionToolbar(ActionPlaces.USAGE_VIEW_TOOLBAR, pinGroup, true); pinToolbar.setReservePlaceAutoPopupIcon(false); final JComponent pinToolBar = pinToolbar.getComponent(); pinToolBar.setBorder(null); pinToolBar.setOpaque(false); return new ActiveComponent() { @Override public void setActive(boolean active) {} @Override public JComponent getComponent() { return pinToolBar; } }; }
@NotNull private JComponent createHintComponent( @NotNull String text, @NotNull final FindUsagesHandler handler, @NotNull final RelativePoint popupPosition, final Editor editor, @NotNull final Runnable cancelAction, final int maxUsages, @NotNull final FindUsagesOptions options) { JComponent label = HintUtil.createInformationLabel(suggestSecondInvocation(options, handler, text + " ")); InplaceButton button = createSettingsButton(handler, popupPosition, editor, maxUsages, cancelAction); JPanel panel = new JPanel(new BorderLayout()) { @Override public void addNotify() { mySearchEverywhereRunnable = new Runnable() { @Override public void run() { searchEverywhere(options, handler, editor, popupPosition, maxUsages); } }; super.addNotify(); } @Override public void removeNotify() { mySearchEverywhereRunnable = null; super.removeNotify(); } }; button.setBackground(label.getBackground()); panel.setBackground(label.getBackground()); label.setOpaque(false); label.setBorder(null); panel.setBorder(HintUtil.createHintBorder()); panel.add(label, BorderLayout.CENTER); panel.add(button, BorderLayout.EAST); return panel; }