@Override protected Pair<JComponent, Dimension> createDiffPanel(JPanel root, ExcludingTraversalPolicy traversalPolicy) { initChangesTree(root); JPanel p = new JPanel(new BorderLayout()); myToolBar = ActionManager.getInstance().createActionToolbar(ActionPlaces.UNKNOWN, createChangesTreeActions(root), true); JPanel toolBarPanel = new JPanel(new BorderLayout()); toolBarPanel.add(myToolBar.getComponent(), BorderLayout.CENTER); if (showSearchField()) { SearchTextField search = createSearchBox(root); toolBarPanel.add(search, BorderLayout.EAST); traversalPolicy.exclude(search.getTextEditor()); } p.add(toolBarPanel, BorderLayout.NORTH); p.add(myChangesTree, BorderLayout.CENTER); return Pair.create((JComponent)p, toolBarPanel.getPreferredSize()); }
public void addTextToRecent(@NotNull JTextComponent textField) { final String text = textField.getText(); if (text.length() > 0) { if (textField == mySearchTextComponent) { FindSettings.getInstance().addStringToFind(text); if (mySearchFieldWrapper.getTargetComponent() instanceof SearchTextField) { ((SearchTextField)mySearchFieldWrapper.getTargetComponent()).addCurrentTextToHistory(); } } else { FindSettings.getInstance().addStringToReplace(text); if (myReplaceFieldWrapper.getTargetComponent() instanceof SearchTextField) { ((SearchTextField)myReplaceFieldWrapper.getTargetComponent()).addCurrentTextToHistory(); } } } }
public void addTextToRecent(@Nonnull JTextComponent textField) { final String text = textField.getText(); if (text.length() > 0) { FindInProjectSettings findInProjectSettings = FindInProjectSettings.getInstance(myProject); if (textField == mySearchTextComponent) { findInProjectSettings.addStringToFind(text); if (mySearchFieldWrapper.getTargetComponent() instanceof SearchTextField) { ((SearchTextField)mySearchFieldWrapper.getTargetComponent()).addCurrentTextToHistory(); } } else { findInProjectSettings.addStringToReplace(text); if (myReplaceFieldWrapper.getTargetComponent() instanceof SearchTextField) { ((SearchTextField)myReplaceFieldWrapper.getTargetComponent()).addCurrentTextToHistory(); } } } }
@NotNull protected static JTextComponent unwrapTextComponent(@NotNull JComponent wrapped) { if (wrapped instanceof SearchTextField) { return ((SearchTextField)wrapped).getTextEditor(); } if (wrapped instanceof SearchTextArea) { return ((SearchTextArea)wrapped).getTextArea(); } throw new AssertionError(); }
@Override @RunsInEDT @Nullable public String textOf(final @Nonnull SearchTextField component) { return execute(new GuiQuery<String>() { @Override protected @Nullable String executeInEDT() { return component.getText(); } }); }
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); }
private void createUIComponents() { myTopPanel = new JPanel(new BorderLayout()) { @Override protected void paintComponent(Graphics g) { ((Graphics2D)g).setPaint(new GradientPaint(0, 0, Gray._206, 0, getHeight() - 1, Gray._172)); g.fillRect(0, 0, getWidth(), getHeight()); g.setColor(Gray._145); g.drawLine(0, getHeight() - 2, getWidth(), getHeight() - 2); g.setColor(Gray._103); g.drawLine(0, getHeight() - 1, getWidth(), getHeight() - 1); } }; final JLabel title = new JLabel("Preferences"); if (!SystemInfo.isMac) { title.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD, 14)); } else { title.setFont(new Font("Lucuda Grande", Font.PLAIN, 12)); } title.setHorizontalTextPosition(SwingConstants.CENTER); title.setHorizontalAlignment(SwingConstants.CENTER); title.setVerticalAlignment(SwingConstants.TOP); myTopPanel.add(title, BorderLayout.NORTH); mySearchTextField = new SearchTextField(); mySearchTextField.setOpaque(false); myTopPanel.add(mySearchTextField, BorderLayout.EAST); }
@Nonnull protected static JTextComponent unwrapTextComponent(@Nonnull JComponent wrapped) { if (wrapped instanceof SearchTextField) { return ((SearchTextField)wrapped).getTextEditor(); } if (wrapped instanceof SearchTextArea) { return ((SearchTextArea)wrapped).getTextArea(); } throw new AssertionError(); }
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); }
@NotNull public ChooseDeviceDefinitionStepFixture enterSearchTerm(@NotNull String searchTerm) { SearchTextField searchField = robot().finder().findByType(target(), SearchTextField.class); replaceText(searchField.getTextEditor(), searchTerm); return this; }
public SearchTextFieldFixture(@NotNull Robot robot, @NotNull SearchTextField target) { super(SearchTextFieldFixture.class, robot, target); }
@NotNull public SearchTextFieldFixture getSearchTextField() { return new SearchTextFieldFixture(robot(), robot().finder().findByType(SearchTextField.class)); }
@Override @RunsInEDT public void requireText(@NotNull SearchTextField component, String expected) { assertThat(textOf(component)).isEqualTo(expected); }
@Override @RunsInEDT public void requireText(@NotNull SearchTextField component, final @NotNull Pattern pattern) { assertThat(textOf(component)).matches(pattern.pattern()); }
@RunsInEDT public void enterText(@Nonnull SearchTextField textBox, @Nonnull String text) { focusAndWaitForFocusGain(textBox); robot.enterText(text); }
@Nonnull public SearchTextField createTextFilter() { return new TextFilterField(myTextFilterModel); }