com.intellij.ide.util.gotoByName.ChooseByNamePopupComponent Java Examples

The following examples show how to use com.intellij.ide.util.gotoByName.ChooseByNamePopupComponent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GotoBaseAction.java    From CppTools with Apache License 2.0 6 votes vote down vote up
protected void gotoActionPerformed(AnActionEvent anActionEvent) {
  final Project project = (Project) anActionEvent.getDataContext().getData(DataConstants.PROJECT);

  final ChooseByNamePopup byNamePopup = ChooseByNamePopup.createPopup(
    project,
    new MyContributorsBasedGotoByModel(project, getNameContributor()),
    (PsiElement)null
  );

  byNamePopup.invoke(new ChooseByNamePopupComponent.Callback() {
    public void elementChosen(Object element) {
      ((NavigationItem)element).navigate(true);
    }
    public void onClose() {
      if (GotoBaseAction.this.getClass().equals(myInAction)) myInAction = null;
    }
  }, ModalityState.current(), false);
}
 
Example #2
Source File: DirectoryChooser.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
protected JComponent createCenterPanel(){
  final JPanel panel = new JPanel(new BorderLayout());

  final DefaultActionGroup actionGroup = new DefaultActionGroup();
  actionGroup.add(new FilterExistentAction());
  final JComponent toolbarComponent = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, actionGroup, true).getComponent();
  toolbarComponent.setBorder(null);
  panel.add(toolbarComponent, BorderLayout.NORTH);

  final Runnable runnable = new Runnable() {
    @Override
    public void run() {
      enableButtons();
    }
  };
  myView.onSelectionChange(runnable);
  final JComponent component = myView.getComponent();
  final JScrollPane jScrollPane = ScrollPaneFactory.createScrollPane(component);
  //noinspection HardCodedStringLiteral
  int prototypeWidth = component.getFontMetrics(component.getFont()).stringWidth("X:\\1234567890\\1234567890\\com\\company\\system\\subsystem");
  jScrollPane.setPreferredSize(new Dimension(Math.max(300, prototypeWidth),300));

  installEnterAction(component);
  panel.add(jScrollPane, BorderLayout.CENTER);
  myTabbedPaneWrapper.addTab("Directory Structure", panel);

  myChooseByNamePanel.invoke(new ChooseByNamePopupComponent.Callback() {
    @Override
    public void elementChosen(Object element) {
      setSelection(element);
    }
  }, ModalityState.stateForComponent(getRootPane()), false);
  myTabbedPaneWrapper.addTab("Choose By Neighbor Class", myChooseByNamePanel.getPanel());

  return myTabbedPaneWrapper.getComponent();
}