void () { // Enable keyboard pressing myTfBundleName.registerKeyboardAction( new AbstractAction() { @Override public void actionPerformed(final ActionEvent e) { myTfBundleName.getButton().doClick(); } }, KeyStroke.getKeyStroke(myLblBundleName.getDisplayedMnemonic(), InputEvent.ALT_DOWN_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW ); myTfBundleName.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { Project project = myEditor.getProject(); final String bundleNameText = myTfBundleName.getText().replace('/', '.'); PropertiesFile file = PropertiesUtilBase.getPropertiesFile(bundleNameText, myEditor.getModule(), myLocale); PsiFile initialPropertiesFile = file == null ? null : file.getContainingFile(); final GlobalSearchScope moduleScope = GlobalSearchScope.moduleWithDependenciesScope(myEditor.getModule()); TreeFileChooser fileChooser = TreeClassChooserFactory.getInstance(project).createFileChooser(UIDesignerBundle.message("title.choose.properties.file"), initialPropertiesFile, PropertiesFileType.INSTANCE, new TreeFileChooser.PsiFileFilter() { @Override public boolean accept(PsiFile file) { final VirtualFile virtualFile = file.getVirtualFile(); return virtualFile != null && moduleScope.contains(virtualFile); } }); fileChooser.showDialog(); PsiFile selectedFile = fileChooser.getSelectedFile(); PropertiesFile propertiesFile = selectedFile instanceof PropertiesFile ? (PropertiesFile)selectedFile : null; if (propertiesFile == null) { return; } final String bundleName = FormReferenceProvider.getBundleName(propertiesFile); if (bundleName == null) { return; } myTfBundleName.setText(bundleName); } } ); // Enable keyboard pressing myTfKey.registerKeyboardAction( new AbstractAction() { @Override public void actionPerformed(final ActionEvent e) { myTfKey.getButton().doClick(); } }, KeyStroke.getKeyStroke(myLblKey.getDisplayedMnemonic(), InputEvent.ALT_DOWN_MASK), JComponent.WHEN_IN_FOCUSED_WINDOW ); myTfKey.addActionListener( new ActionListener() { @Override public void actionPerformed(final ActionEvent e) { // 1. Check that bundle exist. Otherwise we cannot show key chooser final String bundleName = myTfBundleName.getText(); if (bundleName.length() == 0) { Messages.showErrorDialog( UIDesignerBundle.message("error.specify.bundle.name"), CommonBundle.getErrorTitle() ); return; } final PropertiesReferenceManager manager = PropertiesReferenceManager.getInstance(myEditor.getProject()); final PropertiesFile bundle = manager.findPropertiesFile(myEditor.getModule(), bundleName.replace('/', '.'), myLocale); if (bundle == null) { Messages.showErrorDialog( UIDesignerBundle.message("error.bundle.does.not.exist", bundleName), CommonBundle.getErrorTitle() ); return; } // 2. Show key chooser final KeyChooserDialog dialog = new KeyChooserDialog( myTfKey, bundle, bundleName, myTfKey.getText(), // key to preselect myEditor ); if (!dialog.showAndGet()) { return; } // 3. Apply new key/value final StringDescriptor descriptor = dialog.getDescriptor(); if (descriptor == null) { return; } myTfKey.setText(descriptor.getKey()); myTfRbValue.setText(descriptor.getResolvedValue()); } } ); }