Example usage for com.intellij.openapi.ui DialogWrapper OK_EXIT_CODE

List of usage examples for com.intellij.openapi.ui DialogWrapper OK_EXIT_CODE

Introduction

In this page you can find the example usage for com.intellij.openapi.ui DialogWrapper OK_EXIT_CODE.

Prototype

int OK_EXIT_CODE

To view the source code for com.intellij.openapi.ui DialogWrapper OK_EXIT_CODE.

Click Source Link

Document

The default exit code for "OK" action.

Usage

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;// w w w  .  jav  a  2s . c  o  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.action.AssociateWithSonarQube.java

License:Open Source License

private void processResult(Project p, MavenProjectsManager mavenProjectsManager, ProjectSettings settings,
        AssociateDialog dialog) {// w  w  w.  j a v a  2 s.  co  m
    if (dialog.getExitCode() == AssociateDialog.UNASSOCIATE_EXIT_CODE) {
        settings.unassociate();
    } else if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        settings.setServerId(null);
        settings.setProjectKey(null);
        ISonarRemoteProject sonarProject = dialog.getSelectedSonarQubeProject();
        if (sonarProject == null) {
            settings.unassociate();
        } else {
            associate(p, settings, mavenProjectsManager, sonarProject);
        }
    }
}

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

License:Open Source License

public SonarQubeSettingsForm() {
    addButton.addActionListener(new ActionListener() {
        @Override//  w ww. j a v  a2  s .  c  om
        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.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 v a 2 s.co  m*/
    }
    return true;
}

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

License:Open Source License

private void showImportDialog(final com.intellij.openapi.project.Project project,
        final PersistencePreferencesBean prefs, final ImportCallback callback,
        final List<String> invalidPlugins) {
    final ImportPluginsDialog dialog = new ImportPluginsDialog(project, prefs, invalidPlugins);
    dialog.setModal(true);/*from  ww w  .  j av  a2  s.  c  o  m*/
    dialog.pack();
    dialog.show();
    if (DialogWrapper.OK_EXIT_CODE == dialog.getExitCode()) {
        prefs.getPlugins().clear();
        prefs.getPlugins().addAll(dialog.getPlugins());
        callback.validated(prefs);
    } // else do not import
}

From source file:repl.simple.mathematica.Actions.MathREPLConfigureAction.java

License:Open Source License

public void actionPerformed(AnActionEvent e) {
    // get values previously stored and display them as defaults on dialog
    MathREPLConfig dialog = new MathREPLConfig();
    dialog.setModal(true);// ww  w  .ja  v a2  s .c o  m
    dialog.show();
    if (DialogWrapper.OK_EXIT_CODE == dialog.getExitCode()) {
        // set values to be configured into the storage
        // use them when connecting to the kernel
        PropertiesComponent pc = PropertiesComponent.getInstance();
        pc.setValue("repl.simple.mathematica.mathkernel_path", dialog.center.getMathKernelPath());
        pc.setValue("repl.simple.mathematica.native_library_path", dialog.center.getNativeLibPath());
        pc.setValue("repl.simple.mathematica.mathlink_path", dialog.center.getMathLinkPath());
        pc.setValue("repl.simple.mathematica.mathlink_args", dialog.center.getMathLinkArgs());
        // apply color settings
        pc.setValue("repl.simple.mathematica.text_color",
                Integer.toString(dialog.center.getTextColor().getSelectedColor().getRGB()));
        pc.setValue("repl.simple.mathematica.background",
                Integer.toString(dialog.center.getBackground().getSelectedColor().getRGB()));
        pc.setValue("repl.simple.mathematica.system_color",
                Integer.toString(dialog.center.getSystemColor().getSelectedColor().getRGB()));
        pc.setValue("repl.simple.mathematica.string_color",
                Integer.toString(dialog.center.getStringColor().getSelectedColor().getRGB()));
        pc.setValue("repl.simple.mathematica.message_color",
                Integer.toString(dialog.center.getMessageColor().getSelectedColor().getRGB()));
        pc.setValue("repl.simple.mathematica.prompt_color",
                Integer.toString(dialog.center.getPromptColor().getSelectedColor().getRGB()));
        pc.setValue("repl.simple.mathematica.comment_color",
                Integer.toString(dialog.center.getCommentColor().getSelectedColor().getRGB()));

    }
}

From source file:repl.simple.mathematica.ErrorReporter.java

License:Open Source License

/**
 * Reports a bug with given message/*  w w w .  j a  va2 s .  com*/
 *
 * @param message of bug description
 */
public static boolean reportBug(String message, Component comp) {
    final String to = MathREPLBundle.message("authorEmail");

    StringBuffer buf = new StringBuffer(message.length() + 50);

    buf.append("Idea version:");
    buf.append(ApplicationInfo.getInstance().getFullVersion());
    buf.append('\n');

    buf.append("Plugin version:");
    buf.append(MathREPLBundle.message("pluginVersion"));
    buf.append('\n');

    buf.append(message);
    BugReportForm form = new BugReportForm(buf.toString(), comp);

    form.show();
    if (form.getExitCode() != DialogWrapper.OK_EXIT_CODE)
        return false;

    final BugReportModel model = new BugReportModel();

    model.to = to;
    // use restricted gmail server
    model.mailserver = "aspmx.l.google.com";
    model.mailuser = form.mailUser.getText();
    model.message = form.bugReportText.getText();

    sendBugData(model);

    return true;
}

From source file:su.opencode.shuffler.ShuffleAction.java

License:Open Source License

@Override
public void actionPerformed(AnActionEvent anActionEvent) {
    final Project project = anActionEvent.getProject();

    final GlobalSearchScope scope;
    String scopeName;/*w  ww .  j  a  v  a2  s.  co  m*/
    PsiElement psiElement = DataKeys.TARGET_PSI_ELEMENT.getData(anActionEvent.getDataContext());
    VirtualFile directory = DataKeys.VIRTUAL_FILE.getData(anActionEvent.getDataContext());
    Module module = DataKeys.TARGET_MODULE.getData(anActionEvent.getDataContext());
    module = module != null ? module : DataKeys.MODULE.getData(anActionEvent.getDataContext());
    module = module != null ? module : DataKeys.MODULE_CONTEXT.getData(anActionEvent.getDataContext());

    if (psiElement != null && psiElement instanceof PsiDirectory) {
        directory = ((PsiDirectory) psiElement).getVirtualFile();
        scope = GlobalSearchScopes.directoryScope(project, directory, true);
        scopeName = directory.getName();
    } else if (directory != null) {
        scope = GlobalSearchScopes.directoryScope(project, directory, true);
        scopeName = directory.getName();
    } else if (module != null) {
        scope = module.getModuleScope();
        scopeName = module.getName();
    } else {
        scope = GlobalSearchScopes.projectProductionScope(project);
        scopeName = project.getName();
    }

    String warning = String
            .format("Varaiable, class, and method names will be shuffled in %s, comments will be removed. \n"
                    + "It will block Idea and may take awhile. \n" + "Do you want to shuffle?", scopeName);

    int exitCode = Messages.showOkCancelDialog(project, warning, "Shuffle project?", "Shuffle", "Cancel", null);

    if (DialogWrapper.OK_EXIT_CODE != exitCode)
        return;

    Task task = new Task.Modal(project, "Shuffling", false) {

        @Override
        public void run(@NotNull ProgressIndicator indicator) {
            ShuffleRunner runner = new ShuffleRunner(indicator, project, scope);
            runner.run();
        }
    };

    ProgressManager.getInstance().run(task);
}

From source file:wicketforge.facet.ui.WicketAlternateResourcePathItemDialog.java

License:Apache License

/**
 * //  w  w  w  .j ava  2 s .  c o  m
 */
public static void showDialog(@NotNull Project project, @NotNull String title, @NotNull String resourcePath,
        @NotNull WicketFeaturesEditor.Runnable runnable) {
    WicketAlternateResourcePathItemDialog dialog = new WicketAlternateResourcePathItemDialog(project, title,
            resourcePath);
    dialog.show();
    if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        String resourcePathNew = dialog.resourcePathTextFieldPanel.getText();
        if (!resourcePathNew.equals(resourcePath)) {
            runnable.run(VfsUtil.pathToUrl(resourcePathNew));
        }
    }
}