use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.
the class ExportTableDefinitionDialog method createDialogArea.
protected Control createDialogArea(Composite parent) {
getShell().setText(Messages.exportTableDefinitionTitle);
setTitle(Messages.exportTableDefinitionTitle);
setMessage(Messages.exportTableDefinitionMessage);
Composite comp = new Composite(parent, SWT.BORDER);
comp.setLayoutData(new GridData(GridData.FILL_BOTH));
comp.setLayout(new GridLayout(4, false));
Label exlPathLabel = new Label(comp, SWT.NONE);
exlPathLabel.setText(Messages.exportTableDefinitionExcelPathLabel);
exlPathLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
exlPathText = new Text(comp, SWT.BORDER | SWT.READ_ONLY);
exlPathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
Button exlButton = new Button(comp, SWT.NONE);
exlButton.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_END, 1, 1, -1, -1));
exlButton.setText(Messages.brokerLogTopMergeOpenBtn);
exlButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(final SelectionEvent event) {
DirectoryDialog dialog = new DirectoryDialog(PlatformUI.getWorkbench().getDisplay().getActiveShell());
dialog.setFilterPath(PersistUtils.getPreferenceValue(CommonUIPlugin.PLUGIN_ID, PATHFILTER));
String dir = dialog.open();
if (dir != null) {
if (!dir.endsWith(File.separator)) {
dir += File.separator;
}
exlPathText.setText(dir);
excelFullPathText = dir + exlNameText.getText() + ".xls";
PersistUtils.setPreferenceValue(CommonUIPlugin.PLUGIN_ID, PATHFILTER, dir);
}
// validate();
}
});
Label exlNameLabel = new Label(comp, SWT.NONE);
exlNameLabel.setText(Messages.exportTableDefinitionExcelNameLabel);
exlNameLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
exlNameText = new Text(comp, SWT.BORDER);
exlNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
exlNameText.setText(fileName);
exlNameText.addModifyListener(new ModifyListener() {
public void modifyText(final ModifyEvent event) {
excelFullPathText = exlPathText.getText() + exlNameText.getText() + ".xls";
// validate();
}
});
Label exlExtLabel = new Label(comp, SWT.NONE);
exlExtLabel.setText(".xls");
exlExtLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
//
Label exlFileCharsetLabel = new Label(comp, SWT.NONE);
exlFileCharsetLabel.setText(Messages.exportTableDefinitionExcelFileCharsetLabel);
exlFileCharsetLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
fileCharsetCombo = new Combo(comp, SWT.NONE);
fileCharsetCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
{
String[] charsets = QueryOptions.getAllCharset(null);
fileCharsetCombo.setItems(charsets);
fileCharsetCombo.select(0);
int i = 0;
for (String charset : charsets) {
if (charset != null && charset.equalsIgnoreCase(Messages.exportTableDefinitionDefaultCharset)) {
fileCharsetCombo.select(i);
}
i++;
}
}
new Label(comp, SWT.NONE);
Label exlLayoutTypeLabel = new Label(comp, SWT.NONE);
exlLayoutTypeLabel.setText(Messages.exportTableDefinitionExcelLayoutTypeLabel);
exlLayoutTypeLabel.setLayoutData(CommonUITool.createGridData(GridData.HORIZONTAL_ALIGN_BEGINNING, 1, 1, -1, -1));
Button type1Btn = new Button(comp, SWT.RADIO);
type1Btn.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
type1Btn.setText(Messages.exportTableDefinitionExcelLayoutTypeSimple);
type1Btn.setSelection(true);
type1Btn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
exportLayoutType = 1;
}
});
Button type2Btn = new Button(comp, SWT.RADIO);
type2Btn.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
type2Btn.setText(Messages.exportTableDefinitionExcelLayoutTypeGeneric);
type2Btn.setSelection(false);
type1Btn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent e) {
exportLayoutType = 2;
}
});
return parent;
}
use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.
the class SelectWorkspaceDialog method createDialogArea.
/**
* Create the dialog area
*
* @param parent Composite
* @return Control
*/
protected Control createDialogArea(Composite parent) {
Composite parentComp = (Composite) super.createDialogArea(parent);
Composite composite = new Composite(parentComp, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.numColumns = 3;
layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(layout);
CLabel label = new CLabel(composite, SWT.NONE);
label.setText(Messages.lblWorkspace);
label.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
workspacePathCombo = new Combo(composite, SWT.BORDER);
workspacePathCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
// fill in the all workspaces to combo
String lastUsed = PREFERENCES.get(KEY_RECENT_WORKSPACES, null);
recentUsedWorkspaces = new ArrayList<String>();
if (lastUsed != null) {
String[] all = lastUsed.split(WORKSPACE_SPLIT_CHAR);
for (String str : all) {
recentUsedWorkspaces.add(str);
}
}
for (String last : recentUsedWorkspaces) {
workspacePathCombo.add(last);
}
String rootDir = PREFERENCES.get(KEY_LAST_WORKSPACE, null);
if (rootDir == null || rootDir.length() == 0) {
rootDir = getSuggestedWorkspacePath();
}
workspacePathCombo.setText(rootDir == null ? "" : rootDir);
Button btnBrowse = new Button(composite, SWT.PUSH);
btnBrowse.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
btnBrowse.setText(Messages.btnBrowse);
btnBrowse.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DirectoryDialog dialog = new DirectoryDialog(getShell());
dialog.setText(Messages.titleSelectWorkspaceDialog);
dialog.setMessage(Messages.msgSelectWorksapce);
String text = workspacePathCombo.getText();
File file = new File(text);
while (file != null && !file.exists()) {
file = file.getParentFile();
}
if (file != null) {
text = file.getAbsolutePath();
}
dialog.setFilterPath(text);
String path = dialog.open();
if (path == null && workspacePathCombo.getText().length() == 0) {
setErrorMessage(Messages.errNoSelectWorkspace);
} else if (path != null) {
setErrorMessage(null);
workspacePathCombo.setText(path);
}
}
});
label = new CLabel(composite, SWT.NONE);
label.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
label.setVisible(false);
// checkbox below
rememberWorkspaceButton = new Button(composite, SWT.CHECK);
rememberWorkspaceButton.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
rememberWorkspaceButton.setText(Messages.btnAsDefault);
rememberWorkspaceButton.setSelection(PREFERENCES.getBoolean(KEY_NOT_SHOW_WORKSPACE_SELECTION_DIALOG, false));
if (isSwitchWorkspace) {
setTitle(Messages.titleSwitchWorkspaceDialog);
} else {
setTitle(Messages.titleSelectWorkspaceDialog);
}
setMessage(Messages.msgSelectWorkspaceDialog);
return parentComp;
}
use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.
the class FileDialogUtils method getDataExportedDir.
/**
* Get saved file
*
* @param shell Shell
* @param filterPath String
* @return File
*/
public static File getDataExportedDir(Shell shell, String filterPath) {
DirectoryDialog dialog = new DirectoryDialog(shell, SWT.SAVE | SWT.APPLICATION_MODAL);
String filepath = filterPath;
if (filepath == null || filepath.trim().length() == 0) {
filepath = CommonUIPlugin.getSettingValue(EXPORT_FILE_PATH_KEY);
}
if (null != filepath) {
dialog.setFilterPath(filepath);
}
String filePath = dialog.open();
if (filePath == null) {
return null;
} else {
File file = new File(filePath);
if (file != null) {
CommonUIPlugin.putSettingValue(FileDialogUtils.EXPORT_FILE_PATH_KEY, file.getAbsolutePath());
}
return file;
}
}
use of org.eclipse.swt.widgets.DirectoryDialog in project dbeaver by serge-rider.
the class ScriptsImportWizardPage method createControl.
@Override
public void createControl(Composite parent) {
String externalDir = DBeaverCore.getGlobalPreferenceStore().getString(ScriptsExportWizardPage.PREF_SCRIPTS_EXPORT_OUT_DIR);
if (CommonUtils.isEmpty(externalDir)) {
externalDir = RuntimeUtils.getUserHomeDir().getAbsolutePath();
}
Composite placeholder = UIUtils.createPlaceholder(parent, 1);
placeholder.setLayout(new GridLayout(1, false));
// Input settings
Composite generalSettings = UIUtils.createPlaceholder(placeholder, 3);
generalSettings.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
{
UIUtils.createControlLabel(generalSettings, CoreMessages.dialog_scripts_import_wizard_label_input_directory);
directoryText = new Text(generalSettings, SWT.BORDER);
directoryText.setText(externalDir);
directoryText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
directoryText.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent e) {
updateState();
}
});
Button openFolder = new Button(generalSettings, SWT.PUSH);
openFolder.setImage(DBeaverIcons.getImage(DBIcon.TREE_FOLDER));
openFolder.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE);
dialog.setMessage(CoreMessages.dialog_scripts_import_wizard_dialog_choose_dir_message);
dialog.setText(CoreMessages.dialog_scripts_import_wizard_dialog_choose_dir_text);
String directory = directoryText.getText();
if (!CommonUtils.isEmpty(directory)) {
dialog.setFilterPath(directory);
}
directory = dialog.open();
if (directory != null) {
directoryText.setText(directory);
}
}
});
//$NON-NLS-2$
extensionsText = UIUtils.createLabelText(generalSettings, CoreMessages.dialog_scripts_import_wizard_label_file_mask, "*.sql,*.txt");
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
extensionsText.setLayoutData(gd);
UIUtils.createControlLabel(generalSettings, CoreMessages.dialog_scripts_import_wizard_label_default_connection);
scriptsDataSources = new CSmartCombo<>(generalSettings, SWT.BORDER | SWT.DROP_DOWN | SWT.READ_ONLY, new ConnectionLabelProvider());
for (DataSourceDescriptor dataSourceDescriptor : DataSourceRegistry.getAllDataSources()) {
scriptsDataSources.addItem(dataSourceDescriptor);
}
if (scriptsDataSources.getItemCount() > 0) {
scriptsDataSources.select(0);
}
gd = new GridData(GridData.FILL_HORIZONTAL);
gd.horizontalSpan = 2;
gd.verticalIndent = 2;
scriptsDataSources.setLayoutData(gd);
}
UIUtils.createControlLabel(placeholder, CoreMessages.dialog_scripts_import_wizard_label_root_folder);
importRoot = DBeaverCore.getInstance().getNavigatorModel().getRoot();
final DatabaseNavigatorTree scriptsNavigator = new DatabaseNavigatorTree(placeholder, importRoot, SWT.BORDER | SWT.SINGLE, false);
scriptsNavigator.setLayoutData(new GridData(GridData.FILL_BOTH));
scriptsNavigator.getViewer().addSelectionChangedListener(new ISelectionChangedListener() {
@Override
public void selectionChanged(SelectionChangedEvent event) {
IStructuredSelection sel = (IStructuredSelection) event.getSelection();
if (sel == null || sel.isEmpty()) {
importRoot = null;
} else {
importRoot = (DBNNode) sel.getFirstElement();
}
updateState();
}
});
scriptsNavigator.getViewer().addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
return element instanceof DBNResource && ((DBNResource) element).getResource() instanceof IContainer;
}
});
scriptsNavigator.getViewer().expandToLevel(2);
overwriteCheck = UIUtils.createCheckbox(placeholder, CoreMessages.dialog_project_export_wizard_page_checkbox_overwrite_files, false);
GridData gd = new GridData(GridData.BEGINNING);
gd.horizontalSpan = 3;
overwriteCheck.setLayoutData(gd);
setControl(placeholder);
updateState();
}
use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.
the class BackupDatabaseDialog method createBackupInfoComp.
/**
*
* Create backup information tab composite
*
* @return the composite
*/
private Composite createBackupInfoComp() {
/*For [TOOLS-3372], in CUBRID 9.2 or CUBRID 8.4.4, cannot specify the backup volume name*/
String msgVolumeName = CompatibleUtil.isSupportBackupVolumeName(database.getDatabaseInfo()) ? Messages.lblVolName : Messages.lblVolPath;
Composite composite = new Composite(tabFolder, SWT.NONE);
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
GridLayout layout = new GridLayout();
layout.numColumns = 4;
composite.setLayout(layout);
Label databaseNameLabel = new Label(composite, SWT.LEFT);
databaseNameLabel.setText(Messages.lblDbName);
databaseNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
databaseNameText = new Text(composite, SWT.LEFT | SWT.BORDER);
databaseNameText.setEditable(false);
if (database == null) {
return composite;
}
databaseNameText.setText(database.getLabel());
databaseNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
Label volumeNameLabel = new Label(composite, SWT.LEFT);
volumeNameLabel.setText(msgVolumeName);
volumeNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
volumeNameText = new Text(composite, SWT.LEFT | SWT.BORDER);
volumeNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
Label backupLevelLabel = new Label(composite, SWT.LEFT | SWT.WRAP);
backupLevelLabel.setText(Messages.lblBackupLevel);
backupLevelLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
backupLevelCombo = new Combo(composite, SWT.DROP_DOWN | SWT.READ_ONLY);
backupLevelCombo.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 3, 1, -1, -1));
backupLevelCombo.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent event) {
changeVolumeName();
}
public void widgetDefaultSelected(SelectionEvent event) {
changeVolumeName();
}
});
Label backupDirLabel = new Label(composite, SWT.LEFT);
backupDirLabel.setText(Messages.lblBackupDir);
backupDirLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
backupDirText = new Text(composite, SWT.LEFT | SWT.BORDER);
backupDirText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, isLocalServer ? 2 : 3, 1, -1, -1));
if (isLocalServer) {
Button selectTargetDirectoryButton = new Button(composite, SWT.NONE);
selectTargetDirectoryButton.setText(Messages.btnBrowse);
selectTargetDirectoryButton.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
selectTargetDirectoryButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DirectoryDialog dlg = new DirectoryDialog(getShell());
String text = backupDirText.getText();
if (text == null || text.trim().length() == 0) {
text = CubridManagerUIPlugin.getPluginDialogSettings().get(KEY_BACKUP_DB_DIR + database.getId());
}
if (text == null || text.trim().length() == 0) {
text = backupDir;
}
File file = new File(text);
if (!file.exists()) {
text = file.getParent();
}
dlg.setFilterPath(text);
dlg.setText(Messages.msgSelectDir);
dlg.setMessage(Messages.msgSelectDir);
String dir = dlg.open();
if (dir != null) {
backupDirText.setText(dir);
CubridManagerUIPlugin.getPluginDialogSettings().put(KEY_BACKUP_DB_DIR + database.getId(), dir);
}
}
});
}
Label threadNumLabel = new Label(composite, SWT.LEFT);
threadNumLabel.setText(Messages.lblParallelBackup);
threadNumLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
spnThreadNum = new Spinner(composite, SWT.BORDER);
spnThreadNum.setMaximum(Integer.MAX_VALUE);
spnThreadNum.setLayoutData(CommonUITool.createGridData(2, 1, -1, -1));
new Label(composite, SWT.NONE);
consistentButton = new Button(composite, SWT.NONE | SWT.CHECK);
consistentButton.setText(Messages.btnCheckConsistency);
consistentButton.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 4, 1, -1, -1));
archiveLogButton = new Button(composite, SWT.NONE | SWT.CHECK);
archiveLogButton.setText(Messages.btnDeleteLog);
archiveLogButton.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 4, 1, -1, -1));
archiveLogButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (CompatibleUtil.isSupportHA(database.getServer().getServerInfo()) && isReplication() && archiveLogButton.getSelection()) {
safeBackupButton.setSelection(true);
} else {
safeBackupButton.setSelection(false);
}
}
});
useCompressButton = new Button(composite, SWT.NONE | SWT.CHECK);
useCompressButton.setText(Messages.btnCompressVol);
useCompressButton.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 4, 1, -1, -1));
safeBackupButton = new Button(composite, SWT.NONE | SWT.CHECK);
safeBackupButton.setText(Messages.btnSafeBackup);
safeBackupButton.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 4, 1, -1, -1));
safeBackupButton.setEnabled(false);
if (CompatibleUtil.isSupportHA(database.getServer().getServerInfo()) || CompatibleUtil.isAfter840(database.getServer().getServerInfo())) {
safeBackupButton.setVisible(false);
}
return composite;
}
Aggregations