Skip to content

Instantly share code, notes, and snippets.

@neubig
Last active August 26, 2019 15:08

Revisions

  1. neubig revised this gist Aug 26, 2019. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions HelloAction.java
    Original file line number Diff line number Diff line change
    @@ -3,6 +3,7 @@
    import com.intellij.openapi.actionSystem.AnAction;
    import com.intellij.openapi.actionSystem.AnActionEvent;
    import com.intellij.openapi.project.Project;
    import com.intellij.openapi.ui.Messages;
    import com.intellij.openapi.ui.popup.JBPopupFactory;
    import com.intellij.openapi.ui.popup.ListPopup;
    import com.intellij.openapi.ui.popup.PopupStep;
    @@ -15,9 +16,10 @@ public HelloAction() {

    public void actionPerformed(AnActionEvent event) {
    Project project = event.getProject();
    // Messages.showMessageDialog(project, "Hello world!", "Greeting", Messages.getInformationIcon());
    final String query = Messages.showInputDialog(project,"Enter your query:","Query",
    Messages.getQuestionIcon());

    ListPopup lp = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<String>("Chosen",
    ListPopup lp = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<String>("Your query is " + query,
    "Choice1", "Choice2") {
    @Override
    public PopupStep onChosen(String selectedValue, boolean finalChoice) {
  2. neubig created this gist Aug 26, 2019.
    31 changes: 31 additions & 0 deletions HelloAction.java
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    package edu.cmu.empty;

    import com.intellij.openapi.actionSystem.AnAction;
    import com.intellij.openapi.actionSystem.AnActionEvent;
    import com.intellij.openapi.project.Project;
    import com.intellij.openapi.ui.popup.JBPopupFactory;
    import com.intellij.openapi.ui.popup.ListPopup;
    import com.intellij.openapi.ui.popup.PopupStep;
    import com.intellij.openapi.ui.popup.util.BaseListPopupStep;

    public class HelloAction extends AnAction {
    public HelloAction() {
    super("Hello");
    }

    public void actionPerformed(AnActionEvent event) {
    Project project = event.getProject();
    // Messages.showMessageDialog(project, "Hello world!", "Greeting", Messages.getInformationIcon());

    ListPopup lp = JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<String>("Chosen",
    "Choice1", "Choice2") {
    @Override
    public PopupStep onChosen(String selectedValue, boolean finalChoice) {
    System.err.println(selectedValue);
    return super.onChosen(selectedValue, finalChoice);
    }
    });
    lp.showInFocusCenter();

    }
    }