use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.
the class EditBackupPlanDialog method createBasicGroup.
/**
* create the basic group in the Dialog
*
* @param composite Composite
*/
private void createBasicGroup(Composite composite) {
final Group generalInfoGroup = new Group(composite, SWT.RESIZE);
generalInfoGroup.setText(Messages.basicGroupName);
GridLayout groupLayout = new GridLayout();
groupLayout.verticalSpacing = 0;
generalInfoGroup.setLayout(groupLayout);
final GridData gdGeneralInfoGroup = new GridData(SWT.FILL, SWT.CENTER, true, false);
generalInfoGroup.setLayoutData(gdGeneralInfoGroup);
Composite idComposite = new Composite(generalInfoGroup, SWT.RESIZE);
final GridLayout idGridLayout = new GridLayout(4, false);
idComposite.setLayout(idGridLayout);
idComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
final Label idLabel = new Label(idComposite, SWT.RESIZE);
final GridData gdIdLabel = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
gdIdLabel.widthHint = 80;
idLabel.setLayoutData(gdIdLabel);
idLabel.setText(Messages.msgIdLbl);
idText = new Text(idComposite, SWT.BORDER | SWT.RESIZE);
idText.setTextLimit(ValidateUtil.MAX_NAME_LENGTH);
final GridData gdIdText = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
gdIdText.widthHint = 140;
idText.setLayoutData(gdIdText);
final Label levelLabel = new Label(idComposite, SWT.RESIZE);
final GridData gdLevelLabel = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
gdLevelLabel.widthHint = 80;
levelLabel.setLayoutData(gdLevelLabel);
levelLabel.setText(Messages.msgLevelLbl);
leverCombo = new Combo(idComposite, SWT.NONE | SWT.READ_ONLY);
leverCombo.setItems(new String[] { ZERO_LEVER, ONE_LEVER, TWO_LEVER });
final GridData gdLeverCombo = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
gdLeverCombo.widthHint = 135;
leverCombo.setLayoutData(gdLeverCombo);
leverCombo.select(0);
Composite pathComposite = new Composite(generalInfoGroup, SWT.RESIZE);
pathComposite.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
final GridLayout pathGridLayout = new GridLayout(3, false);
pathComposite.setLayout(pathGridLayout);
pathComposite.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
final Label pathLabel = new Label(pathComposite, SWT.RESIZE);
final GridData gdPathLabel = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
gdPathLabel.widthHint = 80;
pathLabel.setLayoutData(gdPathLabel);
pathLabel.setText(Messages.msgPathLbl);
pathText = new Text(pathComposite, SWT.BORDER);
final GridData gdPathText = new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1);
gdPathText.widthHint = 240;
pathText.setLayoutData(gdPathText);
Button selectTargetDirectoryButton = new Button(pathComposite, 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 backupDir = pathText.getText();
if (backupDir != null && backupDir.trim().length() > 0) {
dlg.setFilterPath(backupDir);
}
dlg.setText(Messages.msgSelectDir);
dlg.setMessage(Messages.msgSelectDir);
String dir = dlg.open();
if (dir != null) {
pathText.setText(dir);
}
}
});
ServerInfo serverInfo = database.getServer().getServerInfo();
if (serverInfo != null && !serverInfo.isLocalServer()) {
selectTargetDirectoryButton.setEnabled(false);
}
// sets the initial value
if (operation == AddEditType.EDIT) {
idText.setText(backupPlanInfo.getBackupid());
int selected = Integer.parseInt(backupPlanInfo.getLevel());
leverCombo.select(selected);
pathText.setText(backupPlanInfo.getPath());
idText.setEditable(false);
} else {
idText.setEditable(true);
pathText.setText(defaultPath);
}
idText.addModifyListener(new IdTextModifyListener());
pathText.addModifyListener(new PathTextModifyListener());
}
use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.
the class UnloadDatabaseDialog method createDatabaseInfoGroup.
/**
*
* Create target database information group
*
* @param parent the parent composite
*/
private void createDatabaseInfoGroup(Composite parent) {
Group databaseInfoGroup = new Group(parent, SWT.NONE);
databaseInfoGroup.setText(Messages.grpDbInfo);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
databaseInfoGroup.setLayoutData(gridData);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
databaseInfoGroup.setLayout(layout);
Label databaseNameLabel = new Label(databaseInfoGroup, SWT.LEFT | SWT.WRAP);
databaseNameLabel.setText(Messages.lblTargetDbName);
databaseNameLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
databaseNameText = new Text(databaseInfoGroup, SWT.BORDER);
databaseNameText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 2, 1, -1, -1));
databaseNameText.setEditable(false);
Label targetDirLabel = new Label(databaseInfoGroup, SWT.LEFT | SWT.CHECK);
targetDirLabel.setText(Messages.lblTargetDir);
targetDirLabel.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
targetDirText = new Text(databaseInfoGroup, SWT.BORDER);
targetDirText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, isLocalServer ? 1 : 2, 1, -1, -1));
if (isLocalServer) {
Button selectTargetDirectoryButton = new Button(databaseInfoGroup, 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 = targetDirText.getText();
if (text == null || text.trim().length() == 0) {
text = CubridManagerUIPlugin.getPluginDialogSettings().get(KEY_UNLOADDB_TARGET_DIR + database.getId());
}
if (text == null || text.trim().length() == 0) {
text = dbDir;
}
if (text != null) {
dlg.setFilterPath(text);
}
dlg.setText(Messages.msgSelectDir);
dlg.setMessage(Messages.msgSelectDir);
String dir = dlg.open();
if (dir != null) {
targetDirText.setText(dir);
CubridManagerUIPlugin.getPluginDialogSettings().put(KEY_UNLOADDB_TARGET_DIR + database.getId(), dir);
}
}
});
}
}
use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.
the class RestoreDatabaseDialog method createRestorePathGroup.
/**
*
* Create restore path information group
*
* @param parent the parent composite
*/
private void createRestorePathGroup(Composite parent) {
Group restorePathGroup = new Group(parent, SWT.NONE);
restorePathGroup.setText(Messages.grpDbPath);
GridLayout layout = new GridLayout();
layout.numColumns = 3;
restorePathGroup.setLayout(layout);
restorePathGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
dbPathButton = new Button(restorePathGroup, SWT.LEFT | SWT.CHECK);
dbPathButton.setText(Messages.btnDbPath);
dbPathButton.setLayoutData(CommonUITool.createGridData(1, 1, -1, -1));
dbPathButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
if (dbPathButton.getSelection()) {
dbPathText.setEnabled(true);
String dbDir = CubridManagerUIPlugin.getPluginDialogSettings().get(KEY_RECOVERY_PATH + database.getId());
ServerInfo serverInfo = database.getServer().getServerInfo();
if (dbDir == null || dbDir.trim().length() == 0) {
dbDir = database.getDatabaseInfo().getDbDir();
if (serverInfo != null) {
dbDir = FileUtil.changeSeparatorByOS(dbDir, serverInfo.getServerOsInfo());
}
}
dbPathText.setText(dbDir);
if (dbPathBrowseBtn != null) {
boolean isLocalServer = serverInfo.isLocalServer();
dbPathBrowseBtn.setEnabled(isLocalServer);
}
} else {
dbPathText.setText("");
dbPathText.setEnabled(false);
if (dbPathBrowseBtn != null) {
dbPathBrowseBtn.setEnabled(false);
}
}
}
});
dbPathText = new Text(restorePathGroup, SWT.BORDER);
dbPathText.setLayoutData(CommonUITool.createGridData(GridData.FILL_HORIZONTAL, 1, 1, -1, -1));
dbPathText.addModifyListener(this);
dbPathText.setEnabled(false);
if (isLocalServer) {
dbPathBrowseBtn = new Button(restorePathGroup, SWT.NONE);
dbPathBrowseBtn.setText(Messages.btnBrowse);
dbPathBrowseBtn.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
dbPathBrowseBtn.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
String text = dbPathText.getText();
if (text == null || text.trim().length() == 0) {
text = CubridManagerUIPlugin.getPluginDialogSettings().get(KEY_RECOVERY_PATH + database.getId());
}
DirectoryDialog dlg = new DirectoryDialog(getShell());
if (text != null) {
dlg.setFilterPath(text);
}
dlg.setText(Messages.msgSelectDir);
dlg.setMessage(Messages.msgSelectDir);
String newDir = dlg.open();
if (newDir != null && newDir.trim().length() > 0) {
dbPathText.setText(newDir);
CubridManagerUIPlugin.getPluginDialogSettings().put(KEY_RECOVERY_PATH + database.getId(), newDir);
}
}
});
dbPathBrowseBtn.setEnabled(false);
}
}
use of org.eclipse.swt.widgets.DirectoryDialog in project tdi-studio-se by Talend.
the class ExportItemWizardPage method handleLocationDirectoryButtonPressed.
protected void handleLocationDirectoryButtonPressed() {
DirectoryDialog dialog = new DirectoryDialog(directoryPathField.getShell());
// dialog.setMessage(DataTransferMessages.FileExport_selectDestinationTitle);
//$NON-NLS-1$
dialog.setMessage(Messages.getString("DataTransferMessages.FileExport_selectDestinationTitle"));
String dirName = directoryPathField.getText().trim();
if (dirName.length() == 0) {
dirName = previouslyBrowsedDirectory;
}
if (dirName.length() == 0) {
// dialog.setFilterPath(IDEWorkbenchPlugin.getPluginWorkspace().getRoot().getLocation().toOSString());
dialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
} else {
File path = new File(dirName);
if (path.exists()) {
dialog.setFilterPath(new Path(dirName).toOSString());
}
}
String selectedDirectory = dialog.open();
if (selectedDirectory != null) {
previouslyBrowsedDirectory = selectedDirectory;
directoryPathField.setText(previouslyBrowsedDirectory);
lastPath = directoryPathField.getText().trim();
String exportPath = resetExportPath(lastPath);
saveExportPath(DIRECTORY_PATH, exportPath);
}
}
use of org.eclipse.swt.widgets.DirectoryDialog in project tdi-studio-se by Talend.
the class ImportItemWizardPage method handleLocationDirectoryButtonPressed.
protected void handleLocationDirectoryButtonPressed() {
DirectoryDialog dialog = new DirectoryDialog(directoryPathField.getShell());
// dialog.setMessage(DataTransferMessages.WizardProjectsImportPage_SelectDialogTitle);
//$NON-NLS-1$
dialog.setMessage(Messages.getString("DataTransferMessages.WizardProjectsImportPage_SelectDialogTitle"));
String dirName = directoryPathField.getText().trim();
if (dirName.length() == 0) {
dirName = previouslyBrowsedDirectory;
}
if (dirName.length() == 0) {
// dialog.setFilterPath(IDEWorkbenchPlugin.getPluginWorkspace().getRoot().getLocation().toOSString());
dialog.setFilterPath(ResourcesPlugin.getWorkspace().getRoot().getLocation().toOSString());
} else {
File path = new File(dirName);
if (path.exists()) {
dialog.setFilterPath(new Path(dirName).toOSString());
}
}
String selectedDirectory = dialog.open();
if (selectedDirectory != null) {
previouslyBrowsedDirectory = selectedDirectory;
directoryPathField.setText(previouslyBrowsedDirectory);
updateItemsList(selectedDirectory, false);
}
}
Aggregations