List of usage examples for com.intellij.openapi.ui Messages showYesNoDialog
@YesNoResult public static int showYesNoDialog(String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon)
From source file:com.google.gct.idea.debugger.ProjectRepositoryValidator.java
License:Apache License
public void restoreToOriginalState(final @NotNull Project project) { if (myRepoState.hasSourceRepository()) { assert myRepoState.getSourceRepository() != null; final VirtualFile root = myRepoState.getSourceRepository().getRoot(); //check for an unstash requirement. final Ref<StashInfo> targetStash = new Ref<StashInfo>(); if (!Strings.isNullOrEmpty(myRepoState.getStashMessage())) { GitStashUtils.loadStashStack(project, root, new Consumer<StashInfo>() { @Override/* w w w. j a va 2s . c o m*/ public void consume(StashInfo stashInfo) { if (!Strings.isNullOrEmpty(stashInfo.getMessage()) && stashInfo.getMessage().equals(myRepoState.getStashMessage())) { targetStash.set(stashInfo); } } }); } // If an unstash is required, we will always have an original branch name as well. if (!Strings.isNullOrEmpty(myRepoState.getOriginalBranchName())) { assert myRepoState.getOriginalBranchName() != null; String branchDisplayName = myRepoState.getOriginalBranchName(); if (branchDisplayName.length() > 10) { branchDisplayName = branchDisplayName.substring(0, 7) + "..."; } if (Messages.showYesNoDialog(GctBundle.getString("clouddebug.restorestash", branchDisplayName), GctBundle.getString("clouddebug.restorechanges.title"), Messages.getInformationIcon()) == Messages.YES) { final GitBrancher brancher = ServiceManager.getService(project, GitBrancher.class); brancher.checkout(myRepoState.getOriginalBranchName(), Collections.singletonList(myRepoState.getSourceRepository()), new Runnable() { @Override public void run() { myRepoState.getSourceRepository().update(); if (!targetStash.isNull()) { unstash(project, targetStash, root); } } }); } } } }
From source file:com.google.idea.blaze.android.sync.importer.problems.AddGeneratedResourceDirectoryNavigatable.java
License:Open Source License
@Override public void navigate(boolean requestFocus) { int addToProjectView = Messages .showYesNoDialog(String.format("Whitelist generated resource directory \"%s\" in project view?", generatedResDir.getRelativePath()), "Whitelist generated resource", null); if (addToProjectView == Messages.YES) { addDirectoryToProjectView(project, projectViewFile, generatedResDir); }// w w w . j a v a2 s.com }
From source file:com.hp.alm.ali.idea.action.attachment.AttachmentDeleteAction.java
License:Apache License
@Override protected void actionPerformed(AnActionEvent event, final Project project, final Entity entity) { if (Messages.showYesNoDialog("Do you really want to delete this attachment?", "Confirmation", null) == Messages.YES) {/* ww w . j av a 2s.c o m*/ ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { @Override public void run() { EntityRef parent = new EntityRef(entity.getPropertyValue("parent-type"), Integer.valueOf(entity.getPropertyValue("parent-id"))); project.getComponent(AttachmentService.class).deleteAttachment(entity.getPropertyValue("name"), parent); } }); } }
From source file:com.hp.alm.ali.idea.action.DeleteEntityAction.java
License:Apache License
@Override protected void actionPerformed(AnActionEvent event, final Project project, final Entity entity) { EntityLabelService entityLabelService = project.getComponent(EntityLabelService.class); entityLabelService.loadEntityLabelAsync(entity.getType(), new AbstractCachingService.DispatchCallback<String>() { @Override/*from ww w .ja v a 2 s . c om*/ public void loaded(String entityLabel) { if (Messages.showYesNoDialog("Do you really want to delete this " + entityLabel + "?", "Confirmation", null) == Messages.YES) { ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { @Override public void run() { EntityService entityService = project.getComponent(EntityService.class); entityService.deleteEntity(entity); } }); } } }); }
From source file:com.hp.alm.ali.idea.action.link.LinkDeleteAction.java
License:Apache License
@Override protected void actionPerformed(AnActionEvent event, Project project, Entity entity) { if (Messages.showYesNoDialog("Do you really want to remove the link?", "Confirmation", null) == Messages.YES) {/*from w w w . ja v a 2 s . co m*/ project.getComponent(EntityService.class).deleteEntity(entity); } }
From source file:com.hp.alm.ali.idea.action.task.TaskDeleteAction.java
License:Apache License
@Override protected void actionPerformed(AnActionEvent event, final Project project, final Entity entity) { if (Messages.showYesNoDialog("Do you really want to delete this task?", "Confirmation", null) == Messages.YES) {// www. jav a 2 s . c o m ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { @Override public void run() { EntityService entityService = project.getComponent(EntityService.class); if (entityService.deleteEntity(entity)) { // make sure item values are propagated entityService.getEntityAsync(new EntityRef("release-backlog-item", Integer.valueOf(entity.getPropertyValue("release-backlog-item-id"))), null); } } }); } }
From source file:com.hp.alm.ali.idea.cfg.AliConfigurable.java
License:Apache License
protected Component getSouthernComponent() { JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final TroubleShootService troubleShootService = ApplicationManager.getApplication() .getComponent(TroubleShootService.class); final JButton troubleshoot = new JButton( troubleShootService.isRunning() ? "Stop Troubleshoot" : "Troubleshoot"); troubleshoot.addActionListener(new ActionListener() { @Override// ww w. j ava 2 s.c om public void actionPerformed(ActionEvent e) { if (troubleshoot.getText().equals("Troubleshoot")) { if (!troubleShootService.isRunning()) { if (Messages.showYesNoDialog("Do you want to log complete ALM server communication?", "Confirmation", null) == Messages.YES) { FileSaverDescriptor desc = new FileSaverDescriptor("Log server communication", "Log server communication on the local filesystem."); final VirtualFileWrapper file = FileChooserFactory.getInstance() .createSaveFileDialog(desc, troubleshoot).save(null, "REST_log.txt"); if (file == null) { return; } troubleShootService.start(file.getFile()); troubleshoot.setText("Stop Troubleshoot"); } } } else { troubleShootService.stop(); troubleshoot.setText("Troubleshoot"); } } }); southPanel.add(troubleshoot); return southPanel; }
From source file:com.intellij.ide.actionMacro.ActionMacroConfigurationPanel.java
License:Apache License
public JPanel getPanel() { if (mySplitter == null) { mySplitter = new Splitter(false, 0.5f); final String value = PropertiesComponent.getInstance().getValue(SPLITTER_PROPORTION); if (value != null) { mySplitter.setProportion(Float.parseFloat(value)); }/* ww w. j ava2 s .co m*/ mySplitter.setFirstComponent( ToolbarDecorator.createDecorator(myMacrosList).setEditAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { final int selIndex = myMacrosList.getSelectedIndex(); if (selIndex == -1) return; final ActionMacro macro = (ActionMacro) myMacrosModel.getElementAt(selIndex); String newName; do { newName = Messages.showInputDialog(mySplitter, IdeBundle.message("prompt.enter.new.name"), IdeBundle.message("title.rename.macro"), Messages.getQuestionIcon(), macro.getName(), null); if (newName == null || macro.getName().equals(newName)) return; } while (!canRenameMacro(newName)); if (myRenamingList == null) myRenamingList = new ArrayList<Pair<String, String>>(); myRenamingList.add(new Pair<String, String>(macro.getName(), newName)); macro.setName(newName); myMacrosList.repaint(); } private boolean canRenameMacro(final String name) { final Enumeration elements = myMacrosModel.elements(); while (elements.hasMoreElements()) { final ActionMacro macro = (ActionMacro) elements.nextElement(); if (macro.getName().equals(name)) { if (Messages.showYesNoDialog(IdeBundle.message("message.macro.exists", name), IdeBundle.message("title.macro.name.already.used"), Messages.getWarningIcon()) != 0) { return false; } myMacrosModel.removeElement(macro); break; } } return true; } }).disableAddAction().disableUpDownActions().createPanel()); mySplitter.setSecondComponent(ToolbarDecorator.createDecorator(myMacroActionsList) .setRemoveAction(new AnActionButtonRunnable() { @Override public void run(AnActionButton button) { final int macrosSelectedIndex = myMacrosList.getSelectedIndex(); if (macrosSelectedIndex != -1) { final ActionMacro macro = (ActionMacro) myMacrosModel .getElementAt(macrosSelectedIndex); macro.deleteAction(myMacroActionsList.getSelectedIndex()); } ListUtil.removeSelectedItems(myMacroActionsList); } }).disableAddAction().disableUpDownActions().createPanel()); } return mySplitter; }
From source file:com.intellij.ide.actionMacro.ActionMacroManager.java
License:Apache License
public boolean checkCanCreateMacro(String name) { final ActionManagerEx actionManager = (ActionManagerEx) ActionManager.getInstance(); final String actionId = ActionMacro.MACRO_ACTION_PREFIX + name; if (actionManager.getAction(actionId) != null) { if (Messages.showYesNoDialog(IdeBundle.message("message.macro.exists", name), IdeBundle.message("title.macro.name.already.used"), Messages.getWarningIcon()) != 0) { return false; }//from ww w .jav a 2 s. co m actionManager.unregisterAction(actionId); removeMacro(name); } return true; }
From source file:com.intellij.ide.plugins.ActionInstallPlugin.java
License:Apache License
private static boolean suggestToEnableInstalledPlugins(final InstalledPluginsTableModel pluginsModel, final Set<IdeaPluginDescriptor> disabled, final Set<IdeaPluginDescriptor> disabledDependants, final ArrayList<PluginNode> list) { if (!disabled.isEmpty() || !disabledDependants.isEmpty()) { String message = ""; if (disabled.size() == 1) { message += "Updated plugin '" + disabled.iterator().next().getName() + "' is disabled."; } else if (!disabled.isEmpty()) { message += "Updated plugins " + StringUtil.join(disabled, new Function<IdeaPluginDescriptor, String>() { @Override public String fun(IdeaPluginDescriptor pluginDescriptor) { return pluginDescriptor.getName(); }/*w w w.ja va 2s . com*/ }, ", ") + " are disabled."; } if (!disabledDependants.isEmpty()) { message += "<br>"; message += "Updated plugin" + (list.size() > 1 ? "s depend " : " depends ") + "on disabled"; if (disabledDependants.size() == 1) { message += " plugin '" + disabledDependants.iterator().next().getName() + "'."; } else { message += " plugins " + StringUtil.join(disabledDependants, new Function<IdeaPluginDescriptor, String>() { @Override public String fun(IdeaPluginDescriptor pluginDescriptor) { return pluginDescriptor.getName(); } }, ", ") + "."; } } message += " Disabled plugins and plugins which depends on disabled plugins won't be activated after restart."; int result; if (!disabled.isEmpty() && !disabledDependants.isEmpty()) { result = Messages.showYesNoCancelDialog(XmlStringUtil.wrapInHtml(message), CommonBundle.getWarningTitle(), "Enable all", "Enable updated plugin" + (disabled.size() > 1 ? "s" : ""), CommonBundle.getCancelButtonText(), Messages.getQuestionIcon()); if (result == Messages.CANCEL) return false; } else { message += "<br>Would you like to enable "; if (!disabled.isEmpty()) { message += "updated plugin" + (disabled.size() > 1 ? "s" : ""); } else { //noinspection SpellCheckingInspection message += "plugin dependenc" + (disabledDependants.size() > 1 ? "ies" : "y"); } message += "?</body></html>"; result = Messages.showYesNoDialog(message, CommonBundle.getWarningTitle(), Messages.getQuestionIcon()); if (result == Messages.NO) return false; } if (result == Messages.YES) { disabled.addAll(disabledDependants); pluginsModel.enableRows(disabled.toArray(new IdeaPluginDescriptor[disabled.size()]), true); } else if (result == Messages.NO && !disabled.isEmpty()) { pluginsModel.enableRows(disabled.toArray(new IdeaPluginDescriptor[disabled.size()]), true); } return true; } return false; }