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:be.wimsymons.intellij.polopolyimport.PPImportAction.java
License:Apache License
public void actionPerformed(AnActionEvent e) { VirtualFile[] virtualFiles = e.getData(LangDataKeys.VIRTUAL_FILE_ARRAY); if (target.isConfirm()) { int answer = Messages.showYesNoDialog( "Are you sure to import the selected files into " + target.getProfile() + "?", "Confirm Polopoly Import", Messages.getWarningIcon()); if (answer == Messages.NO) { PPImportPlugin.doNotify("Import cancelled upon confirmation.", NotificationType.INFORMATION); return; }//w ww.j av a2 s. c o m } ProgressManager.getInstance().run(new ImportTask(virtualFiles, this.target, this.includeExtensions, this.replacements, this.uploadMultipleFilesAsJar)); }
From source file:com.android.tools.idea.gradle.eclipse.AdtImportLocationStep.java
License:Apache License
@Override public boolean validate() throws ConfigurationException { WizardContext context = getWizardContext(); GradleImport importer = AdtImportProvider.getImporter(context); if (importer != null) { List<String> errors = importer.getErrors(); if (!errors.isEmpty()) { throw new ConfigurationException(errors.get(0)); }/*from w w w.ja v a 2 s.c o m*/ } // The following code is based on similar code in com.intellij.ide.util.newProjectWizard.ProjectNameStep String projectFileDirectory = getProjectFileDirectory(); if (projectFileDirectory.length() == 0) { throw new ConfigurationException( String.format("Enter %1$s file location", context.getPresentationName())); } boolean shouldPromptCreation = myIsPathChangedByUser; if (!ProjectWizardUtil.createDirectoryIfNotExists( String.format("The %1$s file directory\n", context.getPresentationName()), projectFileDirectory, shouldPromptCreation)) { return false; } boolean shouldContinue = true; File projectFile = new File(getProjectFileDirectory()); String title = "New Project"; if (projectFile.isFile()) { shouldContinue = false; String message = String.format("%s exists and is a file.\nPlease specify a different project location", projectFile.getAbsolutePath()); Messages.showErrorDialog(message, title); } else if (projectFile.isDirectory()) { File[] files = projectFile.listFiles(); if (files != null && files.length > 0) { String message = String.format( "%1$s folder already exists and is not empty.\nIts content may be overwritten.\nContinue?", projectFile.getAbsolutePath()); int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon()); shouldContinue = answer == 0; } } return shouldContinue; }
From source file:com.atlassian.theplugin.idea.autoupdate.PluginDownloader.java
License:Apache License
private void promptShutdownAndShutdown() { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { String title = "IDEA shutdown"; String message = PluginUtil.PRODUCT_NAME + " has been installed successfully.\n" + "IntelliJ IDEA needs to be restarted to activate the plugin.\n" + "Would you like to shutdown IntelliJ IDEA now?"; // todo again add project or parent to the below window int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon()); if (answer == DialogWrapper.OK_EXIT_CODE) { //ApplicationManagerEx.getApplicationEx().exit(true); ApplicationManager.getApplication().exit(); }/*from w ww . j a va2s. c om*/ } }); }
From source file:com.atlassian.theplugin.idea.config.ProjectConfigurationComponent.java
License:Apache License
public static void fireDirectClickedServerPopup(final Project project, final String serverUrl, final ServerType serverType, final Runnable runnable) { /* final Color BACKGROUND_COLOR = new Color(255, 255, 200); //from ww w. ja v a 2 s. c om StringBuilder sb = new StringBuilder("Server <i>" + serverUrl + "</i> not found in configuration<br>"); sb.append("<br>Click on this notification to open configuration panel and add this server"); JEditorPane content = new JEditorPane(); content.setEditable(false); content.setContentType("text/html"); content.setEditorKit(new ClasspathHTMLEditorKit()); content.setText("<html>" + Constants.BODY_WITH_STYLE + sb.toString() + "</body></html>"); content.setBackground(BACKGROUND_COLOR); content.addHyperlinkListener(new GenericHyperlinkListener()); content.addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { if (ProjectConfigurationComponent.addDirectClickedServer(project, serverUrl, serverType)) { EventQueue.invokeLater(runnable); } } }); IdeaVersionFacade.getInstance().fireNotification( project, new JScrollPane(content), content.getText(), "/icons/crucible-blue-16.png", IdeaVersionFacade.OperationStatus.INFO, BACKGROUND_COLOR);*/ if (Messages.showYesNoDialog( "Server " + serverUrl + " not found in configuration,\ndo you want to " + "open configuration panel and add this server?", "Server not found", Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE) { if (ProjectConfigurationComponent.addDirectClickedServer(project, serverUrl, serverType)) { EventQueue.invokeLater(runnable); } } }
From source file:com.atlassian.theplugin.idea.config.serverconfig.ServerTreePanel.java
License:Apache License
public void removeServer() { if (selectedNode != null) { if (selectedNode instanceof ServerNode) { final ServerNode selectedServerNode = (ServerNode) this.selectedNode; int response = Messages.showYesNoDialog("Are you sure you want to delete the selected server?", "Confirm server delete", Messages.getQuestionIcon()); if (response != 0) { return; }/* w w w .j av a 2 s .c om*/ final ServerCfg serverCfg = selectedServerNode.getServer(); if (serverCfg.isShared()) { serverCfg.setDeleted(true); serverConfigPanel.showEmptyPanel(); } else { servers.remove(serverCfg); } TreeNode parent = selectedServerNode.getParent(); selectedServerNode.removeFromParent(); model.nodeStructureChanged(parent); deleteServerFile(serverCfg); } } }
From source file:com.chrisrm.idea.MTLafComponent.java
License:Open Source License
/** * Restart IDE if necessary (ex: material design components) * * @param mtConfig/*from w w w . ja va 2 s . c om*/ * @param form */ private void restartIdeIfNecessary(final MTConfig mtConfig, final MTForm form) { // Restart the IDE if changed if (mtConfig.needsRestart(form)) { final String title = MaterialThemeBundle.message("mt.restartDialog.title"); final String message = MaterialThemeBundle.message("mt.restartDialog.content"); final int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon()); if (answer == Messages.YES) { willRestartIde = true; } } }
From source file:com.chrisrm.idea.MTThemeManager.java
License:Open Source License
private void askForRestart() { final String title = MaterialThemeBundle.message("mt.restartDialog.title"); final String message = MaterialThemeBundle.message("mt.restartDialog.content"); final int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon()); if (answer == Messages.YES) { MTUiUtils.restartIde();//from www.ja v a 2 s . c o m } }
From source file:com.chrisrm.idea.MTThemeManagerTest.java
License:Open Source License
@Override @Before/* www. ja va2s . c o m*/ public void setUp() throws Exception { super.setUp(); mtThemeManagerUnderTest = MTThemeManager.getInstance(); PowerMockito.mockStatic(Messages.class); PowerMockito.when(Messages.showYesNoDialog(Mockito.anyString(), Mockito.anyString(), Mockito.any())) .thenReturn(1); MTConfig.getInstance().resetSettings(); }
From source file:com.github.rholder.gradle.intellij.DependencyViewer.java
License:Apache License
private int useCurrentProjectBuild() { return Messages.showYesNoDialog("Would you like to view the current project's Gradle dependencies?", "Gradle Dependency Viewer", null); }
From source file:com.google.cloud.tools.intellij.debugger.ProjectRepositoryValidator.java
License:Apache License
/** * Restore the repository to its original state. *///from w w w.j a va 2 s. c o m public void restoreToOriginalState(final @NotNull Project project) { if (repoState.hasSourceRepository()) { assert repoState.getSourceRepository() != null; final VirtualFile root = repoState.getSourceRepository().getRoot(); //check for an unstash requirement. final Ref<StashInfo> targetStash = new Ref<StashInfo>(); if (!Strings.isNullOrEmpty(repoState.getStashMessage())) { GitStashUtils.loadStashStack(project, root, new Consumer<StashInfo>() { @Override public void consume(StashInfo stashInfo) { if (!Strings.isNullOrEmpty(stashInfo.getMessage()) && stashInfo.getMessage().equals(repoState.getStashMessage())) { targetStash.set(stashInfo); } } }); } // If an unstash is required, we will always have an original branch name as well. if (!Strings.isNullOrEmpty(repoState.getOriginalBranchName())) { assert repoState.getOriginalBranchName() != null; String branchDisplayName = repoState.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(repoState.getOriginalBranchName(), false, Collections.singletonList(repoState.getSourceRepository()), new Runnable() { @Override public void run() { repoState.getSourceRepository().update(); if (!targetStash.isNull()) { unstash(project, targetStash, root); } } }); } } } }