void () { final JBList<Locale> projectExistLocalesList = new JBList<>(); final MyExistLocalesListModel existLocalesListModel = new MyExistLocalesListModel(); projectExistLocalesList.setModel(existLocalesListModel); projectExistLocalesList.setCellRenderer(getLocaleRenderer()); myProjectExistLocalesPanel = ToolbarDecorator.createDecorator(projectExistLocalesList) .disableRemoveAction() .disableUpDownActions() .createPanel(); myProjectExistLocalesPanel.setBorder(IdeBorderFactory.createTitledBorder( PropertiesBundle.message("create.resource.bundle.project.locales.title"), false)); final JBList localesToAddList = new JBList(); final List<Locale> locales; final List<Locale> restrictedLocales; if (myResourceBundle == null) { locales = Collections.singletonList(PropertiesUtil.DEFAULT_LOCALE); restrictedLocales = Collections.emptyList(); } else { locales = Collections.emptyList(); restrictedLocales = ContainerUtil.map(myResourceBundle.getPropertiesFiles(), PropertiesFile::getLocale); } myLocalesModel = new CollectionListModel<>(locales) { @Override public void add(@NotNull List<? extends Locale> elements) { final List<Locale> currentItems = getItems(); elements = ContainerUtil.filter(elements, locale -> !restrictedLocales.contains(locale) && !currentItems.contains(locale)); super.add(elements); } }; localesToAddList.setModel(myLocalesModel); localesToAddList.setCellRenderer(getLocaleRenderer()); localesToAddList.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { projectExistLocalesList.clearSelection(); } }); projectExistLocalesList.addFocusListener(new FocusAdapter() { @Override public void focusGained(FocusEvent e) { localesToAddList.clearSelection(); } }); myNewBundleLocalesPanel = ToolbarDecorator.createDecorator(localesToAddList).setAddAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { final String rawAddedLocales = Messages.showInputDialog(myProject, PropertiesBundle.message("create.resource.bundle.dialog.add.locales.validator.message"), PropertiesBundle.message("create.resource.bundle.dialog.add.locales.validator.title"), null, null, new InputValidatorEx() { @Nullable @Override public String getErrorText(String inputString) { return checkInput(inputString) ? null : PropertiesBundle.message("create.resource.bundle.invalid.locales.error.text"); } @Override public boolean checkInput(String inputString) { return extractLocalesFromString(inputString) != null; } @Override public boolean canClose(String inputString) { return checkInput(inputString); } }); if (rawAddedLocales != null) { final Map<Locale, String> locales = extractLocalesFromString(rawAddedLocales); LOG.assertTrue(locales != null); myLocaleSuffixes.putAll(locales); myLocalesModel.add(new ArrayList<>(locales.keySet())); } } }).setAddActionName(PropertiesBundle.message("create.resource.bundle.add.locales.by.suffix.action.text")) .disableUpDownActions().createPanel(); myNewBundleLocalesPanel.setBorder(IdeBorderFactory.createTitledBorder( PropertiesBundle.message("create.resource.bundle.locales.to.add.chooser.title"), false)); myAddLocaleFromExistButton = new JButton(AllIcons.Actions.Forward); new ClickListener(){ @Override public boolean onClick(@NotNull MouseEvent event, int clickCount) { if (clickCount == 1) { myLocalesModel.add(projectExistLocalesList.getSelectedValuesList()); return true; } return false; } }.installOn(myAddLocaleFromExistButton); projectExistLocalesList.addListSelectionListener(new ListSelectionListener() { @Override public void valueChanged(ListSelectionEvent e) { final List<Locale> currentItems = myLocalesModel.getItems(); for (Locale l : projectExistLocalesList.getSelectedValuesList()) { if (!restrictedLocales.contains(l) && !currentItems.contains(l)) { myAddLocaleFromExistButton.setEnabled(true); return; } } myAddLocaleFromExistButton.setEnabled(false); } }); myAddLocaleFromExistButton.setEnabled(false); myAddAllButton = new JButton(PropertiesBundle.message("create.resource.bundle.add.all.btn.text")); new ClickListener() { @Override public boolean onClick(@NotNull MouseEvent event, int clickCount) { if (clickCount == 1) { myLocalesModel.add(existLocalesListModel.getLocales()); } return false; } }.installOn(myAddAllButton); }