com.intellij.ui.SearchTextField Java Examples

The following examples show how to use com.intellij.ui.SearchTextField. 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: SearchFilter.java    From azure-devops-intellij with MIT License 5 votes vote down vote up
public SearchFilter() {
    filerLabel = new JLabel(TfPluginBundle.message(TfPluginBundle.KEY_TOOLBAR_FILTER_TITLE));
    searchField = new SearchTextField(true);

    setLayout(new BorderLayout(JBUI.scale(3), 0)); //adds vertical padding so search field isn't crammed in the panel
    add(filerLabel, BorderLayout.LINE_START);
    add(searchField, BorderLayout.LINE_END);
}
 
Example #2
Source File: FlutterLogFilterPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@NotNull
private SearchTextField createSearchTextField() {
  final LogFilterTextField logFilterTextField = new LogFilterTextField();
  logFilterTextField.setOnFilterListener(this::doFilter);
  return logFilterTextField;
}
 
Example #3
Source File: FlutterLogFilterPanel.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@NotNull
private SearchTextField createSearchTextField() {
  final LogFilterTextField logFilterTextField = new LogFilterTextField();
  logFilterTextField.setOnFilterListener(this::doFilter);
  return logFilterTextField;
}
 
Example #4
Source File: VcsLogClassicFilterUi.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public SearchTextField createTextFilter() {
  return new TextFilterField(myTextFilterModel);
}
 
Example #5
Source File: SearchFieldAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
public SearchFieldAction(String text) {
  super("Find: ");
  myField = new SearchTextField(true) {
    @Override
    protected boolean preprocessEventForTextField(KeyEvent e) {
      if ((KeyEvent.VK_ENTER == e.getKeyCode()) || ('\n' == e.getKeyChar())) {
        e.consume();
        addCurrentTextToHistory();
        actionPerformed(null);
      }
      return super.preprocessEventForTextField(e);
    }

    @Override
    protected void onFocusLost() {
      myField.addCurrentTextToHistory();
      actionPerformed(null);
    }

    @Override
    protected void onFieldCleared() {
      actionPerformed(null);
    }
  };
  Border border = myField.getBorder();
  Border emptyBorder = IdeBorderFactory.createEmptyBorder(3, 0, 2, 0);
  if (border instanceof CompoundBorder) {
    if (!UIUtil.isUnderDarcula()) {
      myField.setBorder(new CompoundBorder(emptyBorder, ((CompoundBorder)border).getInsideBorder()));
    }
  }
  else {
    myField.setBorder(emptyBorder);
  }

  myField.setSearchIcon(AllIcons.Actions.Filter_small);
  myComponent = new JPanel();
  final BoxLayout layout = new BoxLayout(myComponent, BoxLayout.X_AXIS);
  myComponent.setLayout(layout);
  if (text.length() > 0) {
    final JLabel label = new JLabel(text);
    //label.setFont(label.getFont().deriveFont(Font.ITALIC));
    label.setForeground(UIUtil.isUnderDarcula() ? UIUtil.getLabelForeground() : UIUtil.getInactiveTextColor());
    label.setBorder(BorderFactory.createEmptyBorder(0,3,0,0));
    myComponent.add(label);
  }
  myComponent.add(myField);
}
 
Example #6
Source File: SearchEverywhereManagerImpl.java    From consulo with Apache License 2.0 4 votes vote down vote up
private SearchEverywhereUI createView(Project project, List<? extends SearchEverywhereContributor<?>> contributors) {
  SearchEverywhereUI view = new SearchEverywhereUI(project, contributors);

  view.setSearchFinishedHandler(() -> {
    if (isShown()) {
      myBalloon.cancel();
    }
  });

  view.addViewTypeListener(viewType -> {
    if (!isShown()) {
      return;
    }

    ApplicationManager.getApplication().invokeLater(() -> {
      if (myBalloon == null || myBalloon.isDisposed()) return;

      Dimension minSize = view.getMinimumSize();
      JBInsets.addTo(minSize, myBalloon.getContent().getInsets());
      myBalloon.setMinimumSize(minSize);

      if (viewType == SearchEverywhereUI.ViewType.SHORT) {
        myBalloonFullSize = myBalloon.getSize();
        JBInsets.removeFrom(myBalloonFullSize, myBalloon.getContent().getInsets());
        myBalloon.pack(false, true);
      }
      else {
        if (myBalloonFullSize == null) {
          myBalloonFullSize = view.getPreferredSize();
          JBInsets.addTo(myBalloonFullSize, myBalloon.getContent().getInsets());
        }
        myBalloonFullSize.height = Integer.max(myBalloonFullSize.height, minSize.height);
        myBalloonFullSize.width = Integer.max(myBalloonFullSize.width, minSize.width);
        myBalloon.setSize(myBalloonFullSize);
      }
    });
  });

  DumbAwareAction.create(__ -> showHistoryItem(true)).registerCustomShortcutSet(SearchTextField.SHOW_HISTORY_SHORTCUT, view);

  DumbAwareAction.create(__ -> showHistoryItem(false)).registerCustomShortcutSet(SearchTextField.ALT_SHOW_HISTORY_SHORTCUT, view);

  return view;
}