List of usage examples for com.intellij.openapi.ui Messages getErrorIcon
@NotNull public static Icon getErrorIcon()
From source file:net.groboclown.idea.p4ic.v2.ui.alerts.LoginFailedHandler.java
License:Apache License
@Override public void handleError(@NotNull final Date when) { LOG.warn("Login problem", getException()); if (isInvalid()) { return;/* ww w. j a v a 2 s . co m*/ } boolean handleEndSeparately = false; if (beginAction(config)) { try { int result = Messages.showDialog(getProject(), P4Bundle.message("configuration.login-problem-ask", getExceptionMessage()), P4Bundle.message("configuration.login-problem.title"), new String[] { P4Bundle.message("configuration.login-problem.yes"), P4Bundle.message("configuration.login-problem.no"), P4Bundle.message("configuration.login-problem.cancel") }, 0, Messages.getErrorIcon()); if (result == 0) { // first option: re-enter password // This needs to run in another event, otherwise the // message dialog will stay active forever. ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { try { PasswordManager.getInstance().askPassword(getProject(), config); connect(); } catch (PasswordStoreException e) { AlertManager.getInstance().addWarning(getProject(), P4Bundle.message("password.store.error.title"), P4Bundle.message("password.store.error"), e, new FilePath[0]); } finally { endAction(config); } } }); handleEndSeparately = true; } else if (result == 1) { // 2nd option: update server config tryConfigChange(); } else { // 3rd option: work offline goOffline(); } } finally { if (!handleEndSeparately) { endAction(config); } } } else { LOG.info("Already handling login for config " + config); } }
From source file:net.groboclown.idea.p4ic.v2.ui.alerts.RetryAuthenticationFailedHandler.java
License:Apache License
@Override public void handleError(@NotNull final Date when) { LOG.warn("Server refused authentication too many times"); boolean handleEndSeparately = false; if (beginAction(config)) { try {//from w ww . ja v a2 s. c o m int result = Messages.showDialog(getProject(), P4Bundle.message("configuration.retry-auth-problem-ask", getExceptionMessage()), P4Bundle.message("configuration.retry-auth-problem.title"), new String[] { P4Bundle.message("configuration.retry-auth-problem.retry"), P4Bundle.message("configuration.retry-auth-problem.config-change"), P4Bundle.message("configuration.retry-auth-problem.offline") }, 0, Messages.getErrorIcon()); if (result == 0) { // first option: re-enter password // This needs to run in another event, otherwise the // message dialog will stay active forever. ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { try { connect(); } finally { endAction(config); } } }); handleEndSeparately = true; } else if (result == 1) { // 2nd option: update server config tryConfigChange(); } else { // 3rd option: work offline goOffline(); } } finally { if (!handleEndSeparately) { endAction(config); } } } else { LOG.info("Already handling login for config " + config); } }
From source file:net.groboclown.idea.p4ic.v2.ui.alerts.SSLFingerprintProblemHandler.java
License:Apache License
@Override public void handleError(@NotNull final Date when) { LOG.warn("SSL fingerprint problem", getException()); if (isInvalid()) { return;/* w w w . j ava 2 s . co m*/ } // TODO this needs to better handle the SSL fingerprint issues. int result = Messages.showYesNoDialog(getProject(), P4Bundle.message("configuration.ssl-fingerprint-problem.ask", getExceptionMessage()), P4Bundle.message("configuration.ssl-fingerprint-problem.title"), Messages.getErrorIcon()); if (result == Messages.YES) { // Signal to the API to try again only if // the user selected "okay". tryConfigChange(); } else { // Work offline goOffline(); } }
From source file:net.groboclown.idea.p4ic.v2.ui.alerts.SSLKeyStrengthProblemHandler.java
License:Apache License
@Override public void handleError(@NotNull final Date when) { LOG.warn("SSL key strength problem", getException()); if (isInvalid()) { return;/*from www . j a v a2 s. com*/ } int result = Messages.showYesNoDialog(getProject(), P4Bundle.message("exception.java.ssl.keystrength-ask", System.getProperty("java.version") == null ? "<unknown>" : System.getProperty("java.version"), System.getProperty("java.vendor") == null ? "<unknown>" : System.getProperty("java.vendor"), System.getProperty("java.vendor.url") == null ? "<unknown>" : System.getProperty("java.vendor.url"), System.getProperty("java.home") == null ? "<unknown>" : System.getProperty("java.home"), getExceptionMessage()), P4Bundle.message("exception.java.ssl.keystrength-ask.title"), P4Bundle.message("dialog.confirm.edit-config"), P4Bundle.message("dialog.confirm.work-offline"), Messages.getErrorIcon()); if (result == Messages.YES) { // Signal to the API to try again only if // the user selected "okay". tryConfigChange(); } else { // Work offline goOffline(); } }
From source file:org.community.intellij.plugins.communitycase.update.BaseRebaseProcess.java
License:Apache License
/** * Merge files//from www . jav a2 s .c o m * * @param root the project root * @param cancelled the cancelled indicator * @param ex the exception holder * @param reverse if true, reverse merge provider will be used */ private void mergeFiles(final VirtualFile root, final Ref<Boolean> cancelled, final Ref<Throwable> ex, final boolean reverse) { com.intellij.util.ui.UIUtil.invokeAndWaitIfNeeded(new Runnable() { public void run() { try { List<VirtualFile> affectedFiles = ChangeUtils.unmergedFiles(myProject, root); while (affectedFiles.size() != 0) { AbstractVcsHelper.getInstance(myProject).showMergeDialog(affectedFiles, reverse ? myVcs.getReverseMergeProvider() : myVcs.getMergeProvider()); affectedFiles = ChangeUtils.unmergedFiles(myProject, root); if (affectedFiles.size() != 0) { int result = Messages.showYesNoDialog(myProject, Bundle.message("update.rebase.unmerged", StringUtil.escapeXml(root.getPresentableUrl())), Bundle.getString("update.rebase.unmerged.title"), Messages.getErrorIcon()); if (result != 0) { cancelled.set(true); return; } } } } catch (Throwable t) { ex.set(t); } } }); }
From source file:org.cordovastudio.actions.NewProjectAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent anActionEvent) { CordovaStudioNewProjectDialog dialog = new CordovaStudioNewProjectDialog(); dialog.show();// w w w . j a v a 2 s . c om if (dialog.isOK()) { LOG.info("Creating new Cordova project..."); /* * Create project with details from dialog */ final ProjectManager pm = ProjectManager.getInstance(); final String projectPath = dialog.getProjectPath(); final String projectName = dialog.getProjectName(); final String projectId = dialog.getProjectId(); if ("".equals(projectPath)) { Messages.showMessageDialog("Project Path can not be empty!", ERROR_MESSAGE_TITLE, Messages.getErrorIcon()); return; } File projectPathFileHandle = new File(projectPath); /* * Check if parent path exists, else create it (createParentDirs() does both of it) */ if (!FileUtilRt.createParentDirs(projectPathFileHandle)) { Messages.showMessageDialog("Project Path could not be created!", ERROR_MESSAGE_TITLE, Messages.getErrorIcon()); return; } File parentPath = projectPathFileHandle.getParentFile(); if (projectPathFileHandle.exists()) { if (projectPathFileHandle.list().length > 0) { Messages.showMessageDialog( "The specified project directory contains files. Cordova project can not be created there. You need to specify a non existent or empty directory.", ERROR_MESSAGE_TITLE, Messages.getErrorIcon()); return; } else { /* Delete File */ if (!FileUtilRt.delete(projectPathFileHandle)) { Messages.showMessageDialog( "The specified project directory could not be altered. Cordova project can not be created there. You need to have write access.", ERROR_MESSAGE_TITLE, Messages.getErrorIcon()); return; } } } /* * Attention! Cordova will try to create the TARGET directory, so it MUST NOT exist already. * The target's PARENT directory, though, MUST exist. */ String execStatement; if (DEBUG) { execStatement = PathMacros.getInstance().getValue("CORDOVA_EXECUTABLE") + " -d create " + projectPath + "/ " + projectId + " " + projectName; } else { execStatement = PathMacros.getInstance().getValue("CORDOVA_EXECUTABLE") + " create " + projectPath + "/ " + projectId + " " + projectName; } try { LOG.info("Trying to execute '" + execStatement + "'..."); Process proc = Runtime.getRuntime().exec(execStatement); proc.waitFor(); int exitCode = proc.exitValue(); if (exitCode > 0) { BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getErrorStream())); StringBuffer output = new StringBuffer(); String line = ""; while ((line = reader.readLine()) != null) { output.append(line + "\n"); } LOG.warn("Cordova process returned with ExitCode " + exitCode + ". Message: " + output.toString()); if (output.toString().contains("node: No such file or directory")) { Messages.showMessageDialog( "NodeJS binary not found. Please install NodeJS (from http://nodejs.org/) and check PATH environment variable.", ERROR_MESSAGE_TITLE, Messages.getErrorIcon()); } else { Messages.showMessageDialog("Cordova could not be executed. Exit code: " + exitCode + ". Message:\n" + output.toString(), ERROR_MESSAGE_TITLE, Messages.getErrorIcon()); } return; } else { BufferedReader reader = new BufferedReader(new InputStreamReader(proc.getInputStream())); StringBuffer output = new StringBuffer(); String line = ""; while ((line = reader.readLine()) != null) { output.append(line + "\n"); } LOG.info(output.toString()); LOG.info("Cordova project created. (ExitCode " + exitCode + ")"); } } catch (IOException e) { Messages.showMessageDialog("Cordova binaries could not be executed.\n" + e.getMessage(), ERROR_MESSAGE_TITLE, Messages.getErrorIcon()); } catch (InterruptedException e) { e.printStackTrace(); } /* Create IDEA project files (i.e. .idea directory) */ final Project project = pm.createProject(projectName, projectPath); LOG.assertTrue(project != null, "Project is null"); /* Create Cordova project */ ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { Module module = ModuleManager.getInstance(project).newModule( projectPath + "/" + projectName + ".iml", CordovaModuleTypeId.CORDOVA_MODULE); CordovaModuleBuilder moduleBuilder = CordovaModuleType.getInstance().createModuleBuilder(); moduleBuilder.commitModule(project, ModuleManager.getInstance(project).getModifiableModel()); FacetType type = FacetTypeRegistry.getInstance().findFacetType("cordova"); Facet facet = type.createFacet(module, "Cordova Facet", type.createDefaultConfiguration(), null); ModifiableFacetModel model = FacetManager.getInstance(module).createModifiableModel(); model.addFacet(facet); model.commit(); project.save(); } }); /* Load project */ // try { // pm.loadAndOpenProject(project.getBasePath()); // // /* Open /www/index.html in Editor */ // VirtualFile indexHtmlFile = LocalFileSystem.getInstance().findFileByIoFile(new File(project.getBasePath()+"/www/index.html")); // // if(indexHtmlFile == null) { // Messages.showMessageDialog("File '/www/index.html' could not be opened. Please check if it exists and try to reopen.", ERROR_MESSAGE_TITLE, Messages.getErrorIcon()); // return; // } // // //FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project, indexHtmlFile), true); // // } catch (Exception e) { // Messages.showMessageDialog(e.getMessage(), ERROR_MESSAGE_TITLE, Messages.getErrorIcon()); // } } }
From source file:org.cordovastudio.editors.designer.designSurface.CordovaDesignerEditorPanel.java
License:Apache License
protected void showErrorPage(final ErrorInfo info) { storeState();//w ww.j a v a 2 s . c om hideProgress(); myRootComponent = null; myErrorMessages.removeAll(); if (info.myShowStack) { ByteArrayOutputStream stream = new ByteArrayOutputStream(); info.myThrowable.printStackTrace(new PrintStream(stream)); myErrorStack.setText(stream.toString()); myErrorStackLayout.show(myErrorStackPanel, ERROR_STACK_CARD); } else { myErrorStack.setText(null); myErrorStackLayout.show(myErrorStackPanel, ERROR_NO_STACK_CARD); } addErrorMessage(new FixableMessageInfo(true, info.myDisplayMessage, "", "", null, null), Messages.getErrorIcon()); for (FixableMessageInfo message : info.myMessages) { addErrorMessage(message, message.myErrorIcon ? Messages.getErrorIcon() : Messages.getWarningIcon()); } myErrorPanel.revalidate(); myLayout.show(myPanel, ERROR_CARD); getDesignerToolWindow().refresh(true); repaint(); }
From source file:org.cordovastudio.editors.designer.propertyTable.PropertyTable.java
License:Apache License
private static void showInvalidInput(Exception e) { Throwable cause = e.getCause(); String message = cause == null ? e.getMessage() : cause.getMessage(); if (message == null || message.length() == 0) { message = "No message"; }/*w ww . j a va 2s .co m*/ Messages.showMessageDialog(MessageFormat.format("Error setting value: {0}", message), "Invalid Input", Messages.getErrorIcon()); }
From source file:org.cordovastudio.startup.CordovaStudioInitializer.java
License:Apache License
/** * Check for existence of Cordova executable and set (if applicable) path variables. * * @author Christoffer T. Timm <kontakt@christoffertimm.de> */// w w w .ja v a 2s . c om private static void initializePathVariables() { PathMacros pathMacros = PathMacros.getInstance(); String cordovaPath = pathMacros.getValue("CORDOVA_EXECUTABLE"); if (cordovaPath == null) { if (new File(DEFAULT_CORDOVA_EXECUTABLE_PATH).exists()) { pathMacros.setMacro("CORDOVA_EXECUTABLE", "/usr/local/bin/cordova"); } else { pathMacros.setMacro("CORDOVA_EXECUTABLE", ""); Messages.showMessageDialog( "Path to Cordova binary can not be found in default location (/usr/local/bin/). Please set 'CORDOVA_EXECUTABLE' in Path Variables in preferences!", "Cordova not found!", Messages.getErrorIcon()); } } }
From source file:org.evosuite.intellij.EvoAction.java
License:Open Source License
public void actionPerformed(AnActionEvent event) { String title = "EvoSuite Plugin"; Project project = event.getData(PlatformDataKeys.PROJECT); ToolWindowManager toolWindowManager = ToolWindowManager.getInstance(project); ToolWindow toolWindow = toolWindowManager.getToolWindow("EvoSuite"); final AsyncGUINotifier notifier = IntelliJNotifier.getNotifier(project); if (EvoSuiteExecutor.getInstance().isAlreadyRunning()) { Messages.showMessageDialog(project, "An instance of EvoSuite is already running", title, Messages.getErrorIcon()); return;/*w w w . java2s . co m*/ } Map<String, Set<String>> map = getCUTsToTest(event); if (map == null || map.isEmpty() || map.values().stream().mapToInt(Set::size).sum() == 0) { Messages.showMessageDialog(project, "No '.java' file or non-empty source folder was selected in a valid module", title, Messages.getErrorIcon()); return; } EvoStartDialog dialog = new EvoStartDialog(); dialog.initFields(project, EvoParameters.getInstance()); dialog.setModal(true); dialog.setLocationRelativeTo(null); //dialog.setLocationByPlatform(true); dialog.pack(); dialog.setVisible(true); if (dialog.isWasOK()) { toolWindow.show(() -> notifier.clearConsole()); EvoParameters.getInstance().save(project); EvoSuiteExecutor.getInstance().run(project, EvoParameters.getInstance(), map, notifier); } }