use of com.intellij.ui.components.JBTextArea in project ExcelReader by obiscr.
the class MySearchReplaceComponent method updateTextComponent.
private boolean updateTextComponent(boolean search) {
JTextComponent oldComponent = mySearchTextComponent;
if (oldComponent != null) {
return false;
}
final MyTextComponentWrapper wrapper = mySearchFieldWrapper;
@NotNull JTextComponent innerTextComponent;
@NotNull JComponent outerComponent;
if (myUseSearchField) {
outerComponent = new SearchTextField(true, this.toString());
innerTextComponent = ((SearchTextField) outerComponent).getTextEditor();
innerTextComponent.setBorder(BorderFactory.createEmptyBorder());
} else {
innerTextComponent = new JBTextArea() {
@Override
public Dimension getPreferredScrollableViewportSize() {
Dimension defaultSize = super.getPreferredScrollableViewportSize();
if (mySplitter != null && mySplitter.getSecondComponent() != null && Registry.is("ide.find.expand.search.field.on.typing", true)) {
Dimension preferredSize = getPreferredSize();
Dimension minimumSize = getMinimumSize();
int spaceForLeftPanel = mySplitter.getWidth() - mySplitter.getSecondComponent().getPreferredSize().width - mySplitter.getDividerWidth();
int allSearchTextAreaIcons = JBUI.scale(180);
int w = spaceForLeftPanel - allSearchTextAreaIcons;
w = Math.max(w, minimumSize.width);
return new Dimension(Math.min(Math.max(defaultSize.width, preferredSize.width), w), defaultSize.height);
}
return defaultSize;
}
};
((JBTextArea) innerTextComponent).setRows(1);
((JBTextArea) innerTextComponent).setColumns(12);
innerTextComponent.setMinimumSize(new Dimension(150, 0));
outerComponent = new SearchTextArea(((JBTextArea) innerTextComponent), search);
myExtraSearchButtons.clear();
myExtraSearchButtons.addAll(((SearchTextArea) outerComponent).setExtraActions(myEmbeddedSearchActions.toArray(AnAction.EMPTY_ARRAY)));
}
UIUtil.addUndoRedoActions(innerTextComponent);
wrapper.setContent(outerComponent);
if (search) {
innerTextComponent.getAccessibleContext().setAccessibleName(FindBundle.message("find.search.accessible.name"));
} else {
innerTextComponent.getAccessibleContext().setAccessibleName(FindBundle.message("find.replace.accessible.name"));
}
// Display empty text only when focused
innerTextComponent.putClientProperty("StatusVisibleFunction", (BooleanFunction<JTextComponent>) (c -> c.getText().isEmpty() && c.isFocusOwner()));
innerTextComponent.putClientProperty(UIUtil.HIDE_EDITOR_FROM_DATA_CONTEXT_PROPERTY, Boolean.TRUE);
innerTextComponent.setBackground(UIUtil.getTextFieldBackground());
JComponent finalTextComponent = innerTextComponent;
innerTextComponent.addFocusListener(new FocusListener() {
@Override
public void focusGained(final FocusEvent e) {
finalTextComponent.repaint();
}
@Override
public void focusLost(final FocusEvent e) {
finalTextComponent.repaint();
}
});
return true;
}
use of com.intellij.ui.components.JBTextArea in project consulo by consulo.
the class PluginHeaderPanel method initComponents.
private void initComponents() {
myRoot = new JPanel(new VerticalLayout(JBUI.scale(5)));
myRoot.setOpaque(false);
myIconLabel = new JBLabel();
myName = new JBTextArea();
myName.setBorder(JBUI.Borders.empty());
myName.setOpaque(false);
myName.setLineWrap(true);
myName.setWrapStyleWord(true);
myName.setEditable(false);
myName.setBorder(JBUI.Borders.empty(0, 5));
myName.setFont(UIUtil.getLabelFont(UIUtil.FontSize.BIGGER));
myInstallButton = new JButton();
myInstallButton.setOpaque(false);
JPanel nameWrapper = new JPanel(new VerticalFlowLayout(VerticalFlowLayout.MIDDLE, true, true));
nameWrapper.setOpaque(false);
nameWrapper.add(myName);
myRoot.add(new BorderLayoutPanel().addToLeft(myIconLabel).addToCenter(nameWrapper).andTransparent());
myRoot.add(new BorderLayoutPanel().addToRight(myInstallButton).andTransparent());
myExperimentalLabel = new JBLabel();
myRoot.add(new BorderLayoutPanel().addToRight(myExperimentalLabel).andTransparent());
myDownloadsPanel = new JPanel(new HorizontalLayout(JBUI.scale(5)));
myDownloadsPanel.setOpaque(false);
myDownloadsPanel.add(myDownloads = new JBLabel());
myDownloadsPanel.add(myRating = new RatesPanel());
myRating.setVisible(PluginDescriptionPanel.ENABLED_STARS);
myRoot.add(new BorderLayoutPanel().andTransparent().addToRight(myDownloadsPanel));
myUpdated = new JBLabel();
myDownloads.setForeground(JBColor.GRAY);
myUpdated.setForeground(JBColor.GRAY);
final Font smallFont = UIUtil.getLabelFont(UIUtil.FontSize.SMALL);
myDownloads.setFont(smallFont);
myUpdated.setFont(smallFont);
myRoot.setVisible(false);
}
use of com.intellij.ui.components.JBTextArea in project consulo by consulo.
the class FindPopupPanel method initComponents.
private void initComponents() {
myTitleLabel = new JBLabel(FindBundle.message("find.in.path.dialog.title"), UIUtil.ComponentStyle.REGULAR);
RelativeFont.BOLD.install(myTitleLabel);
myInfoLabel = new JBLabel("", UIUtil.ComponentStyle.SMALL);
myLoadingDecorator = new LoadingDecorator(new JLabel(EmptyIcon.ICON_16), getDisposable(), 250, true, new AsyncProcessIcon("FindInPathLoading"));
myLoadingDecorator.setLoadingText("");
ItemListener liveResultsPreviewUpdateListener = __ -> scheduleResultsUpdate();
myCbFileFilter = createCheckBox("find.popup.filemask", "FileFilter");
myCbFileFilter.addItemListener(__ -> {
if (myCbFileFilter.isSelected()) {
myFileMaskField.setEnabled(true);
if (myCbFileFilter.getClientProperty("dontRequestFocus") == null) {
IdeFocusManager.getInstance(myProject).requestFocus(myFileMaskField, true);
myFileMaskField.getEditor().selectAll();
}
} else {
myFileMaskField.setEnabled(false);
if (myCbFileFilter.getClientProperty("dontRequestFocus") == null) {
IdeFocusManager.getInstance(myProject).requestFocus(mySearchComponent, true);
}
}
});
myCbFileFilter.addItemListener(liveResultsPreviewUpdateListener);
myFileMaskField = new ComboBox<String>() {
@Override
public Dimension getPreferredSize() {
int width = 0;
int buttonWidth = 0;
Component[] components = getComponents();
for (Component component : components) {
Dimension size = component.getPreferredSize();
int w = size != null ? size.width : 0;
if (component instanceof JButton) {
buttonWidth = w;
}
width += w;
}
ComboBoxEditor editor = getEditor();
if (editor != null) {
Component editorComponent = editor.getEditorComponent();
if (editorComponent != null) {
FontMetrics fontMetrics = editorComponent.getFontMetrics(editorComponent.getFont());
width = Math.max(width, fontMetrics.stringWidth(String.valueOf(getSelectedItem())) + buttonWidth);
// Let's reserve some extra space for just one 'the next' letter
width += fontMetrics.stringWidth("m");
}
}
Dimension size = super.getPreferredSize();
Insets insets = getInsets();
width += insets.left + insets.right;
size.width = MathUtil.clamp(width, JBUIScale.scale(80), JBUIScale.scale(500));
return size;
}
};
myFileMaskField.setEditable(true);
myFileMaskField.setMaximumRowCount(8);
myFileMaskField.addActionListener(__ -> scheduleResultsUpdate());
Component editorComponent = myFileMaskField.getEditor().getEditorComponent();
if (editorComponent instanceof EditorTextField) {
final EditorTextField etf = (EditorTextField) editorComponent;
etf.addDocumentListener(new DocumentListener() {
@Override
public void documentChanged(@Nonnull com.intellij.openapi.editor.event.DocumentEvent event) {
onFileMaskChanged();
}
});
} else {
if (editorComponent instanceof JTextComponent) {
((JTextComponent) editorComponent).getDocument().addDocumentListener(new DocumentAdapter() {
@Override
protected void textChanged(@Nonnull DocumentEvent e) {
onFileMaskChanged();
}
});
} else {
assert false;
}
}
AnAction myShowFilterPopupAction = new MyShowFilterPopupAction();
myFilterContextButton = new ActionButton(myShowFilterPopupAction, myShowFilterPopupAction.getTemplatePresentation(), ActionPlaces.UNKNOWN, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE) {
@Override
public int getPopState() {
int state = super.getPopState();
if (state != ActionButtonComponent.NORMAL)
return state;
return mySelectedContextName.equals(FindInProjectUtil.getPresentableName(FindModel.SearchContext.ANY)) ? ActionButtonComponent.NORMAL : ActionButtonComponent.PUSHED;
}
};
myShowFilterPopupAction.registerCustomShortcutSet(myShowFilterPopupAction.getShortcutSet(), this);
ToggleAction pinAction = new MyPinAction();
ActionButton pinButton = new ActionButton(pinAction, pinAction.getTemplatePresentation(), ActionPlaces.UNKNOWN, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE);
DefaultActionGroup tabOptionsGroup = new DefaultActionGroup() {
{
Presentation presentation = getTemplatePresentation();
presentation.setText(FindBundle.message("find.popup.show.tab.options"));
presentation.setIcon(AllIcons.General.GearPlain);
setPopup(true);
setShortcutSet(CustomShortcutSet.fromString("alt ctrl DOWN"));
add(new MySkipTabWithOneUsageAction());
add(new MyOpenResultsInNewTabAction());
}
};
ActionButton tabOptionsButton = new ActionButton(tabOptionsGroup, tabOptionsGroup.getTemplatePresentation(), ActionPlaces.UNKNOWN, ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE);
DumbAwareAction.create(event -> tabOptionsButton.click()).registerCustomShortcutSet(tabOptionsGroup.getShortcutSet(), this);
myOKButton = new JButton(FindBundle.message("find.popup.find.button"));
myReplaceAllButton = new JButton(FindBundle.message("find.popup.replace.all.button"));
myReplaceSelectedButton = new JButton(FindBundle.message("find.popup.replace.selected.button", 0));
myOkActionListener = __ -> doOK(true);
myReplaceAllButton.addActionListener(__ -> doOK(false));
myReplaceSelectedButton.addActionListener(e -> {
int rowToSelect = myResultsPreviewTable.getSelectionModel().getMinSelectionIndex();
Map<Integer, Usage> usages = getSelectedUsages();
if (usages == null) {
return;
}
CommandProcessor.getInstance().executeCommand(myProject, () -> {
for (Map.Entry<Integer, Usage> entry : usages.entrySet()) {
try {
ReplaceInProjectManager.getInstance(myProject).replaceUsage(entry.getValue(), myHelper.getModel(), Collections.emptySet(), false);
((DefaultTableModel) myResultsPreviewTable.getModel()).removeRow(entry.getKey());
} catch (FindManager.MalformedReplacementStringException ex) {
if (!ApplicationManager.getApplication().isUnitTestMode()) {
Messages.showErrorDialog(this, ex.getMessage(), FindBundle.message("find.replace.invalid.replacement.string.title"));
}
break;
}
}
ApplicationManager.getApplication().invokeLater(() -> {
if (myResultsPreviewTable.getRowCount() > rowToSelect) {
myResultsPreviewTable.getSelectionModel().setSelectionInterval(rowToSelect, rowToSelect);
}
ScrollingUtil.ensureSelectionExists(myResultsPreviewTable);
});
}, FindBundle.message("find.replace.command"), null);
});
myOKButton.addActionListener(myOkActionListener);
TouchbarDataKeys.putDialogButtonDescriptor(myOKButton, 0, true);
boolean enterAsOK = Registry.is("ide.find.enter.as.ok", false);
new MyEnterAction(enterAsOK).registerCustomShortcutSet(new CustomShortcutSet(ENTER), this);
DumbAwareAction.create(__ -> processCtrlEnter()).registerCustomShortcutSet(new CustomShortcutSet(ENTER_WITH_MODIFIERS), this);
DumbAwareAction.create(__ -> myReplaceAllButton.doClick()).registerCustomShortcutSet(new CustomShortcutSet(REPLACE_ALL), this);
myReplaceAllButton.setToolTipText(KeymapUtil.getKeystrokeText(REPLACE_ALL));
List<Shortcut> navigationKeyStrokes = new ArrayList<>();
KeyStroke viewSourceKeyStroke = KeymapUtil.getKeyStroke(CommonShortcuts.getViewSource());
if (viewSourceKeyStroke != null && !Comparing.equal(viewSourceKeyStroke, ENTER_WITH_MODIFIERS) && !Comparing.equal(viewSourceKeyStroke, ENTER)) {
navigationKeyStrokes.add(new KeyboardShortcut(viewSourceKeyStroke, null));
}
KeyStroke editSourceKeyStroke = KeymapUtil.getKeyStroke(CommonShortcuts.getEditSource());
if (editSourceKeyStroke != null && !Comparing.equal(editSourceKeyStroke, ENTER_WITH_MODIFIERS) && !Comparing.equal(editSourceKeyStroke, ENTER)) {
navigationKeyStrokes.add(new KeyboardShortcut(editSourceKeyStroke, null));
}
if (!navigationKeyStrokes.isEmpty()) {
DumbAwareAction.create(e -> navigateToSelectedUsage(e)).registerCustomShortcutSet(new CustomShortcutSet(navigationKeyStrokes.toArray(Shortcut.EMPTY_ARRAY)), this);
}
mySearchComponent = new JBTextArea();
mySearchComponent.setColumns(25);
mySearchComponent.setRows(1);
mySearchComponent.getAccessibleContext().setAccessibleName(FindBundle.message("find.search.accessible.name"));
myReplaceComponent = new JBTextArea();
myReplaceComponent.setColumns(25);
myReplaceComponent.setRows(1);
myReplaceComponent.getAccessibleContext().setAccessibleName(FindBundle.message("find.replace.accessible.name"));
mySearchTextArea = new SearchTextArea(mySearchComponent, true);
myReplaceTextArea = new SearchTextArea(myReplaceComponent, false);
mySearchTextArea.setMultilineEnabled(Registry.is("ide.find.as.popup.allow.multiline"));
myReplaceTextArea.setMultilineEnabled(Registry.is("ide.find.as.popup.allow.multiline"));
AnAction caseSensitiveAction = createAction("find.popup.case.sensitive", "CaseSensitive", AllIcons.Actions.MatchCase, AllIcons.Actions.MatchCaseHovered, AllIcons.Actions.MatchCaseSelected, myCaseSensitiveState, () -> !myHelper.getModel().isReplaceState() || !myPreserveCaseState.get());
AnAction wholeWordsAction = createAction("find.whole.words", "WholeWords", AllIcons.Actions.Words, AllIcons.Actions.WordsHovered, AllIcons.Actions.WordsSelected, myWholeWordsState, () -> !myRegexState.get());
AnAction regexAction = createAction("find.regex", "Regex", AllIcons.Actions.Regex, AllIcons.Actions.RegexHovered, AllIcons.Actions.RegexSelected, myRegexState, () -> !myHelper.getModel().isReplaceState() || !myPreserveCaseState.get());
List<Component> searchExtraButtons = mySearchTextArea.setExtraActions(caseSensitiveAction, wholeWordsAction, regexAction);
AnAction preserveCaseAction = createAction("find.options.replace.preserve.case", "PreserveCase", AllIcons.Actions.PreserveCase, AllIcons.Actions.PreserveCaseHover, AllIcons.Actions.PreserveCaseSelected, myPreserveCaseState, () -> !myRegexState.get() && !myCaseSensitiveState.get());
List<Component> replaceExtraButtons = myReplaceTextArea.setExtraActions(preserveCaseAction);
myExtraActions.addAll(Arrays.asList(caseSensitiveAction, wholeWordsAction, regexAction, preserveCaseAction));
Pair<FindPopupScopeUI.ScopeType, JComponent>[] scopeComponents = myScopeUI.getComponents();
myScopeDetailsPanel = new JPanel(new CardLayout());
myScopeDetailsPanel.setBorder(JBUI.Borders.emptyBottom(UIUtil.isUnderDefaultMacTheme() ? 0 : 3));
List<AnAction> scopeActions = new ArrayList<>(scopeComponents.length);
for (Pair<FindPopupScopeUI.ScopeType, JComponent> scopeComponent : scopeComponents) {
FindPopupScopeUI.ScopeType scopeType = scopeComponent.first;
scopeActions.add(new MySelectScopeToggleAction(scopeType));
myScopeDetailsPanel.add(scopeType.name, scopeComponent.second);
}
myScopeSelectionToolbar = createToolbar(scopeActions.toArray(AnAction.EMPTY_ARRAY));
myScopeSelectionToolbar.setMinimumButtonSize(ActionToolbar.DEFAULT_MINIMUM_BUTTON_SIZE);
mySelectedScope = scopeComponents[0].first;
myResultsPreviewTableModel = createTableModel();
myResultsPreviewTable = new JBTable(myResultsPreviewTableModel) {
@Override
public Dimension getPreferredScrollableViewportSize() {
return new Dimension(getWidth(), 1 + getRowHeight() * 4);
}
};
myResultsPreviewTable.setFocusable(false);
myResultsPreviewTable.getEmptyText().setShowAboveCenter(false);
myResultsPreviewTable.setShowColumns(false);
myResultsPreviewTable.getSelectionModel().setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION);
myResultsPreviewTable.setShowGrid(false);
myResultsPreviewTable.setIntercellSpacing(JBUI.emptySize());
new DoubleClickListener() {
@Override
protected boolean onDoubleClick(@Nonnull MouseEvent event) {
if (event.getSource() != myResultsPreviewTable)
return false;
navigateToSelectedUsage(null);
return true;
}
}.installOn(myResultsPreviewTable);
myResultsPreviewTable.addMouseListener(new MouseAdapter() {
@Override
public void mousePressed(MouseEvent e) {
myResultsPreviewTable.transferFocus();
}
});
applyFont(JBFont.label(), myResultsPreviewTable);
JComponent[] tableAware = { mySearchComponent, myReplaceComponent, myReplaceSelectedButton };
for (JComponent component : tableAware) {
ScrollingUtil.installActions(myResultsPreviewTable, false, component);
}
ActionListener helpAction = __ -> HelpManager.getInstance().invokeHelp("reference.dialogs.findinpath");
registerKeyboardAction(helpAction, KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
registerKeyboardAction(helpAction, KeyStroke.getKeyStroke(KeyEvent.VK_HELP, 0), JComponent.WHEN_IN_FOCUSED_WINDOW);
KeymapManager keymapManager = KeymapManager.getInstance();
Keymap activeKeymap = keymapManager != null ? keymapManager.getActiveKeymap() : null;
if (activeKeymap != null) {
ShortcutSet findNextShortcutSet = new CustomShortcutSet(activeKeymap.getShortcuts("FindNext"));
ShortcutSet findPreviousShortcutSet = new CustomShortcutSet(activeKeymap.getShortcuts("FindPrevious"));
DumbAwareAction findNextAction = DumbAwareAction.create(event -> {
int selectedRow = myResultsPreviewTable.getSelectedRow();
if (selectedRow >= 0 && selectedRow < myResultsPreviewTable.getRowCount() - 1) {
myResultsPreviewTable.setRowSelectionInterval(selectedRow + 1, selectedRow + 1);
ScrollingUtil.ensureIndexIsVisible(myResultsPreviewTable, selectedRow + 1, 1);
}
});
DumbAwareAction findPreviousAction = DumbAwareAction.create(event -> {
int selectedRow = myResultsPreviewTable.getSelectedRow();
if (selectedRow > 0 && selectedRow <= myResultsPreviewTable.getRowCount() - 1) {
myResultsPreviewTable.setRowSelectionInterval(selectedRow - 1, selectedRow - 1);
ScrollingUtil.ensureIndexIsVisible(myResultsPreviewTable, selectedRow - 1, 1);
}
});
for (JComponent component : tableAware) {
findNextAction.registerCustomShortcutSet(findNextShortcutSet, component);
findPreviousAction.registerCustomShortcutSet(findPreviousShortcutSet, component);
}
}
myUsagePreviewTitle = new SimpleColoredComponent();
myUsagePreviewTitle.setBorder(JBUI.Borders.empty(3, 8, 4, 8));
myUsageViewPresentation = new UsageViewPresentation();
myUsagePreviewPanel = new UsagePreviewPanel(myProject, myUsageViewPresentation, Registry.is("ide.find.as.popup.editable.code")) {
@Override
public Dimension getPreferredSize() {
return new Dimension(myResultsPreviewTable.getWidth(), Math.max(getHeight(), getLineHeight() * 15));
}
};
Disposer.register(myDisposable, myUsagePreviewPanel);
final Runnable updatePreviewRunnable = () -> {
if (Disposer.isDisposed(myDisposable))
return;
int[] selectedRows = myResultsPreviewTable.getSelectedRows();
final List<UsageInfo> selection = new SmartList<>();
String file = null;
for (int row : selectedRows) {
Object value = myResultsPreviewTable.getModel().getValueAt(row, 0);
UsageInfoAdapter adapter = (UsageInfoAdapter) value;
file = adapter.getPath();
if (adapter.isValid()) {
selection.addAll(Arrays.asList(adapter.getMergedInfos()));
}
}
myReplaceSelectedButton.setText(FindBundle.message("find.popup.replace.selected.button", selection.size()));
FindInProjectUtil.setupViewPresentation(myUsageViewPresentation, myHelper.getModel().clone());
myUsagePreviewPanel.updateLayout(selection);
myUsagePreviewTitle.clear();
if (myUsagePreviewPanel.getCannotPreviewMessage(selection) == null && file != null) {
myUsagePreviewTitle.append(PathUtil.getFileName(file), SimpleTextAttributes.REGULAR_ATTRIBUTES);
VirtualFile virtualFile = VfsUtil.findFileByIoFile(new File(file), true);
String locationPath = virtualFile == null ? null : getPresentablePath(myProject, virtualFile.getParent(), 120);
if (locationPath != null) {
myUsagePreviewTitle.append(spaceAndThinSpace() + locationPath, new SimpleTextAttributes(STYLE_PLAIN, UIUtil.getContextHelpForeground()));
}
}
};
myResultsPreviewTable.getSelectionModel().addListSelectionListener(e -> {
if (e.getValueIsAdjusting() || Disposer.isDisposed(myPreviewUpdater))
return;
// todo[vasya]: remove this dirty hack of updating preview panel after clicking on Replace button
myPreviewUpdater.addRequest(updatePreviewRunnable, 50);
});
DocumentAdapter documentAdapter = new DocumentAdapter() {
@Override
protected void textChanged(@Nonnull DocumentEvent e) {
if (myDialog == null)
return;
if (e.getDocument() == mySearchComponent.getDocument()) {
scheduleResultsUpdate();
}
if (e.getDocument() == myReplaceComponent.getDocument()) {
applyTo(myHelper.getModel());
if (myHelper.getModel().isRegularExpressions()) {
myComponentValidator.updateInfo(getValidationInfo(myHelper.getModel()));
}
ApplicationManager.getApplication().invokeLater(updatePreviewRunnable);
}
}
};
mySearchComponent.getDocument().addDocumentListener(documentAdapter);
myReplaceComponent.getDocument().addDocumentListener(documentAdapter);
mySearchRescheduleOnCancellationsAlarm = new Alarm();
JBSplitter splitter = new OnePixelSplitter(true, .33f);
splitter.setSplitterProportionKey(SPLITTER_SERVICE_KEY);
splitter.getDivider().setBackground(OnePixelDivider.BACKGROUND);
JBScrollPane scrollPane = new JBScrollPane(myResultsPreviewTable) {
@Override
public Dimension getMinimumSize() {
Dimension size = super.getMinimumSize();
size.height = myResultsPreviewTable.getPreferredScrollableViewportSize().height;
return size;
}
};
scrollPane.setBorder(JBUI.Borders.empty());
splitter.setFirstComponent(scrollPane);
JPanel bottomPanel = new JPanel(new MigLayout("flowx, ins 4 4 4 4, fillx, hidemode 3, gap 0"));
bottomPanel.add(tabOptionsButton);
myOKHintLabel = new JBLabel("");
myOKHintLabel.setEnabled(false);
myNavigationHintLabel = new JBLabel("");
myNavigationHintLabel.setEnabled(false);
myNavigationHintLabel.setFont(JBUI.Fonts.smallFont());
Insets insets = myOKButton.getInsets();
String btnGapLeft = "gapleft " + Math.max(0, JBUIScale.scale(12) - insets.left - insets.right);
bottomPanel.add(myNavigationHintLabel, btnGapLeft);
bottomPanel.add(Box.createHorizontalGlue(), "growx, pushx");
bottomPanel.add(myOKHintLabel);
bottomPanel.add(myOKButton, btnGapLeft);
bottomPanel.add(myReplaceAllButton, btnGapLeft);
bottomPanel.add(myReplaceSelectedButton, btnGapLeft);
myCodePreviewComponent = myUsagePreviewPanel.createComponent();
JPanel previewPanel = new JPanel(new BorderLayout());
previewPanel.add(myUsagePreviewTitle, BorderLayout.NORTH);
previewPanel.add(myCodePreviewComponent, BorderLayout.CENTER);
splitter.setSecondComponent(previewPanel);
JPanel scopesPanel = new JPanel(new MigLayout("flowx, gap 26, ins 0"));
scopesPanel.add(myScopeSelectionToolbar.getComponent());
scopesPanel.add(myScopeDetailsPanel, "growx, pushx");
setLayout(new MigLayout("flowx, ins 4, gap 0, fillx, hidemode 3"));
myTitlePanel = new JPanel(new MigLayout("flowx, ins 0, gap 0, fillx, filly"));
myTitlePanel.add(myTitleLabel, "gapright 4");
myTitlePanel.add(myInfoLabel);
myTitlePanel.add(myLoadingDecorator.getComponent(), "w 24, wmin 24");
myTitlePanel.add(Box.createHorizontalGlue(), "growx, pushx");
add(myTitlePanel, "sx 2, growx, growx, growy");
add(myCbFileFilter);
add(myFileMaskField, "gapleft 4, gapright 16");
if (Registry.is("ide.find.as.popup.allow.pin") || ApplicationManager.getApplication().isInternal()) {
myIsPinned.set(UISettings.getInstance().getPinFindInPath());
JPanel twoButtons = new JPanel(new MigLayout("flowx, ins 0, gap 4, fillx, hidemode 3"));
twoButtons.add(myFilterContextButton);
JComponent separatorComponent = (JComponent) Box.createRigidArea(new JBDimension(1, 24));
separatorComponent.setOpaque(true);
separatorComponent.setBackground(JBUI.CurrentTheme.CustomFrameDecorations.separatorForeground());
twoButtons.add(separatorComponent);
twoButtons.add(pinButton);
add(twoButtons, "wrap");
} else {
add(myFilterContextButton, "wrap");
}
mySearchTextArea.setBorder(new CompoundBorder(JBUI.Borders.customLine(JBUI.CurrentTheme.BigPopup.searchFieldBorderColor(), 1, 0, 1, 0), JBUI.Borders.empty(1, 0, 2, 0)));
add(mySearchTextArea, "pushx, growx, sx 10, pad 0 -4 0 4, gaptop 4, wrap");
myReplaceTextArea.setBorder(new CompoundBorder(JBUI.Borders.customLine(JBUI.CurrentTheme.BigPopup.searchFieldBorderColor(), 0, 0, 1, 0), JBUI.Borders.empty(1, 0, 2, 0)));
add(myReplaceTextArea, "pushx, growx, sx 10, pad 0 -4 0 4, wrap");
add(scopesPanel, "sx 10, pushx, growx, ax left, wrap, gaptop 4, gapbottom 4");
add(splitter, "pushx, growx, growy, pushy, sx 10, wrap, pad -4 -4 4 4");
add(bottomPanel, "pushx, growx, dock south, sx 10");
MnemonicHelper.init(this);
List<Component> focusOrder = new ArrayList<>();
focusOrder.add(mySearchComponent);
focusOrder.add(myReplaceComponent);
focusOrder.addAll(searchExtraButtons);
focusOrder.addAll(replaceExtraButtons);
focusOrder.add(myCbFileFilter);
ContainerUtil.addAll(focusOrder, focusableComponents(myScopeDetailsPanel));
focusOrder.add(editorComponent);
ContainerUtil.addAll(focusOrder, focusableComponents(bottomPanel));
setFocusCycleRoot(true);
setFocusTraversalPolicy(new ListFocusTraversalPolicy(focusOrder));
}
use of com.intellij.ui.components.JBTextArea in project sonarlint-intellij by SonarSource.
the class RuleConfigurationPanel method createTextParam.
private void createTextParam(RulesTreeNode.Rule rule, JPanel panel, GridBagConstraints constraints, RulesTreeNode.RuleParam param) {
addParamLabel(panel, constraints, param);
addTextField(rule, panel, constraints, param, new JBTextArea());
}
use of com.intellij.ui.components.JBTextArea in project midpoint-studio by Evolveum.
the class AbstractOpTreePanel method initLayout.
private void initLayout() {
JBSplitter splitter = new OnePixelSplitter(false);
add(splitter, BorderLayout.CENTER);
List<TreeTableColumnDefinition<String, ?>> columns = new ArrayList<>();
columns.add(new TreeTableColumnDefinition<>("Item", 150, o -> null));
columns.add(new TreeTableColumnDefinition<>("Variable", 400, o -> null, new ExpansionSensitiveTableCellRenderer()));
this.variables = MidPointUtils.createTable2(new DefaultTreeTableModel(new DefaultMutableTreeTableNode(), Arrays.asList("Item", "Variable")), MidPointUtils.createTableColumnModel(columns), false);
this.variables.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
this.variables.addTreeSelectionListener(this::variablesSelectionChanged);
this.variables.addHighlighter(new AbstractHighlighter() {
@Override
protected Component doHighlight(Component component, ComponentAdapter adapter) {
int row = adapter.convertRowIndexToModel(adapter.row);
TreePath pathForRow = variables.getPathForRow(row);
Node node = (Node) pathForRow.getLastPathComponent();
if (adapter.isSelected()) {
component.setBackground(variables.getSelectionBackground());
} else if (node.getBackgroundColor() == null) {
component.setBackground(variables.getBackground());
} else {
component.setBackground(node.getBackgroundColor());
}
return component;
}
});
TableColumn column = this.variables.getColumnModel().getColumn(1);
column.setCellRenderer(new ExpansionSensitiveTableCellRenderer());
JComponent mainToolbar = initMainToolbar();
splitter.setFirstComponent(MidPointUtils.createBorderLayoutPanel(mainToolbar, new JBScrollPane(this.variables), null));
JPanel left = new BorderLayoutPanel();
splitter.setSecondComponent(left);
DefaultActionGroup group = new DefaultActionGroup();
variablesDisplayAs = new FormatComboboxAction() {
@Override
public void setFormat(Format format) {
super.setFormat(format);
variableDisplayAsChanged(format);
}
};
group.add(variablesDisplayAs);
variablesWrapText = new SimpleCheckboxAction("Wrap text") {
@Override
public void onStateChange() {
variablesValue.setLineWrap(isSelected());
variablesValue.invalidate();
}
};
group.add(variablesWrapText);
ActionToolbar toolbar = ActionManager.getInstance().createActionToolbar("TraceViewVariablesToolbar", group, true);
toolbar.setTargetComponent(this);
left.add(toolbar.getComponent(), BorderLayout.NORTH);
variablesValue = new JBTextArea();
left.add(MidPointUtils.borderlessScrollPane(variablesValue), BorderLayout.CENTER);
}
Aggregations