private static ListPopupStep buildStep(@NotNull final List<Pair<AnAction, KeyStroke>> actions, final DataContext ctx) { return new BaseListPopupStep<Pair<AnAction, KeyStroke>>("Choose an action", ContainerUtil.findAll(actions, new Condition<Pair<AnAction, KeyStroke>>() { @Override public boolean value(Pair<AnAction, KeyStroke> pair) { final AnAction action = pair.getFirst(); final Presentation presentation = action.getTemplatePresentation().clone(); AnActionEvent event = new AnActionEvent(null, ctx, ActionPlaces.UNKNOWN, presentation, ActionManager.getInstance(), 0); ActionUtil.performDumbAwareUpdate(action, event, true); return presentation.isEnabled() && presentation.isVisible(); } })) { @Override public PopupStep onChosen(Pair<AnAction, KeyStroke> selectedValue, boolean finalChoice) { invokeAction(selectedValue.getFirst(), ctx); return FINAL_CHOICE; } }; }
private static ListPopupStep buildStep(@Nonnull final List<Pair<AnAction, KeyStroke>> actions, final DataContext ctx) { return new BaseListPopupStep<Pair<AnAction, KeyStroke>>("Choose an action", ContainerUtil.findAll(actions, pair -> { final AnAction action = pair.getFirst(); final Presentation presentation = action.getTemplatePresentation().clone(); AnActionEvent event = new AnActionEvent(null, ctx, ActionPlaces.UNKNOWN, presentation, ActionManager.getInstance(), 0); ActionUtil.performDumbAwareUpdate(LaterInvocator.isInModalContext(), action, event, true); return presentation.isEnabled() && presentation.isVisible(); })) { @Override public PopupStep onChosen(Pair<AnAction, KeyStroke> selectedValue, boolean finalChoice) { invokeAction(selectedValue.getFirst(), ctx); return FINAL_CHOICE; } }; }
public void actionPerformed(AnActionEvent e) { final JBPopupFactory popupFactory = JBPopupFactory.getInstance(); final ListPopupStep popupStep = popupFactory.createActionsStep(myGroup, e.getDataContext(), false, false, myGroup.getTemplatePresentation().getText(), myToolbarComponent, false, 0, false); popupFactory.createListPopup(popupStep).showUnderneathOf(myToolbarComponent); }
public void actionPerformed(AnActionEvent e) { final JBPopupFactory popupFactory = JBPopupFactory.getInstance(); final ListPopupStep step = popupFactory.createActionsStep(myActionGroup, e.getDataContext(), false, false, myActionGroup.getTemplatePresentation().getText(), myTree, true, myPreselection != null ? myPreselection.getDefaultIndex() : 0, true); final ListPopup listPopup = popupFactory.createListPopup(step); listPopup.setHandleAutoSelectionBeforeShow(true); if (e instanceof AnActionButton.AnActionEventWrapper) { ((AnActionButton.AnActionEventWrapper)e).showPopup(listPopup); } else { listPopup.showUnderneathOf(myNorthPanel); } }
public ListPopupModel(ElementFilter filter, SpeedSearch speedSearch, ListPopupStep step) { myFilter = filter; myStep = step; mySpeedSearch = speedSearch; myOriginalList = new ArrayList<Object>(step.getValues()); rebuildLists(); }
@Override protected void customizeComponent(JList list, Object value, boolean isSelected) { super.customizeComponent(list, value, isSelected); myLabel.setVisible(myHasSideBar); ListPopupStep<Object> step = myPopup1.getListStep(); boolean isSelectable = step.isSelectable(value); myLabel.setEnabled(isSelectable); myLabel.setIcon(null); if (isSelected) { setSelected(myLabel); } else { setDeselected(myLabel); } if (value instanceof Wrapper) { Wrapper wrapper = (Wrapper)value; final int mnemonic = wrapper.getMnemonic(); if (mnemonic != -1 && !myPopup1.getSpeedSearch().isHoldingFilter()) { myLabel.setText(mnemonic + "."); myLabel.setDisplayedMnemonicIndex(0); } else { if (wrapper.isChecked()) { myTextLabel.setIcon(isSelected ? RunConfigurationsComboBoxAction.CHECKED_SELECTED_ICON : RunConfigurationsComboBoxAction.CHECKED_ICON); } else { if (myTextLabel.getIcon() == null) { myTextLabel.setIcon(RunConfigurationsComboBoxAction.EMPTY_ICON); } } myLabel.setText(""); } } }
public ResourceQualifierSwitcherPanel(final Project project, @NotNull final VirtualFile file, BidirectionalMap<String, VirtualFile> qualifiers) { super(new BorderLayout()); myProject = project; myFile = file; myQualifiers = qualifiers; final String currentFileQualifier = qualifiers.getKeysByValue(file).get(0); final JLabel label = new JLabel(currentFileQualifier); label.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent event) { if (event.getButton() != MouseEvent.BUTTON1 || event.getClickCount() != 1) { return; } BidirectionalMap<String, VirtualFile> map = collectQualifiers(file.getParent().getParent(), file); ListPopupStep popupStep = new BaseListPopupStep<String>("Choose Qualifier", new ArrayList<String>(map.keySet())) { @Override public PopupStep onChosen(String selectedValue, boolean finalChoice) { switchToFile(selectedValue); return FINAL_CHOICE; } }; ListPopup popup = JBPopupFactory.getInstance().createListPopup(popupStep); popup.showUnderneathOf(label); } }); add(label, BorderLayout.WEST); }
public void actionPerformed(AnActionEvent e) { final JBPopupFactory popupFactory = JBPopupFactory.getInstance(); final ListPopupStep step = popupFactory.createActionsStep(myActionGroup, e.getDataContext(), false, false, myActionGroup.getTemplatePresentation().getText(), myTree, true, myPreselection != null ? myPreselection.getDefaultIndex() : 0, true); final ListPopup listPopup = popupFactory.createListPopup(step); listPopup.setHandleAutoSelectionBeforeShow(true); listPopup.showUnderneathOf(myNorthPanel); }
@Override protected void customizeComponent(JList list, Object value, boolean isSelected) { ListPopupStep<Object> step = myPopup.getListStep(); boolean isSelectable = step.isSelectable(value); myTextLabel.setEnabled(isSelectable); if (step.isMnemonicsNavigationEnabled()) { final int pos = step.getMnemonicNavigationFilter().getMnemonicPos(value); if (pos != -1) { String text = myTextLabel.getText(); text = text.substring(0, pos) + text.substring(pos + 1); myTextLabel.setText(text); myTextLabel.setDisplayedMnemonicIndex(pos); } } else { myTextLabel.setDisplayedMnemonicIndex(-1); } if (step.hasSubstep(value) && isSelectable) { myNextStepLabel.setVisible(true); final boolean isDark = ColorUtil.isDark(UIUtil.getListSelectionBackground()); myNextStepLabel.setIcon(isSelected ? isDark ? AllIcons.Icons.Ide.NextStepInverted : AllIcons.Icons.Ide.NextStep : AllIcons.Icons.Ide.NextStepGrayed); } else { myNextStepLabel.setVisible(false); //myNextStepLabel.setIcon(PopupIcons.EMPTY_ICON); } if (isSelected) { setSelected(myNextStepLabel); } else { setDeselected(myNextStepLabel); } }
@Override public void actionPerformed(AnActionEvent e) { final JBPopupFactory popupFactory = JBPopupFactory.getInstance(); final ListPopupStep step = popupFactory.createActionsStep(myActionGroup, e.getDataContext(), false, false, myActionGroup.getTemplatePresentation().getText(), myTree, true, myPreselection != null ? myPreselection.getDefaultIndex() : 0, true); final ListPopup listPopup = popupFactory.createListPopup(step); listPopup.setHandleAutoSelectionBeforeShow(true); listPopup.showUnderneathOf(myNorthPanel); }
public ListPopupModel(ElementFilter filter, SpeedSearch speedSearch, ListPopupStep step) { myFilter = filter; myStep = step; mySpeedSearch = speedSearch; myOriginalList = new ArrayList<>(step.getValues()); rebuildLists(); }
protected FlatSpeedSearchPopup(@Nullable WizardPopup parent, @Nonnull ListPopupStep step, @Nonnull DataContext dataContext, @Nullable Object value) { super(parent, step, null, dataContext, null, -1); setParentValue(value); }
public MockConfirmation(ListPopupStep aStep, String onYesText) { super(aStep); myOnYesText = onYesText; }
@Override protected void customizeComponent(JList list, Object value, boolean isSelected) { ListPopupStep<Object> step = myPopup.getListStep(); boolean isSelectable = step.isSelectable(value); myTextLabel.setEnabled(isSelectable); if (!isSelected && step instanceof BaseListPopupStep) { Color bg = ((BaseListPopupStep)step).getBackgroundFor(value); Color fg = ((BaseListPopupStep)step).getForegroundFor(value); if (fg != null) myTextLabel.setForeground(fg); if (bg != null) UIUtil.setBackgroundRecursively(myComponent, bg); } if (step.isMnemonicsNavigationEnabled()) { final int pos = step.getMnemonicNavigationFilter().getMnemonicPos(value); if (pos != -1) { String text = myTextLabel.getText(); text = text.substring(0, pos) + text.substring(pos + 1); myTextLabel.setText(text); myTextLabel.setDisplayedMnemonicIndex(pos); } } else { myTextLabel.setDisplayedMnemonicIndex(-1); } if (step.hasSubstep(value) && isSelectable) { myNextStepLabel.setVisible(true); final boolean isDark = ColorUtil.isDark(UIUtil.getListSelectionBackground()); myNextStepLabel.setIcon(isSelected ? isDark ? AllIcons.Icons.Ide.NextStepInverted : AllIcons.Icons.Ide.NextStep : AllIcons.Icons.Ide.NextStepGrayed); } else { myNextStepLabel.setVisible(false); //myNextStepLabel.setIcon(PopupIcons.EMPTY_ICON); } setSelected(myNextStepLabel, isSelected); if (myShortcutLabel != null) { myShortcutLabel.setText(""); if (value instanceof ShortcutProvider) { ShortcutSet set = ((ShortcutProvider)value).getShortcut(); if (set != null) { Shortcut shortcut = ArrayUtil.getFirstElement(set.getShortcuts()); if (shortcut != null) { myShortcutLabel.setText(" " + KeymapUtil.getShortcutText(shortcut)); } } } setSelected(myShortcutLabel, isSelected); myShortcutLabel.setForeground(isSelected ? UIManager.getColor("MenuItem.acceleratorSelectionForeground") : UIManager.getColor("MenuItem.acceleratorForeground")); } }
public RunListPopup(ListPopupStep step) { super(step); registerActions(this); }
protected RunListPopup(WizardPopup aParent, ListPopupStep aStep, Object parentValue) { super(aParent, aStep, parentValue); registerActions(this); }
@Override protected WizardPopup createPopup(WizardPopup parent, PopupStep step, Object parentValue) { return new RunListPopup(parent, (ListPopupStep)step, parentValue); }
@Override protected WizardPopup createPopup(WizardPopup parent, PopupStep step, Object parentValue) { ChildPopup popup = new ChildPopup(parent, (ListPopupStep)step, parentValue); initPopup(popup); return popup; }
ChildPopup(WizardPopup aParent, ListPopupStep aStep, Object parentValue) { super(aParent, aStep, parentValue); }
@Override protected void customizeComponent(JList<? extends E> list, E value, boolean isSelected) { ListPopupStep<Object> step = myPopup.getListStep(); boolean isSelectable = step.isSelectable(value); myTextLabel.setEnabled(isSelectable); if (!isSelected && step instanceof BaseListPopupStep) { Color bg = ((BaseListPopupStep)step).getBackgroundFor(value); Color fg = ((BaseListPopupStep)step).getForegroundFor(value); if (fg != null) myTextLabel.setForeground(fg); if (bg != null) UIUtil.setBackgroundRecursively(myComponent, bg); } if (step.isMnemonicsNavigationEnabled()) { final int pos = step.getMnemonicNavigationFilter().getMnemonicPos(value); if (pos != -1) { String text = myTextLabel.getText(); text = text.substring(0, pos) + text.substring(pos + 1); myTextLabel.setText(text); myTextLabel.setDisplayedMnemonicIndex(pos); } } else { myTextLabel.setDisplayedMnemonicIndex(-1); } if (step.hasSubstep(value) && isSelectable) { myNextStepLabel.setVisible(true); final boolean isDark = ColorUtil.isDark(UIUtil.getListSelectionBackground()); myNextStepLabel.setIcon(isSelected ? isDark ? AllIcons.Icons.Ide.NextStepInverted : AllIcons.Icons.Ide.NextStep : AllIcons.Icons.Ide.NextStepGrayed); } else { myNextStepLabel.setVisible(false); //myNextStepLabel.setIcon(PopupIcons.EMPTY_ICON); } setSelected(myNextStepLabel, isSelected); if (myShortcutLabel != null) { myShortcutLabel.setEnabled(isSelectable); myShortcutLabel.setText(""); if (value instanceof ShortcutProvider) { ShortcutSet set = ((ShortcutProvider)value).getShortcut(); if (set != null) { Shortcut shortcut = ArrayUtil.getFirstElement(set.getShortcuts()); if (shortcut != null) { myShortcutLabel.setText(" " + KeymapUtil.getShortcutText(shortcut)); } } } setSelected(myShortcutLabel, isSelected); myShortcutLabel.setForeground(isSelected ? UIManager.getColor("MenuItem.acceleratorSelectionForeground") : UIManager.getColor("MenuItem.acceleratorForeground")); } }
private BranchActionGroupPopup(@Nullable WizardPopup aParent, @Nonnull ListPopupStep aStep, @Nullable Object parentValue) { super(aParent, aStep, DataContext.EMPTY_CONTEXT, parentValue); // don't store children popup userSize; myKey = null; DataManager.registerDataProvider(getList(), dataId -> POPUP_MODEL == dataId ? getListModel() : null); }
private WizardPopup createListPopupStep(WizardPopup parent, PopupStep step, Object parentValue) { if (step instanceof ListPopupStep) { return new BranchActionGroupPopup(parent, (ListPopupStep)step, parentValue); } return super.createPopup(parent, step, parentValue); }