use of org.eclipse.swt.widgets.DirectoryDialog in project translationstudio8 by heartsome.
the class ExportExternalDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
Composite tparent = (Composite) super.createDialogArea(parent);
GridDataFactory.createFrom(new GridData(GridData.FILL_BOTH)).hint(600, SWT.DEFAULT).applyTo(tparent);
final Group groupFile = new Group(tparent, SWT.NONE);
groupFile.setText(Messages.getString("ExportDocxDialog.lable.xliff"));
groupFile.setLayout(new GridLayout(1, false));
groupFile.setLayoutData(new GridData(GridData.FILL_BOTH));
final TableViewer tbv = new TableViewer(groupFile, SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER);
final Table table = tbv.getTable();
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableLayout tableLayout = new TableLayout();
table.setLayout(tableLayout);
GridDataFactory.swtDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).hint(SWT.DEFAULT, 90).applyTo(table);
tableLayout.addColumnData(new ColumnWeightData(1));
new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.nodot"));
tableLayout.addColumnData(new ColumnWeightData(10));
new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.fullPath"));
tableLayout.addColumnData(new ColumnWeightData(2));
new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.srcLang"));
tableLayout.addColumnData(new ColumnWeightData(2));
new TableColumn(table, SWT.NONE).setText(Messages.getString("ExportDocxDialog.lable.tgtLang"));
tbv.setLabelProvider(new TableViewLabelProvider());
tbv.setContentProvider(new ArrayContentProvider());
tbv.setInput(xlfBeans);
final Group groupExportType = new Group(tparent, SWT.NONE);
groupExportType.setText(Messages.getString("ExportDocxDialog.lable.exporttype"));
groupExportType.setLayout(new GridLayout(3, false));
groupExportType.setLayoutData(new GridData(GridData.FILL_BOTH));
final Label lblExportType = new Label(groupExportType, SWT.NONE);
lblExportType.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblExportType.setText(Messages.getString("ExportDocxDialog.lable.exportchoose"));
cmb = new Combo(groupExportType, SWT.NONE | SWT.READ_ONLY);
GridDataFactory.swtDefaults().span(2, 1).grab(true, false).align(SWT.FILL, SWT.FILL).applyTo(cmb);
for (String type : ExportExternal.getExportTypes()) {
cmb.add(type);
}
cmb.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final int exportCode = ExportExternal.getExportTypeCode(cmb.getSelectionIndex());
btnHsproofNote.setEnabled(exportCode == ExportExternal.EXPORT_HSPROOF);
btnHsproofState.setEnabled(btnHsproofNote.getEnabled());
btnNotrans.setEnabled(exportCode != ExportExternal.EXPORT_TMX && btnFilterWhenState.getSelection());
if (ExportExternal.EXPORT_TMX == exportCode && btnFilterWhenState.getSelection()) {
btnNotrans.setSelection(false);
}
}
});
final Label lblR8State = new Label(groupExportType, SWT.NONE);
lblR8State.setText(Messages.getString("ExportDocxDialog.lable.hsproof"));
btnHsproofState = new Button(groupExportType, SWT.CHECK);
btnHsproofState.setText(Messages.getString("ExportDocxDialog.statusBtn"));
btnHsproofNote = new Button(groupExportType, SWT.CHECK);
btnHsproofNote.setText(Messages.getString("ExportDocxDialog.commentBtn"));
final Group groupFilter = new Group(tparent, SWT.NONE);
groupFilter.setText(Messages.getString("ExportDocxDialog.lable.filter"));
groupFilter.setLayout(new GridLayout(3, false));
groupFilter.setLayoutData(new GridData(GridData.FILL_BOTH));
// 过滤大类
btnAllTrans = new Button(groupFilter, SWT.RADIO);
btnAllTrans.setText(Messages.getString("ExportDocxDialog.lable.filterAll"));
btnAllTrans.setSelection(true);
btnAllTrans.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (btnAllTrans.getSelection()) {
setFilterDefaultValue();
}
}
});
btnOnlySpecial = new Button(groupFilter, SWT.RADIO);
btnOnlySpecial.setText(Messages.getString("ExportDocxDialog.onlyExportBtn"));
btnOnlySpecial.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (btnOnlySpecial.getSelection()) {
setFilterDefaultValue();
}
}
;
});
btnFilterWhenState = new Button(groupFilter, SWT.RADIO);
btnFilterWhenState.setText(Messages.getString("ExportDocxDialog.lable.hasState"));
btnFilterWhenState.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (btnFilterWhenState.getSelection()) {
setFilterDefaultValue();
}
}
;
});
// 大类细节
cmpFilterAllTrans = new Composite(groupFilter, SWT.NONE);
cmpFilterAllTrans.setLayout(new GridLayout(1, false));
cmpFilterAllTrans.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
btnExceptLocked = new Button(cmpFilterAllTrans, SWT.CHECK);
btnExceptLocked.setText(Messages.getString("ExportDocxDialog.lable.exceptLock"));
btnExceptLocked.setEnabled(true);
btnExceptContextMatch = new Button(cmpFilterAllTrans, SWT.CHECK);
btnExceptContextMatch.setText(Messages.getString("ExportDocxDialog.lable.exceptCxtMatch"));
btnExceptContextMatch.setEnabled(true);
btnExceptFullMatch = new Button(cmpFilterAllTrans, SWT.CHECK);
btnExceptFullMatch.setText(Messages.getString("ExportDocxDialog.lable.exceptFullMatch"));
cmpFilterOnlySpecial = new Composite(groupFilter, SWT.NONE);
cmpFilterOnlySpecial.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
cmpFilterOnlySpecial.setLayout(new GridLayout(1, false));
btnHasNote = new Button(cmpFilterOnlySpecial, SWT.CHECK);
btnHasNote.setText(Messages.getString("ExportDocxDialog.onlyExportNoteBtn"));
btnNeedReview = new Button(cmpFilterOnlySpecial, SWT.CHECK);
btnNeedReview.setText(Messages.getString("ExportDocxDialog.onlyExportReviewBtn"));
cmpFilterWhenState = new Composite(groupFilter, SWT.NONE);
cmpFilterWhenState.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
cmpFilterWhenState.setLayout(new GridLayout(1, false));
btnNotrans = new Button(cmpFilterWhenState, SWT.CHECK);
btnNotrans.setText(Messages.getString("ExportDocxDialog.lable.state.noTrans"));
btnNotrans.setText(Messages.getString("ExportDocxDialog.lable.state.noTrans"));
btnNewtrans = new Button(cmpFilterWhenState, SWT.CHECK);
btnNewtrans.setText(Messages.getString("ExportDocxDialog.lable.state.new"));
btnNewtrans.setText(Messages.getString("ExportDocxDialog.lable.state.new"));
btnTransed = new Button(cmpFilterWhenState, SWT.CHECK);
btnTransed.setText(Messages.getString("ExportDocxDialog.lable.state.hasTrans"));
btnApproved = new Button(cmpFilterWhenState, SWT.CHECK);
btnApproved.setText(Messages.getString("ExportDocxDialog.lable.state.hasApprove"));
Composite cmpSaveas = new Composite(tparent, SWT.NONE);
cmpSaveas.setLayout(GridLayoutFactory.swtDefaults().numColumns(3).create());
cmpSaveas.setLayoutData(new GridData(GridData.FILL_BOTH));
Label lblSaveas = new Label(cmpSaveas, SWT.NONE);
lblSaveas.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
lblSaveas.setText(Messages.getString("ExportDocxDialog.lable.saveas"));
txtSaveas = new Text(cmpSaveas, SWT.BORDER | SWT.READ_ONLY);
txtSaveas.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
txtSaveas.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
getButton(IDialogConstants.OK_ID).setEnabled(!txtSaveas.getText().isEmpty());
}
});
Button btnSaveas = new Button(cmpSaveas, SWT.NONE);
btnSaveas.setText(Messages.getString("ExportDocxDialog.browseDocxBtn"));
btnSaveas.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(getShell());
dialog.setFilterPath(dialogSetting.get("defaultPath"));
String path = dialog.open();
if (path != null) {
txtSaveas.setText(path);
dialogSetting.put("defaultPath", path);
}
}
});
setDefaultValue();
return parent;
}
use of org.eclipse.swt.widgets.DirectoryDialog in project otertool by wuntee.
the class GuiWorkshop method selectDirectory.
public static String selectDirectory(Shell shell) {
DirectoryDialog directoryDialog = new DirectoryDialog(shell);
// directoryDialog.setFilterPath("/");
directoryDialog.setMessage("Please select a directory");
String dir = directoryDialog.open();
return (dir);
}
use of org.eclipse.swt.widgets.DirectoryDialog in project azure-tools-for-java by Microsoft.
the class SrvPriSettingsDialog method createDialogArea.
/**
* Create contents of the dialog.
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent) {
setTitle("Create Authentication Files");
Composite area = (Composite) super.createDialogArea(parent);
Composite container = new Composite(area, SWT.NONE);
container.setLayout(new GridLayout(1, false));
container.setLayoutData(new GridData(GridData.FILL_BOTH));
Label lblInfo = new Label(container, SWT.WRAP);
GridData gd_lblInfo = new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1);
gd_lblInfo.heightHint = 82;
lblInfo.setLayoutData(gd_lblInfo);
lblInfo.setText("A new Active Directory service principal representing this IDE will be created as needed and as allowed by your access permissions.\nThe service principal will be granted Contributor-level access to each selected subscription.");
Label lblNewLabel = new Label(container, SWT.NONE);
lblNewLabel.setEnabled(true);
lblNewLabel.setText("Select the subscriptions to create credentials for:");
table = new Table(container, SWT.BORDER | SWT.CHECK | SWT.FULL_SELECTION);
table.setEnabled(true);
GridData gd_table = new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1);
gd_table.heightHint = 300;
table.setLayoutData(gd_table);
table.setHeaderVisible(true);
table.setLinesVisible(true);
TableColumn tblclmnSubscriptionName = new TableColumn(table, SWT.NONE);
tblclmnSubscriptionName.setWidth(250);
tblclmnSubscriptionName.setText("Subscription Name");
TableColumn tblclmnSubscriptionId = new TableColumn(table, SWT.NONE);
tblclmnSubscriptionId.setWidth(300);
tblclmnSubscriptionId.setText("Subscription ID");
for (SubscriptionDetail sd : sdl) {
TableItem item = new TableItem(table, SWT.NULL);
item.setText(new String[] { sd.getSubscriptionName(), sd.getSubscriptionId() });
item.setChecked(sd.isSelected());
}
Group grpDestinationFolder = new Group(container, SWT.NONE);
grpDestinationFolder.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, false, false, 1, 1));
grpDestinationFolder.setText("Destination folder:");
grpDestinationFolder.setLayout(new GridLayout(2, false));
textDestinationFolderPath = new Text(grpDestinationFolder, SWT.BORDER | SWT.READ_ONLY);
textDestinationFolderPath.setEditable(false);
textDestinationFolderPath.setEnabled(true);
textDestinationFolderPath.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
String initDirPath = System.getProperty("user.home");
textDestinationFolderPath.setText(initDirPath);
dirDialog = new DirectoryDialog(this.getShell());
dirDialog.setFilterPath(initDirPath);
dirDialog.setText("Select Destination Folder");
Button btnBrowse = new Button(grpDestinationFolder, SWT.NONE);
btnBrowse.setEnabled(true);
btnBrowse.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
String path = dirDialog.open();
if (path == null)
return;
textDestinationFolderPath.setText(path);
}
});
btnBrowse.setText("...");
return area;
}
use of org.eclipse.swt.widgets.DirectoryDialog in project azure-tools-for-java by Microsoft.
the class AzureNewDockerLoginPage method initUIMainContainer.
private void initUIMainContainer(Composite mainContainer) {
dockerHostImportKeyvaultCredsRadioButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dockerHostImportKeyvaultComboBox.setEnabled(true);
dockerHostUsernameTextField.setEnabled(false);
dockerHostFirstPwdField.setEnabled(false);
dockerHostSecondPwdField.setEnabled(false);
dockerHostNoSshRadioButton.setEnabled(false);
dockerHostAutoSshRadioButton.setEnabled(false);
dockerHostImportSshRadioButton.setEnabled(false);
dockerHostImportSSHTextField.setEnabled(false);
dockerHostImportSSHBrowseButton.setEnabled(false);
dockerHostNoTlsRadioButton.setEnabled(false);
dockerHostAutoTlsRadioButton.setEnabled(false);
dockerHostImportTlsRadioButton.setEnabled(false);
dockerHostImportTLSTextField.setEnabled(false);
dockerHostImportTLSBrowseButton.setEnabled(false);
setErrorMessage(null);
setPageComplete(doValidate());
}
});
dockerHostImportKeyvaultComboBox.setEnabled(false);
for (AzureDockerCertVault certVault : dockerManager.getDockerKeyVaults()) {
dockerHostImportKeyvaultComboBox.add(certVault.name);
dockerHostImportKeyvaultComboBox.setData(certVault.name, certVault);
}
if (dockerManager.getDockerKeyVaults().size() > 0) {
dockerHostImportKeyvaultComboBox.select(0);
}
dockerHostImportKeyvaultComboBox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
setPageComplete(doValidate());
}
});
dockerHostNewCredsRadioButton.setSelection(true);
dockerHostNewCredsRadioButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dockerHostImportKeyvaultComboBox.setEnabled(false);
dockerHostUsernameTextField.setEnabled(true);
dockerHostFirstPwdField.setEnabled(true);
dockerHostSecondPwdField.setEnabled(true);
dockerHostNoSshRadioButton.setEnabled(true);
dockerHostAutoSshRadioButton.setEnabled(true);
dockerHostImportSshRadioButton.setEnabled(true);
if (dockerHostImportSshRadioButton.getSelection()) {
dockerHostImportSSHTextField.setEnabled(true);
dockerHostImportSSHBrowseButton.setEnabled(true);
}
dockerDaemonPortTextField.setEnabled(true);
dockerHostNoTlsRadioButton.setEnabled(true);
dockerHostAutoTlsRadioButton.setEnabled(true);
dockerHostImportTlsRadioButton.setEnabled(true);
if (dockerHostImportTlsRadioButton.getSelection()) {
dockerHostImportTLSTextField.setEnabled(true);
dockerHostImportTLSBrowseButton.setEnabled(true);
}
setErrorMessage(null);
setPageComplete(doValidate());
}
});
dockerHostUsernameTextField.setText(newHost.certVault.vmUsername);
dockerHostUsernameTextField.setToolTipText(AzureDockerValidationUtils.getDockerHostUserNameTip());
dockerHostUsernameTextField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent event) {
if (AzureDockerValidationUtils.validateDockerHostUserName(((Text) event.getSource()).getText())) {
errDispatcher.removeMessage("dockerHostUsernameTextField", dockerHostUsernameTextField);
setErrorMessage(null);
setPageComplete(doValidate());
} else {
errDispatcher.addMessage("dockerHostUsernameTextField", AzureDockerValidationUtils.getDockerHostUserNameTip(), null, IMessageProvider.ERROR, dockerHostUsernameTextField);
setErrorMessage("Invalid user name");
setPageComplete(false);
}
}
});
dockerHostFirstPwdField.setToolTipText(AzureDockerValidationUtils.getDockerHostPasswordTip());
dockerHostFirstPwdField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent event) {
String text = ((Text) event.getSource()).getText();
if (text == null || text.isEmpty() || AzureDockerValidationUtils.validateDockerHostPassword(text)) {
errDispatcher.removeMessage("dockerHostFirstPwdField", dockerHostFirstPwdField);
setErrorMessage(null);
setPageComplete(doValidate());
} else {
errDispatcher.addMessage("dockerHostFirstPwdField", AzureDockerValidationUtils.getDockerHostPasswordTip(), null, IMessageProvider.ERROR, dockerHostFirstPwdField);
setErrorMessage("Invalid password");
setPageComplete(false);
}
}
});
dockerHostSecondPwdField.setToolTipText(AzureDockerValidationUtils.getDockerHostPasswordTip());
dockerHostSecondPwdField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent event) {
String pwd1 = dockerHostFirstPwdField.getText();
String pwd2 = ((Text) event.getSource()).getText();
if ((pwd1 == null && pwd2 == null) || pwd2.equals(pwd1)) {
errDispatcher.removeMessage("dockerHostFirstPwdField", dockerHostFirstPwdField);
errDispatcher.removeMessage("dockerHostSecondPwdField", dockerHostSecondPwdField);
setErrorMessage(null);
setPageComplete(doValidate());
} else {
errDispatcher.addMessage("dockerHostSecondPwdField", AzureDockerValidationUtils.getDockerHostPasswordTip(), null, IMessageProvider.ERROR, dockerHostSecondPwdField);
setErrorMessage("Invalid confirmation password");
setPageComplete(false);
}
}
});
dockerHostNoSshRadioButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dockerHostPwdLabel.setText("(Required)");
dockerHostImportSSHTextField.setEnabled(false);
dockerHostImportSSHBrowseButton.setEnabled(false);
errDispatcher.removeMessage("dockerHostImportSSHTextField", dockerHostImportSSHTextField);
setErrorMessage(null);
setPageComplete(doValidate());
}
});
dockerHostAutoSshRadioButton.setSelection(true);
dockerHostAutoSshRadioButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dockerHostPwdLabel.setText("(Optional)");
dockerHostImportSSHTextField.setEnabled(false);
dockerHostImportSSHBrowseButton.setEnabled(false);
errDispatcher.removeMessage("dockerHostImportSSHTextField", dockerHostImportSSHTextField);
setErrorMessage(null);
setPageComplete(doValidate());
}
});
dockerHostImportSshRadioButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dockerHostPwdLabel.setText("(Optional)");
dockerHostImportSSHTextField.setEnabled(true);
dockerHostImportSSHBrowseButton.setEnabled(true);
setPageComplete(doValidate());
}
});
dockerHostImportSSHTextField.setEnabled(false);
dockerHostImportSSHTextField.setToolTipText(AzureDockerValidationUtils.getDockerHostSshDirectoryTip());
dockerHostImportSSHTextField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent event) {
if (AzureDockerValidationUtils.validateDockerHostSshDirectory(((Text) event.getSource()).getText())) {
errDispatcher.removeMessage("dockerHostImportSSHTextField", dockerHostImportSSHTextField);
setErrorMessage(null);
setPageComplete(doValidate());
} else {
errDispatcher.addMessage("dockerHostImportSSHTextField", AzureDockerValidationUtils.getDockerHostSshDirectoryTip(), null, IMessageProvider.ERROR, dockerHostImportSSHTextField);
setErrorMessage("SSH key files not found in the specified directory");
setPageComplete(false);
}
}
});
dockerHostImportSSHBrowseButton.setEnabled(false);
dockerHostImportSSHBrowseButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog directoryDialog = new DirectoryDialog(dockerHostImportSSHBrowseButton.getShell());
directoryDialog.setText("Select SSH Keys Directory");
directoryDialog.setFilterPath(System.getProperty("user.home"));
String path = directoryDialog.open();
if (path == null) {
return;
}
dockerHostImportSSHTextField.setText(path);
setPageComplete(doValidate());
}
});
dockerDaemonPortTextField.setText(newHost.port);
dockerDaemonPortTextField.setToolTipText(AzureDockerValidationUtils.getDockerHostPortTip());
dockerDaemonPortTextField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent event) {
if (AzureDockerValidationUtils.validateDockerHostPort(((Text) event.getSource()).getText())) {
errDispatcher.removeMessage("dockerDaemonPortTextField", dockerDaemonPortTextField);
setErrorMessage(null);
setPageComplete(doValidate());
} else {
errDispatcher.addMessage("dockerDaemonPortTextField", AzureDockerValidationUtils.getDockerHostPortTip(), null, IMessageProvider.ERROR, dockerDaemonPortTextField);
setErrorMessage("Invalid Docker daemon port setting");
setPageComplete(false);
}
}
});
dockerHostNoTlsRadioButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dockerHostImportTLSTextField.setEnabled(false);
dockerHostImportTLSBrowseButton.setEnabled(false);
errDispatcher.removeMessage("dockerHostImportTLSTextField", dockerHostImportTLSTextField);
setErrorMessage(null);
setPageComplete(doValidate());
}
});
dockerHostAutoTlsRadioButton.setSelection(true);
dockerHostAutoTlsRadioButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dockerHostImportTLSTextField.setEnabled(false);
dockerHostImportTLSBrowseButton.setEnabled(false);
errDispatcher.removeMessage("dockerHostImportTLSTextField", dockerHostImportTLSTextField);
setErrorMessage(null);
setPageComplete(doValidate());
}
});
dockerHostImportTlsRadioButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dockerHostImportTLSTextField.setEnabled(true);
dockerHostImportTLSBrowseButton.setEnabled(true);
setPageComplete(doValidate());
}
});
dockerHostImportTLSTextField.setEnabled(false);
dockerHostImportTLSTextField.setToolTipText(AzureDockerValidationUtils.getDockerHostTlsDirectoryTip());
dockerHostImportTLSTextField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent event) {
if (AzureDockerValidationUtils.validateDockerHostTlsDirectory(((Text) event.getSource()).getText())) {
errDispatcher.removeMessage("dockerHostImportTLSTextField", dockerHostImportTLSTextField);
setErrorMessage(null);
setPageComplete(doValidate());
} else {
errDispatcher.addMessage("dockerHostImportTLSTextField", AzureDockerValidationUtils.getDockerHostTlsDirectoryTip(), null, IMessageProvider.ERROR, dockerHostImportTLSTextField);
setErrorMessage("TLS certificate files not found in the specified directory");
setPageComplete(false);
}
}
});
dockerHostImportTLSBrowseButton.setEnabled(false);
dockerHostImportTLSBrowseButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog directoryDialog = new DirectoryDialog(dockerHostImportTLSBrowseButton.getShell());
directoryDialog.setText("Select TLS Certificate Directory");
directoryDialog.setFilterPath(System.getProperty("user.home"));
String path = directoryDialog.open();
if (path == null) {
return;
}
dockerHostImportTLSTextField.setText(path);
setPageComplete(doValidate());
}
});
dockerHostSaveCredsCheckBox.setSelection(true);
dockerHostSaveCredsCheckBox.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
dockerHostNewKeyvaultTextField.setEnabled(dockerHostSaveCredsCheckBox.getSelection());
setPageComplete(doValidate());
}
});
dockerHostNewKeyvaultTextField.setText(newHost.certVault.name);
dockerHostNewKeyvaultTextField.setToolTipText(AzureDockerValidationUtils.getDockerHostKeyvaultNameTip());
dockerHostNewKeyvaultTextField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent event) {
if (AzureDockerValidationUtils.validateDockerHostKeyvaultName(((Text) event.getSource()).getText(), dockerManager, false)) {
errDispatcher.removeMessage("dockerHostNewKeyvaultTextField", dockerHostNewKeyvaultTextField);
setErrorMessage(null);
setPageComplete(doValidate());
} else {
errDispatcher.addMessage("dockerHostNewKeyvaultTextField", AzureDockerValidationUtils.getDockerHostPortTip(), null, IMessageProvider.ERROR, dockerHostNewKeyvaultTextField);
setErrorMessage("Invalid key vault name");
setPageComplete(false);
}
}
});
}
use of org.eclipse.swt.widgets.DirectoryDialog in project azure-tools-for-java by Microsoft.
the class AzureExportDockerTlsKeysDialog method createDialogArea.
/**
* Create contents of the dialog.
* @param parent
*/
@Override
protected Control createDialogArea(Composite parent) {
setTitle("Export TLS Certificates");
setMessage(pathToolTip);
Composite area = (Composite) super.createDialogArea(parent);
Composite mainContainer = new Composite(area, SWT.NONE);
mainContainer.setLayout(new GridLayout(2, false));
GridData gd_mainContainer = new GridData(GridData.FILL_BOTH);
gd_mainContainer.widthHint = 524;
mainContainer.setLayoutData(gd_mainContainer);
exportTlsPathTextField = new Text(mainContainer, SWT.BORDER);
exportTlsPathTextField.setToolTipText(pathToolTip);
exportTlsPathTextField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent event) {
path = (((Text) event.getSource()).getText());
if (path != null && Files.isDirectory(Paths.get(path))) {
errDispatcher.removeMessage("exportTlsPathTextField", exportTlsPathTextField);
setErrorMessage(null);
} else {
errDispatcher.addMessage("exportTlsPathTextField", pathToolTip, null, IMessageProvider.ERROR, exportTlsPathTextField);
setErrorMessage("Invalid directory path");
}
}
});
GridData gd_exportTlsPathTextField = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
gd_exportTlsPathTextField.widthHint = 380;
gd_exportTlsPathTextField.verticalIndent = 5;
gd_exportTlsPathTextField.horizontalIndent = 5;
exportTlsPathTextField.setLayoutData(gd_exportTlsPathTextField);
Button exportTlsPathBrowseButton = new Button(mainContainer, SWT.NONE);
exportTlsPathBrowseButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog directoryDialog = new DirectoryDialog(exportTlsPathTextField.getShell());
directoryDialog.setText("Select TLS Certificates Directory");
directoryDialog.setFilterPath(System.getProperty("user.home"));
String pathSelected = directoryDialog.open();
if (pathSelected == null) {
return;
}
path = pathSelected;
exportTlsPathTextField.setText(path);
}
});
GridData gd_exportTlsPathBrowseButton = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_exportTlsPathBrowseButton.verticalIndent = 5;
exportTlsPathBrowseButton.setLayoutData(gd_exportTlsPathBrowseButton);
exportTlsPathBrowseButton.setText("Browse...");
Label lblNote = new Label(mainContainer, SWT.NONE);
GridData gd_lblNote = new GridData(SWT.LEFT, SWT.CENTER, false, false, 1, 1);
gd_lblNote.verticalIndent = 5;
gd_lblNote.horizontalIndent = 5;
lblNote.setLayoutData(gd_lblNote);
lblNote.setText("Note:");
new Label(mainContainer, SWT.NONE);
Label lblAnyExisting = new Label(mainContainer, SWT.NONE);
GridData gd_lblAnyExisting = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
gd_lblAnyExisting.horizontalIndent = 20;
lblAnyExisting.setLayoutData(gd_lblAnyExisting);
lblAnyExisting.setText("Any existing \"ca.pem\", \"ca-key.pem\", \"cert.pem\",\"key.pem\", \"server.pem\" and \"server-key.pem\"");
Label lblWillBeOverwritten = new Label(mainContainer, SWT.NONE);
GridData gd_lblWillBeOverwritten = new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1);
gd_lblWillBeOverwritten.horizontalIndent = 20;
lblWillBeOverwritten.setLayoutData(gd_lblWillBeOverwritten);
lblWillBeOverwritten.setText("certificate files in the selected directory will be overwritten!");
FormToolkit toolkit = new FormToolkit(mainContainer.getDisplay());
toolkit.getHyperlinkGroup().setHyperlinkUnderlineMode(HyperlinkSettings.UNDERLINE_HOVER);
managedForm = new ManagedForm(mainContainer);
errMsgForm = managedForm.getForm();
errMsgForm.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, false, false, 2, 1));
errMsgForm.setBackground(mainContainer.getBackground());
errDispatcher = managedForm.getMessageManager();
return area;
}
Aggregations