List of usage examples for com.intellij.openapi.ui Messages showYesNoDialog
@YesNoResult public static int showYesNoDialog(@NotNull Component parent, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon)
From source file:com.android.tools.idea.uibuilder.handlers.ViewEditorImpl.java
License:Apache License
@Override public void copyLayoutToMainModuleSourceSet(@NotNull String layout, @Language("XML") @NotNull String xml) { String message = "Do you want to copy layout " + layout + " to your main module source set?"; if (Messages.showYesNoDialog(myScreen.getModel().getProject(), message, "Copy Layout", Messages.getQuestionIcon()) == Messages.NO) { return;/* w w w. j a v a2s. c o m*/ } createResourceFile(FD_RES_LAYOUT, layout + DOT_XML, xml.getBytes(StandardCharsets.UTF_8)); }
From source file:com.arcbees.plugin.idea.utils.PackageUtilExt.java
License:Apache License
/** * @deprecated/*from www . j a va2 s. 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 ww. jav a 2 s . 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.atlassian.theplugin.idea.action.issues.activetoolbar.ActiveIssueUtils.java
License:Apache License
/** * Should be called from the UI thread/*from w w w . ja va 2 s . c om*/ * * @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.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;/*from w ww . j a v a 2s. com*/ } // 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); } }); }
From source file:com.atlassian.theplugin.idea.config.serverconfig.CrucibleServerConfigForm.java
License:Apache License
private void createUIComponents() { crucibleDetailConfigForm = new CrucibleDetailConfigForm(crucibleServerFacade); final CrucibleConnector connector = new CrucibleConnector(crucibleServerFacade, fishEyeServerFacade); genericServerConfigForm = new GenericServerConfigForm(project, defaultUser, connector) { @Override//from ww w. jav a2 s . c o m public void onSuccess() { if (connector.isFisheye() == true && !crucibleDetailConfigForm.isFishEyeInstance()) { int res = Messages.showYesNoDialog(project, "This Crucible server is connected to Fisheye.\nWould you like to connect to the Fisheye server as well?", "Combined FishEye & Crucible detected", Messages.getQuestionIcon()); if (res == DialogWrapper.OK_EXIT_CODE) { crucibleDetailConfigForm.setIsFishEyeInstance(true); } } } }; }
From source file:com.cfsoft.ofbiz.facet.ui.ComponentFileSetConfigurationTab.java
License:Apache License
private void remove() { final SimpleNode[] nodes = myTree.getSelectedNodesIfUniform(); for (final SimpleNode node : nodes) { if (node instanceof FileSetNode) { final OfbizFileSet fileSet = ((FileSetNode) node).mySet; if (fileSet.getFiles().isEmpty()) { myBuffer.remove(fileSet); return; }/* w w w.ja v a2 s . c om*/ final int result = Messages.showYesNoDialog(myPanel, String.format("Remove File Set '%s' ?", fileSet.getName()), "Confirm removal", Messages.getQuestionIcon()); if (result == DialogWrapper.OK_EXIT_CODE) { if (fileSet.isAutodetected()) { fileSet.setRemoved(true); myBuffer.add(fileSet); } else { myBuffer.remove(fileSet); } } } else if (node instanceof ConfigFileNode) { final VirtualFilePointer filePointer = ((ConfigFileNode) node).myFilePointer; final OfbizFileSet fileSet = ((FileSetNode) node.getParent()).mySet; fileSet.removeFile(filePointer); } } }
From source file:com.github.cssxfire.IncomingChangesComponent.java
License:Apache License
public void initComponent() { if (!CssXFireConnector.getInstance().isInitialized()) { return;/*from ww w.ja v a2 s .co m*/ } IdeaPluginDescriptor pluginDescriptor = PluginManager.getPlugin(PluginId.getId("CSS-X-Fire")); if (pluginDescriptor == null) { return; } String currentVersion = pluginDescriptor.getVersion(); String previousVersion = PropertiesComponent.getInstance().getValue(PREVIOUS_VERSION_PROPERTY_NAME); if (!currentVersion.equals(previousVersion)) { PropertiesComponent.getInstance().setValue(PREVIOUS_VERSION_PROPERTY_NAME, currentVersion); final String message = previousVersion == null ? "CSS-X-Fire has been installed.\n\nPress Yes to install the browser plugin." : "CSS-X-Fire has been upgraded from " + previousVersion + " to " + currentVersion + ".\n\nPress Yes to update the browser plugin."; ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { int res = Messages.showYesNoDialog(project, message, "CSS-X-Fire", null); if (res == 0) { new AnAction("Help", "Show the CSS-X-Fire help page", AllIcons.Actions.Help) { @Override public void actionPerformed(AnActionEvent anActionEvent) { CssUtils.openInFirefox("http://localhost:6776/files/about.html"); } }.actionPerformed(null); } } }); } }
From source file:com.google.gct.idea.appengine.deploy.AppEngineUpdateDialog.java
License:Apache License
@Override protected void doOKAction() { if (getOKAction().isEnabled()) { Module selectedModule = myModuleComboBox.getSelectedModule(); String sdk = ""; String war = ""; AppEngineGradleFacet facet = AppEngineGradleFacet.getAppEngineFacetByModule(selectedModule); if (facet != null) { AppEngineConfigurationProperties model = facet.getConfiguration().getState(); if (model != null) { sdk = model.APPENGINE_SDKROOT; war = model.WAR_DIR;/*from w w w . jav a 2s .c o m*/ } } String client_secret = null; String client_id = null; String refresh_token = null; CredentialedUser selectedUser = myElysiumProjectId.getSelectedUser(); if (selectedUser == null) { selectedUser = GoogleLogin.getInstance().getActiveUser(); // Ask the user if he wants to continue using the active user credentials. if (selectedUser != null) { if (Messages.showYesNoDialog(this.getPeer().getOwner(), "The Project ID you entered could not be found. Do you want to deploy anyway using " + GoogleLogin.getInstance().getActiveUser().getEmail() + " for credentials?", "Deploy", Messages.getQuestionIcon()) != Messages.YES) { return; } } else { // This should not happen as its validated. Messages.showErrorDialog(this.getPeer().getOwner(), "You need to be logged in to deploy.", "Login"); return; } } if (selectedUser != null) { client_secret = selectedUser.getGoogleLoginState().fetchOAuth2ClientSecret(); client_id = selectedUser.getGoogleLoginState().fetchOAuth2ClientId(); refresh_token = selectedUser.getGoogleLoginState().fetchOAuth2RefreshToken(); } if (Strings.isNullOrEmpty(client_secret) || Strings.isNullOrEmpty(client_id) || Strings.isNullOrEmpty(refresh_token)) { // The login is somehow invalid, bail -- this shouldn't happen. LOG.error("StartUploading while logged in, but it doesn't have full credentials."); if (Strings.isNullOrEmpty(client_secret)) { LOG.error("(null) client_secret"); } if (Strings.isNullOrEmpty(client_id)) { LOG.error("(null) client_id"); } if (Strings.isNullOrEmpty(refresh_token)) { LOG.error("(null) refresh_token"); } Messages.showErrorDialog(this.getPeer().getOwner(), "The project ID is not a valid Google Console Developer Project.", "Login"); return; } // These should not fail as they are a part of the dialog validation. if (Strings.isNullOrEmpty(sdk) || Strings.isNullOrEmpty(war) || Strings.isNullOrEmpty(myElysiumProjectId.getText()) || selectedModule == null) { Messages.showErrorDialog(this.getPeer().getOwner(), "Could not deploy due to missing information (sdk/war/projectid).", "Deploy"); LOG.error("StartUploading was called with bad module/sdk/war"); return; } close(OK_EXIT_CODE); // We close before kicking off the update so it doesn't interfere with the output window coming to focus. // Kick off the upload. detailed status will be shown in an output window. new AppEngineUpdater(myProject, selectedModule, sdk, war, myElysiumProjectId.getText(), myVersion.getText(), client_secret, client_id, refresh_token).startUploading(); } }
From source file:com.googlecode.cssxfire.IncomingChangesComponent.java
License:Apache License
public void initComponent() { if (!CssXFireConnector.getInstance().isInitialized()) { return;/* w w w . j a v a 2 s .c om*/ } IdeaPluginDescriptor pluginDescriptor = PluginManager.getPlugin(PluginId.getId("CSS-X-Fire")); if (pluginDescriptor == null) { return; } String currentVersion = pluginDescriptor.getVersion(); AppMeta appMeta = CssXFireConnector.getInstance().getState(); String previousVersion = appMeta.getVersion(); if (!currentVersion.equals(previousVersion)) { appMeta.setVersion(currentVersion); final String message = previousVersion == null ? "CSS-X-Fire has been installed.\n\nPress Yes to install the browser plugin." : "CSS-X-Fire has been upgraded from " + previousVersion + " to " + currentVersion + ".\n\nPress Yes to update the browser plugin."; ApplicationManager.getApplication().invokeLater(new Runnable() { public void run() { int res = Messages.showYesNoDialog(project, message, "CSS-X-Fire", null); if (res == 0) { new Help().actionPerformed(null); } } }); } }