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.google.gct.intellij.endpoints.action.GenerateCloudBackendAction.java
License:Apache License
void doAction(final Project project, Module androidModule, GenerateBackendDialog dialog) { new CloudBackendGenerator(project, androidModule, dialog).generate(new CloudBackendGenerator.Callback() { @Override//from w ww .j a v a 2s .c o m public void backendCreated(@NotNull Module androidLibModule, @NotNull Module appEngineModule) { // We don't need to do anything here, the process is complete. } @Override public void onFailure(final String errorMessage) { ApplicationManager.getApplication().invokeLater(new Runnable() { @Override public void run() { Messages.showErrorDialog(project, "An error occurred during backend generation : " + errorMessage, MESSAGE_TITLE); } }); } }); }
From source file:com.google.gct.intellij.endpoints.action.GenerateCloudBackendAction.java
License:Apache License
protected boolean passesExternalChecks(Project project) { File mavenHome = MavenUtil.resolveMavenHomeDirectory(null); if (mavenHome == null) { Messages.showErrorDialog(project, "Could not find a valid installation of maven. " + "Perhaps you have not installed Maven or have not setup your Maven paths", MESSAGE_TITLE);// w w w.j av a 2s. co m return false; } String mavenVersion = MavenUtil.getMavenVersion(mavenHome.getAbsolutePath()); if (StringUtil.compareVersionNumbers("3", mavenVersion) > 0) { Messages.showErrorDialog(project, "Cloud Endpoints requires Maven version 3 or higher", MESSAGE_TITLE); return false; } if (MavenProjectsManager.getInstance(project).getGeneralSettings().isWorkOffline()) { Messages.showErrorDialog(project, "Could not connect to MavenCentral because Maven is in 'offline' mode. Switch maven to 'online' " + "mode and try again", MESSAGE_TITLE); return false; } if (!new File(AndroidSdkUtils.tryToChooseAndroidSdk().getLocation() + GctConstants.ANDROID_SDK_GCM_PATH) .exists()) { Messages.showErrorDialog(project, "Could not find gcm.jar. Please install the Android " + "SDK Extra : 'Google Cloud Messaging for Android Library' using the Android SDK Manager.", MESSAGE_TITLE); return false; } return true; }
From source file:com.google.gct.intellij.endpoints.action.GenerateEndpointAction.java
License:Apache License
@Override public void actionPerformed(AnActionEvent e) { // TODO: check if app engine module in here as well PsiJavaFile psiJavaFile = getPsiJavaFileFromContext(e); final Project project = e.getProject(); final Module module = e.getData(LangDataKeys.MODULE); if (psiJavaFile == null || module == null) { Messages.showErrorDialog(project, "Please select a Java file to create an Endpoint for", ERROR_MESSAGE_TITLE);/* w w w . j a v a 2 s . co m*/ return; } final AppEngineMavenProject appEngineMavenProject = AppEngineMavenProject.get(module); if (appEngineMavenProject == null) { Messages.showErrorDialog(project, "Please select a valid Maven enabled App Engine module", ERROR_MESSAGE_TITLE); return; } PsiClass entityClass = PsiUtils.getPublicAnnotatedClass(psiJavaFile, GctConstants.APP_ENGINE_ANNOTATION_ENTITY); if (entityClass == null) { Messages.showErrorDialog(project, "No JPA @Entity Class found in " + psiJavaFile.getName(), ERROR_MESSAGE_TITLE); return; } PsiField idField = PsiUtils.getAnnotatedFieldFromClass(entityClass, GctConstants.APP_ENGINE_ANNOTATION_ID); if (idField == null) { Messages.showErrorDialog(project, "No JPA @Id found in " + psiJavaFile.getName(), ERROR_MESSAGE_TITLE); return; } // TODO: this check is a little strange, but maybe necessary for information sake? if (idField.getType().getCanonicalText().equals(GctConstants.APP_ENGINE_TYPE_KEY)) { int retVal = Messages.showOkCancelDialog(project, "Endpoints with @Id of type " + GctConstants.APP_ENGINE_TYPE_KEY + " are not fully " + "compatible with the generation template and may require some user modification to work", "Warning", "Continue", "Cancel", Messages.getWarningIcon()); if (retVal != 0) { return; } } doAction(project, appEngineMavenProject, entityClass, idField); }
From source file:com.google.gct.intellij.endpoints.action.GenerateEndpointAction.java
License:Apache License
void doAction(final Project project, final AppEngineMavenProject appEngineMavenProject, PsiClass entityClass, PsiField idField) {// ww w.j a va 2 s . co m AppEngineEndpointGenerator generator = new AppEngineEndpointGenerator(appEngineMavenProject); try { generator.generateEndpoint(entityClass, idField); } catch (IOException e) { Messages.showErrorDialog(project, "Failed to generated an Endpoint class because : " + e.getMessage(), ERROR_MESSAGE_TITLE); LOG.error(e); } }
From source file:com.google.gct.intellij.endpoints.action.ui.GenerateBackendDialog.java
License:Apache License
@Override protected void doOKAction() { // TODO : this might be redundant ValidationInfo validationInfo = doValidate(); if (validationInfo != null) { Messages.showErrorDialog(myProjectNumField, "Cannot Generate Backend : ", validationInfo.message); return;//from www . j av a 2s. co m } myAppId = myAppIdField.getText().trim(); myProjectNum = myProjectNumField.getText().trim(); myApiKey = myApiKeyField.getText().trim(); super.doOKAction(); }
From source file:com.google.idea.blaze.android.resources.actions.BlazeCreateResourceFileDialog.java
License:Open Source License
@Override protected void doOKAction() { String fileName = myFileNameField.getText().trim(); final CreateTypedResourceFileAction action = getSelectedAction(myResourceTypeCombo); assert action != null; if (fileName.length() == 0) { Messages.showErrorDialog(myPanel, AndroidBundle.message("file.name.not.specified.error"), CommonBundle.getErrorTitle()); return;/*from w ww.ja va 2s . co m*/ } String rootElement = getRootElement(); if (!action.isChooseTagName() && rootElement.length() == 0) { Messages.showErrorDialog(myPanel, AndroidBundle.message("root.element.not.specified.error"), CommonBundle.getErrorTitle()); return; } final String subdirName = getSubdirName(); if (subdirName.length() == 0) { Messages.showErrorDialog(myPanel, AndroidBundle.message("directory.not.specified.error"), CommonBundle.getErrorTitle()); return; } final String errorMessage = getNameError(fileName); if (errorMessage != null) { Messages.showErrorDialog(myPanel, errorMessage, CommonBundle.getErrorTitle()); return; } PsiDirectory resDir = getResourceDirectory(); if (resDir == null) { Messages.showErrorDialog(myPanel, AndroidBundle.message("check.resource.dir.error", myFacet.getModule()), CommonBundle.getErrorTitle()); super.doOKAction(); return; } myValidator = myValidatorFactory.create(resDir, subdirName, rootElement); if (myValidator.checkInput(fileName) && myValidator.canClose(fileName)) { super.doOKAction(); } }
From source file:com.google.idea.blaze.base.projectview.ProjectViewEdit.java
License:Open Source License
private void apply(boolean isApply) { SaveUtil.saveAllFiles();/*from w w w . java 2 s.co m*/ for (Modification modification : modifications) { ProjectView projectView = isApply ? modification.newProjectView : modification.oldProjectView; String projectViewText = ProjectViewParser.projectViewToString(projectView); try { ProjectViewStorageManager.getInstance().writeProjectView(projectViewText, modification.projectViewFile); } catch (IOException e) { LOG.error(e); Messages.showErrorDialog(project, "Could not write updated project view. Is the file write protected?", "Edit Failed"); } } }
From source file:com.google.idea.blaze.base.ui.BlazeValidationError.java
License:Open Source License
/** * Shows an error dialog.//w w w . ja v a2s. c om * * @return true if there are no errors */ public static boolean verify(@NotNull Project project, @NotNull String title, @NotNull Collection<BlazeValidationError> errors) { if (!errors.isEmpty()) { BlazeValidationError error = errors.iterator().next(); Messages.showErrorDialog(project, error.getError(), title); return false; } return true; }
From source file:com.google.idea.blaze.clwb.wizard2.BlazeNewProjectWizard.java
License:Open Source License
private boolean commitStepData(ProjectImportWizardStep step) { try {//from w ww . ja v a 2 s . c o m if (!step.validate()) { return false; } } catch (ConfigurationException e) { Messages.showErrorDialog(myContentPanel, e.getMessage(), e.getTitle()); return false; } step.updateDataModel(); return true; }
From source file:com.google.idea.blaze.java.libraries.AttachSourceJarAction.java
License:Open Source License
@Override public void actionPerformed(AnActionEvent e) { Project project = e.getProject();// ww w .j a va2 s .c o m assert project != null; BlazeProjectData blazeProjectData = BlazeProjectDataManager.getInstance(project).getBlazeProjectData(); if (blazeProjectData == null) { return; } Library library = LibraryActionHelper.findLibraryForAction(e); if (library != null) { BlazeJarLibrary blazeLibrary = LibraryActionHelper.findLibraryFromIntellijLibrary(project, blazeProjectData, library); if (blazeLibrary == null) { Messages.showErrorDialog(project, "Could not find this library in the project.", CommonBundle.getErrorTitle()); return; } final LibraryArtifact libraryArtifact = blazeLibrary.libraryArtifact; if (libraryArtifact.sourceJar == null) { return; } SourceJarManager sourceJarManager = SourceJarManager.getInstance(project); boolean attachSourceJar = !sourceJarManager.hasSourceJarAttached(blazeLibrary.key); sourceJarManager.setHasSourceJarAttached(blazeLibrary.key, attachSourceJar); ApplicationManager.getApplication().runWriteAction(() -> { LibraryTable libraryTable = ProjectLibraryTable.getInstance(project); LibraryTable.ModifiableModel libraryTableModel = libraryTable.getModifiableModel(); LibraryEditor.updateLibrary(project, blazeProjectData.artifactLocationDecoder, libraryTable, libraryTableModel, blazeLibrary); libraryTableModel.commit(); }); } }