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

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

Introduction

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

Prototype

@YesNoResult
public static int showYesNoDialog(String message,
        @NotNull @Nls(capitalization = Nls.Capitalization.Title) String title, @Nullable Icon icon) 

Source Link

Document

Use this method only if you do not know project or component

Usage

From source file:com.microsoft.intellij.ui.azureroles.SSLOffloadingPanel.java

License:Open Source License

private ItemListener createComboEndptListener() {
    return new ItemListener() {
        @Override// w w  w.  ja v  a2s . c om
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED && isManualUpdate) {
                try {
                    isManualUpdate = false;
                    setModified(true);
                    String newText = (String) comboEndpt.getSelectedItem();
                    int port = Integer
                            .valueOf(newText.substring(newText.indexOf(":") + 1, newText.indexOf(",")));
                    if (port == HTTPS_PORT) {
                        // user trying to set endpoint with public port 443
                        PluginUtil.displayWarningDialog(message("sslTtl"), message("sslWarnMsg"));
                    } else if (port == HTTP_PORT) {
                        WindowsAzureEndpoint httpsEndPt = WAEclipseHelperMethods
                                .findEndpointWithPubPort(HTTPS_PORT, waRole);
                        if (httpsEndPt != null) {
                            /*
                             * If HTTPS endpoint with public port 443,
                            * is present on same role and listed in endpoint combo box
                            * then show warning
                            */
                            PluginUtil.displayWarningDialog(message("sslTtl"), String.format(
                                    message("httpsPresent"), httpsEndPt.getName(), httpsEndPt.getPort()));
                            comboEndpt.setSelectedItem(null);
                        } else {
                            WindowsAzureRole role = WAEclipseHelperMethods.findRoleWithEndpntPubPort(HTTPS_PORT,
                                    waProjManager);
                            WindowsAzureEndpoint httpEndPt = WAEclipseHelperMethods
                                    .findEndpointWithPubPort(HTTP_PORT, waRole);
                            int pubPort = HTTPS_NXT_PORT;
                            if (role != null) {
                                /*
                                 * Else if endpoint with public port 443
                                * is already used by some other role or
                                * on same role but with type InstanceInput
                                * then prompt for changing port 80
                                * with the next available public port starting with 8443
                                * across all roles
                                */
                                while (!waProjManager.isValidPort(String.valueOf(pubPort),
                                        WindowsAzureEndpointType.Input)) {
                                    pubPort++;
                                }
                            } else {
                                // Else prompt for changing port 80 with 443 across all roles
                                pubPort = HTTPS_PORT;
                            }
                            int choice = Messages.showYesNoDialog(
                                    message("sslhttp").replace("${epName}", httpEndPt.getName())
                                            .replace("${pubPort}", String.valueOf(pubPort))
                                            .replace("${privPort}", httpEndPt.getPrivatePort()),
                                    message("sslTtl"), Messages.getQuestionIcon());
                            if (choice == Messages.YES) {
                                httpEndPt.setPort(String.valueOf(pubPort));
                                populateEndPointList();
                                comboEndpt.setSelectedItem(String.format(message("dbgEndPtStr"),
                                        httpEndPt.getName(), httpEndPt.getPort(), httpEndPt.getPrivatePort()));
                                isEditableEndpointCombo(httpEndPt);
                            } else {
                                comboEndpt.setSelectedItem(null);
                            }
                        }
                    }
                } catch (Exception ex) {
                    log(message("sslTtl"), ex);
                } finally {
                    isManualUpdate = true;
                }
                removeErrorMsg();
            }
        }
    };
}

From source file:com.microsoft.intellij.ui.azureroles.SSLOffloadingPanel.java

License:Open Source License

private WindowsAzureEndpoint findInputEndpt() throws WindowsAzureInvalidProjectOperationException {
    WindowsAzureEndpoint endpt = null;/*from   w ww  . ja  v a  2  s  .  c om*/
    WindowsAzureEndpoint sessionAffEndPt = waRole.getSessionAffinityInputEndpoint();
    // check session affinity is already enabled, then consider same endpoint
    if (sessionAffEndPt != null) {
        // check port of session affinity endpoint
        String stSesPubPort = sessionAffEndPt.getPort();
        if (stSesPubPort.equalsIgnoreCase(String.valueOf(HTTP_PORT))) {
            // check 443 is already available on same role (input enpoint)
            WindowsAzureEndpoint httpsEndPt = WAEclipseHelperMethods.findEndpointWithPubPort(HTTPS_PORT,
                    waRole);
            if (httpsEndPt != null) {
                /*
                * If HTTPS endpoint with public port 443,
                * is present on same role then show warning
                */
                PluginUtil.displayWarningDialog(String.format(message("httpsPresentSt"), httpsEndPt.getName(),
                        httpsEndPt.getPort(), httpsEndPt.getName()), message("sslTtl"));
                endpt = null;
            } else {
                /*
                 * Check if 443 is used on same role (instance endpoint)
                 * or any other role
                 * if yes then consider 8443.
                 */
                int portToUse = HTTPS_PORT;
                if (WAEclipseHelperMethods.findRoleWithEndpntPubPort(HTTPS_PORT, waProjManager) != null) {
                    // need to use 8443
                    int pubPort = HTTPS_NXT_PORT;
                    while (!waProjManager.isValidPort(String.valueOf(pubPort),
                            WindowsAzureEndpointType.Input)) {
                        pubPort++;
                    }
                    portToUse = pubPort;
                }
                int choice = Messages.showYesNoDialog(
                        message("sslhttp").replace("${epName}", sessionAffEndPt.getName())
                                .replace("${pubPort}", String.valueOf(portToUse))
                                .replace("${privPort}", sessionAffEndPt.getPrivatePort()),
                        message("sslTtl"), Messages.getQuestionIcon());
                if (choice == Messages.YES) {
                    sessionAffEndPt.setPort(String.valueOf(portToUse));
                    endpt = sessionAffEndPt;
                } else {
                    // no button pressed
                    endpt = null;
                }
            }
        } else {
            // port is other than 80, then directly consider it.
            endpt = sessionAffEndPt;
        }
    } else {
        // check this role uses public port 443
        endpt = WAEclipseHelperMethods.findEndpointWithPubPort(HTTPS_PORT, waRole);
        if (endpt != null) {
            // endpoint on this role uses public port 443
            PluginUtil.displayWarningDialog(message("sslTtl"), message("sslWarnMsg"));
        } else {
            // check if another role uses 443 as a public port
            WindowsAzureRole roleWithHTTPS = WAEclipseHelperMethods.findRoleWithEndpntPubPort(HTTPS_PORT,
                    waProjManager);
            if (roleWithHTTPS != null) {
                // another role uses 443 as a public port
                // 1. If this role uses public port 80
                endpt = WAEclipseHelperMethods.findEndpointWithPubPort(HTTP_PORT, waRole);
                if (endpt != null) {
                    /*
                     * endpoint on this role uses public port 80
                     * and 443 has been used on some other role then set to 8443
                     * or some suitable public port
                     */
                    int pubPort = HTTPS_NXT_PORT;
                    while (!waProjManager.isValidPort(String.valueOf(pubPort),
                            WindowsAzureEndpointType.Input)) {
                        pubPort++;
                    }
                    int choice = Messages.showYesNoDialog(
                            message("sslhttp").replace("${epName}", endpt.getName())
                                    .replace("${pubPort}", String.valueOf(pubPort))
                                    .replace("${privPort}", endpt.getPrivatePort()),
                            message("sslTtl"), Messages.getQuestionIcon());
                    if (choice == Messages.YES) {
                        endpt.setPort(String.valueOf(pubPort));
                    } else {
                        // no button pressed
                        endpt = null;
                    }
                } else {
                    // 2. Ask for creating new endpoint
                    List<String> endPtData = WASSLOffloadingUtilMethods.prepareEndpt(HTTPS_NXT_PORT, waRole,
                            waProjManager);
                    int choice = Messages.showYesNoCancelDialog(String.format(message("sslNoHttp"),
                            endPtData.get(0), endPtData.get(1), endPtData.get(2)), message("sslTtl"),
                            Messages.getQuestionIcon());
                    if (choice == Messages.YES) {
                        endpt = waRole.addEndpoint(endPtData.get(0), WindowsAzureEndpointType.Input,
                                endPtData.get(2), endPtData.get(1));
                        setModified(true);
                    } else {
                        // no button pressed
                        endpt = null;
                    }
                }
            } else {
                // no public port 443 on this role, nor on other any role
                // 1. If this role uses public port 80
                endpt = WAEclipseHelperMethods.findEndpointWithPubPort(HTTP_PORT, waRole);
                if (endpt != null) {
                    // endpoint on this role uses public port 80
                    int choice = Messages.showYesNoDialog(
                            message("sslhttp").replace("${epName}", endpt.getName())
                                    .replace("${pubPort}", String.valueOf(HTTPS_PORT))
                                    .replace("${privPort}", endpt.getPrivatePort()),
                            message("sslTtl"), Messages.getQuestionIcon());
                    if (choice == Messages.YES) {
                        endpt.setPort(String.valueOf(HTTPS_PORT));
                    } else {
                        // no button pressed
                        endpt = null;
                    }
                } else {
                    // 2. Ask for creating new endpoint
                    List<String> endPtData = WASSLOffloadingUtilMethods.prepareEndpt(HTTPS_PORT, waRole,
                            waProjManager);
                    int choice = Messages.showYesNoDialog(String.format(message("sslNoHttp"), endPtData.get(0),
                            endPtData.get(1), endPtData.get(2)), message("sslTtl"), Messages.getQuestionIcon());
                    if (choice == Messages.YES) {
                        endpt = waRole.addEndpoint(endPtData.get(0), WindowsAzureEndpointType.Input,
                                endPtData.get(2), endPtData.get(1));
                        setModified(true);
                    } else {
                        // no button pressed
                        endpt = null;
                    }
                }
            }
        }
    }
    return endpt;
}

From source file:com.microsoft.intellij.ui.libraries.ApplicationInsightsPanel.java

License:Open Source License

private void handleWebXML() throws Exception {
    String xmlPath = String.format("%s%s%s", PluginUtil.getModulePath(module), File.separator, webxmlPath);
    if (new File(xmlPath).exists()) {
        handler.parseWebXmlPath(xmlPath);
        handler.setAIFilterConfig();/*from  ww  w. j av a  2  s . c om*/
    } else { // create web.xml
        int choice = Messages.showYesNoDialog(message("depDescMsg"), message("depDescTtl"),
                Messages.getQuestionIcon());
        if (choice == Messages.YES) {
            String path = createFileIfNotExists(message("depFileName"), message("depDirLoc"),
                    message("aiWebXmlResFileLoc"));
            handler.parseWebXmlPath(path);
        } else {
            throw new Exception(": Application Insights cannot be configured without creating web.xml ");
        }
    }
}

From source file:com.microsoft.intellij.ui.libraries.LibraryPropertiesPanel.java

License:Open Source License

private ActionListener createRequiredHttpsCheckListener() {
    return new ActionListener() {
        @Override/*from  ww  w .j a v  a  2  s  .  c o m*/
        public void actionPerformed(ActionEvent e) {
            if (requiresHttpsCheck.isSelected()) {
                //Do nothing
            } else {
                int choice = Messages.showYesNoDialog(message("requiresHttpsDlgMsg"),
                        message("requiresHttpsDlgTitle"), Messages.getQuestionIcon());
                if (choice == Messages.NO) {
                    requiresHttpsCheck.setSelected(true);
                }
            }
        }
    };
}

From source file:com.microsoft.intellij.ui.libraries.LibraryPropertiesPanel.java

License:Open Source License

/**
 * Method adds ACS filter and filter mapping tags in web.xml
 * and saves input values given on ACS library page.
 * In case of edit, populates previously set values.
 *//*from w  ww.  ja v  a2 s .  c o  m*/
private void configureDeployment() {
    ACSFilterHandler handler = null;
    try {
        String xmlPath = String.format("%s%s%s", PluginUtil.getModulePath(module), File.separator,
                message("xmlPath"));
        File webXml = new File(xmlPath);
        if (webXml.exists()) {
            handler = new ACSFilterHandler(xmlPath);
            handler.setAcsFilterParams(message("acsAttr"), acsTxt.getText());
            handler.setAcsFilterParams(message("relAttr"), relTxt.getText());
            if (!embedCertCheck.isSelected()) {
                handler.setAcsFilterParams(message("certAttr"), certTxt.getText());
                if (getEmbeddedCertInfo() != null)
                    removeEmbedCert();
            } else {
                handler.removeParamsIfExists(message("certAttr"));
                if (!certTxt.getText().isEmpty()) {
                    String webinfLoc = String.format("%s%s%s", PluginUtil.getModulePath(module), File.separator,
                            message("depDirLoc"));
                    String certLoc = String.format("%s%s%s", webinfLoc, File.separator, message("acsCertLoc"));
                    File destination = new File(certLoc);
                    if (!destination.getParentFile().exists())
                        destination.getParentFile().mkdir();
                    copy(new File(CerPfxUtil.getCertificatePath(certTxt.getText())), destination);
                }
            }
            handler.setAcsFilterParams(message("secretKeyAttr"), generateKey());
            handler.setAcsFilterParams(message("allowHTTPAttr"),
                    requiresHttpsCheck.isSelected() ? "false" : "true");
        } else {
            int choice = Messages.showYesNoDialog(message("depDescMsg"), message("depDescTtl"),
                    Messages.getQuestionIcon());
            if (choice == Messages.YES) {
                String path = createWebXml();
                //copy cert into WEB-INF/cert/_acs_signing.cer location if embed cert is selected
                if (embedCertCheck.isSelected()) {
                    String webinfLoc = String.format("%s%s%s", PluginUtil.getModulePath(module), File.separator,
                            message("depDirLoc"));
                    String certLoc = String.format("%s%s%s", webinfLoc, File.separator, message("acsCertLoc"));
                    File destination = new File(certLoc);
                    if (!destination.getParentFile().exists())
                        destination.getParentFile().mkdir();
                    copy(new File(CerPfxUtil.getCertificatePath(certTxt.getText())), destination);
                }
                handler = new ACSFilterHandler(path);
                handler.setAcsFilterParams(message("acsAttr"), acsTxt.getText());
                handler.setAcsFilterParams(message("relAttr"), relTxt.getText());
                if (!embedCertCheck.isSelected()) { //Do not make entry if embed cert is selected
                    handler.setAcsFilterParams(message("certAttr"), certTxt.getText());
                    if (getEmbeddedCertInfo() != null)
                        removeEmbedCert();
                }
                handler.setAcsFilterParams(message("secretKeyAttr"), generateKey());
                handler.setAcsFilterParams(message("allowHTTPAttr"),
                        requiresHttpsCheck.isSelected() ? "false" : "true");
            } else {
                return;
            }
        }
    } catch (Exception e) {
        PluginUtil.displayErrorDialogAndLog(message("acsErrTtl"), message("acsErrMsg"), e);
    }
    try {
        handler.save();
    } catch (Exception e) {
        PluginUtil.displayErrorDialogAndLog(message("acsErrTtl"), message("saveErrMsg"), e);
    }
}

From source file:com.microsoftopentechnologies.intellij.ui.azureroles.ComponentsPanel.java

License:Apache License

/**
 * Listener method for remove button which
 * deletes the selected component.//from w  ww.  j  ava 2s. c  o m
 */
private void removeComponent() {
    WindowsAzureRoleComponent component = tblComponents.getSelectedObject();
    //        IWorkspace workspace = ResourcesPlugin.getWorkspace();
    //        IWorkspaceRoot root = workspace.getRoot();
    //        WindowsAzureRoleComponent component = listComponents.get(selIndex);
    try {
        /* First condition: Checks component is part of a JDK,
        * server configuration
        * Second condition: For not showing error message
        * "Disable Server JDK Configuration"
        * while removing server application
        * when server or JDK  is already disabled.
        */
        if (component.getIsPreconfigured() && (!(component.getType().equals(message("typeSrvApp"))
                && windowsAzureRole.getServerName() == null))) {
            PluginUtil.displayErrorDialog(message("jdkDsblErrTtl"), message("jdkDsblErrMsg"));
        } else {
            int choice = Messages.showYesNoDialog(message("cmpntRmvMsg"), message("cmpntRmvTtl"),
                    Messages.getQuestionIcon());
            if (choice == Messages.YES) {
                String cmpntPath = String.format("%s%s%s%s%s",
                        PluginUtil.getModulePath(ModuleManager.getInstance(project)
                                .findModuleByName(waProjManager.getProjectName())),
                        File.separator, windowsAzureRole.getName(), message("approot"),
                        component.getDeployName());
                File file = new File(cmpntPath);
                // Check import source is equal to approot
                if (component.getImportPath().isEmpty() && file.exists()) {
                    int selected = Messages.showYesNoCancelDialog(message("cmpntSrcRmvMsg"),
                            message("cmpntSrcRmvTtl"), Messages.getQuestionIcon());
                    switch (selected) {
                    case Messages.YES:
                        //yes
                        component.delete();
                        //                                tblViewer.refresh();
                        fileToDel.add(file);
                        break;
                    case Messages.NO:
                        //no
                        component.delete();
                        //                                tblViewer.refresh();
                        break;
                    case Messages.CANCEL:
                        //cancel
                        break;
                    default:
                        break;
                    }
                } else {
                    component.delete();
                    //                        tblViewer.refresh();
                    fileToDel.add(file);
                }
                myModified = true;
            }
        }
        //            if (tblComponents.getItemCount() == 0) {
        //                // table is empty i.e. number of rows = 0
        //                btnRemove.setEnabled(false);
        //                btnEdit.setEnabled(false);
        //            }
    } catch (WindowsAzureInvalidProjectOperationException e) {
        PluginUtil.displayErrorDialogAndLog(message("cmpntSetErrTtl"), message("cmpntRmvErrMsg"), e);
    }
}

From source file:com.microsoftopentechnologies.intellij.ui.azureroles.RoleEndpointsPanel.java

License:Apache License

/**
 * Listener method for remove button which
 * deletes the selected endpoint.// w  ww. j a v  a2s  .  co m
 */
private void removeEndpoint() {
    WindowsAzureEndpoint waEndpoint = tblEndpoints.getSelectedObject();
    try {
        WindowsAzureEndpoint debugEndpt = windowsAzureRole.getDebuggingEndpoint();
        String dbgEndptName = "";
        if (debugEndpt != null) {
            dbgEndptName = debugEndpt.getName();
        }
        // delete the selected endpoint
        /*
         * Check end point selected for removal
        * is associated with Caching then give error
        * and does not allow to remove.
        */
        if (waEndpoint.isCachingEndPoint()) {
            PluginUtil.displayErrorDialog(message("cachDsblErTtl"), message("endPtRmvErMsg"));
        }
        /*
        * Check end point selected for removal
        * is associated with Debugging.
        */
        else if (waEndpoint.getName().equalsIgnoreCase(dbgEndptName)) {
            StringBuilder msg = new StringBuilder(message("dlgEPDel"));
            msg.append(message("dlgEPDel1"));
            msg.append(message("dlgEPDel2"));
            int choice = Messages.showYesNoDialog(msg.toString(), message("dlgDelEndPt1"),
                    Messages.getQuestionIcon());
            if (choice == Messages.YES) {
                waEndpoint.delete();
                setModified(true);
                windowsAzureRole.setDebuggingEndpoint(null);
            }
        }
        /*
         * Endpoint associated with both SSL
         * and Session affinity
         */
        else if (waEndpoint.isStickySessionEndpoint() && waEndpoint.isSSLEndpoint()) {
            int choice = Messages.showOkCancelDialog(message("bothDelMsg"), message("dlgDelEndPt1"),
                    Messages.getQuestionIcon());
            if (choice == Messages.OK) {
                setModified(true);
                if (waEndpoint.getEndPointType().equals(WindowsAzureEndpointType.Input)) {
                    windowsAzureRole.setSessionAffinityInputEndpoint(null);
                    windowsAzureRole.setSslOffloading(null, null);
                    waEndpoint.delete();
                } else {
                    windowsAzureRole.setSessionAffinityInputEndpoint(null);
                    windowsAzureRole.setSslOffloading(null, null);
                }
            }
        }
        /*
        * Check end point selected for removal
        * is associated with Load balancing
        * i.e (HTTP session affinity).
        */
        else if (waEndpoint.isStickySessionEndpoint()) {
            int choice = Messages.showOkCancelDialog(message("ssnAffDelMsg"), message("dlgDelEndPt1"),
                    Messages.getQuestionIcon());
            if (choice == Messages.OK) {
                setModified(true);
                if (waEndpoint.getEndPointType().equals(WindowsAzureEndpointType.Input)) {
                    windowsAzureRole.setSessionAffinityInputEndpoint(null);
                    waEndpoint.delete();
                } else {
                    windowsAzureRole.setSessionAffinityInputEndpoint(null);
                }
            }
        }
        /*
         * Endpoint associated with SSL
         */
        else if (waEndpoint.isSSLEndpoint()) {
            int choice = Messages.showOkCancelDialog(message("sslDelMsg"), message("dlgDelEndPt1"),
                    Messages.getQuestionIcon());
            if (choice == Messages.OK) {
                setModified(true);
                if (waEndpoint.getEndPointType().equals(WindowsAzureEndpointType.Input)) {
                    windowsAzureRole.setSslOffloading(null, null);
                    waEndpoint.delete();
                } else {
                    windowsAzureRole.setSslOffloading(null, null);
                }
            }
        }
        /*
         * Endpoint associated with SSL redirection.
         */
        else if (waEndpoint.isSSLRedirectEndPoint()) {
            int choice = Messages.showOkCancelDialog(message("sslRedirectDelMsg"), message("dlgDelEndPt1"),
                    Messages.getQuestionIcon());
            if (choice == Messages.OK) {
                windowsAzureRole.deleteSslOffloadingRedirectionEndpoint();
                setModified(true);
            }
        }
        /*
         * Normal end point.
         */
        else {
            int choice = Messages.showOkCancelDialog(message("dlgDelEndPt2"), message("dlgDelEndPt1"),
                    Messages.getQuestionIcon());
            if (choice == Messages.OK) {
                setModified(true);
                waEndpoint.delete();
            }
        }
    } catch (WindowsAzureInvalidProjectOperationException e) {
        PluginUtil.displayErrorDialogAndLog(message("adRolErrMsgBox1") + message("adRolErrMsgBox2"),
                message("adRolErrTitle"), e);
    }
}

From source file:com.microsoftopentechnologies.intellij.ui.azureroles.SSLOffloadingPanel.java

License:Apache License

private WindowsAzureEndpoint findInputEndpt() throws WindowsAzureInvalidProjectOperationException {
    WindowsAzureEndpoint endpt = null;//w  w w.j  av a  2 s .  c  o  m
    WindowsAzureEndpoint sessionAffEndPt = waRole.getSessionAffinityInputEndpoint();
    // check session affinity is already enabled, then consider same endpoint
    if (sessionAffEndPt != null) {
        // check port of session affinity endpoint
        String stSesPubPort = sessionAffEndPt.getPort();
        if (stSesPubPort.equalsIgnoreCase(String.valueOf(HTTP_PORT))) {
            // check 443 is already available on same role (input enpoint)
            WindowsAzureEndpoint httpsEndPt = WAEclipseHelperMethods.findEndpointWithPubPort(HTTPS_PORT,
                    waRole);
            if (httpsEndPt != null) {
                /*
                 * If HTTPS endpoint with public port 443,
                 * is present on same role then show warning
                 */
                PluginUtil.displayWarningDialog(String.format(message("httpsPresentSt"), httpsEndPt.getName(),
                        httpsEndPt.getPort(), httpsEndPt.getName()), message("sslTtl"));
                endpt = null;
            } else {
                /*
                 * Check if 443 is used on same role (instance endpoint)
                 * or any other role
                 * if yes then consider 8443.
                 */
                int portToUse = HTTPS_PORT;
                if (WAEclipseHelperMethods.findRoleWithEndpntPubPort(HTTPS_PORT, waProjManager) != null) {
                    // need to use 8443
                    int pubPort = HTTPS_NXT_PORT;
                    while (!waProjManager.isValidPort(String.valueOf(pubPort),
                            WindowsAzureEndpointType.Input)) {
                        pubPort++;
                    }
                    portToUse = pubPort;
                }
                int choice = Messages.showYesNoDialog(
                        message("sslhttp").replace("${epName}", sessionAffEndPt.getName())
                                .replace("${pubPort}", String.valueOf(portToUse))
                                .replace("${privPort}", sessionAffEndPt.getPrivatePort()),
                        message("sslTtl"), Messages.getQuestionIcon());
                if (choice == Messages.YES) {
                    sessionAffEndPt.setPort(String.valueOf(portToUse));
                    endpt = sessionAffEndPt;
                } else {
                    // no button pressed
                    endpt = null;
                }
            }
        } else {
            // port is other than 80, then directly consider it.
            endpt = sessionAffEndPt;
        }
    } else {
        // check this role uses public port 443
        endpt = WAEclipseHelperMethods.findEndpointWithPubPort(HTTPS_PORT, waRole);
        if (endpt != null) {
            // endpoint on this role uses public port 443
            PluginUtil.displayWarningDialog(message("sslTtl"), message("sslWarnMsg"));
        } else {
            // check if another role uses 443 as a public port
            WindowsAzureRole roleWithHTTPS = WAEclipseHelperMethods.findRoleWithEndpntPubPort(HTTPS_PORT,
                    waProjManager);
            if (roleWithHTTPS != null) {
                // another role uses 443 as a public port
                // 1. If this role uses public port 80
                endpt = WAEclipseHelperMethods.findEndpointWithPubPort(HTTP_PORT, waRole);
                if (endpt != null) {
                    /*
                     * endpoint on this role uses public port 80
                     * and 443 has been used on some other role then set to 8443
                     * or some suitable public port
                     */
                    int pubPort = HTTPS_NXT_PORT;
                    while (!waProjManager.isValidPort(String.valueOf(pubPort),
                            WindowsAzureEndpointType.Input)) {
                        pubPort++;
                    }
                    int choice = Messages.showYesNoDialog(
                            message("sslhttp").replace("${epName}", endpt.getName())
                                    .replace("${pubPort}", String.valueOf(pubPort))
                                    .replace("${privPort}", endpt.getPrivatePort()),
                            message("sslTtl"), Messages.getQuestionIcon());
                    if (choice == Messages.YES) {
                        endpt.setPort(String.valueOf(pubPort));
                    } else {
                        // no button pressed
                        endpt = null;
                    }
                } else {
                    // 2. Ask for creating new endpoint
                    List<String> endPtData = WASSLOffloadingUtilMethods.prepareEndpt(HTTPS_NXT_PORT, waRole,
                            waProjManager);
                    int choice = Messages.showYesNoCancelDialog(String.format(message("sslNoHttp"),
                            endPtData.get(0), endPtData.get(1), endPtData.get(2)), message("sslTtl"),
                            Messages.getQuestionIcon());
                    if (choice == Messages.YES) {
                        endpt = waRole.addEndpoint(endPtData.get(0), WindowsAzureEndpointType.Input,
                                endPtData.get(2), endPtData.get(1));
                        setModified(true);
                    } else {
                        // no button pressed
                        endpt = null;
                    }
                }
            } else {
                // no public port 443 on this role, nor on other any role
                // 1. If this role uses public port 80
                endpt = WAEclipseHelperMethods.findEndpointWithPubPort(HTTP_PORT, waRole);
                if (endpt != null) {
                    // endpoint on this role uses public port 80
                    int choice = Messages.showYesNoDialog(
                            message("sslhttp").replace("${epName}", endpt.getName())
                                    .replace("${pubPort}", String.valueOf(HTTPS_PORT))
                                    .replace("${privPort}", endpt.getPrivatePort()),
                            message("sslTtl"), Messages.getQuestionIcon());
                    if (choice == Messages.YES) {
                        endpt.setPort(String.valueOf(HTTPS_PORT));
                    } else {
                        // no button pressed
                        endpt = null;
                    }
                } else {
                    // 2. Ask for creating new endpoint
                    List<String> endPtData = WASSLOffloadingUtilMethods.prepareEndpt(HTTPS_PORT, waRole,
                            waProjManager);
                    int choice = Messages.showYesNoDialog(String.format(message("sslNoHttp"), endPtData.get(0),
                            endPtData.get(1), endPtData.get(2)), message("sslTtl"), Messages.getQuestionIcon());
                    if (choice == Messages.YES) {
                        endpt = waRole.addEndpoint(endPtData.get(0), WindowsAzureEndpointType.Input,
                                endPtData.get(2), endPtData.get(1));
                        setModified(true);
                    } else {
                        // no button pressed
                        endpt = null;
                    }
                }
            }
        }
    }
    return endpt;
}

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  ww. 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: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  . j a  v  a2  s .co m
            }
            if (ivyHome != null && !ivyHome.equals(ResolverLoader.this.ivyHome)) {
                ResolverLoader.this.ivyHome = ivyHome;
                reloadResolver(ivyHome);
            }
            result.set(ivyHome != null);
        }
    });
    return result.get();
}