protected Control createContents(Composite parent) { Composite container = new Composite(parent, SWT.NONE); GridLayout gridLayout = new GridLayout(2, false); container.setLayout(gridLayout); GridData gridData = new GridData(); gridData.widthHint = 200; container.setLayoutData(gridData); Label lblName = new Label(container, SWT.LEFT); gridData = new GridData(); gridData.horizontalIndent = 10; lblName.setLayoutData(gridData); lblName.setText(Messages.adRolName); txtName = new Text(container, SWT.SINGLE | SWT.BORDER); gridData = new GridData(); gridData.horizontalAlignment = GridData.END; gridData.grabExcessHorizontalSpace = true; gridData.widthHint = 75; txtName.setLayoutData(gridData); createEndptTypeComponent(container); createPublicPortComponent(container); Label lblPrivatePort = new Label(container, SWT.LEFT); gridData = new GridData(); gridData.horizontalIndent = 10; lblPrivatePort.setLayoutData(gridData); lblPrivatePort.setText(Messages.adRolPrivatePort); txtPrivatePort = new Text(container, SWT.SINGLE | SWT.BORDER); gridData = new GridData(); gridData.horizontalAlignment = GridData.END; gridData.grabExcessHorizontalSpace = true; gridData.widthHint = 75; txtPrivatePort.setLayoutData(gridData); if (isEditEndpt) { txtName.setText(waEndpt.getName()); txtPrivatePort.setText(waEndpt.getPrivatePort()); txtPublicPort.setText(waEndpt.getPort()); comboType.setText(waEndpt.getEndPointType().toString()); if (comboType.getText().equalsIgnoreCase(WindowsAzureEndpointType.Internal.toString())) { txtPublicPort.setEnabled(false); lblPublicPort.setEnabled(false); txtPublicPort.setText(""); } } return super.createContents(parent); }
@Override protected void init() { setTitle(waEndpt == null ? message("adRolEndPtTitle") : message("endptEditTitle")); comboType.setModel(new DefaultComboBoxModel(WindowsAzureEndpointType.values())); comboType.addItemListener(createComboTypeListener()); lblName.setPreferredSize(lblPrivatePort.getPreferredSize()); // Edit Endpoint scenario if (waEndpt != null) { txtName.setText(waEndpt.getName()); // type WindowsAzureEndpointType type = null; try { type = waEndpt.getEndPointType(); comboType.setSelectedItem(type); } catch (WindowsAzureInvalidProjectOperationException e) { PluginUtil.displayErrorDialog(message("dlgDbgEndPtErrTtl"), message("endPtTypeErr")); } // private port String prvPort = waEndpt.getPrivatePort(); if (prvPort == null && !type.equals(WindowsAzureEndpointType.InstanceInput)) { txtPrivatePort.setText(AUTO); } else { String[] prvPortRange = prvPort.split("-"); txtPrivatePort.setText(prvPortRange[0]); if (prvPortRange.length > 1) { txtPrivatePortRangeEnd.setText(prvPortRange[1]); } } // Public port String[] portRange = waEndpt.getPort().split("-"); txtPublicPort.setText(portRange[0]); if (portRange.length > 1) { txtPublicPortRangeEnd.setText(portRange[1]); } } else { /* * Add Endpoint scenario. * Endpoint type is Internal for the first time. */ txtPrivatePort.setText(AUTO); } enableControlsDependingOnEnpointType((WindowsAzureEndpointType) comboType.getSelectedItem()); txtPrivatePort.addFocusListener(createPortFocusListener()); txtPrivatePortRangeEnd.addFocusListener(createPortFocusListener()); super.init(); }
/** * This method populates the endpoint list every time we made any changes in the endpoint list. * * @throws com.interopbridges.tools.windowsazure.WindowsAzureInvalidProjectOperationException */ private void populateEndPointList() throws WindowsAzureInvalidProjectOperationException { List<WindowsAzureEndpoint> endpointsList; endpointsList = new ArrayList<WindowsAzureEndpoint>(waRole.getEndpoints()); comboEndPoint.removeAll(); for (WindowsAzureEndpoint endpoint : endpointsList) { if (((endpoint.getEndPointType().equals(WindowsAzureEndpointType.Input) && endpoint.getPrivatePort() != null) || endpoint.getEndPointType().equals(WindowsAzureEndpointType.InstanceInput)) && !endpoint.equals(waRole.getSessionAffinityInputEndpoint()) && !endpoint.equals(waRole.getSslOffloadingInputEndpoint())) { comboEndPoint.addItem( String.format( message("dbgEndPtStr"), endpoint.getName(), endpoint.getPort(), endpoint.getPrivatePort())); } } }
/** 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); } }
/** This method removed the associated debug end point if debug check box get unchecked. */ private void removeDebugAssociatedEndpoint() { List<WindowsAzureEndpoint> endpointsList; try { endpointsList = new ArrayList<WindowsAzureEndpoint>(waRole.getEndpoints()); for (WindowsAzureEndpoint endpoint : endpointsList) { if (((String) comboEndPoint.getSelectedItem()) .equalsIgnoreCase( String.format( message("dbgEndPtStr"), endpoint.getName(), endpoint.getPort(), endpoint.getPrivatePort()))) { endpoint.delete(); } } comboEndPoint.removeAllItems(); // comboEndPoint.setText(""); makeAllDisable(); waRole.setDebuggingEndpoint(null); } 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); } }