ArrayList<AnAction> (boolean fromPopup) { ArrayList<AnAction> result = new ArrayList<>(); result.add(new DumbAwareAction(CopyrightBundle.messagePointer("action.DumbAware.CopyrightProfilesPanel.text.add"), CopyrightBundle.messagePointer("action.DumbAware.CopyrightProfilesPanel.description.add"), IconUtil.getAddIcon()) { { registerCustomShortcutSet(CommonActionsPanel.getCommonShortcut(CommonActionsPanel.Buttons.ADD), myTree); } @Override public void actionPerformed(@NotNull AnActionEvent event) { doAddProfile(); } }); result.add(new MyDeleteAction()); result.add(new DumbAwareAction( CopyrightBundle.messagePointer("action.DumbAware.CopyrightProfilesPanel.text.copy"), CopyrightBundle.messagePointer("action.DumbAware.CopyrightProfilesPanel.description.copy"), PlatformIcons.COPY_ICON) { { registerCustomShortcutSet(CommonShortcuts.getDuplicate(), myTree); } @Override public void actionPerformed(@NotNull AnActionEvent event) { String profileName = askForProfileName(CopyrightBundle.message("copy.copyright.profile"), ""); if (profileName == null) { return; } CopyrightProfile clone = new CopyrightProfile(); clone.copyFrom((CopyrightProfile)Objects.requireNonNull(getSelectedObject())); clone.setName(profileName); addProfileNode(clone); } @Override public void update(@NotNull AnActionEvent event) { event.getPresentation().setEnabled(getSelectedObject() != null); } @Override public @NotNull ActionUpdateThread getActionUpdateThread() { return ActionUpdateThread.EDT; } }); result.add(new DumbAwareAction(CopyrightBundle.messagePointer("action.DumbAware.CopyrightProfilesPanel.text.import"), CopyrightBundle.messagePointer("action.DumbAware.CopyrightProfilesPanel.description.import"), PlatformIcons.IMPORT_ICON) { @Override public void actionPerformed(@NotNull AnActionEvent event) { FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor() .withFileFilter(file -> { final FileType fileType = file.getFileType(); return fileType == ModuleFileType.INSTANCE || fileType == XmlFileType.INSTANCE; }) .withTitle(CopyrightBundle.message("dialog.file.chooser.title.choose.file.containing.copyright.notice")); FileChooser.chooseFile(descriptor, myProject, null, file -> { final List<CopyrightProfile> profiles = ExternalOptionHelper.loadOptions(VfsUtilCore.virtualToIoFile(file)); if (profiles == null) return; if (!profiles.isEmpty()) { if (profiles.size() == 1) { importProfile(profiles.get(0)); } else { JBPopupFactory.getInstance() .createListPopup(new BaseListPopupStep<>(CopyrightBundle.message("popup.title.choose.profile.to.import"), profiles) { @Override public PopupStep<?> onChosen(final CopyrightProfile selectedValue, boolean finalChoice) { return doFinalStep(() -> importProfile(selectedValue)); } @NotNull @Override public String getTextFor(CopyrightProfile value) { return value.getName(); } }) .showUnderneathOf(myNorthPanel); } } else { Messages.showWarningDialog(myProject, CopyrightBundle.message("dialog.message.the.selected.file.copyright.settings"), CopyrightBundle.message("dialog.title.import.failure")); } }); } private void importProfile(CopyrightProfile copyrightProfile) { final String profileName = askForProfileName(CopyrightBundle.message("import.copyright.profile"), copyrightProfile.getName()); if (profileName == null) return; copyrightProfile.setName(profileName); addProfileNode(copyrightProfile); Messages.showInfoMessage(myProject, CopyrightBundle.message("dialog.message.the.copyright.settings.imported"), CopyrightBundle.message("dialog.title.import.complete")); } }); return result; }