List of usage examples for com.intellij.openapi.ui Messages showErrorDialog
public static void showErrorDialog(@Nullable Component component, String message, @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title)
From source file:com.facebook.plugin.config.GradleBuildConfigurator.java
License:Open Source License
@Override public void doConfigure(final Module module) { final GroovyFile gradleFile = getBuildGradleFile(module.getProject(), module); if ((gradleFile != null) && WritingAccessProvider.isPotentiallyWritable(gradleFile.getVirtualFile(), null)) { new WriteCommandAction(gradleFile.getProject()) { @Override/*from w ww . ja va 2 s . c o m*/ protected void run(@NotNull Result result) { final GrClosableBlock repositoriesBlock = findOrCreateBlock(gradleFile, BLOCK_REPOSITORIES); if (!repositoriesBlock.getText().contains(repository)) { addChildExpression(repositoriesBlock, FORMAT_REPOSITORY.replace("{repository}", repository)); } final GrClosableBlock dependenciesBlock = findOrCreateBlock(gradleFile, BLOCK_DEPENDENCIES); if (!repositoriesBlock.getText().contains(library)) { addChildExpression(dependenciesBlock, FORMAT_DEPENDENCY.replace("{library}", library).replace("{version}", version)); } CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(gradleFile); } }.execute(); OpenFileAction.openFile(gradleFile.getVirtualFile().getPath(), module.getProject()); } else { Messages.showErrorDialog(module.getProject(), "Cannot find or modify build.gradle file for module " + module.getName(), "Facebook SDK Plugin"); } }
From source file:com.facebook.plugin.ui.AccountKitInstallActivityForm.java
License:Open Source License
@Override public boolean commitForm() { AccountKitActivityConfigurator.AvailableActivity activity = (AccountKitActivityConfigurator.AvailableActivity) activitySelector .getSelectedItem();//from www.j av a2s . com if ((activity == null) || (activity.getPsiClass() == null)) { Messages.showErrorDialog(project, "Please select a valid activity to continue.", "Install Failed"); return false; } if (StringUtils.isBlank(requestCodeField.getText())) { Messages.showErrorDialog(project, "Request Code cannot be blank.", "Install Failed"); return false; } AccountKitActivityConfigurator activityConfigurator; try { activityConfigurator = new AccountKitActivityConfigurator(requestCodeField.getText()); } catch (Exception e) { Messages.showErrorDialog(project, "Failed to load the activity configurator code.", "Install Failed"); return false; } if (!activityConfigurator.isConfigured(activity.getPsiClass())) { activityConfigurator.doConfigure(activity.getPsiClass()); } return true; }
From source file:com.facebook.plugin.ui.AccountKitInstallDependenciesForm.java
License:Open Source License
@Override public boolean commitForm() { AccountKitModuleConfigurator.AvailableModule selectedModule = (AccountKitModuleConfigurator.AvailableModule) moduleSelector .getSelectedItem();//from w w w .ja va2s . c o m if (selectedModule == null) { Messages.showErrorDialog(project, "Please select a module to continue.", "Install Failed"); return false; } if (selectedModule.getInstallationType() == AccountKitModuleConfigurator.InstallationType.CannotInstall) { Messages.showErrorDialog(project, "Cannot install AccountKit on module " + selectedModule.getModule().getName() + " because it either is not an Android module " + "or is not built using Gradle.", "Install Failed"); return false; } if (selectedModule .getInstallationType() == AccountKitModuleConfigurator.InstallationType.AlreadyInstalled) { return true; } if (StringUtils.isBlank(appNameField.getText())) { Messages.showErrorDialog(project, "App Name cannot be blank.", "Install Failed"); return false; } if (StringUtils.isBlank(appIdField.getText()) || !StringUtils.isNumeric(appIdField.getText())) { Messages.showErrorDialog(project, "App Id must be a valid number.", "Install Failed"); return false; } if (StringUtils.isBlank(clientTokenField.getText())) { Messages.showErrorDialog(project, "Client Token cannot be blank.", "Install Failed"); return false; } AccountKitModuleConfigurator accountKitModuleConfigurator = new AccountKitModuleConfigurator( appNameField.getText(), appIdField.getText(), clientTokenField.getText()); if (!accountKitModuleConfigurator.isConfigured(selectedModule.getModule())) { try { accountKitModuleConfigurator.doConfigure(selectedModule.getModule()); } catch (Exception e) { Messages.showErrorDialog(project, "Something went wrong while installing module " + selectedModule.getModule().getName() + ": \n" + e.getMessage(), "Install Failed"); } } return true; }
From source file:com.github.intelliguard.action.AbstractExportAction.java
License:Apache License
public void actionPerformed(AnActionEvent e) { final Module module = getModule(e); if (module == null) { return;/*from w ww . j a va 2 s. co m*/ } final GuardFacet guardFacet = getGuardFacet(module); if (guardFacet == null) { return; } final ExportOptionsForm exportOptionsForm = FormDialogWrapper.showExportOptionsForm(guardFacet); if (exportOptionsForm == null) { // user aborted return; } GuardFacetConfiguration configuration = guardFacet.getConfiguration(); configuration.mainclass = exportOptionsForm.getMainClass(); configuration.inFile = exportOptionsForm.getJarPath(); configuration.outFile = exportOptionsForm.getObfuscatedJarPath(); String errorMessage = null; if (configuration.inFile.length() == 0) { errorMessage = "Output jar path not specified"; } else if (configuration.outFile.length() == 0) { errorMessage = "Obfuscation jar path not specified"; } else if (configuration.inFile.equals(configuration.outFile)) { errorMessage = "Output jar path and obfuscated jar path can not be the same"; } if (errorMessage != null) { Messages.showErrorDialog(module.getProject(), errorMessage, "Export error"); return; } // output configuration to toolwindow final String config = generateConfiguration(guardFacet); final ProgressInfoReceiver receiver = module.getProject().getComponent(GuardProjectComponent.class) .createProgressInfoReceiver(); receiver.info(config); // ask for saving to file final int answer = Messages.showYesNoCancelDialog(module.getProject(), "Would you like to export configuration to a file?", "Export configuration", Icons.OBFUSCATION_NODE_ICON); if (answer == 0) { // show file chooser final Component component = DataKeys.CONTEXT_COMPONENT.getData(e.getDataContext()); final JFileChooser jFileChooser = FileChooserFactory.createPreferredDirectoryFileChooser( "Save '" + module.getName() + "' obfuscation settings", module.getModuleFilePath()); // suggest a suitable name for the output file jFileChooser.setSelectedFile(new File(jFileChooser.getCurrentDirectory(), module.getName() + "-obfuscation." + getConfigFileExtension())); int res = jFileChooser.showSaveDialog(component); if (res == JFileChooser.APPROVE_OPTION) { final File selectedFile = jFileChooser.getSelectedFile(); if (!selectedFile.exists() || selectedFile.canWrite()) { dumpFile(config, selectedFile); } } } UiUtils.showInfoBallon(module.getProject(), "Generated obfuscation settings"); }
From source file:com.github.intelliguard.action.RunObfuscationAction.java
License:Apache License
public void actionPerformed(AnActionEvent e) { final Module module = e.getData(DataKeys.MODULE); if (module == null) { System.out.println("RunObfuscationAction.actionPerformed: no Module"); return;/*w w w. j a v a 2 s.c o m*/ } final GuardFacet guardFacet = GuardFacet.getInstance(module); if (guardFacet == null) { System.out.println("RunObfuscationAction.actionPerformed: no GuardFacet"); return; } VirtualFile baseDir = module.getProject().getBaseDir(); if (baseDir == null) { System.out.println("RunObfuscationAction.actionPerformed: no baseDir"); return; } if (guardFacet.getConfiguration().yGuardJar == null) { Messages.showErrorDialog(module.getProject(), "Missing yGuard archive\n\nPlease check Obfuscation facet settings.", "Obfuscation error"); return; } final ValidationResult yGuardValidationResult = ObfuscatorUtils .checkYGuard(guardFacet.getConfiguration().yGuardJar); if (yGuardValidationResult != ValidationResult.OK) { Messages.showErrorDialog(module.getProject(), "Invalid yGuard archive: " + yGuardValidationResult.getErrorMessage() + "\n\nPlease check Obfuscation facet settings.", "Obfuscation error"); return; } File outputDir = ModuleUtils.getModuleOutputDir(module); if (outputDir != null) { guardFacet.getConfiguration().jarConfig.addEntry(outputDir.getAbsolutePath()); } JarOptionsForm jarOptionsForm = FormDialogWrapper.showJarOptionsForm(guardFacet); if (jarOptionsForm != null) { GuardFacetConfiguration configuration = guardFacet.getConfiguration(); configuration.jarConfig.setLinkLibraries(jarOptionsForm.getLibrariesManifestPath()); configuration.mainclass = jarOptionsForm.getMainClass(); configuration.inFile = jarOptionsForm.getJarPath(); configuration.outFile = jarOptionsForm.getObfuscatedJarPath(); String errorMessage = null; if (configuration.inFile.length() == 0) { errorMessage = "Output jar path not specified"; } else if (configuration.outFile.length() == 0) { errorMessage = "Obfuscation jar path not specified"; } else if (configuration.inFile.equals(configuration.outFile)) { errorMessage = "Output jar path and obfuscated jar path can not be the same"; } if (errorMessage != null) { Messages.showErrorDialog(module.getProject(), errorMessage, "Obfuscation error"); return; } final File inJar = new File(configuration.inFile); final File outJar = new File(configuration.outFile); final RunProgress runProgress = new RunProgress( module.getProject().getComponent(GuardProjectComponent.class).createProgressInfoReceiver()); final Runnable jarTask = new JarTask(runProgress, module, configuration.jarConfig, configuration.mainclass, inJar); final Runnable obfuscateTask = new ObfuscateTask(runProgress, guardFacet); if (jarOptionsForm.getExecuteMake()) { CompilerManager compilerManager = CompilerManager.getInstance(module.getProject()); compilerManager.make(module.getProject(), new Module[] { module }, new CompileStatusNotification() { public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) { if (errors == 0 && !aborted) { ProgressManager.getInstance().runProcessWithProgressSynchronously(jarTask, "Building jar " + inJar.getName(), true, module.getProject()); if (runProgress.lookingGood()) { ProgressManager.getInstance().runProcessWithProgressSynchronously(obfuscateTask, "Obfuscating jar " + inJar.getName(), true, module.getProject()); if (runProgress.lookingGood()) { UiUtils.showInfoBallon(module.getProject(), "Obfuscated jar: " + outJar.getAbsolutePath()); } else { UiUtils.showErrorBallon(module.getProject(), "Error obfuscating jar " + outJar.getAbsolutePath()); } } else { UiUtils.showErrorBallon(module.getProject(), "Error building jar " + inJar.getAbsolutePath()); } } else { runProgress.markError("Obfuscation aborted. Compilation errors: " + errors); UiUtils.showErrorBallon(module.getProject(), "Obfuscation aborted. Compilation errors: " + errors); } } }); } else { ProgressManager.getInstance().runProcessWithProgressSynchronously(jarTask, "Building jar " + inJar.getName(), true, module.getProject()); if (runProgress.lookingGood()) { ProgressManager.getInstance().runProcessWithProgressSynchronously(obfuscateTask, "Obfuscating jar " + inJar.getName(), true, module.getProject()); if (runProgress.lookingGood()) { UiUtils.showInfoBallon(module.getProject(), "Obfuscated jar: " + outJar.getAbsolutePath()); } else { UiUtils.showErrorBallon(module.getProject(), "Error obfuscating jar " + outJar.getAbsolutePath()); } } else { UiUtils.showErrorBallon(module.getProject(), "Error building jar " + inJar.getAbsolutePath()); } } } }
From source file:com.github.pshirshov.ShowByteCodeAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { final DataContext dataContext = e.getDataContext(); final Project project = e.getProject(); if (project == null) { return;/*from w w w. j a va 2s .c o m*/ } final Editor editor = e.getData(CommonDataKeys.EDITOR); final PsiElement psiElement = PsiUtils.getPsiElement(dataContext, project, editor); if (psiElement == null) { return; } final String psiElementTitle = PsiUtils.getTitle(psiElement); final VirtualFile virtualFile = PsiUtilCore.getVirtualFile(psiElement); if (virtualFile == null) { return; } final SmartPsiElementPointer element = SmartPointerManager.getInstance(project) .createSmartPsiElementPointer(psiElement); ProgressManager.getInstance().run(new Task.Backgroundable(project, "Looking for bytecode...") { private String myByteCode; private String myErrorMessage; private String myErrorTitle; @Override public void run(@NotNull ProgressIndicator indicator) { if (ProjectRootManager.getInstance(project).getFileIndex().isInContent(virtualFile) && isMarkedForCompilation(project, virtualFile)) { myErrorMessage = "Unable to show bytecode for '" + psiElementTitle + "'. Class file does not exist or is out-of-date."; myErrorTitle = "Class File Out-Of-Date"; } else { myByteCode = ApplicationManager.getApplication().runReadAction(new Computable<String>() { @Override public String compute() { return new BytecodeConverter(disassembleStrategy).getByteCode(psiElement); } }); } } @Override public void onSuccess() { if (project.isDisposed()) { return; } if ((myErrorMessage != null) && (myTitle != null)) { Messages.showWarningDialog(project, myErrorMessage, myErrorTitle); return; } final PsiElement targetElement = element.getElement(); if (targetElement == null) { return; } if (myByteCode == null) { Messages.showErrorDialog(project, "Unable to parse class file for '" + psiElementTitle + "'.", "Bytecode not Found"); return; } PsiClass psiClass = PsiUtils.getContainingClass(psiElement); FileEditorManager manager = FileEditorManager.getInstance(project); final String filename = '/' + psiClass.getQualifiedName().replace('.', '/') + ".bc"; BCEVirtualFile BCEVirtualFile = new BCEVirtualFile(filename, JavaClassFileType.INSTANCE, myByteCode.getBytes(), psiElement, disassembleStrategy); for (FileEditor fileEditor : FileEditorManager.getInstance(project).getAllEditors()) { if (fileEditor instanceof ByteCodeEditor) { final ByteCodeEditor asBce = (ByteCodeEditor) fileEditor; if (asBce.getFile().getPath().equals(BCEVirtualFile.getPath())) { FileEditorManager.getInstance(project).openFile(asBce.getFile(), true, true); asBce.update(BCEVirtualFile); return; } } } manager.openFile(BCEVirtualFile, true, true); } }); }
From source file:com.goide.runconfig.before.GoBeforeRunTaskProvider.java
License:Apache License
private static void showAddingTaskErrorMessage(Project project, String message) { Messages.showErrorDialog(project, message, "Go Command Task"); }
From source file:com.google.cloud.tools.intellij.debugger.CloudDebugProcessStateController.java
License:Apache License
/** * Called from the {@link CloudBreakpointHandler} to remove breakpoints from the server. * * @param breakpointId the {@link Breakpoint} Id to delete *///from w w w. j a v a2 s .com private void deleteBreakpoint(@NotNull final String breakpointId, boolean performAsync) { if (state == null) { throw new IllegalStateException(); } final Debugger client = CloudDebuggerClient.getLongTimeoutClient(state); if (client == null) { LOG.warn("no client available attempting to setBreakpoint"); Messages.showErrorDialog(state.getProject(), GctBundle.getString("clouddebug.bad.login.message"), GctBundle.getString("clouddebug.message.title")); return; } final String debuggeeId = state.getDebuggeeId(); assert debuggeeId != null; Runnable performDelete = new Runnable() { @Override public void run() { try { client.debuggees().breakpoints().delete(debuggeeId, breakpointId) .setClientVersion(ServiceManager.getService(CloudToolsPluginInfoService.class) .getClientVersionForCloudDebugger()) .execute(); } catch (IOException ex) { LOG.warn("exception deleting breakpoint " + breakpointId, ex); } } }; if (performAsync) { ApplicationManager.getApplication().executeOnPooledThread(performDelete); } else { performDelete.run(); } }
From source file:com.google.cloud.tools.intellij.vcs.SetupCloudRepositoryAction.java
License:Apache License
private static boolean isGitSupported(final Project project) { final GitVcsApplicationSettings settings = GitVcsApplicationSettings.getInstance(); final String executable = settings.getPathToGit(); final GitVersion version; try {/* ww w . j a va 2s . c o m*/ version = GitVersion.identifyVersion(executable); } catch (Exception ex) { Messages.showErrorDialog(project, GctBundle.message("uploadtogcp.giterror"), ex.getMessage()); return false; } if (!version.isSupported()) { Messages.showWarningDialog(project, GctBundle.message("uploadtogcp.git.unsupported.message", version.toString(), GitVersion.MIN), GctBundle.message("uploadtogcp.giterror")); return false; } return true; }
From source file:com.google.cloud.tools.intellij.vcs.UploadSourceAction.java
License:Apache License
private static void uploadProjectToGoogleCloud(@NotNull final Project project, @Nullable final VirtualFile file) { BasicAction.saveAll();//from w ww .j a v a2 s . com project.save(); final GitRepository gitRepository = getGitRepository(project, file); final boolean gitDetected = gitRepository != null; final VirtualFile root = gitDetected ? gitRepository.getRoot() : project.getBaseDir(); // check for existing git repo boolean externalRemoteDetected = false; if (gitDetected) { final String gcpRemote = GcpHttpAuthDataProvider.findGcpRemoteUrl(gitRepository); if (gcpRemote != null) { Messages.showErrorDialog(project, GctBundle.message("uploadtogcp.alreadyexists"), "Google"); return; } externalRemoteDetected = !gitRepository.getRemotes().isEmpty(); } ChooseProjectDialog dialog = new ChooseProjectDialog(project, GctBundle.message("uploadtogcp.selecttext"), GctBundle.message("uploadtogcp.oktext")); DialogManager.show(dialog); if (!dialog.isOK() || dialog.getCredentialedUser() == null || Strings.isNullOrEmpty(dialog.getProjectId())) { return; } final String projectId = dialog.getProjectId(); final CredentialedUser user = dialog.getCredentialedUser(); // finish the job in background final boolean finalExternalRemoteDetected = externalRemoteDetected; new Task.Backgroundable(project, GctBundle.message("uploadtogcp.backgroundtitle")) { @Override public void run(@NotNull ProgressIndicator indicator) { // creating empty git repo if git is not initialized LOG.info("Binding local project with Git"); if (!gitDetected) { LOG.info("No git detected, creating empty git repo"); indicator.setText(GctBundle.message("uploadtogcp.indicatorinit")); if (!createEmptyGitRepository(project, root, indicator)) { return; } } GitRepositoryManager repositoryManager = GitUtil.getRepositoryManager(project); final GitRepository repository = repositoryManager.getRepositoryForRoot(root); LOG.assertTrue(repository != null, "GitRepository is null for root " + root); if (repository == null) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { Messages.showErrorDialog(project, GctBundle.message("uploadtogcp.failedtocreategit"), "Google"); } }); return; } final String remoteUrl = GcpHttpAuthDataProvider.getGcpUrl(projectId); final String remoteName = finalExternalRemoteDetected ? "cloud-platform" : "origin"; LOG.info("Adding Google as a remote host"); indicator.setText(GctBundle.message("uploadtogcp.addingremote")); if (!addGitRemote(project, repository, remoteName, remoteUrl)) { return; } boolean succeeded = false; try { PropertiesComponent.getInstance(project).setValue(GcpHttpAuthDataProvider.GCP_USER, user.getEmail()); LOG.info("Fetching from Google remote"); indicator.setText(GctBundle.message("uploadtogcp.fetching")); if (!fetchGit(project, indicator, repository, remoteName) || hasRemoteBranch(project, repository, remoteName, projectId)) { return; } // create sample commit for binding project if (!performFirstCommitIfRequired(project, root, repository, indicator)) { return; } //git push origin master LOG.info("Pushing to Google master"); indicator.setText(GctBundle.message("uploadtogcp.pushingtotgcp")); if (!pushCurrentBranch(project, repository, remoteName, remoteUrl)) { return; } succeeded = true; } finally { if (!succeeded) { //remove the remote if possible on a failure, so the user can try again. removeGitRemote(project, repository, remoteName); } } showInfoUrl(project, remoteName, GctBundle.message("uploadtogcp.success"), remoteUrl); } }.queue(); }