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

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

Introduction

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

Prototype

@OkCancelResult
@Deprecated
public static int showOkCancelDialog(String message,
        @Nls(capitalization = Nls.Capitalization.Title) String title, 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.CertificatesPanel.java

License:Open Source License

private void removeCertificate() {
    try {/* w ww . j a  v  a  2  s .c  om*/
        WindowsAzureCertificate delCert = tblCertificates.getSelectedObject();
        if (delCert.isRemoteAccess() && delCert.isSSLCert()) {
            String temp = String.format("%s%s%s", message("sslTtl"), " and ", message("cmhLblRmtAces"));
            PluginUtil.displayErrorDialog(message("certRmTtl"),
                    String.format(message("certComMsg"), temp, temp));
        } else if (delCert.isRemoteAccess()) {
            PluginUtil.displayErrorDialog(message("certRmTtl"),
                    String.format(message("certComMsg"), message("cmhLblRmtAces"), message("cmhLblRmtAces")));
        } else if (delCert.isSSLCert()) {
            PluginUtil.displayErrorDialog(message("certRmTtl"),
                    String.format(message("certComMsg"), message("sslTtl"), message("sslTtl")));
        } else {
            int choice = Messages.showOkCancelDialog(String.format(message("certRmMsg"), delCert.getName()),
                    message("certRmTtl"), Messages.getQuestionIcon());
            if (choice == Messages.OK) {
                delCert.delete();
                certSelected = "";
                setModified(true);
                tblCertificates.getListTableModel().removeRow(tblCertificates.getSelectedRow());
            }
        }
    } catch (WindowsAzureInvalidProjectOperationException e) {
        PluginUtil.displayErrorDialogAndLog(message("certErrTtl"), message("certErrMsg"), e);
    }
}

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

License:Open Source License

/**
 * This method sets the status of debug option
 * based on the user input.If user checks the debug check box
 * first time then it will add a debugging end point otherwise it will
 * prompt the user for removal of associated end point for debugging if
 * user already has some debug end point associated and unchecked
 * the debug check box./* www. ja  v a 2  s  .  c  o m*/
 */
private void debugOptionStatus() {
    if (debugCheck.isSelected()) {
        makeDebugEnable();
        try {
            waRole.setDebuggingEndpoint(dbgSelEndpoint);
            waRole.setStartSuspended(jvmCheck.isSelected());
        } catch (WindowsAzureInvalidProjectOperationException e1) {
            PluginUtil.displayErrorDialogAndLog(message("adRolErrTitle"), message("dlgDbgErr"), e1);
        }
    } else {
        if (isDebugChecked && !"".equals(comboEndPoint.getSelectedItem())) {
            String msg = String.format("%s%s", message("dlgDbgEdPtAscMsg"), comboEndPoint.getSelectedItem());
            int choice = Messages.showOkCancelDialog(msg, message("dlgDbgEndPtErrTtl"),
                    Messages.getQuestionIcon());
            if (choice == Messages.OK) {
                removeDebugAssociatedEndpoint();
            } else {
                makeAllDisable();
                try {
                    waRole.setDebuggingEndpoint(null);
                } catch (WindowsAzureInvalidProjectOperationException e) {
                    PluginUtil.displayErrorDialogAndLog(message("adRolErrTitle"), message("dlgDbgErr"), e);
                }
            }
        } else {
            removeDebugAssociatedEndpoint();
        }
    }
}

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

License:Open Source License

/**
 * Listener method for remove button which
 * deletes the selected endpoint.//from   ww  w.ja v  a2 s .c om
 */
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.microsoft.intellij.ui.debug.AzureRemoteStateState.java

License:Open Source License

public ExecutionResult execute(final Executor executor, @NotNull final ProgramRunner runner)
        throws ExecutionException {
    try {//from   w  w  w  . j a  va  2  s . c o  m
        // get web app name to which user want to debug his application
        String website = webAppName;
        if (!website.isEmpty()) {
            website = website.substring(0, website.indexOf('(')).trim();
            Map<WebSite, WebSiteConfiguration> webSiteConfigMap = AzureSettings.getSafeInstance(project)
                    .loadWebApps();
            // retrieve web apps configurations
            for (Map.Entry<WebSite, WebSiteConfiguration> entry : webSiteConfigMap.entrySet()) {
                final WebSite websiteTemp = entry.getKey();
                if (websiteTemp.getName().equals(website)) {
                    final WebSiteConfiguration webSiteConfiguration = entry.getValue();
                    // case - if user uses shortcut without going to Azure Tab
                    Map<String, Boolean> mp = AzureSettings.getSafeInstance(project).getWebsiteDebugPrep();
                    if (!mp.containsKey(website)) {
                        mp.put(website, false);
                    }
                    AzureSettings.getSafeInstance(project).setWebsiteDebugPrep(mp);
                    // check if web app prepared for debugging and process has started
                    if (AzureSettings.getSafeInstance(project).getWebsiteDebugPrep().get(website).booleanValue()
                            && !Utils.isPortAvailable(Integer.parseInt(socketPort))) {
                        ConsoleViewImpl consoleView = new ConsoleViewImpl(project, false);
                        RemoteDebugProcessHandler process = new RemoteDebugProcessHandler(project);
                        consoleView.attachToProcess(process);
                        return new DefaultExecutionResult(consoleView, process);
                    } else {
                        if (AzureSettings.getSafeInstance(project).getWebsiteDebugPrep().get(website)
                                .booleanValue()) {
                            // process not started
                            ApplicationManager.getApplication().invokeLater(new Runnable() {
                                @Override
                                public void run() {
                                    int choice = Messages.showOkCancelDialog(message("processDebug"),
                                            "Azure Web App", Messages.getQuestionIcon());
                                    if (choice == Messages.OK) {
                                        // check is there a need for preparation
                                        ProcessForDebug task = new ProcessForDebug(websiteTemp,
                                                webSiteConfiguration);
                                        try {
                                            task.queue();
                                            Messages.showInfoMessage(message("debugReady"), "Azure Web App");
                                        } catch (Exception e) {
                                            AzurePlugin.log(e.getMessage(), e);
                                        }
                                    }
                                }
                            }, ModalityState.defaultModalityState());
                        } else {
                            // start the process of preparing the web app, in a blocking way
                            if (Utils.isPortAvailable(Integer.parseInt(socketPort))) {
                                ApplicationManager.getApplication().invokeLater(new Runnable() {
                                    @Override
                                    public void run() {
                                        int choice = Messages.showOkCancelDialog(message("remoteDebug"),
                                                "Azure Web App", Messages.getQuestionIcon());
                                        if (choice == Messages.OK) {
                                            // check is there a need for preparation
                                            PrepareForDebug task = new PrepareForDebug(websiteTemp,
                                                    webSiteConfiguration);
                                            try {
                                                task.queue();
                                                Messages.showInfoMessage(message("debugReady"),
                                                        "Azure Web App");
                                            } catch (Exception e) {
                                                AzurePlugin.log(e.getMessage(), e);
                                            }
                                        }
                                    }
                                }, ModalityState.defaultModalityState());
                            } else {
                                ApplicationManager.getApplication().invokeLater(new Runnable() {
                                    @Override
                                    public void run() {
                                        PluginUtil.displayErrorDialog("Azure Web App",
                                                String.format(message("portMsg"), socketPort));
                                    }
                                }, ModalityState.defaultModalityState());
                            }
                        }
                    }
                    break;
                }
            }
        }
    } catch (Exception ex) {
        AzurePlugin.log(ex.getMessage(), ex);
    }
    return null;
}

From source file:com.microsoft.intellij.ui.StorageAccountPanel.java

License:Open Source License

private ActionListener createRemoveButtonListener() {
    return new ActionListener() {
        @Override/*from   w  w w . ja v  a2  s .com*/
        public void actionPerformed(ActionEvent e) {
            int curSelIndex = accountsTable.getSelectedRow();
            if (curSelIndex > -1) {
                int choice = Messages.showOkCancelDialog(message("accRmvMsg"), message("accRmvTtl"),
                        Messages.getQuestionIcon());
                if (choice == Messages.OK) {
                    StorageAccountRegistry.getStrgList().remove(curSelIndex);
                    AzureSettings.getSafeInstance(myProject).saveStorage();
                    ((StorageAccountTableModel) accountsTable.getModel()).setAccounts(getTableContent());
                    ((StorageAccountTableModel) accountsTable.getModel()).fireTableDataChanged();
                }
            }
        }
    };
}

From source file:com.microsoft.intellij.ui.WARemoteAccessPanel.java

License:Open Source License

public boolean doOKAction() {
    try {//from  ww w.ja  va 2  s.com
        loadProject();
        if (remoteChkBtn.isSelected()) {
            waProjManager.setRemoteAccessAllRoles(true);
            String userName = txtUserName.getText();
            String pwd = txtPassword.getText();
            String cnfPwd = txtConfirmPwd.getText();
            String newPath = txtPath.getText();
            Date expDate = txtExpiryDate.getDate();
            String tempPath = newPath;
            boolean isPathChanged = false;
            waProjManager.setRemoteAccessUsername(userName);
            if (!newPath.equals(waProjManager.getRemoteAccessCertificatePath()) && !newPath.isEmpty()) {
                isPathChanged = true;
                /*
                 * check If certificate file path has changed,
                 * If yes then prompt user
                 * for changing the password as well,
                 * if that is not changed.
                 * Because we have to encrypt the new password
                 * and then we will generate certificate
                 * based on that.
                 * Case 1 :- If user has changed the path
                 * and password is old then it
                 * will prompt for new password or re-enter the password.
                 * If user changes the password
                 * then it will generate certificate based
                 * on that new password.
                 * Case 2 :- If user set the blank password
                 * even after displaying that
                 * password change prompt, in that case
                 * we will display warning messages
                 * to user that whether he want to continue
                 * with empty password, If yes
                 * then we will consider that blank password
                 * else use will have to enter
                 * new password.
                 */
                if (pwd.equals(waProjManager.getRemoteAccessEncryptedPassword()) && !pwd.isEmpty()) {
                    txtPassword.setText("");
                    txtConfirmPwd.setText("");
                    PluginUtil.displayErrorDialog(message("remAccErTxtTitle"), message("remAccPwdMstChng"));
                    return false;
                }
            }
            if (pwd.isEmpty()) {
                int choice = Messages.showOkCancelDialog(message("remAccErTxtTitle"), message("remAccWarnPwd"),
                        Messages.getQuestionIcon());
                if (!(choice == Messages.OK)) {
                    return false;
                }
            }
            if (expDate == null) {
                PluginUtil.displayErrorDialog(message("remAccErTxtTitle"), message("remAccExpDateNull"));
                return false;
            } else {
                boolean status = validateExpDate(expDate);
                if (!status) {
                    return false;
                }
            }
            if (newPath.equalsIgnoreCase("")) {
                PluginUtil.displayErrorDialog(message("remAccErTxtTitle"), message("remAccPathNull"));
                return false;
            }
            /*
             * Check for displaying the relative path
             * in case when user select the certificate file path
             * as workspace or of current project.
             * We will be showing relative path in that case on UI.
             */
            if (tempPath.startsWith(BASE_PATH)) {
                tempPath = tempPath.substring(tempPath.indexOf("}") + 1, tempPath.length());
                tempPath = String.format("%s%s", PluginUtil.getModulePath(myModule), tempPath);
            }
            File file = new File(tempPath);
            //if path is not correct.display error message for that.
            if (file.exists() && tempPath.endsWith(".cer")) {
                waProjManager.setRemoteAccessCertificatePath(newPath);
            } else {
                PluginUtil.displayErrorDialog(message("remAccErTxtTitle"), message("remAccInvldPath"));
                return false;
            }
            try {
                if (isPathChanged) {
                    String thumbprint = CerPfxUtil.getThumbPrint(tempPath);
                    if (waProjManager.isRemoteAccessTryingToUseSSLCert(thumbprint)) {
                        PluginUtil.displayErrorDialog(message("remAccSyntaxErr"), message("usedBySSL"));
                        return false;
                    } else {
                        waProjManager.setRemoteAccessCertificateFingerprint(thumbprint);
                    }
                }
            } catch (Exception e) {
                PluginUtil.displayErrorDialogAndLog(message("remAccSyntaxErr"), message("remAccErTmbPrint"), e);
                return false;
            }
            if (cnfPwd.equals(pwd)) {
                try {
                    /*
                     * Encrypting the password
                     * if it is not dummy & blank from xml
                     * and isPwdChanged is true that means
                     * user has changes the password.
                     */
                    String modifiedPwd = message("remAccDummyPwd");
                    if (!pwd.equals(modifiedPwd) && !pwd.isEmpty() && isPwdChanged) {
                        String encryptedPwd = EncUtilHelper.encryptPassword(pwd, tempPath,
                                AzurePlugin.pluginFolder);
                        waProjManager.setRemoteAccessEncryptedPassword(encryptedPwd);
                    } else {
                        waProjManager.setRemoteAccessEncryptedPassword(pwd);
                    }
                } catch (Exception e) {
                    PluginUtil.displayErrorDialogAndLog(message("remAccSyntaxErr"), message("remAccErPwd"), e);
                    return false;
                }
            } else {
                PluginUtil.displayErrorDialog(message("remAccErTxtTitle"), message("remAccPwdNotMatch"));
                return false;
            }
        } else {
            waProjManager.setRemoteAccessAllRoles(false);
        }
        waProjManager.save();
    } catch (WindowsAzureInvalidProjectOperationException e) {
        PluginUtil.displayErrorDialogAndLog(message("remAccSyntaxErr"),
                message("proPageErrMsgBox1") + message("proPageErrMsgBox2"), e);
    } catch (ParseException e) {
        PluginUtil.displayErrorDialogAndLog(message("remAccErrTitle"), message("remAccErDateParse"), e);
        return false;
    }
    LocalFileSystem.getInstance().findFileByPath(PluginUtil.getModulePath(myModule)).refresh(true, true);
    isFrmEncLink = false;
    return true;
}

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

License:Apache License

/**
 * Method checks if number of instances are equal to 1
 * and caching is enabled as well as high availability
 * feature is on then ask input from user,
 * whether to turn off high availability feature
 * or he wants to edit instances./*ww w.  j  a v a 2s  .  c om*/
 *
 * @param val
 * @return boolean
 */
private boolean handleHighAvailabilityFeature(boolean val) {
    boolean isBackupSet = false;
    boolean okToProceed = val;
    try {
        /*
        * checks if number of instances are equal to 1
        * and caching is enabled
        */
        if (txtNoOfInstances.getText().trim().equalsIgnoreCase("1")
                && windowsAzureRole.getCacheMemoryPercent() > 0) {
            /*
             * Check high availability feature of any of the cache is on
             */
            Map<String, WindowsAzureNamedCache> mapCache = windowsAzureRole.getNamedCaches();
            for (Iterator<WindowsAzureNamedCache> iterator = mapCache.values().iterator(); iterator
                    .hasNext();) {
                WindowsAzureNamedCache cache = (WindowsAzureNamedCache) iterator.next();
                if (cache.getBackups()) {
                    isBackupSet = true;
                }
            }
            /*
             * High availability feature of any of the cache is on.
             */
            if (isBackupSet) {
                int choice = Messages.showOkCancelDialog(message("highAvailMsg"), message("highAvailTtl"),
                        Messages.getQuestionIcon());
                /*
                * Set High availability feature to No.
                */
                if (choice == Messages.OK) {
                    for (Iterator<WindowsAzureNamedCache> iterator = mapCache.values().iterator(); iterator
                            .hasNext();) {
                        WindowsAzureNamedCache cache = iterator.next();
                        if (cache.getBackups()) {
                            cache.setBackups(false);
                        }
                    }
                    okToProceed = true;
                    waProjManager.save();
                } else {
                    /*
                     * Stay on Role properties page.
                     */
                    okToProceed = false;
                    txtNoOfInstances.requestFocus();
                }
            }
        }
    } catch (WindowsAzureInvalidProjectOperationException e) {
        PluginUtil.displayErrorDialogAndLog(message("cachErrTtl"), message("cachGetErMsg"), e);
        okToProceed = false;
    }
    return okToProceed;
}

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

License:Apache License

/**
 * Listener method for remove button which
 * deletes the selected endpoint.//from   ww w . ja v  a 2  s  .  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.WARemoteAccessPanel.java

License:Apache License

public boolean doOKAction() {
    try {/*from w  ww.  j a v  a2s . co  m*/
        loadProject();
        if (remoteChkBtn.isSelected()) {
            waProjManager.setRemoteAccessAllRoles(true);
            String userName = txtUserName.getText();
            String pwd = txtPassword.getText();
            String cnfPwd = txtConfirmPwd.getText();
            String newPath = txtPath.getText();
            Date expDate = txtExpiryDate.getDate();
            String tempPath = newPath;
            boolean isPathChanged = false;
            waProjManager.setRemoteAccessUsername(userName);
            if (!newPath.equals(waProjManager.getRemoteAccessCertificatePath()) && !newPath.isEmpty()) {
                isPathChanged = true;
                /*
                 * check If certificate file path has changed,
                 * If yes then prompt user
                 * for changing the password as well,
                 * if that is not changed.
                 * Because we have to encrypt the new password
                 * and then we will generate certificate
                 * based on that.
                 * Case 1 :- If user has changed the path
                 * and password is old then it
                 * will prompt for new password or re-enter the password.
                 * If user changes the password
                 * then it will generate certificate based
                 * on that new password.
                 * Case 2 :- If user set the blank password
                 * even after displaying that
                 * password change prompt, in that case
                 * we will display warning messages
                 * to user that whether he want to continue
                 * with empty password, If yes
                 * then we will consider that blank password
                 * else use will have to enter
                 * new password.
                 */
                if (pwd.equals(waProjManager.getRemoteAccessEncryptedPassword()) && !pwd.isEmpty()) {
                    txtPassword.setText("");
                    txtConfirmPwd.setText("");
                    PluginUtil.displayErrorDialog(message("remAccErTxtTitle"), message("remAccPwdMstChng"));
                    return false;
                }
            }
            if (pwd.isEmpty()) {
                int choice = Messages.showOkCancelDialog(message("remAccErTxtTitle"), message("remAccWarnPwd"),
                        Messages.getQuestionIcon());
                if (!(choice == Messages.OK)) {
                    return false;
                }
            }
            if (expDate == null) {
                PluginUtil.displayErrorDialog(message("remAccErTxtTitle"), message("remAccExpDateNull"));
                return false;
            } else {
                boolean status = validateExpDate(expDate);
                if (!status) {
                    return false;
                }
            }
            if (newPath.equalsIgnoreCase("")) {
                PluginUtil.displayErrorDialog(message("remAccErTxtTitle"), message("remAccPathNull"));
                return false;
            }
            /*
             * Check for displaying the relative path
             * in case when user select the certificate file path
             * as workspace or of current project.
             * We will be showing relative path in that case on UI.
             */
            if (tempPath.startsWith(BASE_PATH)) {
                tempPath = tempPath.substring(tempPath.indexOf("}") + 1, tempPath.length());
                tempPath = String.format("%s%s", PluginUtil.getModulePath(myModule), tempPath);
            }
            File file = new File(tempPath);
            //if path is not correct.display error message for that.
            if (file.exists() && tempPath.endsWith(".cer")) {
                waProjManager.setRemoteAccessCertificatePath(newPath);
            } else {
                PluginUtil.displayErrorDialog(message("remAccErTxtTitle"), message("remAccInvldPath"));
                return false;
            }
            try {
                if (isPathChanged) {
                    String thumbprint = CerPfxUtil.getThumbPrint(tempPath);
                    if (waProjManager.isRemoteAccessTryingToUseSSLCert(thumbprint)) {
                        PluginUtil.displayErrorDialog(message("remAccSyntaxErr"), message("usedBySSL"));
                        return false;
                    } else {
                        waProjManager.setRemoteAccessCertificateFingerprint(thumbprint);
                    }
                }
            } catch (Exception e) {
                PluginUtil.displayErrorDialogAndLog(message("remAccSyntaxErr"), message("remAccErTmbPrint"), e);
                return false;
            }
            if (cnfPwd.equals(pwd)) {
                try {
                    /*
                     * Encrypting the password
                     * if it is not dummy & blank from xml
                     * and isPwdChanged is true that means
                     * user has changes the password.
                     */
                    String modifiedPwd = message("remAccDummyPwd");
                    if (!pwd.equals(modifiedPwd) && !pwd.isEmpty() && isPwdChanged) {
                        String encryptedPwd = EncUtilHelper.encryptPassword(pwd, tempPath,
                                AzurePlugin.encFolder);
                        waProjManager.setRemoteAccessEncryptedPassword(encryptedPwd);
                    } else {
                        waProjManager.setRemoteAccessEncryptedPassword(pwd);
                    }
                } catch (Exception e) {
                    PluginUtil.displayErrorDialogAndLog(message("remAccSyntaxErr"), message("remAccErPwd"), e);
                    return false;
                }
            } else {
                PluginUtil.displayErrorDialog(message("remAccErTxtTitle"), message("remAccPwdNotMatch"));
                return false;
            }
        } else {
            waProjManager.setRemoteAccessAllRoles(false);
        }
        waProjManager.save();
    } catch (WindowsAzureInvalidProjectOperationException e) {
        PluginUtil.displayErrorDialogAndLog(message("remAccSyntaxErr"),
                message("proPageErrMsgBox1") + message("proPageErrMsgBox2"), e);
    } catch (ParseException e) {
        PluginUtil.displayErrorDialogAndLog(message("remAccErrTitle"), message("remAccErDateParse"), e);
        return false;
    }
    //        WAEclipseHelper.refreshWorkspace(Messages.remAccWarning, Messages.remAccWarnMsg);
    isFrmEncLink = false;
    return true;
}

From source file:com.perl5.lang.perl.idea.configuration.module.PerlInterpreterForModuleStep.java

License:Apache License

public boolean validate() {
    final Sdk jdk = myJdkChooser.getChosenJdk();
    if (jdk == null) {
        int result = Messages.showOkCancelDialog(IdeBundle.message("prompt.confirm.project.no.jdk"),
                IdeBundle.message("title.no.jdk.specified"), Messages.getWarningIcon());
        if (result != Messages.OK) {
            return false;
        }/*from w w  w .  j  a  v a 2  s  . c  o m*/
    }
    return true;
}