use of org.eclipse.swt.widgets.DirectoryDialog in project dbeaver by serge-rider.
the class TextWithOpenFolder method openBrowser.
protected void openBrowser() {
DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.NONE);
dialog.setText(title);
dialog.setFilterPath(getText());
String selected = dialog.open();
if (selected != null) {
setText(selected);
}
}
use of org.eclipse.swt.widgets.DirectoryDialog in project dbeaver by serge-rider.
the class ExasolExportTableToolDialog method createControls.
@Override
protected void createControls(final Composite parent) {
Group optionsGroup = UIUtils.createControlGroup(parent, ExasolMessages.dialog_table_tools_options, 1, 0, 0);
optionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Composite composite = new Composite(optionsGroup, 2);
composite.setLayout(new GridLayout(2, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
// Directory select Button
btSelectDirectory = UIUtils.createPushButton(composite, ExasolMessages.dialog_table_open_output_directory, null);
btSelectDirectory.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final DirectoryDialog dialog = new DirectoryDialog(parent.getShell());
final String directory = dialog.open();
if (directory != null) {
selectedDirectory.setVisible(true);
selectedDirectory.setText(directory + File.separatorChar);
} else {
selectedDirectory.setVisible(false);
}
updateSQL();
}
});
//label for selected directory
selectedDirectory = UIUtils.createLabel(composite, "");
selectedDirectory.setVisible(false);
//file template
filename = "${schema}_${table}_${date}";
txFileName = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_file_template, filename);
txFileName.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
filename = txFileName.getText();
updateSQL();
}
});
// compress output
btSelectCompress = UIUtils.createCheckbox(composite, ExasolMessages.dialog_table_tools_export_compress, false);
btSelectCompress.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateSQL();
}
});
// PlaceHolder
UIUtils.createPlaceholder(composite, 1);
// include column headings
btInclColNames = UIUtils.createCheckbox(composite, ExasolMessages.dialog_table_tools_column_heading, true);
btInclColNames.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateSQL();
}
});
// PlaceHolder
UIUtils.createPlaceholder(composite, 1);
// encoding combo
cbEncoding = UIUtils.createLabelCombo(composite, ExasolMessages.dialog_table_tools_encoding, SWT.DROP_DOWN | SWT.READ_ONLY);
for (String enc : ExasolConstants.encodings) {
cbEncoding.add(enc);
}
cbEncoding.select(0);
encoding = ExasolConstants.encodings.get(0);
cbEncoding.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
encoding = ExasolConstants.encodings.get(cbEncoding.getSelectionIndex());
updateSQL();
}
});
// row seperator
cbRowSep = UIUtils.createLabelCombo(composite, ExasolMessages.dialog_table_tools_string_sep_mode, SWT.DROP_DOWN | SWT.READ_ONLY);
for (String mode : ExasolConstants.rowSeperators) {
cbRowSep.add(mode);
}
cbRowSep.select(0);
rowSep = ExasolConstants.rowSeperators.get(0);
cbRowSep.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
rowSep = ExasolConstants.rowSeperators.get(cbRowSep.getSelectionIndex());
updateSQL();
}
});
// string sep mode
cbStringSepMode = UIUtils.createLabelCombo(composite, ExasolMessages.dialog_table_tools_string_sep_mode, SWT.DROP_DOWN | SWT.READ_ONLY);
for (String mode : ExasolConstants.stringSepModes) {
cbStringSepMode.add(mode);
}
cbStringSepMode.select(0);
sepMode = ExasolConstants.stringSepModes.get(0);
cbStringSepMode.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
sepMode = ExasolConstants.stringSepModes.get(cbStringSepMode.getSelectionIndex());
updateSQL();
}
});
// column sep
txColSep = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_column_sep, ";");
txColSep.setTextLimit(1);
txColSep.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
updateSQL();
}
});
// string sep
txStringSep = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_string_sep, "\"");
txStringSep.setTextLimit(1);
txStringSep.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
updateSQL();
}
});
createObjectsSelector(parent);
}
use of org.eclipse.swt.widgets.DirectoryDialog in project dbeaver by serge-rider.
the class ExasolImportTableToolDialog method createControls.
@Override
protected void createControls(final Composite parent) {
Group optionsGroup = UIUtils.createControlGroup(parent, ExasolMessages.dialog_table_tools_options, 1, 0, 0);
optionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
Composite composite = new Composite(optionsGroup, 2);
composite.setLayout(new GridLayout(2, false));
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
// Directory select Button
btSelectDirectory = UIUtils.createPushButton(composite, ExasolMessages.dialog_table_open_output_directory, null);
btSelectDirectory.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
final DirectoryDialog dialog = new DirectoryDialog(parent.getShell());
final String directory = dialog.open();
if (directory != null) {
selectedDirectory.setVisible(true);
selectedDirectory.setText(directory + File.separatorChar);
} else {
selectedDirectory.setVisible(false);
}
updateSQL();
}
});
//label for selected directory
selectedDirectory = UIUtils.createLabel(composite, "");
selectedDirectory.setVisible(false);
//file template
filename = "${schema}_${table}_${date}";
txFileName = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_file_template, filename);
txFileName.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
filename = txFileName.getText();
updateSQL();
}
});
// compress output
btSelectCompress = UIUtils.createCheckbox(composite, ExasolMessages.dialog_table_tools_export_compress, false);
btSelectCompress.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateSQL();
}
});
// PlaceHolder
UIUtils.createPlaceholder(composite, 1);
// include column headings
btInclColNames = UIUtils.createCheckbox(composite, ExasolMessages.dialog_table_tools_column_heading, true);
btInclColNames.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
updateSQL();
}
});
// PlaceHolder
UIUtils.createPlaceholder(composite, 1);
// encoding combo
cbEncoding = UIUtils.createLabelCombo(composite, ExasolMessages.dialog_table_tools_encoding, SWT.DROP_DOWN | SWT.READ_ONLY);
for (String enc : ExasolConstants.encodings) {
cbEncoding.add(enc);
}
cbEncoding.select(0);
encoding = ExasolConstants.encodings.get(0);
cbEncoding.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
encoding = ExasolConstants.encodings.get(cbEncoding.getSelectionIndex());
updateSQL();
}
});
// row seperator
cbRowSep = UIUtils.createLabelCombo(composite, ExasolMessages.dialog_table_tools_string_sep_mode, SWT.DROP_DOWN | SWT.READ_ONLY);
for (String mode : ExasolConstants.rowSeperators) {
cbRowSep.add(mode);
}
cbRowSep.select(0);
rowSep = ExasolConstants.rowSeperators.get(0);
cbRowSep.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
rowSep = ExasolConstants.rowSeperators.get(cbRowSep.getSelectionIndex());
updateSQL();
}
});
// column sep
txColSep = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_column_sep, ";");
txColSep.setTextLimit(1);
txColSep.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
updateSQL();
}
});
// string sep
txStringSep = UIUtils.createLabelText(composite, ExasolMessages.dialog_table_tools_string_sep, "\"");
txStringSep.setTextLimit(1);
txStringSep.addModifyListener(new ModifyListener() {
@Override
public void modifyText(ModifyEvent arg0) {
updateSQL();
}
});
createObjectsSelector(parent);
}
use of org.eclipse.swt.widgets.DirectoryDialog in project dbeaver by serge-rider.
the class ScriptsExportWizardPage method createControl.
@Override
public void createControl(Composite parent) {
String outDir = DBeaverCore.getGlobalPreferenceStore().getString(PREF_SCRIPTS_EXPORT_OUT_DIR);
if (CommonUtils.isEmpty(outDir)) {
outDir = RuntimeUtils.getUserHomeDir().getAbsolutePath();
}
Composite placeholder = UIUtils.createPlaceholder(parent, 1);
placeholder.setLayout(new GridLayout(1, false));
// Project list
scriptsNavigator = new DatabaseNavigatorTree(placeholder, DBeaverCore.getInstance().getNavigatorModel().getRoot(), SWT.BORDER | SWT.CHECK);
GridData gd = new GridData(GridData.FILL_BOTH);
scriptsNavigator.setLayoutData(gd);
CheckboxTreeViewer viewer = (CheckboxTreeViewer) scriptsNavigator.getViewer();
viewer.addCheckStateListener(new ICheckStateListener() {
@Override
public void checkStateChanged(CheckStateChangedEvent event) {
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;
}
});
// Output folder
Composite generalSettings = UIUtils.createPlaceholder(placeholder, 3);
generalSettings.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
{
overwriteCheck = UIUtils.createCheckbox(generalSettings, CoreMessages.dialog_project_export_wizard_page_checkbox_overwrite_files, false);
gd = new GridData(GridData.BEGINNING);
gd.horizontalSpan = 3;
overwriteCheck.setLayoutData(gd);
UIUtils.createControlLabel(generalSettings, CoreMessages.dialog_project_export_wizard_page_label_directory);
directoryText = new Text(generalSettings, SWT.BORDER);
directoryText.setText(outDir);
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_project_export_wizard_page_dialog_choose_export_dir_message);
dialog.setText(CoreMessages.dialog_project_export_wizard_page_dialog_choose_export_dir_text);
String directory = directoryText.getText();
if (!CommonUtils.isEmpty(directory)) {
dialog.setFilterPath(directory);
}
directory = dialog.open();
if (directory != null) {
directoryText.setText(directory);
}
}
});
}
setControl(placeholder);
updateState();
}
use of org.eclipse.swt.widgets.DirectoryDialog in project translationstudio8 by heartsome.
the class ExportDocxDialog method initListener.
/**
* 初始化按钮监听 ;
*/
private void initListener() {
btnBrowseXLIFF.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent event) {
FileFolderSelectionDialog dialog = new FileFolderSelectionDialog(getShell(), false, IResource.FILE) {
// 打开对话框时展开树形目录
public void create() {
super.create();
super.getTreeViewer().expandAll();
}
};
dialog.setTitle(Messages.getString("ExportDocxDialog.browseXLIFFBtn.msg0"));
dialog.setMessage(Messages.getString("ExportDocxDialog.browseXLIFFBtn.msg1"));
dialog.setDoubleClickSelects(true);
dialog.setAllowMultiple(false);
try {
dialog.setInput(EFS.getStore(root.getLocationURI()));
} catch (CoreException e1) {
LOGGER.error(Messages.getString("ExportDocxDialog.logger.getXliffError"), e1);
MessageDialog.openInformation(getShell(), Messages.getString("all.dialog.ok.title"), Messages.getString("ExportDocxDialog.browseXLIFFBtn.msg2"));
}
dialog.addFilter(new ViewerFilter() {
@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {
if (element instanceof LocalFile) {
LocalFile folder = (LocalFile) element;
if (folder.getName().equalsIgnoreCase(".hsConfig") || folder.getName().equalsIgnoreCase(".metadata")) {
return false;
}
if (lstProject.contains(folder.toString())) {
return true;
}
String xliffFolderPath = folder.toString();
for (String projectPath : lstProject) {
String path1 = projectPath + System.getProperty("file.separator") + Constant.FOLDER_XLIFF;
if (xliffFolderPath.startsWith(path1)) {
return true;
}
}
}
return false;
}
});
dialog.create();
dialog.open();
if (dialog.getResult() != null) {
Object obj = dialog.getFirstResult();
IFile file = root.getFileForLocation(Path.fromOSString(obj.toString()));
xliffPathTxt.setText(file.getFullPath().toOSString());
strXliffFullPath = ResourceUtils.iFileToOSPath(file);
}
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
browseDocxBtn.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
DirectoryDialog dialog = new DirectoryDialog(getShell());
dialog.setText(Messages.getString("ExportDocxDialog.browseDocxBtn.msg0"));
String defaultPath = System.getProperty("user.home");
if (docxPathTxt.getText() != null && !docxPathTxt.getText().trim().equals("")) {
defaultPath = docxPathTxt.getText();
}
dialog.setFilterPath(defaultPath);
String path = dialog.open();
if (path != null) {
docxPathTxt.setText(path);
}
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
excludeBtn.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
boolean isSelection = excludeBtn.getSelection();
excludeGroup.setEnabled(isSelection);
excludeLockedBtn.setEnabled(isSelection);
exclude101Btn.setEnabled(isSelection);
exclude100Btn.setEnabled(isSelection);
onlyExportGroup.setEnabled(!isSelection);
onlyExportNoteBtn.setEnabled(!isSelection);
onlyExportReviewBtn.setEnabled(!isSelection);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
onlyExportBtn.addSelectionListener(new SelectionListener() {
public void widgetSelected(SelectionEvent e) {
boolean isSelection = onlyExportBtn.getSelection();
excludeGroup.setEnabled(!isSelection);
excludeLockedBtn.setEnabled(!isSelection);
exclude101Btn.setEnabled(!isSelection);
exclude100Btn.setEnabled(!isSelection);
onlyExportGroup.setEnabled(isSelection);
onlyExportNoteBtn.setEnabled(isSelection);
onlyExportReviewBtn.setEnabled(isSelection);
}
public void widgetDefaultSelected(SelectionEvent e) {
}
});
}
Aggregations