/**
  * 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.
  */
 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();
     }
   }
 }
  /** This method enables all the control on UI if Debug is enabled. */
  private void makeDebugEnable() {
    try {
      createDebug.setEnabled(true);
      comboEndPoint.setEnabled(true);
      jvmCheck.setEnabled(true);
      lblDebugEndPoint.setEnabled(true);

      RoleAndEndpoint obj = WARDebuggingUtilMethods.getDebuggingEndpoint(waRole, waProjManager);
      waRole = obj.getRole();
      WindowsAzureEndpoint endpt = obj.getEndPt();

      populateEndPointList();
      comboEndPoint.setSelectedItem(
          String.format(
              message("dbgEndPtStr"), endpt.getName(), endpt.getPort(), endpt.getPrivatePort()));

      dbgSelEndpoint = endpt;
    } catch (WindowsAzureInvalidProjectOperationException e) {
      PluginUtil.displayErrorDialogAndLog(message("adRolErrTitle"), message("dlgDbgErr"), e);
    }
  }
  private void init() {
    try {
      WindowsAzureEndpoint endPt = waRole.getDebuggingEndpoint();
      if (endPt == null) {
        debugCheck.setSelected(false);
        comboEndPoint.removeAllItems(); // todo: ???
        makeAllDisable();
      } else {
        populateEndPointList();
        comboEndPoint.setSelectedItem(
            String.format(
                message("dbgEndPtStr"), endPt.getName(), endPt.getPort(), endPt.getPrivatePort()));
      }
    } catch (Exception e) {
      PluginUtil.displayErrorDialogAndLog(message("adRolErrTitle"), message("dlgDbgErr"), e);
    }
    isDebugChecked = false;
    try {
      isDebugChecked = waRole.getDebuggingEndpoint() != null;
    } catch (Exception ex) {
      // As getTitle() is also showing the error message if any exception
      // occurs in role.getDebuggingEndpoint(), so only logging
      // the exception. getTitle() gets called every time this page is
      // selected but createContents() is called only once while creating
      // the page.
      log(message("dlgDbgErr"), ex);
    }
    debugCheck.setSelected(isDebugChecked);
    debugCheck.addItemListener(createDebugCheckListener());
    try {
      populateEndPointList();
    } catch (WindowsAzureInvalidProjectOperationException e1) {
      PluginUtil.displayErrorDialogAndLog(message("adRolErrTitle"), message("dlgDbgErr"), e1);
    }
    comboEndPoint.addItemListener(createComboEndPointListener());

    try {
      if (isDebugChecked) {
        jvmCheck.setSelected(waRole.getStartSuspended());
      } else {
        jvmCheck.setSelected(false);
      }

    } catch (WindowsAzureInvalidProjectOperationException e2) {
      PluginUtil.displayErrorDialogAndLog(message("adRolErrTitle"), message("dlgDbgErr"), e2);
    }
    jvmCheck.addItemListener(createJvmCheckListener());
    createDebug.addActionListener(createCreateDebugListener());

    try {
      if (isDebugChecked) {
        WindowsAzureEndpoint endPt = waRole.getDebuggingEndpoint();
        comboEndPoint.setSelectedItem(
            String.format(
                message("dbgEndPtStr"), endPt.getName(), endPt.getPort(), endPt.getPrivatePort()));
      } else {
        makeAllDisable();
      }
    } catch (WindowsAzureInvalidProjectOperationException e1) {
      PluginUtil.displayErrorDialogAndLog(message("adRolErrTitle"), message("dlgDbgErr"), e1);
    }
    if (debugCheck.isSelected() && comboEndPoint.getSelectedItem().equals("")) {
      //            setValid(false);
    }
  }
 /** This method disables all the control on UI if Debug is disabled. */
 private void makeAllDisable() {
   createDebug.setEnabled(false);
   comboEndPoint.setEnabled(false);
   jvmCheck.setEnabled(false);
   lblDebugEndPoint.setEnabled(false);
 }