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:com.android.tools.idea.uibuilder.property.NlIdPropertyItemTest.java

License:Apache License

public void testSetValueChangeReferences() {
    when(myBuilder.show()).thenReturn(DialogWrapper.OK_EXIT_CODE);
    myItem.setValue("label");

    assertThat(myTextView.getId()).isEqualTo("label");
    assertThat(myCheckBox1.getAttribute(ANDROID_URI, ATTR_LAYOUT_BELOW)).isEqualTo("@id/label");
    assertThat(myCheckBox2.getAttribute(ANDROID_URI, ATTR_LAYOUT_TO_RIGHT_OF)).isEqualTo("@id/label");
}

From source file:com.android.tools.idea.uibuilder.property.NlIdPropertyItemTest.java

License:Apache License

public void testSetValueAndYesToChangeReferencesAndDoNotCheckAgain() {
    doAnswer(invocation -> {/*from w  w w.  ja va2s  .  com*/
        ArgumentCaptor<JPanel> panel = ArgumentCaptor.forClass(JPanel.class);
        verify(myBuilder).setCenterPanel(panel.capture());
        for (Component component : panel.getValue().getComponents()) {
            if (component instanceof JBCheckBox) {
                ((JBCheckBox) component).setSelected(true);
            }
        }
        return DialogWrapper.OK_EXIT_CODE;
    }).when(myBuilder).show();

    myItem.setValue("other");
    assertThat(myTextView.getId()).isEqualTo("other");
    assertThat(myCheckBox1.getAttribute(ANDROID_URI, ATTR_LAYOUT_BELOW)).isEqualTo("@id/other");
    assertThat(myCheckBox2.getAttribute(ANDROID_URI, ATTR_LAYOUT_TO_RIGHT_OF)).isEqualTo("@id/other");

    // Set id again, this time expect references to be changed without showing a dialog
    verify(myBuilder, times(1)).show();
    myItem.setValue("last");
    verify(myBuilder, times(1)).show();

    assertThat(myTextView.getId()).isEqualTo("last");
    assertThat(myCheckBox1.getAttribute(ANDROID_URI, ATTR_LAYOUT_BELOW)).isEqualTo("@id/last");
    assertThat(myCheckBox2.getAttribute(ANDROID_URI, ATTR_LAYOUT_TO_RIGHT_OF)).isEqualTo("@id/last");
}

From source file:com.android.tools.idea.wizard.NewProjectWizardTest.java

License:Apache License

@Override
public void tearDown() throws Exception {
    try {/* www .j a  v a  2s.c o  m*/
        myWizard.close(DialogWrapper.OK_EXIT_CODE);
    } finally {
        super.tearDown();
    }
}

From source file:com.atlassian.theplugin.idea.action.issues.activetoolbar.ActiveIssueUtils.java

License:Apache License

/**
 * Should be called from the UI thread/*from w w  w . j  ava2 s .c om*/
 *
 * @param project project
 * @param issue   issue
 */
public static void checkIssueState(final Project project, final JiraIssueAdapter issue) {
    ActiveJiraIssue activeIssue = getActiveJiraIssue(project);
    if (issue != null && activeIssue != null) {

        if (issue.getJiraServerData() != null && issue.getKey().equals(activeIssue.getIssueKey())
                && issue.getJiraServerData().getServerId().equals(activeIssue.getServerId())) {

            ProgressManager.getInstance().run(new Task.Backgroundable(project, "Checking active issue state") {
                public void run(final ProgressIndicator indicator) {

                    if (!issue.getJiraServerData().getUsername().equals(issue.getAssigneeId())) {

                        SwingUtilities.invokeLater(new Runnable() {
                            public void run() {
                                int isOk = Messages.showYesNoDialog(project,
                                        "Issue " + issue.getKey() + " has changed assignee (assigned to:"
                                                + issue.getAssignee() + ", status: " + issue.getStatus()
                                                + ").\nDo you want to deactivate?",
                                        "Issue " + issue.getKey(), Messages.getQuestionIcon());

                                if (isOk == DialogWrapper.OK_EXIT_CODE) {
                                    deactivate(project, new ActiveIssueResultHandler() {
                                        public void success() {
                                            final JiraWorkspaceConfiguration conf = IdeaHelper
                                                    .getProjectComponent(project,
                                                            JiraWorkspaceConfiguration.class);
                                            if (conf != null) {
                                                conf.setActiveJiraIssuee(null);
                                            }
                                        }

                                        public void failure(Throwable problem) {
                                        }

                                        public void cancel(String problem) {
                                        }
                                    });
                                }
                            }
                        });
                    }
                }
            });
        }
    }
}

From source file:com.atlassian.theplugin.idea.autoupdate.PluginDownloader.java

License:Apache License

private void promptShutdownAndShutdown() {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
        public void run() {
            String title = "IDEA shutdown";
            String message = PluginUtil.PRODUCT_NAME + " has been installed successfully.\n"
                    + "IntelliJ IDEA needs to be restarted to activate the plugin.\n"
                    + "Would you like to shutdown IntelliJ IDEA now?";
            // todo again add project or parent to the below window
            int answer = Messages.showYesNoDialog(message, title, Messages.getQuestionIcon());
            if (answer == DialogWrapper.OK_EXIT_CODE) {
                //ApplicationManagerEx.getApplicationEx().exit(true);
                ApplicationManager.getApplication().exit();
            }//from ww w . ja v  a2 s  .  c  om
        }
    });
}

From source file:com.atlassian.theplugin.idea.config.ProjectConfigurationComponent.java

License:Apache License

private void migrateOldPrivateProjectSettings(final JDomProjectConfigurationDao cfgFactory) {
    final SAXBuilder builder = new SAXBuilder(false);
    final File privateCfgFile = getPrivateOldCfgFilePath();
    boolean someMigrationHappened = false;
    if (privateCfgFile != null) {
        try {/*from   w ww  .  ja  va  2  s  .co  m*/
            final Document privateRoot = builder.build(privateCfgFile);
            final PrivateProjectConfiguration ppc = cfgFactory
                    .loadOldPrivateConfiguration(privateRoot.getRootElement());
            for (PrivateServerCfgInfo privateServerCfgInfo : ppc.getPrivateServerCfgInfos()) {
                try {
                    final PrivateServerCfgInfo newPsci = privateCfgDao.load(privateServerCfgInfo.getServerId());
                    if (newPsci == null) {
                        privateCfgDao.save(privateServerCfgInfo);
                        someMigrationHappened = true;
                    }
                } catch (ServerCfgFactoryException e) {
                    // ignore here - just don't try to overwrite it with data from old XML file
                }
            }
        } catch (Exception e) {
            handleServerCfgFactoryException(project, e);
        }
    }

    if (someMigrationHappened) {
        ApplicationManager.getApplication().invokeLater(new Runnable() {
            public void run() {
                int value = Messages.showYesNoCancelDialog(project,
                        "Configuration has been succesfully migrated to new location (home directory).\n"
                                + "Would you like to delete the old configuration file?\n\nDelete file: ["
                                + privateCfgFile + "]",
                        PluginUtil.PRODUCT_NAME + " upgrade process", Messages.getQuestionIcon());

                if (value == DialogWrapper.OK_EXIT_CODE) {
                    if (!privateCfgFile.delete()) {
                        Messages.showWarningDialog(project,
                                "Cannot remove file [" + privateCfgFile.getAbsolutePath()
                                        + "].\nTry removing it manually.\n" + PluginUtil.PRODUCT_NAME
                                        + " should still behave correctly.",
                                PluginUtil.PRODUCT_NAME);
                    }

                }
            }
        });
    }
}

From source file:com.atlassian.theplugin.idea.config.ProjectConfigurationComponent.java

License:Apache License

public static void fireDirectClickedServerPopup(final Project project, final String serverUrl,
        final ServerType serverType, final Runnable runnable) {
    /*      final Color BACKGROUND_COLOR = new Color(255, 255, 200);
            //www . j  a  va 2  s.c o m
          StringBuilder sb = new StringBuilder("Server <i>" + serverUrl + "</i> not found in configuration<br>");
          sb.append("<br>Click on this notification to open configuration panel and add this server");
            
          JEditorPane content = new JEditorPane();
          content.setEditable(false);
          content.setContentType("text/html");
          content.setEditorKit(new ClasspathHTMLEditorKit());
          content.setText("<html>" + Constants.BODY_WITH_STYLE + sb.toString() + "</body></html>");
          content.setBackground(BACKGROUND_COLOR);
          content.addHyperlinkListener(new GenericHyperlinkListener());
            
          content.addMouseListener(new MouseAdapter() {
             @Override
             public void mouseClicked(MouseEvent e) {
    if (ProjectConfigurationComponent.addDirectClickedServer(project, serverUrl, serverType)) {
       EventQueue.invokeLater(runnable);
    }
             }
          });
            
          IdeaVersionFacade.getInstance().fireNotification(
    project,
    new JScrollPane(content),
    content.getText(),
    "/icons/crucible-blue-16.png",
    IdeaVersionFacade.OperationStatus.INFO,
    BACKGROUND_COLOR);*/

    if (Messages.showYesNoDialog(
            "Server " + serverUrl + " not found in configuration,\ndo you want to "
                    + "open configuration panel and add this server?",
            "Server not found", Messages.getQuestionIcon()) == DialogWrapper.OK_EXIT_CODE) {
        if (ProjectConfigurationComponent.addDirectClickedServer(project, serverUrl, serverType)) {
            EventQueue.invokeLater(runnable);
        }
    }
}

From source file:com.atlassian.theplugin.idea.config.ProjectConfigurationPanel.java

License:Apache License

public void askForDefaultCredentials() {
    final ServerCfg selectedServer = serverConfigPanel.getSelectedServer();

    // PL-1703 - when adding a StAC server, there is no selected server,
    // as two servers are added simultaneously 
    if (selectedServer == null) {
        return;/*from   w  w  w. j a  v  a 2s  .  co  m*/
    }

    // PL-1617 - Ugly ugly. I am not sure why this is b0rked sometimes,
    // but one of these seems to be null for apparent reason every once in a while
    ProjectCfgManager cfgMgr = IdeaHelper.getProjectCfgManager(project);
    if (cfgMgr == null) {
        LoggerImpl.getInstance().warn("askDefaultCredentials() - cfgMgr is null");
    }

    final boolean alreadyExists = cfgMgr != null && cfgMgr.getServerr(selectedServer.getServerId()) != null;

    ApplicationManager.getApplication().executeOnPooledThread(new Runnable() {
        public void run() {

            final ModalityState modalityState = ModalityState.stateForComponent(ProjectConfigurationPanel.this);
            ApplicationManager.getApplication().invokeLater(new Runnable() {
                public void run() {

                    if (!alreadyExists && !defaultCredentialsAsked
                            && (defaultCredentials == null || (defaultCredentials.getPassword().equals("")
                                    && defaultCredentials.getPassword().equals(""))
                                    && selectedServer.getUsername().length() > 0)) {
                        int answer = Messages.showYesNoDialog(project, "<html>Do you want to set server <b>"
                                + selectedServer.getName() + "</b> <i>username</i> and <i>password</i>"
                                + " as default credentials for the " + PluginUtil.PRODUCT_NAME + "?</html>",
                                "Set as default", Messages.getQuestionIcon());

                        ProjectCfgManagerImpl cfgMgr = (ProjectCfgManagerImpl) IdeaHelper
                                .getProjectCfgManager(project);

                        if (answer == DialogWrapper.OK_EXIT_CODE) {
                            UserCfg credentials = new UserCfg(selectedServer.getUsername(),
                                    selectedServer.getPassword(), true);
                            if (cfgMgr != null) {
                                cfgMgr.setDefaultCredentials(credentials);
                            }
                            defaultsConfigurationPanel.setDefaultCredentials(credentials);
                        }
                        if (cfgMgr != null) {
                            cfgMgr.setDefaultCredentialsAsked(true);
                        }
                        ProjectConfigurationPanel.this.defaultCredentialsAsked = true;
                    }
                }
            }, modalityState);
        }
    });
}

From source file:com.atlassian.theplugin.idea.config.serverconfig.CrucibleServerConfigForm.java

License:Apache License

private void createUIComponents() {
    crucibleDetailConfigForm = new CrucibleDetailConfigForm(crucibleServerFacade);
    final CrucibleConnector connector = new CrucibleConnector(crucibleServerFacade, fishEyeServerFacade);
    genericServerConfigForm = new GenericServerConfigForm(project, defaultUser, connector) {
        @Override//from   ww  w.j  av  a  2s  . c o m
        public void onSuccess() {
            if (connector.isFisheye() == true && !crucibleDetailConfigForm.isFishEyeInstance()) {
                int res = Messages.showYesNoDialog(project,
                        "This Crucible server is connected to Fisheye.\nWould you like to connect to the Fisheye server as well?",
                        "Combined FishEye & Crucible detected", Messages.getQuestionIcon());
                if (res == DialogWrapper.OK_EXIT_CODE) {
                    crucibleDetailConfigForm.setIsFishEyeInstance(true);
                }
            }
        }
    };
}

From source file:com.atlassian.theplugin.idea.crucible.CrucibleCreatePostCommitReviewForm.java

License:Apache License

public void updateChanges() {
    CrucibleRevisionsNumber dialog = new CrucibleRevisionsNumber(revisionsNumber);
    dialog.show();/*from w w w  .  j av a 2  s. c  o m*/
    if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        revisionsNumber = dialog.getValue();
        this.taskExecutor.execute(new ChangesRefreshTask("Fetching recent commits", getContentPane()));
    }
}