コード例 #1
0
 /**
  * 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
  */
 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;
 }
 /**
  * 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
  */
 private boolean handleChangeForDebugEndpt(WindowsAzureEndpointType oldType)
     throws WindowsAzureInvalidProjectOperationException {
   boolean retVal = true;
   if (oldType.equals(WindowsAzureEndpointType.Input)
       && comboType.getText().equalsIgnoreCase(WindowsAzureEndpointType.Internal.toString())) {
     StringBuffer msg = new StringBuffer(Messages.dlgEPDel);
     msg.append(Messages.dlgEPChangeType);
     msg.append(Messages.dlgEPDel2);
     boolean choice =
         MessageDialog.openQuestion(new Shell(), Messages.dlgTypeTitle, msg.toString());
     if (choice) {
       waEndpt.setEndPointType(WindowsAzureEndpointType.valueOf(comboType.getText()));
       windowsAzureRole.setDebuggingEndpoint(null);
     } else {
       retVal = false;
     }
   } else if (!waEndpt.getPrivatePort().equalsIgnoreCase(txtPrivatePort.getText())) {
     boolean isSuspended = windowsAzureRole.getStartSuspended();
     windowsAzureRole.setDebuggingEndpoint(null);
     waEndpt.setPrivatePort(txtPrivatePort.getText());
     windowsAzureRole.setDebuggingEndpoint(waEndpt);
     windowsAzureRole.setStartSuspended(isSuspended);
   }
   return retVal;
 }
  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);
    }
  }