void (@NotNull AnActionEvent e) { Project project = e.getData(CommonDataKeys.PROJECT); if (project == null) return; GroupItem groupItem = e.getData(GroupItem.DATA_KEY); PsiFile psiFile = e.getData(CommonDataKeys.PSI_FILE); PsiElement elementToAdd = (psiFile != null) ? findElementToAdd(psiFile) : null; String className = ""; if (elementToAdd instanceof PsiClass) { className = ((PsiClass)elementToAdd).getQualifiedName(); assert className != null; } else if (elementToAdd instanceof PsiFile) { try { className = Utils.getBoundClassName(elementToAdd.getText()); } catch (Exception e1) { className = ""; } } // Show dialog final ComponentItem itemToBeAdded = new ComponentItem( project, className, null, null, new GridConstraints(), new HashMap<>(), true/*all user defined components are removable*/, false, false ); Window parentWindow = WindowManager.getInstance().suggestParentWindow(project); final ComponentItemDialog dialog = new ComponentItemDialog(project, parentWindow, itemToBeAdded, false); dialog.setTitle(UIDesignerBundle.message("title.add.component")); dialog.showGroupChooser(groupItem); if (!dialog.showAndGet()) { return; } groupItem = dialog.getSelectedGroup(); // If the itemToBeAdded is already in palette do nothing if (groupItem.containsItemClass(itemToBeAdded.getClassName())) { return; } assignDefaultIcon(project, itemToBeAdded); // add to the group final Palette palette = Palette.getInstance(project); palette.addItem(groupItem, itemToBeAdded); palette.fireGroupsChanged(); }