public CreateXmlResourceDialog( @NotNull Module module, @NotNull ResourceType resourceType, @Nullable String predefinedName, @Nullable String predefinedValue, boolean chooseName, @Nullable VirtualFile defaultFile) { super(module.getProject()); myResourceType = resourceType; if (predefinedName != null && predefinedName.length() > 0) { if (!chooseName) { myNameLabel.setVisible(false); myNameField.setVisible(false); } myNameField.setText(predefinedName); } if (predefinedValue != null && predefinedValue.length() > 0) { myValueLabel.setVisible(false); myValueField.setVisible(false); myValueField.setText(predefinedValue); } final Set<Module> modulesSet = new HashSet<Module>(); modulesSet.add(module); for (AndroidFacet depFacet : AndroidUtils.getAllAndroidDependencies(module, true)) { modulesSet.add(depFacet.getModule()); } assert modulesSet.size() > 0; if (modulesSet.size() == 1) { myModule = module; myModuleLabel.setVisible(false); myModuleCombo.setVisible(false); } else { myModule = null; final Module[] modules = modulesSet.toArray(new Module[modulesSet.size()]); Arrays.sort( modules, new Comparator<Module>() { @Override public int compare(Module m1, Module m2) { return m1.getName().compareTo(m2.getName()); } }); myModuleCombo.setModel(new DefaultComboBoxModel(modules)); myModuleCombo.setSelectedItem(module); myModuleCombo.setRenderer(new ModuleListCellRendererWrapper(myModuleCombo.getRenderer())); } if (defaultFile == null) { final String defaultFileName = AndroidResourceUtil.getDefaultResourceFileName(resourceType); if (defaultFileName != null) { myFileNameCombo.getEditor().setItem(defaultFileName); } } myDirectoriesList = new CheckBoxList(); myDirectoriesLabel.setLabelFor(myDirectoriesList); final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myDirectoriesList); decorator.setEditAction(null); decorator.disableUpDownActions(); decorator.setAddAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { doAddNewDirectory(); } }); decorator.setRemoveAction( new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { doDeleteDirectory(); } }); final AnActionButton selectAll = new AnActionButton("Select All", null, PlatformIcons.SELECT_ALL_ICON) { @Override public void actionPerformed(AnActionEvent e) { doSelectAllDirs(); } }; decorator.addExtraAction(selectAll); final AnActionButton unselectAll = new AnActionButton("Unselect All", null, PlatformIcons.UNSELECT_ALL_ICON) { @Override public void actionPerformed(AnActionEvent e) { doUnselectAllDirs(); } }; decorator.addExtraAction(unselectAll); myDirectoriesPanel.add(decorator.createPanel()); updateDirectories(true); myModuleCombo.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { updateDirectories(true); } }); final JCheckBox valuesCheckBox = myCheckBoxes.get(SdkConstants.FD_RES_VALUES); if (valuesCheckBox != null) { valuesCheckBox.setSelected(true); } if (defaultFile != null) { resetFromFile(defaultFile, module.getProject()); } init(); }