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:org.napile.idea.thermit.config.impl.configuration.AnActionListEditor.java

License:Apache License

public void addRemoveButtonForAnt(final Condition<T> removeCondition, String actionName) {
    final ReorderableListController<T>.RemoveActionDescription description = myForm.getListActionsBuilder()
            .addRemoveAction(actionName);
    description.addPostHandler(new ReorderableListController.ActionNotification<List<T>>() {
        public void afterActionPerformed(List<T> list) {
            for (T item : list) {
                if (myAdded.contains(item)) {
                    myAdded.remove(item);
                } else {
                    myRemoved.add(item);
                }/*from ww  w  .  j  a  va2s.  c o m*/
            }
        }
    });
    description.setEnableCondition(removeCondition);
    description.setConfirmation(new Condition<List<T>>() {
        public boolean value(final List<T> list) {
            if (list.size() == 1) {
                return Messages.showOkCancelDialog(description.getList(),
                        ThermitBundle.message("delete.selected.ant.configuration.confirmation.text"),
                        ExecutionBundle.message("delete.confirmation.dialog.title"),
                        Messages.getQuestionIcon()) == 0;
            } else {
                return Messages.showOkCancelDialog(description.getList(),
                        ThermitBundle.message("delete.selected.ant.configurations.confirmation.text"),
                        ExecutionBundle.message("delete.confirmation.dialog.title"),
                        Messages.getQuestionIcon()) == 0;
            }
        }
    });

    description.setShowText(true);
}

From source file:org.qi4j.ide.plugin.idea.common.actions.AbstractCreateElementActionBase.java

License:Apache License

protected MyInputValidator doInvokeDialog(Project project, PsiDirectory directory) {
    MyInputValidator validator = new MyInputValidator(project, directory);
    Messages.showInputDialog(project, getDialogPrompt(), getDialogTitle(), Messages.getQuestionIcon(), "",
            validator);// w  w w.ja va  2s.c  om
    return validator;
}

From source file:org.qi4j.ide.plugin.idea.concerns.actions.create.inPackage.CreateConcernOfInPackageAction.java

License:Apache License

@NotNull
protected final PsiElement[] invokeDialog(Project project, PsiDirectory directory) {
    MyInputValidator validator = new MyInputValidator(project, directory);
    Messages.showInputDialog(project, message("createConcernOfInPackage.dlg.prompt"),
            message("createConcernOfInPackage.dlg.title"), Messages.getQuestionIcon(), "", validator);
    return validator.getCreatedElements();
}

From source file:org.sonar.ide.idea.autoupdate.PluginDownloader.java

License:Open Source License

private void promptShutdownAndShutdown() {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        public void run() {
            String title = "IDEA shutdown";
            String message = "Sonar Plugin has been installed succssfully.\n"
                    + "IntelliJ IDEA needs to be restarted to activate the plugin.\n"
                    + "Would you like to shutdown IntelliJ IDEA now?";
            int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon());
            if (answer == DialogWrapper.OK_EXIT_CODE) {
                // TODO maybe restart?
                ApplicationManager.getApplication().exit();
            }// ww w.j  av  a2 s . co m
        }
    });
}

From source file:org.sonar.ide.idea.autoupdate.PluginDownloader.java

License:Open Source License

public static void checkUpdate() {
    final PluginId pluginId = PluginManager.getPluginByClassName(VersionInfo.class.getName());
    final IdeaPluginDescriptor pluginDescriptor = PluginManager.getPlugin(pluginId);
    if (pluginDescriptor == null) {
        // should never happen
        return;//from  w w w  .j ava  2  s.co  m
    }
    final VersionInfo versionInfo = VersionInfo.getLatestPluginVersion();
    if (versionInfo != null && !pluginDescriptor.getVersion().equals(versionInfo.getVersion())) {
        ApplicationManager.getApplication().invokeLater(new Runnable() {
            public void run() {
                String title = "New Sonar Plugin";
                String message = "New Sonar Plugin version " + versionInfo.getVersion() + " is available.\n"
                        + "Do you want to upgrade from " + pluginDescriptor.getVersion() + "?";
                int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon());
                if (answer == DialogWrapper.OK_EXIT_CODE) {
                    new PluginDownloader().run(versionInfo);
                }
            }
        });
    }
}

From source file:org.sonar.ide.intellij.config.SonarQubeSettingsForm.java

License:Open Source License

public SonarQubeSettingsForm() {
    addButton.addActionListener(new ActionListener() {
        @Override//from w  w  w .  j a  va 2  s .  c o  m
        public void actionPerformed(ActionEvent e) {
            SonarQubeServerDialog dialog = new SonarQubeServerDialog(formComponent, null, getServers());
            dialog.show();
            if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
                serversList.addItem(dialog.getServer());
                serversList.setSelectedItem(dialog.getServer());
                modified = true;
                refreshButtons();
            }
        }
    });
    serversList.setRenderer(new ListCellRendererWrapper() {

        @Override
        public void customize(JList list, Object value, int index, boolean selected, boolean hasFocus) {
            setText(value != null ? ((SonarQubeServer) value).getId()
                    : SonarQubeBundle.message("sonarqube.settings.server.no_server"));
        }

    });
    editButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            SonarQubeServerDialog dialog = new SonarQubeServerDialog(formComponent,
                    (SonarQubeServer) serversList.getSelectedItem(), getServers());
            dialog.show();
            if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
                DefaultComboBoxModel model = (DefaultComboBoxModel) serversList.getModel();
                int selectedIndex = model.getIndexOf(model.getSelectedItem());
                model.removeElementAt(selectedIndex);
                model.insertElementAt(dialog.getServer(), selectedIndex);
                model.setSelectedItem(dialog.getServer());
                modified = true;
                refreshButtons();
            }
        }
    });
    removeButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            SonarQubeServer server = (SonarQubeServer) serversList.getSelectedItem();
            if (server != null && Messages.showYesNoDialog(formComponent,
                    SonarQubeBundle.message("sonarqube.settings.server.remove.msg", server.getId()),
                    SonarQubeBundle.message("sonarqube.settings.server.remove.title"),
                    Messages.getQuestionIcon()) == Messages.YES) {
                serversList.removeItem(serversList.getSelectedItem());
                modified = true;
                refreshButtons();
            }
        }
    });
}

From source file:org.trzcinka.intellitrac.view.toolwindow.tickets.reports_list.ReportsListForm.java

License:Apache License

public ReportsListForm() {
    editButton.addActionListener(new ActionListener() {
        /**/*w  w  w .  j av  a2  s  .co m*/
         * Invoked when an action occurs.
         */
        public void actionPerformed(ActionEvent e) {
            Report selectedReport = (Report) reportsList.getSelectedValue();
            if (selectedReport != null) {
                State stateInfo = State.REPORT_EDITOR;
                ticketsModel.getCurrentReportModel().setCurrentReport(selectedReport);
                ticketsModel.setCurrentState(stateInfo);
            }
        }
    });
    removeButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            Report selectedReport = (Report) reportsList.getSelectedValue();
            if (selectedReport != null) {
                String message = bundle.getString("tool_window.tickets.reports_list.confirm_report_removal");
                int answer = Messages.showYesNoDialog(ApplicationModel.getProject(), message,
                        bundle.getString("dialogs.warning"), Messages.getQuestionIcon());
                if (answer == 0) {
                    ticketsModel.getReportsListModel().removeReport(selectedReport);
                }
            }
        }
    });
    addButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            State state = State.REPORT_EDITOR;
            ticketsModel.getCurrentReportModel().setCurrentReport(new Report());
            ticketsModel.setCurrentState(state);
        }
    });
    openButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            openReport();
        }
    });
    reportsList.addComponentListener(new ComponentAdapter() {
    });
    reportsList.addMouseListener(new MouseAdapter() {
        @Override
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 2) {
                openReport();
            }
        }
    });
}

From source file:org.twodividedbyzero.idea.findbugs.actions.ImportBugCollection.java

License:Open Source License

@SuppressFBWarnings("SIC_INNER_SHOULD_BE_STATIC_ANON")
@Override/*  w w  w.  j  a v a  2  s .  com*/
void actionPerformedImpl(@NotNull final AnActionEvent e, @NotNull final Project project,
        @Nullable final Module module, @NotNull final FindBugsPlugin plugin,
        @NotNull final ToolWindow toolWindow, @NotNull final FindBugsState state,
        @NotNull final FindBugsPreferences preferences) {

    final DialogBuilder dialogBuilder = new DialogBuilder(project);
    dialogBuilder.addOkAction();
    dialogBuilder.addCancelAction();
    dialogBuilder.setTitle("Import previous saved bug collection xml");

    final String exportDir = preferences.getProperty(FindBugsPreferences.EXPORT_BASE_DIR,
            FindBugsPluginConstants.DEFAULT_EXPORT_DIR) + File.separatorChar + project.getName();

    final ImportFileDialog importFileDialog = new ImportFileDialog(exportDir, dialogBuilder);
    dialogBuilder.showModal(true);
    if (dialogBuilder.getDialogWrapper().getExitCode() == DialogWrapper.CANCEL_EXIT_CODE) {
        return;
    }
    final String fileToImport = importFileDialog.getText();
    if (fileToImport == null || fileToImport.trim().isEmpty()) {
        return;
    }

    final BugCollection bugCollection = plugin.getToolWindowPanel().getBugCollection();
    if (bugCollection != null && !bugCollection.getCollection().isEmpty()) {
        //noinspection DialogTitleCapitalization
        final int result = Messages.showYesNoDialog(project,
                "Current result in the 'Found bugs view' will be deleted. Continue ?", "Delete found bugs?",
                Messages.getQuestionIcon());
        if (result == 1) {
            return;
        }
    }

    final AtomicBoolean taskCanceled = new AtomicBoolean();
    final TransferToEDTQueue<Runnable> transferToEDTQueue = new TransferToEDTQueue<Runnable>(
            "Add New Bug Instance", new Processor<Runnable>() {
                @Override
                public boolean process(Runnable runnable) {
                    runnable.run();
                    return true;
                }
            }, new Condition<Object>() {
                @Override
                public boolean value(Object o) {
                    return project.isDisposed() || taskCanceled.get();
                }
            }, 500);

    //Create a task to import the bug collection from XML
    final BackgroundableTask task = new BackgroundableTask(project, "Importing Findbugs Result", true) {
        private ProgressIndicator _indicator;

        @SuppressWarnings({ "IOResourceOpenedButNotSafelyClosed" })
        @Override
        public void run(@NotNull final ProgressIndicator indicator) {

            MessageBusManager.publishAnalysisStartedToEDT(project);
            setProgressIndicator(indicator);
            indicator.setFraction(0.0);
            indicator.setIndeterminate(false);
            indicator.setText(fileToImport);
            SortedBugCollection importBugCollection = null;
            try {
                final SortedBugCollection bugCollection = new SortedBugCollection();
                final FindBugsPlugin pluginComponent = IdeaUtilImpl.getPluginComponent(project);
                importBugCollection = bugCollection.createEmptyCollectionWithMetadata();
                final edu.umd.cs.findbugs.Project importProject = importBugCollection.getProject();
                importProject.setGuiCallback(new PluginGuiCallback(pluginComponent));
                importBugCollection.setDoNotUseCloud(true);
                for (final Plugin plugin : Plugin.getAllPlugins()) {
                    importProject.setPluginStatusTrinary(plugin.getPluginId(),
                            !preferences.isPluginDisabled(plugin.getPluginId()));
                }
                importBugCollection.readXML(fileToImport);

                final ProjectStats projectStats = importBugCollection.getProjectStats();
                int bugCount = 0;
                for (final BugInstance bugInstance : importBugCollection) {
                    if (indicator.isCanceled()) {
                        taskCanceled.set(true);
                        MessageBusManager.publishAnalysisAbortedToEDT(project);
                        Thread.currentThread().interrupt();
                        return;
                    }
                    final Integer bugCounter = bugCount++;
                    final double fraction = bugCounter.doubleValue() / projectStats.getTotalBugs();
                    indicator.setFraction(fraction);
                    indicator.setText2("Importing bug '" + bugCount + "' of '" + projectStats.getTotalBugs()
                            + "' - " + bugInstance.getMessageWithoutPrefix());
                    /**
                     * Guarantee thread visibility *one* time.
                     */
                    final AtomicReference<BugInstance> bugInstanceRef = New.atomicRef(bugInstance);
                    final AtomicReference<ProjectStats> projectStatsRef = New.atomicRef(projectStats);
                    transferToEDTQueue.offer(new Runnable() {
                        /**
                         * Invoked by EDT.
                         */
                        @Override
                        public void run() {
                            MessageBusManager.publishNewBugInstance(project, bugInstanceRef.get(),
                                    projectStatsRef.get());
                        }
                    });
                }

                EventDispatchThreadHelper.invokeLater(new Runnable() {
                    public void run() {
                        transferToEDTQueue.drain();
                        FindBugsPluginImpl.showToolWindowNotifier(project,
                                "Imported bug collection from '" + fileToImport + "'.", MessageType.INFO);
                    }
                });

                importBugCollection.setDoNotUseCloud(false);
                importBugCollection.setTimestamp(System.currentTimeMillis());
                importBugCollection.reinitializeCloud();
            } catch (final IOException e1) {
                MessageBusManager.publishAnalysisAbortedToEDT(project);
                final String message = "Import failed";
                showToolWindowNotifier(project, message, MessageType.ERROR);
                LOGGER.error(message, e1);

            } catch (final DocumentException e1) {
                MessageBusManager.publishAnalysisAbortedToEDT(project);
                final String message = "Import failed";
                showToolWindowNotifier(project, message, MessageType.ERROR);
                LOGGER.error(message, e1);

            } finally {
                MessageBusManager.publishAnalysisFinishedToEDT(project, importBugCollection, null, null);
                Thread.currentThread().interrupt();
            }
        }

        @Override
        public void setProgressIndicator(@NotNull final ProgressIndicator indicator) {
            _indicator = indicator;
        }

        @Override
        public ProgressIndicator getProgressIndicator() {
            return _indicator;
        }
    };

    task.setCancelText("Cancel");
    task.asBackgroundable();
    task.queue();
}

From source file:org.twodividedbyzero.idea.findbugs.gui.preferences.ConfigurationPanel.java

License:Open Source License

private boolean validatePreferences(@Nullable final PersistencePreferencesBean prefs) {
    if (prefs == null) {
        Messages.showErrorDialog(this, "The configuration is invalid.", "Invalid Configuration");
        return false;
    } else if (prefs.isEmpty()) {
        final int answer = Messages.showYesNoDialog(this, "The configuration is empty. Do you want to proceed?",
                "Empty Configuration", Messages.getQuestionIcon());
        if (answer != DialogWrapper.OK_EXIT_CODE) {
            return false;
        }/*  w w  w .j a va  2s  .  co m*/
    }
    return true;
}

From source file:org.twodividedbyzero.idea.findbugs.gui.settings.ModuleSettingsPane.java

License:Open Source License

@Override
void initHeaderPane(@NotNull final JPanel topPanel) {
    overrideProjectSettingsCheckbox = new JBCheckBox(
            ResourcesLoader.getString("settings.module.overrideProjectSettings"));
    overrideProjectSettingsCheckbox.addActionListener(new ActionListener() {
        @Override//from   w  w  w . ja v a2  s. c  o  m
        public void actionPerformed(final ActionEvent e) {
            if (overrideProjectSettingsCheckbox.isSelected()) {
                if (Messages.YES == Messages.showYesNoDialog(overrideProjectSettingsCheckbox,
                        ResourcesLoader.getString("settings.module.loadProject.text"),
                        StringUtil.capitalizeWords(
                                ResourcesLoader.getString("settings.module.loadProject.title"), true),
                        Messages.getQuestionIcon())) {
                    reset(ProjectSettings.getInstance(project));
                }
            } else {
                if (Messages.YES == Messages
                        .showYesNoDialog(overrideProjectSettingsCheckbox,
                                ResourcesLoader.getString("settings.module.reset.text"),
                                StringUtil.capitalizeWords(
                                        ResourcesLoader.getString("settings.action.reset.title"), true),
                                Messages.getQuestionIcon())) {
                    final ModuleSettings settings = new ModuleSettings();
                    reset(settings);
                    resetModule(settings);
                }
            }
            updateControls();
        }
    });
    topPanel.add(overrideProjectSettingsCheckbox);
}