void (final DataContext dataContext) { final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, true, false) { @Override public boolean isFileVisible(VirtualFile file, boolean showHiddenFiles) { return super.isFileVisible(file, showHiddenFiles) && (file.isDirectory() || "xml".equals(file.getExtension()) || FileTypeRegistry.getInstance().isFileOfType(file, ArchiveFileType.INSTANCE)); } @Override public boolean isFileSelectable(@Nullable VirtualFile file) { return file != null && FileTypeRegistry.getInstance().isFileOfType(file, StdFileTypes.XML); } }; descriptor.setDescription(IntelliLangBundle.message("dialog.file.chooser.description.please.select.the.configuration.file")); descriptor.setTitle(IntelliLangBundle.message("dialog.file.chooser.title.import.configuration")); descriptor.putUserData(LangDataKeys.MODULE_CONTEXT, PlatformCoreDataKeys.MODULE.getData(dataContext)); final SplitterProportionsData splitterData = new SplitterProportionsDataImpl(); splitterData.externalizeFromDimensionService("IntelliLang.ImportSettingsKey.SplitterProportions"); final VirtualFile file = FileChooser.chooseFile(descriptor, myProject, null); if (file == null) return; try { final Configuration cfg = Configuration.load(file.getInputStream()); if (cfg == null) { Messages.showWarningDialog(myProject, IntelliLangBundle.message("dialog.message.the.selected.file"), IntelliLangBundle.message("dialog.title.nothing.to.import")); return; } final CfgInfo info = getDefaultCfgInfo(); final Map<String,Set<InjInfo>> currentMap = ContainerUtil.classify(info.injectionInfos.iterator(), o -> o.injection.getSupportId()); final List<BaseInjection> originalInjections = new ArrayList<>(); final List<BaseInjection> newInjections = new ArrayList<>(); //// remove duplicates //for (String supportId : InjectorUtils.getActiveInjectionSupportIds()) { // final Set<BaseInjection> currentInjections = currentMap.get(supportId); // if (currentInjections == null) continue; // for (BaseInjection injection : currentInjections) { // Configuration.importInjections(newInjections, Collections.singleton(injection), originalInjections, newInjections); // } //} //myInjections.clear(); //myInjections.addAll(newInjections); for (String supportId : InjectorUtils.getActiveInjectionSupportIds()) { ArrayList<InjInfo> list = new ArrayList<>(ObjectUtils.notNull(currentMap.get(supportId), Collections.emptyList())); final List<BaseInjection> currentInjections = getInjectionList(list); final List<BaseInjection> importingInjections = cfg.getInjections(supportId); Configuration.importInjections(currentInjections, importingInjections, originalInjections, newInjections); } info.replace(originalInjections, newInjections); myInjectionsTable.getListTableModel().setItems(getInjInfoList(myInfos)); final int n = newInjections.size(); if (n > 1) { Messages.showInfoMessage(myProject, IntelliLangBundle.message("dialog.message.0.entries.have.been.successfully.imported", n), IntelliLangBundle.message("dialog.title.import.successful")); } else if (n == 1) { Messages.showInfoMessage(myProject, IntelliLangBundle.message("dialog.message.one.entry.has.been.successfully.imported"), IntelliLangBundle.message("dialog.title.import.successful")); } else { Messages.showInfoMessage(myProject, IntelliLangBundle.message("dialog.message.no.new.entries.have.been.imported"), IntelliLangBundle.message("dialog.title.import")); } } catch (Exception ex) { Configuration.LOG.error(ex); final String msg = ex.getLocalizedMessage(); Messages.showErrorDialog(myProject, msg != null && msg.length() > 0 ? msg : ex.toString(), IntelliLangBundle.message("dialog.title.import.failed")); } }