JComponent () { final JPanel panel = new JPanel(new GridBagLayout()); panel.setBackground(UIUtil.getToolTipActionBackground()); panel.setBorder(IdeBorderFactory.createTitledBorder(AntBundle.message("configurable.hector.border.title.file.context"), false)); myCombo = new ComboBox<>(); myCombo.putClientProperty(CONTEXTS_COMBO_KEY, Boolean.TRUE); GridBagConstraints constraints = new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.NONE, JBInsets.create(5, 0), 0, 0); panel.add(new JLabel(AntBundle.message("configurable.hector.included.into")), constraints); panel.add( myCombo, new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, JBUI.insets(5, 5, 5, 0), 0, 0)); final PsiManager psiManager = PsiManager.getInstance(myProject); final FileBasedIndex fbi = FileBasedIndex.getInstance(); final Collection<VirtualFile> antFiles = fbi.getContainingFiles(AntImportsIndex.INDEX_NAME, AntImportsIndex.ANT_FILES_WITH_IMPORTS_KEY, myFileFilter); for (VirtualFile file : antFiles) { final PsiFile psiFile = psiManager.findFile(file); if (!(psiFile instanceof XmlFile xmlFile)) { continue; } if (!xmlFile.equals(myFile) && AntDomFileDescription.isAntFile(xmlFile)) { final String path = PathUtil.getLocalPath(file); final XmlFile previous = myPathToFileMap.put(path, xmlFile); assert previous == null; } } final List<String> paths = new ArrayList<>(myPathToFileMap.keySet()); paths.sort(Comparator.naturalOrder()); myCombo.addItem(myNoneText); for (@NlsSafe String path : paths) { myCombo.addItem(path); } final AntConfigurationBase antConfig = AntConfigurationBase.getInstance(myProject); final XmlFile currentContext = antConfig.getContextFile(myFile); if (currentContext != null) { final VirtualFile vFile = currentContext.getVirtualFile(); assert vFile != null; final String path = PathUtil.getLocalPath(vFile); if (!FileUtil.pathsEqual(path, myLocalPath)) { myOriginalContext = path; } } myCombo.setSelectedItem(myOriginalContext); return panel; }