use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.
the class GitPushTargetPanel method showRemoteSelector.
private void showRemoteSelector(@NotNull Component component, @NotNull Point point) {
List<PopupItem> remotes = getPopupItems();
if (remotes.size() <= 1) {
return;
}
ListPopup popup = new ListPopupImpl(new BaseListPopupStep<PopupItem>(null, remotes) {
@Override
public PopupStep onChosen(@NotNull PopupItem selectedValue, boolean finalChoice) {
return doFinalStep(() -> {
if (selectedValue.isDefineRemote()) {
showDefineRemoteDialog();
} else {
myRemoteRenderer.updateLinkText(selectedValue.getPresentable());
if (myFireOnChangeAction != null && !myTargetEditor.isShowing()) {
//fireOnChange only when editing completed
myFireOnChangeAction.run();
}
}
});
}
@Nullable
@Override
public ListSeparator getSeparatorAbove(PopupItem value) {
return value.isDefineRemote() ? new ListSeparator() : null;
}
}) {
@Override
public void cancel(InputEvent e) {
super.cancel(e);
if (myTargetEditor.isShowing()) {
//repaint and force move focus to target editor component
GitPushTargetPanel.this.repaint();
IdeFocusManager.getInstance(myProject).requestFocus(myTargetEditor, true);
}
}
};
popup.show(new RelativePoint(component, point));
}
use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.
the class TemplateListPanel method addTemplateOrGroup.
private void addTemplateOrGroup(AnActionButton button) {
DefaultActionGroup group = new DefaultActionGroup();
group.add(new DumbAwareAction("Live Template") {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
addTemplate();
}
});
group.add(new DumbAwareAction("Template Group...") {
@Override
public void actionPerformed(@NotNull AnActionEvent e) {
String newName = Messages.showInputDialog(myTree, "Enter the new group name:", "Create New Group", null, "", new TemplateGroupInputValidator(null));
if (newName != null) {
TemplateGroup newGroup = new TemplateGroup(newName);
setSelectedNode(insertNewGroup(newGroup));
}
}
});
DataContext context = DataManager.getInstance().getDataContext(button.getContextComponent());
ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(null, group, context, JBPopupFactory.ActionSelectionAid.ALPHA_NUMBERING, true, null);
popup.show(button.getPreferredPopupPoint());
}
use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.
the class GotoActionAction method performAction.
public static void performAction(Object element, @Nullable final Component component, @Nullable final AnActionEvent e, @Nullable final Runnable callback) {
// element could be AnAction (SearchEverywhere)
if (component == null)
return;
final AnAction action = element instanceof AnAction ? (AnAction) element : ((GotoActionModel.ActionWrapper) element).getAction();
TransactionGuard.getInstance().submitTransactionLater(ApplicationManager.getApplication(), () -> {
DataManager instance = DataManager.getInstance();
DataContext context = instance != null ? instance.getDataContext(component) : DataContext.EMPTY_CONTEXT;
InputEvent inputEvent = e == null ? null : e.getInputEvent();
AnActionEvent event = AnActionEvent.createFromAnAction(action, inputEvent, ActionPlaces.ACTION_SEARCH, context);
if (ActionUtil.lastUpdateAndCheckDumb(action, event, false)) {
if (action instanceof ActionGroup && ((ActionGroup) action).getChildren(event).length > 0) {
ListPopup popup = JBPopupFactory.getInstance().createActionGroupPopup(event.getPresentation().getText(), (ActionGroup) action, context, false, callback, -1);
Window window = SwingUtilities.getWindowAncestor(component);
if (window != null) {
popup.showInCenterOf(window);
} else {
popup.showInFocusCenter();
}
} else {
ActionUtil.performActionDumbAware(action, event);
if (callback != null)
callback.run();
}
}
});
}
use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.
the class SelectInAction method invoke.
private static void invoke(@NotNull DataContext dataContext, @NotNull SelectInContext context) {
final List<SelectInTarget> targetVector = Arrays.asList(getSelectInManager(context.getProject()).getTargets());
ListPopup popup;
if (targetVector.isEmpty()) {
DefaultActionGroup group = new DefaultActionGroup();
group.add(new NoTargetsAction());
popup = JBPopupFactory.getInstance().createActionGroupPopup(IdeBundle.message("title.popup.select.target"), group, dataContext, JBPopupFactory.ActionSelectionAid.MNEMONICS, true);
} else {
popup = JBPopupFactory.getInstance().createListPopup(new SelectInActionsStep(targetVector, context));
}
popup.showInBestPositionFor(dataContext);
}
use of com.intellij.openapi.ui.popup.ListPopup in project intellij-community by JetBrains.
the class AddNewLibraryDependencyAction method chooseTypeAndCreate.
public static void chooseTypeAndCreate(final ClasspathPanel classpathPanel, final StructureConfigurableContext context, final JButton contextButton, @NotNull final LibraryCreatedCallback callback) {
if (LibraryEditingUtil.hasSuitableTypes(classpathPanel)) {
final ListPopup popup = JBPopupFactory.getInstance().createListPopup(LibraryEditingUtil.createChooseTypeStep(classpathPanel, libraryType -> doCreateLibrary(classpathPanel, context, callback, contextButton, libraryType)));
popup.showUnderneathOf(contextButton);
} else {
doCreateLibrary(classpathPanel, context, callback, contextButton, null);
}
}
Aggregations