JComponent () { Splitter splitter = new JBSplitter(true); myUsagePreviewPanel = new UsagePreviewPanel(myProject, new UsageViewPresentation()); myTable = new JBTable(new MyKeyValueModel()); DefaultTableCellRenderer renderer = new DefaultTableCellRenderer(); renderer.putClientProperty("html.disable", Boolean.TRUE); myTable.setDefaultRenderer(String.class, renderer); myTable.getSelectionModel().addListSelectionListener(e -> { updateUsagePreview(myTable); }); AnActionButtonRunnable removeAction = new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { TableUtil.removeSelectedItems(myTable); myTable.repaint(); updateUsagePreview(myTable); } }; ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myTable).setRemoveAction(removeAction); if (myMarkAsNonNlsButtonIcon != null) { AnActionButton markAsNonNls = new AnActionButton(JavaI18nBundle.message("action.text.mark.as.nonnls"), myMarkAsNonNlsButtonIcon) { @Override public void actionPerformed(@NotNull AnActionEvent e) { TableUtil.stopEditing(myTable); List<Pair<Integer, I18nizedPropertyData<D>>> selection = getSelectedDataWithIndices(); boolean mark = shouldMarkAsNonNls(selection); for (Pair<Integer, I18nizedPropertyData<D>> dataWithIndex : selection) { myKeyValuePairs.set(dataWithIndex.first, dataWithIndex.second.setMarkAsNonNls(mark)); } myTable.repaint(); } @Override public void updateButton(@NotNull AnActionEvent e) { List<Pair<Integer, I18nizedPropertyData<D>>> selection = getSelectedDataWithIndices(); e.getPresentation().setEnabled(!selection.isEmpty()); e.getPresentation().setText(shouldMarkAsNonNls(selection) ? JavaI18nBundle.message("action.text.mark.as.nonnls") : JavaI18nBundle.message("action.text.unmark.as.nonnls")); } @Override public @NotNull ActionUpdateThread getActionUpdateThread() { // getSelectedDataWithIndices() is used which queries swing return ActionUpdateThread.EDT; } private boolean shouldMarkAsNonNls(List<Pair<Integer, I18nizedPropertyData<D>>> selection) { return !ContainerUtil.and(selection, data -> data.second.markAsNonNls()); } }; markAsNonNls.setShortcut(new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_N, InputEvent.ALT_DOWN_MASK))); decorator.addExtraAction(markAsNonNls); } splitter.setFirstComponent(decorator.createPanel()); splitter.setSecondComponent(myUsagePreviewPanel); return splitter; }