in PluginsAndFeatures/azure-toolkit-for-eclipse/com.microsoft.azuretools.core/src/com/microsoft/azuretools/core/ui/login/ServicePrincipalLoginDialog.java [103:230]
public ServicePrincipalLoginPanel(Composite parent, int style) {
super(parent, style);
Composite container = this;
setLayout(new GridLayout(2, false));
Label lblTenantId = new Label(container, SWT.NONE);
lblTenantId.setText("Tenant Id: ");
txtTenantId = new GuidAzureTextInput(container);
txtTenantId.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
txtTenantId.setLabeledBy(lblTenantId);
txtTenantId.setRequired(true);
Label lblClientId = new Label(container, SWT.NONE);
lblClientId.setText("Client Id: ");
txtClientId = new GuidAzureTextInput(container);
txtClientId.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
txtClientId.setRequired(true);
txtClientId.setLabeledBy(lblClientId);
Label lblSecret = new Label(container, SWT.NONE);
lblSecret.setText("Secret: ");
Group composite = new Group(container, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
GridLayout glComposite = new GridLayout(2, false);
glComposite.verticalSpacing = 0;
glComposite.marginHeight = 0;
glComposite.marginTop = 1;
glComposite.marginRight = 5;
glComposite.marginLeft = 5;
glComposite.marginWidth = 0;
composite.setLayout(glComposite);
radioPassword = new Button(composite, SWT.RADIO);
radioPassword.setSelection(true);
radioPassword.setText("Password:");
txtPassword = new AzureTextInput(composite, SWT.BORDER | SWT.PASSWORD);
txtPassword.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
txtPassword.setLabel("Password");
radioCertificate = new Button(composite, SWT.RADIO);
radioCertificate.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
radioCertificate.setText("Certificate:");
Composite compositeCert = new Composite(composite, SWT.NONE);
compositeCert.setLayout(new FormLayout());
GridData gdCompositeCert = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
gdCompositeCert.widthHint = 191;
compositeCert.setLayoutData(gdCompositeCert);
txtCertificate = new AzureTextInput(compositeCert, SWT.BORDER | SWT.READ_ONLY);
txtCertificate.setEnabled(false);
FormData fdTxtCertificate = new FormData();
fdTxtCertificate.top = new FormAttachment(0, 3);
fdTxtCertificate.left = new FormAttachment(0, 0);
txtCertificate.setLayoutData(fdTxtCertificate);
txtCertificate.setLabel("Certificate");
btnOpenFileButton = new Button(compositeCert, SWT.CENTER);
fdTxtCertificate.right = new FormAttachment(btnOpenFileButton, -6);
FormData fdBtnOpenFileButton = new FormData();
fdBtnOpenFileButton.top = new FormAttachment(0, 1);
fdBtnOpenFileButton.right = new FormAttachment(100);
btnOpenFileButton.setLayoutData(fdBtnOpenFileButton);
btnOpenFileButton.setText("...");
btnOpenFileButton.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
FileDialog dlg = new FileDialog(btnOpenFileButton.getShell(), SWT.OPEN);
dlg.setText("Open");
String path = dlg.open();
if (path == null) {
return;
}
txtCertificate.setText(path);
}
});
btnOpenFileButton.setEnabled(false);
Label lblJson = new Label(container, SWT.NONE);
lblJson.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, true, 1, 1));
lblJson.setText("JSON:");
Composite composite2 = new Composite(container, SWT.NONE);
composite2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
composite2.setLayout(new FillLayout(SWT.HORIZONTAL));
txtJson = new Text(composite2, SWT.MULTI | SWT.BORDER);
txtJson.setLayoutData(new GridData(GridData.FILL_BOTH));
txtJson.addModifyListener(event -> {
this.json2UIComponents();
});
radioCertificate.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
triggerPasswordCertState();
}
});
radioPassword.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
triggerPasswordCertState();
}
});
Stream.of(txtCertificate, txtClientId, txtPassword, txtTenantId).forEach(d -> d.addModifyListener(r -> updateToJsonEditor()));
Stream.of(radioCertificate, radioPassword).forEach(d -> d.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
super.widgetSelected(e);
updateToJsonEditor();
}
}));
}