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

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

Introduction

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

Prototype

@NotNull
    public static Icon getWarningIcon() 

Source Link

Usage

From source file:bazaar4idea.action.BzrInit.java

License:Apache License

private static void doInit(final Project project, FileChooserDescriptor fcd, VirtualFile baseDir,
        final VirtualFile finalBaseDir) {
    FileChooser.chooseFile(fcd, project, baseDir, new Consumer<VirtualFile>() {
        @Override// w  w w . j ava 2 s .  c o m
        public void consume(final VirtualFile root) {
            if (BzrUtil.isUnderBzr(root) && Messages.showYesNoDialog(project,
                    BzrBundle.message("init.warning.already.under.bzr",
                            StringUtil.escapeXml(root.getPresentableUrl())),
                    BzrBundle.getString("init.warning.title"), Messages.getWarningIcon()) != Messages.YES) {
                return;
            }

            BzrCommandResult result = ServiceManager.getService(Bzr.class).init(project, root);
            if (!result.success()) {
                BzrVcs vcs = BzrVcs.getInstance(project);
                if (vcs != null && vcs.getExecutableValidator().checkExecutableAndNotifyIfNeeded()) {
                    BzrUIUtil.notify(BzrVcs.IMPORTANT_ERROR_NOTIFICATION, project, "Bazaar init failed",
                            result.getErrorOutputAsHtmlString(), NotificationType.ERROR, null);
                }
                return;
            }

            if (project.isDefault()) {
                return;
            }
            final String path = root.equals(finalBaseDir) ? "" : root.getPath();
            BzrVcs.runInBackground(new Task.Backgroundable(project, BzrBundle.getString("common.refreshing")) {
                @Override
                public void run(@NotNull ProgressIndicator indicator) {
                    refreshAndConfigureVcsMappings(project, root, path);
                }
            });
        }
    });
}

From source file:be.wimsymons.intellij.polopolyimport.PPImportAction.java

License:Apache License

public void actionPerformed(AnActionEvent e) {
    VirtualFile[] virtualFiles = e.getData(LangDataKeys.VIRTUAL_FILE_ARRAY);
    if (target.isConfirm()) {
        int answer = Messages.showYesNoDialog(
                "Are you sure to import the selected files into " + target.getProfile() + "?",
                "Confirm Polopoly Import", Messages.getWarningIcon());
        if (answer == Messages.NO) {
            PPImportPlugin.doNotify("Import cancelled upon confirmation.", NotificationType.INFORMATION);
            return;
        }// w w  w  .j  a va2  s.  c o m
    }
    ProgressManager.getInstance().run(new ImportTask(virtualFiles, this.target, this.includeExtensions,
            this.replacements, this.uploadMultipleFilesAsJar));
}

From source file:com.ansorgit.plugins.bash.settings.facet.ui.AbstractFileTreeTable.java

License:Apache License

public boolean clearSubdirectoriesOnDemandOrCancel(final VirtualFile parent, final String message,
        final String title) {
    Map<VirtualFile, T> mappings = myModel.myCurrentMapping;
    Map<VirtualFile, T> subdirectoryMappings = new THashMap<VirtualFile, T>();
    for (VirtualFile file : mappings.keySet()) {
        if (file != null && (parent == null || VfsUtil.isAncestor(parent, file, true))) {
            subdirectoryMappings.put(file, mappings.get(file));
        }//from  ww  w  .  j  a  v a2s  . c  o m
    }
    if (subdirectoryMappings.isEmpty()) {
        return true;
    } else {
        int ret = Messages.showDialog(myModule.getProject(), message, title,
                new String[] { "Override", "Do Not Override", "Cancel" }, 0, Messages.getWarningIcon());
        if (ret == 0) {
            for (VirtualFile file : subdirectoryMappings.keySet()) {
                myModel.setValueAt(null, new DefaultMutableTreeNode(file), 1);
            }
        }
        return ret != 2;
    }
}

From source file:com.google.cloud.tools.intellij.appengine.cloud.CloudSdkAppEngineHelper.java

License:Apache License

@Override
public Path stageCredentials(String googleUserName) {
    Path credentials = doStageCredentials(googleUserName);
    if (credentials != null) {
        return credentials;
    }//from  www  .j  a v  a 2  s. c om

    int addUserResult = Messages.showOkCancelDialog(
            GctBundle.message("appengine.staging.credentials.error.message"),
            GctBundle.message("appengine.staging.credentials.error.dialog.title"),
            GctBundle.message("appengine.staging.credentials.error.dialog.addaccount.button"),
            GctBundle.message("appengine.staging.credentials.error.dialog.cancel.button"),
            Messages.getWarningIcon());

    if (addUserResult == Messages.OK) {
        Services.getLoginService().logIn();
        return doStageCredentials(googleUserName);
    }

    return null;
}

From source file:com.google.cloud.tools.intellij.settings.ExportSettings.java

License:Apache License

/**
 * Exports IDEA settings.//from   w  w  w.j  a v  a2s  .  c o  m
 */
public static void doExport(String path) {
    final Set<ExportableComponent> exportableComponents = new HashSet<ExportableComponent>(Arrays
            .asList(ApplicationManager.getApplication().getComponents(ExportableApplicationComponent.class)));
    exportableComponents.addAll(
            ServiceBean.loadServicesFromBeans(ExportableComponent.EXTENSION_POINT, ExportableComponent.class));

    if (exportableComponents.isEmpty()) {
        return;
    }

    Set<File> exportFiles = new HashSet<File>();
    for (final ExportableComponent markedComponent : exportableComponents) {
        ContainerUtil.addAll(exportFiles, markedComponent.getExportFiles());
    }

    ApplicationManager.getApplication().saveSettings();

    final File saveFile = new File(path);
    try {
        if (saveFile.exists()) {
            final int ret = Messages.showOkCancelDialog(
                    IdeBundle.message("prompt.overwrite.settings.file",
                            FileUtil.toSystemDependentName(saveFile.getPath())),
                    IdeBundle.message("title.file.already.exists"), Messages.getWarningIcon());
            if (ret != Messages.OK) {
                return;
            }
        }

        final JarOutputStream output = new JarOutputStream(new FileOutputStream(saveFile));
        try {
            final File configPath = new File(PathManager.getConfigPath());
            final Set<String> writtenItemRelativePaths = new HashSet<String>();
            for (File file : exportFiles) {
                final String rPath = FileUtil.getRelativePath(configPath, file);
                assert rPath != null;
                final String relativePath = FileUtil.toSystemIndependentName(rPath);
                if (file.exists()) {
                    ZipUtil.addFileOrDirRecursively(output, saveFile, file, relativePath, null,
                            writtenItemRelativePaths);
                }
            }

            exportInstalledPlugins(saveFile, output, writtenItemRelativePaths);

            final File magicFile = new File(FileUtil.getTempDirectory(), SETTINGS_JAR_MARKER);
            FileUtil.createIfDoesntExist(magicFile);
            magicFile.deleteOnExit();
            ZipUtil.addFileToZip(output, magicFile, SETTINGS_JAR_MARKER, writtenItemRelativePaths, null);
        } finally {
            output.close();
        }
    } catch (IOException e1) {
        Messages.showErrorDialog(IdeBundle.message("error.writing.settings", e1.toString()),
                IdeBundle.message("title.error.writing.file"));
    }

}

From source file:com.google.gct.idea.settings.ExportSettings.java

License:Apache License

public static void doExport(String path) {
    final Set<ExportableComponent> exportableComponents = new HashSet<ExportableComponent>(Arrays
            .asList(ApplicationManager.getApplication().getComponents(ExportableApplicationComponent.class)));
    exportableComponents.addAll(//from   w w  w .j  a va2  s  .  com
            ServiceBean.loadServicesFromBeans(ExportableComponent.EXTENSION_POINT, ExportableComponent.class));

    if (exportableComponents.isEmpty()) {
        return;
    }

    Set<File> exportFiles = new HashSet<File>();
    for (final ExportableComponent markedComponent : exportableComponents) {
        ContainerUtil.addAll(exportFiles, markedComponent.getExportFiles());
    }

    ApplicationManager.getApplication().saveSettings();

    final File saveFile = new File(path);
    try {
        if (saveFile.exists()) {
            final int ret = Messages.showOkCancelDialog(
                    IdeBundle.message("prompt.overwrite.settings.file",
                            FileUtil.toSystemDependentName(saveFile.getPath())),
                    IdeBundle.message("title.file.already.exists"), Messages.getWarningIcon());
            if (ret != Messages.OK)
                return;
        }

        final JarOutputStream output = new JarOutputStream(new FileOutputStream(saveFile));
        try {
            final File configPath = new File(PathManager.getConfigPath());
            final HashSet<String> writtenItemRelativePaths = new HashSet<String>();
            for (File file : exportFiles) {
                final String rPath = FileUtil.getRelativePath(configPath, file);
                assert rPath != null;
                final String relativePath = FileUtil.toSystemIndependentName(rPath);
                if (file.exists()) {
                    ZipUtil.addFileOrDirRecursively(output, saveFile, file, relativePath, null,
                            writtenItemRelativePaths);
                }
            }

            exportInstalledPlugins(saveFile, output, writtenItemRelativePaths);

            final File magicFile = new File(FileUtil.getTempDirectory(), SETTINGS_JAR_MARKER);
            FileUtil.createIfDoesntExist(magicFile);
            magicFile.deleteOnExit();
            ZipUtil.addFileToZip(output, magicFile, SETTINGS_JAR_MARKER, writtenItemRelativePaths, null);
        } finally {
            output.close();
        }
    } catch (IOException e1) {
        Messages.showErrorDialog(IdeBundle.message("error.writing.settings", e1.toString()),
                IdeBundle.message("title.error.writing.file"));
    }

}

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);/*from  w w  w .java  2  s .c om*/
        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.headwire.aem.tooling.intellij.communication.MessageManager.java

License:Apache License

private Icon getIcon(NotificationType type) {
    switch (type) {
    case INFORMATION:
        return Messages.getInformationIcon();
    case WARNING:
        return Messages.getWarningIcon();
    case ERROR:/*from   w  w w .  jav  a 2 s .com*/
    default:
        return Messages.getErrorIcon();
    }
}

From source file:com.intellij.analysis.BaseClassesAnalysisAction.java

License:Apache License

@Override
protected void analyze(@NotNull final Project project, final AnalysisScope scope) {
    FileDocumentManager.getInstance().saveAllDocuments();

    ProgressManager.getInstance()/*w w  w.  j a va 2s  .  c  o  m*/
            .run(new Task.Backgroundable(project, AnalysisScopeBundle.message("analyzing.project"), true) {
                @Override
                public void run(@NotNull final ProgressIndicator indicator) {
                    indicator.setIndeterminate(true);
                    indicator.setText(AnalysisScopeBundle.message("checking.class.files"));

                    final CompilerManager compilerManager = CompilerManager.getInstance(myProject);
                    final boolean upToDate = compilerManager
                            .isUpToDate(compilerManager.createProjectCompileScope(myProject));

                    ApplicationManager.getApplication().invokeLater(new Runnable() {
                        @Override
                        public void run() {
                            if (!upToDate) {
                                final int i = Messages.showYesNoCancelDialog(getProject(),
                                        AnalysisScopeBundle.message("recompile.confirmation.message"),
                                        AnalysisScopeBundle.message("project.is.out.of.date"),
                                        Messages.getWarningIcon());

                                if (i == 2)
                                    return;

                                if (i == 0) {
                                    compileAndAnalyze(project, scope);
                                } else {
                                    doAnalyze(project, scope);
                                }
                            } else {
                                doAnalyze(project, scope);
                            }
                        }
                    });
                }
            });
}

From source file:com.intellij.application.options.editor.JavaAutoImportConfigurable.java

License:Apache License

public JavaAutoImportConfigurable() {
    mySmartPasteCombo.addItem(INSERT_IMPORTS_ALWAYS);
    mySmartPasteCombo.addItem(INSERT_IMPORTS_ASK);
    mySmartPasteCombo.addItem(INSERT_IMPORTS_NONE);

    myExcludePackagesList = new JBList();
    myExcludeFromImportAndCompletionPanel.add(
            ToolbarDecorator.createDecorator(myExcludePackagesList).setAddAction(new AnActionButtonRunnable() {
                @Override/*from  w  ww. ja  v a  2 s  . c o  m*/
                public void run(AnActionButton button) {
                    InputValidator validator = new InputValidator() {

                        @Override
                        public boolean checkInput(String inputString) {
                            return ourPackagePattern.matcher(inputString).matches();
                        }

                        @Override
                        public boolean canClose(String inputString) {
                            return checkInput(inputString);
                        }
                    };
                    String packageName = Messages.showInputDialog(myWholePanel,
                            ApplicationBundle.message("exclude.from.completion.prompt"),
                            ApplicationBundle.message("exclude.from.completion.title"),
                            Messages.getWarningIcon(), "", validator);
                    addExcludePackage(packageName);
                }
            }).disableUpDownActions().createPanel(), BorderLayout.CENTER);

    myExcludePackagesList.getEmptyText()
            .setText(ApplicationBundle.message("exclude.from.imports.no.exclusions"));
}