Example usage for com.intellij.openapi.ui Messages getQuestionIcon

List of usage examples for com.intellij.openapi.ui Messages getQuestionIcon

Introduction

In this page you can find the example usage for com.intellij.openapi.ui Messages getQuestionIcon.

Prototype

@NotNull
    public static Icon getQuestionIcon() 

Source Link

Usage

From source file:gradleplug.ResolverLoader.java

License:Apache License

public boolean loadGradle() {
    final AtomicBoolean result = new AtomicBoolean();
    UIUtil.invokeAndWaitIfNeeded(new Runnable() {
        public void run() {
            String gradleHome = getGradleHomeFromProjectSettings();
            if (gradleHome == null) {
                boolean takeToGradleSettings = Messages.showYesNoDialog(
                        GradlePlugBundle.message("no.configured.gradle.message"),
                        GradlePlugBundle.message("no.configured.gradle.title"),
                        Messages.getQuestionIcon()) == 0;
                if (takeToGradleSettings) {
                    ShowSettingsUtil.getInstance().showSettingsDialog(project, "Gradle");
                    gradleHome = getGradleHomeFromProjectSettings();
                }//from   w w w . jav  a  2  s.co  m
            }
            if (gradleHome != null && !gradleHome.equals(ResolverLoader.this.gradleHome)) {
                ResolverLoader.this.gradleHome = gradleHome;
                reloadResolver(gradleHome);
            }
            result.set(gradleHome != null);
        }
    });
    return result.get();
}

From source file:intellijeval.toolwindow.NewFileAction.java

License:Apache License

private static void createNewFile(FileSystemTree fileSystemTree, final FileType fileType,
        final String initialContent) {
    final VirtualFile file = fileSystemTree.getNewFileParent();
    if (file == null || !file.isDirectory())
        return;//from   w  ww  .j a va2 s .  c  o m

    String newFileName;
    while (true) {
        newFileName = Messages.showInputDialog(
                UIBundle.message("create.new.file.enter.new.file.name.prompt.text"),
                UIBundle.message("new.file.dialog.title"), Messages.getQuestionIcon());
        if (newFileName == null) {
            return;
        }
        if ("".equals(newFileName.trim())) {
            Messages.showMessageDialog(
                    UIBundle.message("create.new.file.file.name.cannot.be.empty.error.message"),
                    UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
            continue;
        }
        Exception failReason = ((FileSystemTreeImpl) fileSystemTree).createNewFile(file, newFileName, fileType,
                initialContent);
        if (failReason != null) {
            Messages.showMessageDialog(
                    UIBundle.message("create.new.file.could.not.create.file.error.message", newFileName),
                    UIBundle.message("error.dialog.title"), Messages.getErrorIcon());
            continue;
        }
        return;
    }
}

From source file:io.ballerina.plugins.idea.sdk.BallerinaSdkUtils.java

License:Open Source License

@Messages.YesNoResult
public static void showRestartDialog(Project project) {
    ApplicationManager.getApplication().invokeLater(() -> {
        String action = project != null && ProjectManagerEx.getInstanceEx().canClose(project) ? "Reload Project"
                : "Restart IDE";
        String message = "Project/IDE reloading action is required to apply changes. Do you wish to continue?";
        if (Messages.showYesNoDialog(message, "Apply Changes", action, "Postpone",
                Messages.getQuestionIcon()) == Messages.YES) {
            if (action.equals("Reload Project")) {
                ProjectManagerEx.getInstanceEx().reloadProject(project);
            } else {
                ApplicationManagerEx.getApplicationEx().restart(true);
            }/* w  w  w  . jav  a  2s. c om*/
        }
    });
}

From source file:ivyplug.ResolverLoader.java

License:Apache License

public boolean loadIvy() {
    final AtomicBoolean result = new AtomicBoolean();
    UIUtil.invokeAndWaitIfNeeded(new Runnable() {
        public void run() {
            File ivyHome = getIvyHomeFromProjectSettings();
            if (ivyHome == null) {
                boolean takeToIvyPlugSettings = Messages.showYesNoDialog(
                        IvyPlugBundle.message("no.configured.ivy.message.description"),
                        IvyPlugBundle.message("no.configured.ivy.message.title"),
                        Messages.getQuestionIcon()) == 0;
                if (takeToIvyPlugSettings) {
                    ShowSettingsUtil.getInstance().showSettingsDialog(project,
                            IvyPlugBundle.message("ivyplug.project.configuration.tab.title"));
                    ivyHome = getIvyHomeFromProjectSettings();
                }//from   w  w w .ja v a2s .c  o m
            }
            if (ivyHome != null && !ivyHome.equals(ResolverLoader.this.ivyHome)) {
                ResolverLoader.this.ivyHome = ivyHome;
                reloadResolver(ivyHome);
            }
            result.set(ivyHome != null);
        }
    });
    return result.get();
}

From source file:jetbrains.communicator.idea.IDEAFacade.java

License:Apache License

@Override
public String getMessageLine(String labelText, String titleText) {
    return Messages.showInputDialog(labelText, titleText, Messages.getQuestionIcon());
}

From source file:jetbrains.communicator.jabber.JabberConnectionCommand.java

License:Apache License

public void execute() {
    if (isConnected()) {
        if (Messages.YES == Messages.showYesNoDialog(StringUtil.getMsg("disconnect.from.jabber.account"),
                StringUtil.getMsg("disconnect.confirmation"), Messages.getQuestionIcon())) {
            myJabberFacade.disconnect();
            myJabberFacade.getMyAccount().setLoginAllowed(false);
            myJabberFacade.saveSettings();
        }// ww w  .  j  ava 2s  .co  m
    } else {
        myJabberUi.login(myParentComponent);
    }
}

From source file:liveplugin.IDEUtil.java

License:Apache License

public static void askIsUserWantsToRestartIde(String message) {
    int answer = showOkCancelDialog(message, "Restart Is Required", "Restart", "Postpone",
            Messages.getQuestionIcon());
    if (answer == Messages.OK) {
        ApplicationManagerEx.getApplicationEx().restart(true);
    }//from  w  w w  .  ja va2  s. c om
}

From source file:manuylov.maxim.ocaml.actions.BaseCreateOCamlFileAction.java

License:Open Source License

@Override
protected void invokeDialog(@Nonnull final Project project, @Nonnull final PsiDirectory directory,
        Consumer<PsiElement[]> elementsConsumer) {
    final MyInputValidator validator = new MyInputValidator(project, directory);
    Messages.showInputDialog(project, "Enter module name:",
            "New OCaml Module " + getCapitalizedType() + " File", Messages.getQuestionIcon(), null, validator);
    elementsConsumer.accept(validator.getCreatedElements());
}

From source file:manuylov.maxim.ocaml.actions.SwitchModuleFileAction.java

License:Open Source License

public void actionPerformed(final AnActionEvent e) {
    final Project project = e.getProject();
    if (project == null) {
        return;/*from  w w  w .  j a v a 2  s  .  c o m*/
    }

    final IdeView view = e.getData(LangDataKeys.IDE_VIEW);
    if (view == null) {
        return;
    }

    final VirtualFile file = e.getData(PlatformDataKeys.VIRTUAL_FILE);
    if (file == null) {
        return;
    }

    final VirtualFile parent = file.getParent();
    if (parent == null) {
        return;
    }

    final File anotherFile = new File(parent.getPath(), OCamlFileUtil.getAnotherFileName(file));
    VirtualFile anotherVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(anotherFile);

    if (anotherVirtualFile == null) {
        final String anotherFilePath = FileUtil.toSystemDependentName(anotherFile.getAbsolutePath());
        final Module module = ModuleUtil.findModuleForFile(file, project);
        if (OCamlModuleUtil.hasOCamlExtension(module)
                && ModuleRootManager.getInstance(module).getFileIndex().isInSourceContent(file)) {
            if (Messages.showYesNoCancelDialog(project,
                    "File \"" + anotherFilePath + "\" does not exist. Do you want to create it?",
                    "Open file \"" + anotherFilePath + "\"", Messages.getQuestionIcon()) != 0) {
                return;
            }
            ApplicationManager.getApplication().runWriteAction(new Runnable() {
                public void run() {
                    try {
                        parent.createChildData(SwitchModuleFileAction.this, anotherFile.getName());
                    } catch (final IOException e) {
                        Messages.showErrorDialog(project, e.getMessage(), "Error");
                    }
                }
            });
            anotherVirtualFile = LocalFileSystem.getInstance().findFileByIoFile(anotherFile);
            if (anotherVirtualFile == null) {
                return;
            }
        } else {
            Messages.showErrorDialog(project, "File \"" + anotherFilePath + "\" does not exist.",
                    "Open file \"" + anotherFilePath + "\"");
            return;
        }
    }

    final PsiFile anotherPsiFile = PsiManager.getInstance(project).findFile(anotherVirtualFile);
    if (anotherPsiFile == null) {
        return;
    }

    view.selectElement(anotherPsiFile);
}

From source file:manuylov.maxim.ocaml.module.OCamlSourcesPathStep.java

License:Open Source License

public boolean validate() throws ConfigurationException {
    if (!super.validate()) {
        return false;
    }//from  ww  w.  j av  a2  s .  co m

    if (myRbCreateSource.isSelected()) {
        final String sourceDirectoryPath = getSourceDirectoryPath();
        final String relativePath = myTfSourceDirectoryName.getText().trim();
        if (relativePath.length() == 0) {
            final String contentRoot = sourceDirectoryPath == null ? " "
                    : "\n\"" + FileUtil.toSystemDependentName(sourceDirectoryPath) + "\"\n";
            final String text = "Relative path to sources is empty.\nWould you like to mark the module content root"
                    + contentRoot + "as a source directory?";
            final int answer = Messages.showDialog(myTfSourceDirectoryName, text, "Mark source directory",
                    new String[] { "Mark", "Do Not Mark", CommonBundle.getCancelButtonText() }, 0,
                    Messages.getQuestionIcon());
            if (answer == 2) {
                return false; // cancel
            }
            if (answer == 1) { // don't mark
                myRbNoSource.doClick();
            }
        }
        if (sourceDirectoryPath != null) {
            final File rootDir = new File(getContentRootPath());
            final File srcDir = new File(sourceDirectoryPath);
            try {
                if (!FileUtil.isAncestor(rootDir, srcDir, false)) {
                    Messages.showErrorDialog(myTfSourceDirectoryName,
                            "Source directory should be under module content root directory",
                            CommonBundle.getErrorTitle());
                    return false;
                }
            } catch (IOException e) {
                Messages.showErrorDialog(myTfSourceDirectoryName, e.getMessage(), CommonBundle.getErrorTitle());
                return false;
            }
        }
    }
    return true;
}