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

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

Introduction

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

Prototype

int YES

To view the source code for com.intellij.openapi.ui Messages YES.

Click Source Link

Usage

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

License:Open Source License

private void handleSmallVMCacheConf() {
    try {/*from   w ww .  j  a  va  2 s .co m*/
        if (message("txtExtraSmallVM").equals((String) comboVMSize.getSelectedItem())
                && windowsAzureRole.getCacheMemoryPercent() > 0) {
            // If extra small VM and cache is enabled
            int choice = Messages.showYesNoDialog((Project) null, message("cacheConfMsg"),
                    message("cacheConfTitle"), Messages.getWarningIcon());
            if (choice == Messages.YES) {
                // Yes - Disable cache
                windowsAzureRole.setCacheMemoryPercent(0);
            } else {
                // No or if dialog is closed directly then reset VM size back to original
                comboVMSize.setSelectedItem(arrVMSize[getVMSizeIndex()]);
            }
        }
    } catch (WindowsAzureInvalidProjectOperationException e) {
        PluginUtil.displayErrorDialogAndLog(message("cachErrTtl"), message("cachGetErMsg"), e);
    }
}

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

License:Open Source License

/**
 * Listener method for remove button which
 * deletes the selected cache entry.//from   ww w  .j a va2  s  .c o m
 */
protected void removeBtnListener() {
    try {
        int choice = Messages.showYesNoDialog(message("cachRmvMsg"), message("cachRmvTtl"),
                Messages.getQuestionIcon());
        if (choice == Messages.YES) {
            WindowsAzureNamedCache cachToDel = tblCache.getSelectedObject();
            cachToDel.delete();
            tblCache.getListTableModel().setItems(new ArrayList<WindowsAzureNamedCache>(mapCache.values()));
            setModified(true);
        }
    } catch (WindowsAzureInvalidProjectOperationException e) {
        PluginUtil.displayErrorDialogAndLog(message("cachErrTtl"), message("cachDelErMsg"), e);
    }
}

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

License:Open Source License

/**
 * Listener method for remove button which
 * deletes the selected component.//  w  w w .  java  2 s.co  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.microsoft.intellij.ui.azureroles.EndpointDialog.java

License:Open Source License

/**
 * Disables the debugging if debug endpoint's type is changed to 'Internal',
 * and if private port is modified then assigns the new debugging port
 * by setting the modified endpoint as a debugging endpoint.
 *
 * @param oldType : old type of the endpoint.
 * @return retVal : false if any error occurs.
 * @throws WindowsAzureInvalidProjectOperationException
 */// w w  w  .  ja  v  a 2 s  .  com
private boolean handleChangeForDebugEndpt(WindowsAzureEndpointType oldType, String privatePort)
        throws WindowsAzureInvalidProjectOperationException {
    boolean retVal = true;
    if (oldType.equals(WindowsAzureEndpointType.Input)
            && comboType.getSelectedItem().equals(WindowsAzureEndpointType.Internal.toString())) {
        int choice = Messages.showYesNoDialog(
                String.format("%s%s%s", message("dlgEPDel"), message("dlgEPChangeType"), message("dlgEPDel2")),
                message("dlgTypeTitle"), Messages.getQuestionIcon());
        if (choice == Messages.YES) {
            waEndpt.setEndPointType((WindowsAzureEndpointType) comboType.getSelectedItem());
            waRole.setDebuggingEndpoint(null);
        } else {
            retVal = false;
        }
    } else if (privatePort == null) {
        PluginUtil.displayErrorDialog(message("dlgInvldPort"), message("dbgPort"));
        retVal = false;
    } else if (!waEndpt.getPrivatePort().equalsIgnoreCase(privatePort)) {
        boolean isSuspended = waRole.getStartSuspended();
        waRole.setDebuggingEndpoint(null);
        waEndpt.setPrivatePort(privatePort);
        waRole.setDebuggingEndpoint(waEndpt);
        waRole.setStartSuspended(isSuspended);
    }
    return retVal;
}

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

License:Open Source License

/**
 * Listener for remove button, which removes the
 * environment variable from the role./*from w w  w .  ja  v  a2 s  .co m*/
 */
@SuppressWarnings("unchecked")
protected void removeBtnListener() {
    try {
        Entry<String, String> mapEntry = tblEnvVariables.getSelectedObject();
        // Check environment variable is associated with component
        if (waRole.getIsEnvPreconfigured(mapEntry.getKey())) {
            PluginUtil.displayErrorDialog(message("jdkDsblErrTtl"), message("envJdkDslErrMsg"));
        } else {
            int choice = Messages.showYesNoDialog(message("evRemoveMsg"), message("evRemoveTtl"),
                    Messages.getQuestionIcon());
            if (choice == Messages.YES) {
                /*
                 * to delete call rename with
                 * newName(second param) as empty
                 */
                waRole.renameRuntimeEnv(mapEntry.getKey(), "");
                setModified(true);
            }
        }
    } catch (Exception ex) {
        PluginUtil.displayErrorDialogAndLog(message("adRolErrTitle"),
                message("adRolErrMsgBox1") + message("adRolErrMsgBox2"), ex);
    }
}

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

License:Open Source License

/**
 * Enable session affinity.// www.jav  a 2s .co m
 */
protected void enableSessionAff() {
    try {
        WindowsAzureEndpoint endpt = null;
        isManualUpdate = false;
        populateEndPointList();
        endpt = WARLoadBalanceUtilMethods.findInputEndpt(waRole, endpointsList);
        if (endpt == null) {
            int choice = Messages.showYesNoDialog(message("lbCreateEndptTtl"), message("lbCreateEndptMsg"),
                    Messages.getQuestionIcon());
            if (choice == Messages.YES) {
                WindowsAzureEndpoint newEndpt = createEndpt();
                populateEndPointList();
                comboEndpt.setSelectedItem(String.format(message("dbgEndPtStr"), newEndpt.getName(),
                        newEndpt.getPort(), newEndpt.getPrivatePort()));
                waRole.setSessionAffinityInputEndpoint(newEndpt);
                btnSsnAffinity.setSelected(true);
                setModified(true);
                isEditableEndpointCombo(newEndpt);
            } else {
                btnSsnAffinity.setSelected(false);
                lblEndptToUse.setEnabled(false);
                comboEndpt.setEnabled(false);
            }
        } else {
            comboEndpt.setSelectedItem(String.format(message("dbgEndPtStr"), endpt.getName(), endpt.getPort(),
                    endpt.getPrivatePort()));
            waRole.setSessionAffinityInputEndpoint(endpt);
            setModified(true);
            isEditableEndpointCombo(endpt);
        }
    } catch (WindowsAzureInvalidProjectOperationException e) {
        PluginUtil.displayErrorDialogAndLog(message("adRolErrTitle"),
                message("adRolErrMsgBox1") + message("adRolErrMsgBox2"), e);
    } finally {
        isManualUpdate = true;
    }
}

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

License:Open Source License

/**
 * Listener method for remove button which
 * deletes the selected local storage resource.
 *///from   www.  j  a v  a2s.  c  o  m
@SuppressWarnings("unchecked")
protected void removeBtnListener() {
    try {
        WindowsAzureLocalStorage delRes = tblResources.getSelectedObject();
        /*
         * Check local storage selected for removal
        * is associated with caching then give error
        * and does not allow to remove.
        */
        if (delRes.isCachingLocalStorage()) {
            PluginUtil.displayErrorDialog(message("cachDsblErTtl"), message("lclStrRmvErMsg"));
        } else {
            int choice = Messages.showYesNoDialog(message("lclStgRmvMsg"), message("lclStgRmvTtl"),
                    Messages.getQuestionIcon());
            if (choice == Messages.YES) {
                delRes.delete();
                setModified(true);
                tblResources.getListTableModel().removeRow(tblResources.getSelectedRow());
            }
        }
    } catch (WindowsAzureInvalidProjectOperationException e) {
        PluginUtil.displayErrorDialogAndLog(message("lclStgSetErrTtl"), message("lclStgSetErrMsg"), e);
    }
}

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

License:Open Source License

/**
 * Validates the size of VM.//from www  .ja  va2 s .c  om
 *
 * @param size : user entered size
 * @return isValidSize : true if size is valid else false.
 */
private boolean isValidSize(String size) {
    boolean isValidSize;
    try {
        int value = Integer.parseInt(size);
        if (value <= 0) {
            PluginUtil.displayErrorDialog(message("lclStgSizeErrTtl"), message("lclStgSizeErrMsg"));
            isValidSize = false;
        } else if (value > maxSize) {
            int choice = Messages.showYesNoDialog(
                    String.format("%s%s%s", message("lclStgMxSizeMsg1"), maxSize, message("lclStgMxSizeMsg2")),
                    message("lclStgMxSizeTtl"), Messages.getQuestionIcon());
            /*
             * If user selects No
             * then keep dialog open.
             */
            isValidSize = choice == Messages.YES;
        } else {
            isValidSize = true;
        }
    } catch (NumberFormatException e) {
        PluginUtil.displayErrorDialogAndLog(message("lclStgSizeErrTtl"), message("lclStgSizeErrMsg"), e);
        isValidSize = false;
    }
    return isValidSize;
}

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 .  j av  a  2  s  .c  o 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.microsoft.intellij.ui.azureroles.SSLOffloadingPanel.java

License:Open Source License

private ItemListener createComboEndptListener() {
    return new ItemListener() {
        @Override/*from w w w.jav  a2 s . c o  m*/
        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();
            }
        }
    };
}