コード例 #1
0
  /** Show the dialog to select the method to override. */
  private void showDialog() {
    List<Function> functionNames = finder.getFunctionNames();

    // Select the closest element found from the current position.
    final JBList jbList = new JBList(functionNames.toArray());

    // Open a pop-up to select which describe() or it() you want to change.
    JBPopupFactory.getInstance()
        .createListPopupBuilder(jbList)
        .setTitle("Select the method to override")
        .setFilteringEnabled(
            new com.intellij.util.Function<Object, String>() {
              @Override
              public String fun(Object o) {
                return o == null ? "" : o.toString();
              }
            })
        .setItemChoosenCallback(
            new Runnable() {
              public void run() {
                if (jbList.getSelectedValue() != null) {
                  addNewMethod((Function) jbList.getSelectedValue());
                }
              }
            })
        .createPopup()
        .showCenteredInCurrentWindow(project);
  }