JPanel () { listModel = new DefaultListModel<>(); updateTagsPreviewModel(); JBList<String> tagsList = new JBList<>(listModel); tagsList.setEmptyText(ImagesBundle.message("list.empty.text.no.tags.defined")); ImageTagManager imageTagManager = ImageTagManager.getInstance(thumbnailView.getProject()); return ToolbarDecorator.createDecorator(tagsList) .setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { JBPopupFactory.getInstance().createActionGroupPopup(IdeBundle.message("popup.title.add.tags"), new AddTagGroup(), button.getDataContext(), JBPopupFactory.ActionSelectionAid.SPEEDSEARCH, false) .show(button.getPreferredPopupPoint()); } }) .setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { String selectedValue = tagsList.getSelectedValue(); if (selectedValue != null) { Arrays.stream(getSelection()) .forEach(virtualFile -> imageTagManager.removeTag(selectedValue, virtualFile)); } updateTagsPreviewModel(); } }) .disableUpDownActions() .setToolbarPosition(ActionToolbarPosition.RIGHT) .createPanel(); }