List of usage examples for com.intellij.openapi.ui Messages getQuestionIcon
@NotNull public static Icon getQuestionIcon()
From source file:com.anecdote.ideaplugins.commitlog.GenerateCommentAction.java
License:Apache License
public void actionPerformed(AnActionEvent e) { CheckinProjectPanel panel = (CheckinProjectPanel) e.getData(CheckinProjectPanel.PANEL_KEY); JTextArea commentEditor = e.getData(CHANGES_BAR_COMMENT_EDITOR_DATA_KEY); if (panel != null || commentEditor != null) { final Project project = panel != null ? panel.getProject() : DataKeys.PROJECT.getData(e.getDataContext()); if (project != null) { int confirmation = Messages.showDialog(project, "Generate commit comment? ", "Confirm Generate Comment", new String[] { GENERATE, CommonBundle.getCancelButtonText() }, 0, Messages.getQuestionIcon()); if (confirmation == 0) { CommitLogProjectComponent projectComponent = project .getComponent(CommitLogProjectComponent.class); String commitMessage; Collection<File> files; if (panel != null) { commitMessage = panel.getCommitMessage(); files = panel.getFiles(); } else { commitMessage = commentEditor.getText(); LocalChangeList changeList = e.getData(SELECTED_CHANGE_LIST_DATA_KEY); if (changeList == null) { return; }/*from ww w . j a v a 2 s . com*/ ProjectLevelVcsManager vcsManager = ProjectLevelVcsManager.getInstance(project); files = new HashSet<File>(); for (Change change : changeList.getChanges()) { FilePath filepath = ChangesUtil.getFilePath(change); files.add(filepath.getIOFile()); } } CommitLogBuilder commitLogBuilder = CommitLogBuilder.createCommitLogBuilder( projectComponent.getTextualCommitCommentTemplate(), commitMessage, project, files); try { String commitLog = commitLogBuilder.buildCommitLog(new Date()); if (panel != null) { panel.setCommitMessage(commitLog); } else { commentEditor.setText(commitLog); commentEditor.requestFocusInWindow(); } } catch (CommitLogTemplateParser.TextTemplateParserException e1) { int result = Messages.showDialog(project, "Error parsing Comment Template :\n" + e1.getMessage() + "\n\nEdit Comment Template now?", "Error Generating Comment", new String[] { CommonBundle.getYesButtonText(), CommonBundle.getNoButtonText() }, 0, Messages.getErrorIcon()); if (result == 0) { projectComponent.setFocusCommentTemplateEditor(true); ShowSettingsUtil.getInstance().editConfigurable(project, projectComponent); } } } } } }
From source file:com.ansorgit.plugins.bash.actions.NewBashActionBase.java
License:Apache License
@NotNull protected final PsiElement[] invokeDialog(final Project project, final PsiDirectory directory) { log.debug("invokeDialog"); final MyInputValidator validator = new MyInputValidator(project, directory); Messages.showInputDialog(project, getDialogPrompt(), getDialogTitle(), Messages.getQuestionIcon(), "", validator);/*from ww w . j a v a2 s . c o m*/ final PsiElement[] elements = validator.getCreatedElements(); log.debug("Result: " + elements); return elements; }
From source file:com.arcbees.plugin.idea.utils.PackageUtilExt.java
License:Apache License
/** * @deprecated//w w w. jav a2s. c o m */ @Nullable public static PsiDirectory findOrCreateDirectoryForPackage(Project project, String packageName, PsiDirectory baseDir, boolean askUserToCreate, boolean filterSourceDirsForTestBaseDir) throws IncorrectOperationException { PsiDirectory psiDirectory = null; if (!"".equals(packageName)) { PsiPackage rootPackage = findLongestExistingPackage(project, packageName); if (rootPackage != null) { int beginIndex = rootPackage.getQualifiedName().length() + 1; packageName = beginIndex < packageName.length() ? packageName.substring(beginIndex) : ""; String postfixToShow = packageName.replace('.', File.separatorChar); if (packageName.length() > 0) { postfixToShow = File.separatorChar + postfixToShow; } PsiDirectory[] directories = rootPackage.getDirectories(); if (filterSourceDirsForTestBaseDir) { directories = filterSourceDirectories(baseDir, project, directories); } psiDirectory = DirectoryChooserUtil.selectDirectory(project, directories, baseDir, postfixToShow); if (psiDirectory == null) return null; } } if (psiDirectory == null) { PsiDirectory[] sourceDirectories = ProjectRootUtil.getSourceRootDirectories(project); psiDirectory = DirectoryChooserUtil.selectDirectory(project, sourceDirectories, baseDir, File.separatorChar + packageName.replace('.', File.separatorChar)); if (psiDirectory == null) return null; } String restOfName = packageName; boolean askedToCreate = false; while (restOfName.length() > 0) { final String name = getLeftPart(restOfName); PsiDirectory foundExistingDirectory = psiDirectory.findSubdirectory(name); if (foundExistingDirectory == null) { if (!askedToCreate && askUserToCreate) { int toCreate = Messages.showYesNoDialog(project, IdeBundle.message("prompt.create.non.existing.package", packageName), IdeBundle.message("title.package.not.found"), Messages.getQuestionIcon()); if (toCreate != 0) { return null; } askedToCreate = true; } psiDirectory = createSubdirectory(psiDirectory, name, project); } else { psiDirectory = foundExistingDirectory; } restOfName = cutLeftPart(restOfName); } return psiDirectory; }
From source file:com.arcbees.plugin.idea.utils.PackageUtilExt.java
License:Apache License
@Nullable public static PsiDirectory findOrCreateDirectoryForPackage(@NotNull Module module, String packageName, PsiDirectory baseDir, boolean askUserToCreate, boolean filterSourceDirsForBaseTestDirectory) throws IncorrectOperationException { final Project project = module.getProject(); PsiDirectory psiDirectory = baseDir; // if (!packageName.isEmpty()) { // PsiPackage rootPackage = findLongestExistingPackage(module, packageName); // if (rootPackage != null) { // int beginIndex = rootPackage.getQualifiedName().length() + 1; // packageName = beginIndex < packageName.length() ? packageName.substring(beginIndex) : ""; // String postfixToShow = packageName.replace('.', File.separatorChar); // if (packageName.length() > 0) { // postfixToShow = File.separatorChar + postfixToShow; // }//from w w w. ja v a 2s.c o m // PsiDirectory[] moduleDirectories = getPackageDirectoriesInModule(rootPackage, module); // if (filterSourceDirsForBaseTestDirectory) { // moduleDirectories = filterSourceDirectories(baseDir, project, moduleDirectories); // } // psiDirectory = DirectoryChooserUtil.selectDirectory(project, moduleDirectories, baseDir, postfixToShow); // if (psiDirectory == null) return null; // } // } if (psiDirectory == null) { if (!checkSourceRootsConfigured(module, askUserToCreate)) return null; final VirtualFile[] sourceRoots = ModuleRootManager.getInstance(module).getSourceRoots(); List<PsiDirectory> directoryList = new ArrayList<PsiDirectory>(); for (VirtualFile sourceRoot : sourceRoots) { final PsiDirectory directory = PsiManager.getInstance(project).findDirectory(sourceRoot); if (directory != null) { directoryList.add(directory); } } PsiDirectory[] sourceDirectories = directoryList.toArray(new PsiDirectory[directoryList.size()]); psiDirectory = DirectoryChooserUtil.selectDirectory(project, sourceDirectories, baseDir, File.separatorChar + packageName.replace('.', File.separatorChar)); if (psiDirectory == null) return null; } String restOfName = packageName; boolean askedToCreate = false; while (restOfName.length() > 0) { final String name = getLeftPart(restOfName); final PsiDirectory passDir = psiDirectory; PsiDirectory foundExistingDirectory = null; try { foundExistingDirectory = ActionRunner .runInsideWriteAction(new ActionRunner.InterruptibleRunnableWithResult<PsiDirectory>() { public PsiDirectory run() throws Exception { return passDir.findSubdirectory(name); } }); } catch (Exception e) { e.printStackTrace(); } if (foundExistingDirectory == null) { if (!askedToCreate && askUserToCreate) { if (!ApplicationManager.getApplication().isUnitTestMode()) { int toCreate = Messages.showYesNoDialog(project, IdeBundle.message("prompt.create.non.existing.package", packageName), IdeBundle.message("title.package.not.found"), Messages.getQuestionIcon()); if (toCreate != 0) { return null; } } askedToCreate = true; } final PsiDirectory psiDirectory1 = psiDirectory; try { psiDirectory = ActionRunner .runInsideWriteAction(new ActionRunner.InterruptibleRunnableWithResult<PsiDirectory>() { public PsiDirectory run() throws Exception { return psiDirectory1.createSubdirectory(name); } }); } catch (IncorrectOperationException e) { throw e; } catch (IOException e) { throw new IncorrectOperationException(e.toString(), e); } catch (Exception e) { LOG.error(e); } } else { psiDirectory = foundExistingDirectory; } restOfName = cutLeftPart(restOfName); } return psiDirectory; }
From source file:com.aspiro.git.actions.GitTag.java
License:Apache License
public void perform(@NotNull Project project, GitVcs vcs, @NotNull List<VcsException> exceptions, @NotNull VirtualFile[] affectedFiles) throws VcsException { saveAll();/*from ww w . jav a 2s. c o m*/ if (!ProjectLevelVcsManager.getInstance(project).checkAllFilesAreUnder(vcs, affectedFiles)) return; final String tagName = Messages.showInputDialog(project, "Specify tag name", "Tag", Messages.getQuestionIcon()); if (tagName == null) return; //todo: support multiple roots? GitCommand command = new GitCommand(project, vcs.getSettings(), GitUtil.getVcsRoot(project, affectedFiles[0])); final String output = command.tag(tagName); if (output.trim().length() != 0) { Messages.showInfoMessage(project, output, "Result"); } }
From source file:com.atlassian.theplugin.idea.action.issues.activetoolbar.ActiveIssueUtils.java
License:Apache License
/** * Should be called from the UI thread/*from w ww . j a v a2s .c o m*/ * * @param project project * @param issue issue */ public static void checkIssueState(final Project project, final JiraIssueAdapter issue) { ActiveJiraIssue activeIssue = getActiveJiraIssue(project); if (issue != null && activeIssue != null) { if (issue.getJiraServerData() != null && issue.getKey().equals(activeIssue.getIssueKey()) && issue.getJiraServerData().getServerId().equals(activeIssue.getServerId())) { ProgressManager.getInstance().run(new Task.Backgroundable(project, "Checking active issue state") { public void run(final ProgressIndicator indicator) { if (!issue.getJiraServerData().getUsername().equals(issue.getAssigneeId())) { SwingUtilities.invokeLater(new Runnable() { public void run() { int isOk = Messages.showYesNoDialog(project, "Issue " + issue.getKey() + " has changed assignee (assigned to:" + issue.getAssignee() + ", status: " + issue.getStatus() + ").\nDo you want to deactivate?", "Issue " + issue.getKey(), Messages.getQuestionIcon()); if (isOk == DialogWrapper.OK_EXIT_CODE) { deactivate(project, new ActiveIssueResultHandler() { public void success() { final JiraWorkspaceConfiguration conf = IdeaHelper .getProjectComponent(project, JiraWorkspaceConfiguration.class); if (conf != null) { conf.setActiveJiraIssuee(null); } } public void failure(Throwable problem) { } public void cancel(String problem) { } }); } } }); } } }); } } }
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 ww w.ja v a2 s . c o m*/ } }); }
From source file:com.atlassian.theplugin.idea.config.ProjectConfigurationComponent.java
License:Apache License
private void migrateOldPrivateProjectSettings(final JDomProjectConfigurationDao cfgFactory) { final SAXBuilder builder = new SAXBuilder(false); final File privateCfgFile = getPrivateOldCfgFilePath(); boolean someMigrationHappened = false; if (privateCfgFile != null) { try {/*from www. j a va2 s. c o m*/ final Document privateRoot = builder.build(privateCfgFile); final PrivateProjectConfiguration ppc = cfgFactory .loadOldPrivateConfiguration(privateRoot.getRootElement()); for (PrivateServerCfgInfo privateServerCfgInfo : ppc.getPrivateServerCfgInfos()) { try { final PrivateServerCfgInfo newPsci = privateCfgDao.load(privateServerCfgInfo.getServerId()); if (newPsci == null) { privateCfgDao.save(privateServerCfgInfo); someMigrationHappened = true; } } catch (ServerCfgFactoryException e) { // ignore here - just don't try to overwrite it with data from old XML file } } } catch (Exception e) { handleServerCfgFactoryException(project, e); } } if (someMigrationHappened) { ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { int value = Messages.showYesNoCancelDialog(project, "Configuration has been succesfully migrated to new location (home directory).\n" + "Would you like to delete the old configuration file?\n\nDelete file: [" + privateCfgFile + "]", PluginUtil.PRODUCT_NAME + " upgrade process", Messages.getQuestionIcon()); if (value == DialogWrapper.OK_EXIT_CODE) { if (!privateCfgFile.delete()) { Messages.showWarningDialog(project, "Cannot remove file [" + privateCfgFile.getAbsolutePath() + "].\nTry removing it manually.\n" + PluginUtil.PRODUCT_NAME + " should still behave correctly.", PluginUtil.PRODUCT_NAME); } } } }); } }
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); /* w w w . jav a 2 s.co m*/ 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.ProjectConfigurationPanel.java
License:Apache License
public void askForDefaultCredentials() { final ServerCfg selectedServer = serverConfigPanel.getSelectedServer(); // PL-1703 - when adding a StAC server, there is no selected server, // as two servers are added simultaneously if (selectedServer == null) { return;// ww w . j av a2 s .c o m } // PL-1617 - Ugly ugly. I am not sure why this is b0rked sometimes, // but one of these seems to be null for apparent reason every once in a while ProjectCfgManager cfgMgr = IdeaHelper.getProjectCfgManager(project); if (cfgMgr == null) { LoggerImpl.getInstance().warn("askDefaultCredentials() - cfgMgr is null"); } final boolean alreadyExists = cfgMgr != null && cfgMgr.getServerr(selectedServer.getServerId()) != null; ApplicationManager.getApplication().executeOnPooledThread(new Runnable() { public void run() { final ModalityState modalityState = ModalityState.stateForComponent(ProjectConfigurationPanel.this); ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { if (!alreadyExists && !defaultCredentialsAsked && (defaultCredentials == null || (defaultCredentials.getPassword().equals("") && defaultCredentials.getPassword().equals("")) && selectedServer.getUsername().length() > 0)) { int answer = Messages.showYesNoDialog(project, "<html>Do you want to set server <b>" + selectedServer.getName() + "</b> <i>username</i> and <i>password</i>" + " as default credentials for the " + PluginUtil.PRODUCT_NAME + "?</html>", "Set as default", Messages.getQuestionIcon()); ProjectCfgManagerImpl cfgMgr = (ProjectCfgManagerImpl) IdeaHelper .getProjectCfgManager(project); if (answer == DialogWrapper.OK_EXIT_CODE) { UserCfg credentials = new UserCfg(selectedServer.getUsername(), selectedServer.getPassword(), true); if (cfgMgr != null) { cfgMgr.setDefaultCredentials(credentials); } defaultsConfigurationPanel.setDefaultCredentials(credentials); } if (cfgMgr != null) { cfgMgr.setDefaultCredentialsAsked(true); } ProjectConfigurationPanel.this.defaultCredentialsAsked = true; } } }, modalityState); } }); }