com.intellij.openapi.ui.ex.MessagesEx Java Examples

The following examples show how to use com.intellij.openapi.ui.ex.MessagesEx. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FrameDiffTool.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static boolean askForceOpenDiff(DiffRequest data) {
  byte[] bytes1;
  byte[] bytes2;
  try {
    bytes1 = data.getContents()[0].getBytes();
    bytes2 = data.getContents()[1].getBytes();
  }
  catch (IOException e) {
    MessagesEx.error(data.getProject(), e.getMessage()).showNow();
    return false;
  }
  String message = Arrays.equals(bytes1, bytes2)
                   ? DiffBundle.message("diff.contents.are.identical.message.text")
                   : DiffBundle.message("diff.contents.have.differences.only.in.line.separators.message.text");
  Messages.showInfoMessage(data.getProject(), message, DiffBundle.message("no.differences.dialog.title"));
  return false;
  //return Messages.showDialog(data.getProject(), message + "\nShow diff anyway?", "No Differences", new String[]{"Yes", "No"}, 1,
  //                    Messages.getQuestionIcon()) == 0;
}
 
Example #2
Source File: HaskellModuleFilenameFix.java    From intellij-haskforce with Apache License 2.0 5 votes vote down vote up
/**
 * Called when user invokes intention.
 */
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
    VirtualFile vFile = file.getVirtualFile();
    Document document = PsiDocumentManager.getInstance(project).getDocument(file);
    if (document == null) return;

    FileDocumentManager.getInstance().saveDocument(document);
    try {
        vFile.rename(file.getManager(), myTargetName);
    } catch (IOException e) {
        MessagesEx.error(project, e.getMessage()).showLater();
    }
}
 
Example #3
Source File: RenameFileFix.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void invoke(@Nonnull Project project, Editor editor, PsiFile file) {
  VirtualFile vFile = file.getVirtualFile();
  Document document = PsiDocumentManager.getInstance(project).getDocument(file);
  FileDocumentManager.getInstance().saveDocument(document);
  try {
    vFile.rename(file.getManager(), myNewFileName);
  }
  catch(IOException e){
    MessagesEx.error(project, e.getMessage()).showLater();
  }
}
 
Example #4
Source File: AbstractLayoutCodeProcessor.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean checkFileWritable(final PsiFile file) {
  if (!file.isWritable()) {
    MessagesEx.fileIsReadOnly(myProject, file.getVirtualFile()).setTitle(CodeInsightBundle.message("error.dialog.readonly.file.title")).showLater();
    return false;
  }
  else {
    return true;
  }
}
 
Example #5
Source File: TalendModuleBuilder.java    From component-runtime with Apache License 2.0 4 votes vote down vote up
@Override
public Module createModule(final ModifiableModuleModel moduleModel) throws InvalidDataException, IOException,
        ModuleWithNameAlreadyExists, ConfigurationException, JDOMException {
    final Module module = super.createModule(moduleModel);
    getApplication().invokeLater(() -> {
        ProgressManager.getInstance().runProcessWithProgressSynchronously(() -> {
            final ProjectDownloader downloader = new ProjectDownloader(this, request);
            try {
                downloader.download(ProgressManager.getInstance().getProgressIndicator());
            } catch (IOException e) {
                getApplication()
                        .invokeLater(() -> MessagesEx
                                .showErrorDialog(e.getMessage(), getMessage("download.project.file.error")));
            }
        }, getMessage("download.project.file"), true, null);

        final Project moduleProject = module.getProject();
        switch (jsonProject.get("buildType").getAsString()) {
        case "Maven":
            final VirtualFile pomFile = findFileUnderRootInModule(module, "pom.xml");
            if (pomFile != null) {
                final MavenProjectsManager mavenProjectsManager = MavenProjectsManager.getInstance(moduleProject);
                mavenProjectsManager.addManagedFiles(singletonList(pomFile));
            }
            break;
        case "Gradle":
            final VirtualFile gradleFile = findFileUnderRootInModule(module, "build.gradle");
            if (gradleFile != null) {
                final ProjectDataManager projectDataManager = getService(ProjectDataManager.class);
                // todo: move to JavaGradleProjectImportBuilder
                final GradleProjectImportBuilder importBuilder = new GradleProjectImportBuilder(projectDataManager);
                final GradleProjectImportProvider importProvider = new GradleProjectImportProvider(importBuilder);
                final AddModuleWizard addModuleWizard =
                        new AddModuleWizard(moduleProject, gradleFile.getPath(), importProvider);
                if (addModuleWizard.getStepCount() == 0 && addModuleWizard.showAndGet()) {
                    // user chose to import via the gradle import prompt
                    importBuilder.commit(moduleProject, null, null);
                }
            }
            break;
        default:
            break;
        }

    }, ModalityState.current());
    return module;
}