@NotNull public static List<GotoRelatedItem> collectRelatedItems( @NotNull PsiElement contextElement, @Nullable DataContext dataContext) { Set<GotoRelatedItem> items = ContainerUtil.newLinkedHashSet(); for (GotoRelatedProvider provider : Extensions.getExtensions(GotoRelatedProvider.EP_NAME)) { items.addAll(provider.getItems(contextElement)); if (dataContext != null) { items.addAll(provider.getItems(dataContext)); } } GotoRelatedItem[] result = items.toArray(new GotoRelatedItem[items.size()]); Arrays.sort( result, (i1, i2) -> { String o1 = i1.getGroup(); String o2 = i2.getGroup(); return StringUtil.isEmpty(o1) ? 1 : StringUtil.isEmpty(o2) ? -1 : o1.compareTo(o2); }); return Arrays.asList(result); }
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(); }