use of org.eclipse.swt.widgets.DirectoryDialog in project azure-tools-for-java by Microsoft.
the class AzureInputDockerLoginCredsDialog method initUIComponents.
private void initUIComponents(Composite mainContainer) {
setTitle("Docker Host Log In Credentials");
if (resetCredentials) {
setMessage(String.format("Update %s with new log in credentials", editableDockerHost.originalDockerHost.name), IMessageProvider.INFORMATION);
} else {
setMessage(String.format("Docker host %s log in credentials not found; enter your log in credentials", editableDockerHost.originalDockerHost.name), IMessageProvider.INFORMATION);
}
copyFromAzureKeyButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
AzureSelectKeyVault azureSelectKeyVaultDialog = new AzureSelectKeyVault(mainContainer.getShell(), dockerManager);
if (azureSelectKeyVaultDialog.open() == Window.OK && azureSelectKeyVaultDialog.getSelectedKeyvault() != null) {
updateUIWithKeyvault(azureSelectKeyVaultDialog.getSelectedKeyvault());
}
okButton.setEnabled(doValidate());
}
});
dockerHostUsernameTextField.setText((editableDockerHost.originalDockerHost.certVault != null && editableDockerHost.originalDockerHost.certVault.vmUsername != null) ? editableDockerHost.originalDockerHost.certVault.vmUsername : "");
dockerHostUsernameTextField.setToolTipText(AzureDockerValidationUtils.getDockerHostUserNameTip());
dockerHostUsernameTextField.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent event) {
if (!resetCredentials || AzureDockerValidationUtils.validateDockerHostUserName(((Text) event.getSource()).getText())) {
errDispatcher.removeMessage("dockerHostUsernameTextField", dockerHostUsernameTextField);
setErrorMessage(null);
okButton.setEnabled(doValidate());
} else {
errDispatcher.addMessage("dockerHostUsernameTextField", AzureDockerValidationUtils.getDockerHostUserNameTip(), null, IMessageProvider.ERROR, dockerHostUsernameTextField);
setErrorMessage("Invalid user name");
okButton.setEnabled(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() || (!resetCredentials || AzureDockerValidationUtils.validateDockerHostPassword(text))) {
errDispatcher.removeMessage("dockerHostFirstPwdField", dockerHostFirstPwdField);
setErrorMessage(null);
if (!resetCredentials) {
dockerHostSecondPwdField.setText(text);
}
okButton.setEnabled(doValidate());
} else {
errDispatcher.addMessage("dockerHostFirstPwdField", AzureDockerValidationUtils.getDockerHostPasswordTip(), null, IMessageProvider.ERROR, dockerHostFirstPwdField);
setErrorMessage("Invalid password");
okButton.setEnabled(false);
}
}
});
dockerHostSecondPwdField.setVisible(resetCredentials);
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("dockerHostSecondPwdField", dockerHostSecondPwdField);
setErrorMessage(null);
okButton.setEnabled(doValidate());
} else {
errDispatcher.addMessage("dockerHostSecondPwdField", AzureDockerValidationUtils.getDockerHostPasswordTip(), null, IMessageProvider.ERROR, dockerHostSecondPwdField);
setErrorMessage("Invalid confirmation password");
okButton.setEnabled(false);
}
}
});
dockerHostKeepSshRadioButton.setSelection(true);
dockerHostKeepSshRadioButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
dockerHostImportSSHTextField.setEnabled(false);
dockerHostImportSSHBrowseButton.setEnabled(false);
errDispatcher.removeMessage("dockerHostImportSSHTextField", dockerHostImportSSHTextField);
setErrorMessage(null);
if (editableDockerHost.originalDockerHost.hasSSHLogIn) {
AzureDockerCertVaultOps.copyVaultSshKeys(editableDockerHost.updatedDockerHost.certVault, editableDockerHost.originalDockerHost.certVault);
}
editableDockerHost.updatedDockerHost.hasSSHLogIn = editableDockerHost.originalDockerHost.hasSSHLogIn;
okButton.setEnabled(doValidate());
}
});
dockerHostImportSshRadioButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
dockerHostImportSSHTextField.setEnabled(true);
dockerHostImportSSHBrowseButton.setEnabled(true);
okButton.setEnabled(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);
okButton.setEnabled(doValidate());
} else {
errDispatcher.addMessage("dockerHostImportSSHTextField", AzureDockerValidationUtils.getDockerHostSshDirectoryTip(), null, IMessageProvider.ERROR, dockerHostImportSSHTextField);
setErrorMessage("SSH key files not found in the specified directory");
okButton.setEnabled(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);
okButton.setEnabled(doValidate());
}
});
dockerHostAutoSshRadioButton.setVisible(resetCredentials);
dockerHostAutoSshRadioButton.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent event) {
dockerHostImportSSHTextField.setEnabled(false);
dockerHostImportSSHBrowseButton.setEnabled(false);
errDispatcher.removeMessage("dockerHostImportSSHTextField", dockerHostImportSSHTextField);
setErrorMessage(null);
AzureDockerCertVault certVault = AzureDockerCertVaultOps.generateSSHKeys(null, "SSH keys for " + editableDockerHost.updatedDockerHost.name);
AzureDockerCertVaultOps.copyVaultSshKeys(editableDockerHost.updatedDockerHost.certVault, certVault);
editableDockerHost.updatedDockerHost.hasSSHLogIn = true;
okButton.setEnabled(doValidate());
}
});
}
use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.
the class RunSQLFileDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
getShell().setText(Messages.runSQLDialogTitle);
setTitle(Messages.runSQLDialogTitle);
setMessage(Messages.runSQLDialogMessage);
Composite comp = new Composite(parent, SWT.BORDER);
comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
comp.setLayout(new GridLayout(6, false));
Composite sqlFileComp = new Composite(comp, SWT.BORDER);
GridData sqlFileCompGd = new GridData(GridData.FILL_BOTH);
sqlFileCompGd.horizontalSpan = 6;
sqlFileComp.setLayoutData(sqlFileCompGd);
sqlFileComp.setLayout(new GridLayout(2, false));
new Label(sqlFileComp, SWT.NONE).setText(Messages.runSQLDialogFilePathLabel);
Button sqlFileButton = new Button(sqlFileComp, SWT.NONE);
sqlFileButton.setText(Messages.btnAdd);
sqlFileButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
FileDialog dialog = new FileDialog(getShell(), SWT.OPEN | SWT.MULTI);
dialog.setFilterPath(PersistUtils.getPreferenceValue(CommonUIPlugin.PLUGIN_ID, SQLFILEPATH));
dialog.setText(Messages.runSQLSelectFiles);
dialog.setFilterExtensions(new String[] { "*.sql" });
dialog.setOverwrite(false);
String filePath = dialog.open();
if (filePath != null) {
String[] files = dialog.getFileNames();
for (int i = 0; i < files.length; i++) {
String fileName = dialog.getFilterPath() + File.separator + files[i];
if (!filesList.contains(fileName)) {
filesList.add(fileName);
}
}
PersistUtils.setPreferenceValue(CommonUIPlugin.PLUGIN_ID, SQLFILEPATH, filePath);
saveErrExcelPath.setText(dialog.getFilterPath());
sqlFileTableViewer.setInput(filesList);
}
}
});
Composite textComp = new Composite(sqlFileComp, SWT.NONE);
GridData textCompGd = new GridData(GridData.FILL_BOTH);
textCompGd.horizontalSpan = 2;
textCompGd.heightHint = 100;
textComp.setLayoutData(textCompGd);
textComp.setLayout(new GridLayout(1, true));
sqlFileTableViewer = new TableViewer(textComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
sqlFileTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
sqlFileTableViewer.getTable().setLinesVisible(true);
sqlFileTableViewer.getTable().setHeaderVisible(false);
final TableViewerColumn fileNameCol = new TableViewerColumn(sqlFileTableViewer, SWT.NONE);
fileNameCol.getColumn().setWidth(500);
fileNameCol.getColumn().setText("");
sqlFileTableViewer.setContentProvider(new SQLFileTableContentProvider());
sqlFileTableViewer.setLabelProvider(new SQLFileTableLabelProvider());
Composite databaseComp = new Composite(comp, SWT.BORDER);
GridData databaseCompGd = new GridData(GridData.FILL_BOTH);
databaseCompGd.horizontalSpan = 6;
databaseCompGd.heightHint = 100;
databaseComp.setLayoutData(databaseCompGd);
databaseComp.setLayout(new GridLayout(1, false));
new Label(databaseComp, SWT.NONE).setText(Messages.runSQLDialogDatabaseLabel);
databaseTableComp = new Composite(databaseComp, SWT.NONE);
GridData databaseTableCompGd = new GridData(GridData.FILL_BOTH);
databaseTableCompGd.horizontalSpan = 1;
databaseTableCompGd.heightHint = 100;
databaseTableComp.setLayoutData(databaseTableCompGd);
databaseTableComp.setLayout(new GridLayout(1, false));
databaseTableViewer = new TableViewer(databaseTableComp, SWT.BORDER | SWT.FULL_SELECTION | SWT.MULTI);
databaseTableViewer.getTable().setLayoutData(new GridData(GridData.FILL_BOTH));
databaseTableViewer.getTable().setLinesVisible(true);
databaseTableViewer.getTable().setHeaderVisible(false);
final TableViewerColumn databaseCol = new TableViewerColumn(databaseTableViewer, SWT.NONE);
databaseCol.getColumn().setWidth(500);
databaseCol.getColumn().setText("");
databaseTableViewer.setContentProvider(new DatabaseTableContentProvider());
databaseTableViewer.setLabelProvider(new DatabaseTableLabelProvider());
new Label(comp, SWT.NONE).setText(com.cubrid.common.ui.cubrid.table.Messages.lblFileCharset);
fileCharsetCombo = new Combo(comp, SWT.NONE);
{
GridData gridData = new GridData(GridData.BEGINNING);
fileCharsetCombo.setLayoutData(gridData);
fileCharsetCombo.setItems(QueryOptions.getAllCharset(null));
fileCharsetCombo.select(0);
}
Label threadCountLabel = new Label(comp, SWT.NONE);
threadCountLabel.setText(Messages.runSQLDialogLabelThreadCount);
threadCountLabel.setToolTipText(Messages.runSQLDialogLabelThreadCountTooltip);
threadCountSpinner = new Spinner(comp, SWT.BORDER | SWT.LEFT);
threadCountSpinner.setValues(1, 1, 50, 0, 1, 1);
threadCountSpinner.setToolTipText(Messages.runSQLDialogLabelThreadCountTooltip);
Label commitCountLabel = new Label(comp, SWT.NONE);
commitCountLabel.setText(Messages.runSQLDialogLabelCommitCount);
commitCountLabel.setToolTipText(Messages.runSQLDialogLabelCommitCountTooltip);
commitCountSpinner = new Spinner(comp, SWT.BORDER | SWT.LEFT);
commitCountSpinner.setValues(1000, 1, 10000, 0, 1, 1000);
commitCountSpinner.setToolTipText(Messages.runSQLDialogLabelCommitCountTooltip);
Composite autoSaveComp = new Composite(comp, SWT.BORDER);
GridData autoSaveCompGd = new GridData(GridData.FILL_BOTH);
autoSaveCompGd.horizontalSpan = 6;
autoSaveComp.setLayoutData(autoSaveCompGd);
autoSaveComp.setLayout(new GridLayout(3, false));
Composite autoSaveBtnComp = new Composite(autoSaveComp, SWT.NONE);
GridData autoSaveBtnCompGd = new GridData(GridData.FILL_BOTH);
autoSaveBtnCompGd.horizontalSpan = 3;
autoSaveBtnComp.setLayoutData(autoSaveBtnCompGd);
autoSaveBtnComp.setLayout(new GridLayout(2, false));
new Label(autoSaveBtnComp, SWT.NONE).setText(Messages.runSQLDialogCheckBtnDescription);
new Label(autoSaveComp, SWT.NONE).setText(Messages.runSQLDialogExcelPathLabel);
saveErrExcelPath = new Text(autoSaveComp, SWT.BORDER);
saveErrExcelPath.setLayoutData(new GridData(GridData.FILL_BOTH));
saveErrExcelPath.setEditable(false);
saveErrExcelBtn = new Button(autoSaveComp, SWT.NONE);
saveErrExcelBtn.setText(Messages.brokerLogTopMergeOpenBtn);
saveErrExcelBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
DirectoryDialog dialog = new DirectoryDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
dialog.setFilterPath(saveErrExcelPath.getText());
String dir = dialog.open();
if (dir != null) {
if (!dir.endsWith(File.separator)) {
dir += File.separator;
}
saveErrExcelPath.setText(dir);
}
}
});
registerContextMenu();
setInput();
return parent;
}
use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.
the class DataCompareEditorPart method createTopPanel.
private void createTopPanel(Composite parent) {
final Group container = new Group(parent, SWT.NONE);
container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
CommonUITool.createGridLayout(container, 2, 0, 5, 0, 5, 0, 0, 0, 0);
// Left area
final Composite left = new Composite(container, SWT.NONE);
left.setLayoutData(CommonUITool.createGridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
CommonUITool.createGridLayout(left, 1, 0, 0, 0, 0, 0, 0, 0, 5);
{
final Composite left1 = new Composite(left, SWT.NONE);
left1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
CommonUITool.createGridLayout(left1, 6, 0, 0, 2, 0, 0, 0, 3, 0);
String msg = "[" + Messages.lblSource + "] " + getSourceDB().getDbName() + "@" + getSourceDB().getBrokerIP() + " --> [" + Messages.lblTarget + "] " + getTargetDB().getDbName() + "@" + getTargetDB().getBrokerIP();
Label lbl = new Label(left1, SWT.NONE);
lbl.setText(msg);
}
{
final Composite left2 = new Composite(left, SWT.NONE);
left2.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false));
CommonUITool.createGridLayout(left2, 6, 2, 0, 2, 0, 0, 0, 3, 3);
btnAll = new Button(left2, SWT.RADIO);
btnAll.setText(Messages.lblBtnAll);
btnAll.setSelection(true);
btnAll.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 6, 1, -1, -1));
btnRge = new Button(left2, SWT.RADIO);
btnRge.setText(Messages.lblBtnRange);
CommonUITool.createLabel(left2, Messages.lblStartPos);
txtRgeBegin = new Text(left2, SWT.BORDER | SWT.RIGHT);
txtRgeBegin.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, 70, -1));
txtRgeBegin.setText("1");
txtRgeBegin.setEnabled(false);
CommonUITool.createLabel(left2, Messages.lblRowLimit);
txtRgeLimit = new Text(left2, SWT.BORDER | SWT.RIGHT);
txtRgeLimit.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, 60, -1));
txtRgeLimit.setText("1000");
txtRgeLimit.setEnabled(false);
CommonUITool.createLabel(left2, ")");
}
// Right area
final Composite right = new Composite(container, SWT.NONE);
right.setLayoutData(CommonUITool.createGridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
CommonUITool.createGridLayout(right, 3, 0, 0, 0, 0, 0, 0, 0, 3);
countRecordBtn = new Button(right, SWT.PUSH);
countRecordBtn.setText(Messages.btnDataCompareRefresh);
countRecordBtn.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, 50));
startBtn = new Button(right, SWT.PUSH);
startBtn.setText(Messages.btnDataCompareStart);
startBtn.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 90, 50));
final Composite right2 = new Composite(right, SWT.NONE);
right2.setLayoutData(CommonUITool.createGridData(GridData.VERTICAL_ALIGN_BEGINNING | GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
CommonUITool.createGridLayout(right2, 1, 0, 0, 0, 0, 0, 0, 0, 0);
continueBtn = new Button(right2, SWT.PUSH);
continueBtn.setText(Messages.btnDataCompareContinue);
continueBtn.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 80, -1));
continueBtn.setEnabled(false);
exportBtn = new Button(right2, SWT.PUSH);
exportBtn.setText(Messages.btnExportReport);
exportBtn.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, 80, -1));
exportBtn.setEnabled(refreshedRecordCounts);
// Define events
btnAll.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
txtRgeBegin.setEnabled(false);
txtRgeLimit.setEnabled(false);
continueBtn.setEnabled(canBeContinued);
}
});
btnRge.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
txtRgeBegin.setEnabled(true);
txtRgeLimit.setEnabled(true);
continueBtn.setEnabled(false);
}
});
startBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (isRunButtonState) {
startCompare(true);
} else {
stopCompare();
}
}
});
continueBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
startCompare(false);
}
});
countRecordBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
refreshTableAndRecordCounts();
}
});
exportBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
if (!CommonUITool.openConfirmBox(Messages.msgDataCompareExport)) {
return;
}
DirectoryDialog pathDialog = new DirectoryDialog(Display.getDefault().getActiveShell(), SWT.NONE);
pathDialog.setFilterPath("/");
final String resultPath = pathDialog.open();
if (resultPath == null) {
CommonUITool.openErrorBox(Messages.errNeedSelectLogPathSimple);
return;
}
exportDiffLog(resultPath);
}
});
}
use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.
the class RenameDatabaseDialog method createNewDatabaseInfoComp.
/**
*
* Create database name group
*
* @param parent the parent composite
*/
private void createNewDatabaseInfoComp(Composite parent) {
Composite comp = new Composite(parent, SWT.NONE);
GridData gridData = new GridData(GridData.FILL_BOTH);
comp.setLayoutData(gridData);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
comp.setLayout(layout);
Label databaseNameLabel = new Label(comp, SWT.LEFT | SWT.WRAP);
databaseNameLabel.setText(Messages.lblNewDbName);
gridData = new GridData();
gridData.widthHint = 150;
databaseNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
databaseNameText = new Text(comp, SWT.BORDER);
databaseNameText.setTextLimit(ValidateUtil.MAX_DB_NAME_LENGTH);
databaseNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
exVolumePathButton = new Button(comp, SWT.LEFT | SWT.RADIO);
exVolumePathButton.setText(Messages.btnExtendedVolumePath);
exVolumePathButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
exVolumePathButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (exVolumePathButton.getSelection()) {
exVolumePathText.setEditable(true);
renameVolumeButton.setSelection(false);
volumeTable.setEnabled(false);
if (selectVolumeDirectoryButton != null) {
ServerInfo serverInfo = database.getServer().getServerInfo();
selectVolumeDirectoryButton.setEnabled(serverInfo != null && serverInfo.isLocalServer());
}
} else {
exVolumePathText.setEditable(false);
volumeTable.setEnabled(true);
if (selectVolumeDirectoryButton != null) {
selectVolumeDirectoryButton.setEnabled(false);
}
}
}
});
exVolumePathButton.setSelection(true);
boolean isLocalServer = database.getServer().getServerInfo().isLocalServer();
exVolumePathText = new Text(comp, SWT.BORDER);
exVolumePathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, isLocalServer ? 1 : 2, 1, -1, -1));
if (isLocalServer) {
selectVolumeDirectoryButton = new Button(comp, SWT.NONE);
selectVolumeDirectoryButton.setText(Messages.btnBrowse);
selectVolumeDirectoryButton.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
selectVolumeDirectoryButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
String text = exVolumePathText.getText();
if (text == null || text.trim().length() == 0) {
text = CubridManagerUIPlugin.getPluginDialogSettings().get(KEY_EXTENDED_VOLUME_PATH + database.getId());
}
if (text == null || text.trim().length() == 0) {
text = extVolumePath;
}
DirectoryDialog dlg = new DirectoryDialog(getShell());
if (text != null) {
dlg.setFilterPath(text);
}
dlg.setText(Messages.msgSelectDir);
dlg.setMessage(Messages.msgSelectDir);
String dir = dlg.open();
if (dir != null) {
exVolumePathText.setText(dir);
CubridManagerUIPlugin.getPluginDialogSettings().put(KEY_EXTENDED_VOLUME_PATH + database.getId(), dir);
}
}
});
selectVolumeDirectoryButton.setEnabled(true);
}
renameVolumeButton = new Button(comp, SWT.LEFT | SWT.RADIO);
renameVolumeButton.setText(Messages.btnRenameIndiVolume);
renameVolumeButton.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
renameVolumeButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (renameVolumeButton.getSelection()) {
volumeTable.setEnabled(true);
} else {
volumeTable.setEnabled(false);
}
}
});
final String[] columnNameArr = new String[] { Messages.tblColumnCurrVolName, Messages.tblColumnNewVolName, Messages.tblColumnCurrDirPath, Messages.tblColumnNewDirPath };
volumeTableViewer = CommonUITool.createCommonTableViewer(comp, new TableViewerSorter(), columnNameArr, CommonUITool.createGridData(GridData.FILL_BOTH, 3, 1, -1, 200));
volumeTable = volumeTableViewer.getTable();
volumeTable.setEnabled(false);
volumeTableViewer.setColumnProperties(columnNameArr);
CellEditor[] editors = new CellEditor[4];
editors[0] = null;
editors[1] = new TextCellEditor(volumeTable);
editors[2] = null;
editors[3] = new TextCellEditor(volumeTable);
volumeTableViewer.setCellEditors(editors);
volumeTableViewer.setCellModifier(new ICellModifier() {
@SuppressWarnings("unchecked")
public boolean canModify(Object element, String property) {
Map<String, String> map = (Map<String, String>) element;
String name = map.get("0");
if (property.equals(columnNameArr[0]) || property.equals(columnNameArr[2])) {
return false;
} else if (property.equals(columnNameArr[1]) && name.equals(database.getName())) {
return false;
}
return true;
}
@SuppressWarnings("unchecked")
public Object getValue(Object element, String property) {
Map<String, String> map = (Map<String, String>) element;
if (property.equals(columnNameArr[1])) {
return map.get("1");
} else if (property.equals(columnNameArr[3])) {
return map.get("3");
}
return null;
}
@SuppressWarnings("unchecked")
public void modify(Object element, String property, Object value) {
Object obj = null;
if (element instanceof Item) {
obj = ((Item) element).getData();
}
if (obj == null) {
return;
}
Map<String, String> map = (Map<String, String>) obj;
if (property.equals(columnNameArr[1])) {
map.put("1", value.toString());
} else if (property.equals(columnNameArr[3])) {
map.put("3", value.toString());
}
volumeTableViewer.refresh();
}
});
forceDelBackupVolumeButton = new Button(comp, SWT.LEFT | SWT.CHECK);
forceDelBackupVolumeButton.setText(Messages.btnForceDelBackupVolume);
forceDelBackupVolumeButton.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
}
use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.
the class ExportDashboardDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
getShell().setText(Messages.exportDashboardDialogTitle);
setTitle(Messages.exportDashboardDialogTitle);
setMessage(Messages.exportDashboardDialogMessage);
Composite comp = new Composite(parent, SWT.BORDER);
comp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
comp.setLayout(new GridLayout(1, false));
Composite charsetComp = new Composite(comp, SWT.NONE);
charsetComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
charsetComp.setLayout(new GridLayout(2, false));
new Label(charsetComp, SWT.NONE).setText(com.cubrid.common.ui.cubrid.table.Messages.lblFileCharset);
fileCharsetCombo = new Combo(charsetComp, SWT.NONE);
{
GridData gridData = new GridData(GridData.BEGINNING);
fileCharsetCombo.setLayoutData(gridData);
fileCharsetCombo.setItems(QueryOptions.getAllCharset(null));
fileCharsetCombo.select(0);
}
Composite excelNameComp = new Composite(comp, SWT.NONE);
excelNameComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
excelNameComp.setLayout(new GridLayout(2, false));
new Label(excelNameComp, SWT.NONE).setText(Messages.exportDashboardDialogLblFileName);
saveExcelName = new Text(excelNameComp, SWT.BORDER);
GridData saveExcelNameGd = new GridData();
saveExcelNameGd.widthHint = 150;
saveExcelName.setLayoutData(saveExcelNameGd);
saveExcelName.setText(xlsName);
Composite exlComp = new Composite(comp, SWT.NONE);
exlComp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
exlComp.setLayout(new GridLayout(3, false));
new Label(exlComp, SWT.NONE).setText(com.cubrid.common.ui.common.Messages.runSQLDialogExcelPathLabel);
saveExcelPath = new Text(exlComp, SWT.BORDER);
saveExcelPath.setLayoutData(new GridData(GridData.FILL_BOTH));
saveExcelPath.setEditable(false);
saveExcelBtn = new Button(exlComp, SWT.NONE);
saveExcelBtn.setText(com.cubrid.common.ui.common.Messages.brokerLogTopMergeOpenBtn);
saveExcelBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
DirectoryDialog dialog = new DirectoryDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
dialog.setFilterPath(saveExcelPath.getText());
String dir = dialog.open();
if (dir != null) {
if (!dir.endsWith(File.separator)) {
dir += File.separator;
}
saveExcelPath.setText(dir);
}
}
});
return parent;
}
Aggregations