use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.
the class ImportHostsAction method run.
/**
* Import hosts and groups
*/
public void run() {
Shell shell = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell();
DirectoryDialog dialog = new DirectoryDialog(shell, SWT.OPEN | SWT.APPLICATION_MODAL);
String filePath = CommonUIPlugin.getSettingValue("IMPORT_HOSTS_WORKSPACE_KEY");
if (null != filePath) {
dialog.setFilterPath(filePath);
}
dialog.setMessage(Messages.msgSelectWorkspace);
filePath = dialog.open();
if (filePath == null) {
return;
}
final String workspacePath = filePath;
filePath = filePath + File.separator + ".metadata" + File.separator + ".plugins" + File.separator + "org.eclipse.core.runtime" + File.separator + ".settings" + File.separator + "com.cubrid.cubridmanager.ui.prefs";
File file = new File(filePath);
if (file == null || !file.exists()) {
CommonUITool.openErrorBox(Messages.errInvalidWorkspace);
return;
} else {
CommonUIPlugin.putSettingValue("IMPORT_HOSTS_WORKSPACE_KEY", workspacePath);
}
BusyIndicator.showWhile(Display.getDefault(), new Runnable() {
public void run() {
CMGroupNodePersistManager groupNodePersistManager = CMGroupNodePersistManager.getInstance();
boolean isImportHost = CMHostNodePersistManager.getInstance().loadSevers(workspacePath);
boolean isImportGroup = groupNodePersistManager.loadGroupNode(workspacePath);
boolean isImportDb = CMDBNodePersistManager.getInstance().loadDatabases(workspacePath);
if (isImportHost || isImportGroup || isImportDb) {
CubridHostNavigatorView view = (CubridHostNavigatorView) CubridNavigatorView.getNavigatorView(CubridHostNavigatorView.ID);
if (view != null && view.getViewer() != null) {
view.getViewer().refresh(true);
}
}
}
});
}
use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.
the class TableUtil method getSavedDirForCreateCodes.
/**
* Get saved file for create php/java files
*
* @param shell Shell
* @param filterPath String
* @return File
*/
public static File getSavedDirForCreateCodes(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(TABLE_CREATE_FILE_PATH_KEY);
}
if (null != filepath) {
dialog.setFilterPath(filepath);
}
String filePath = dialog.open();
if (filePath == null) {
return null;
} else {
File file = new File(filePath);
CommonUIPlugin.putSettingValue(TableUtil.TABLE_CREATE_FILE_PATH_KEY, file.getAbsolutePath());
return file;
}
}
use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.
the class GeneralInfoPage method createGenericVolumeGroup.
/**
* Create generic volume information group
*
* @param parent the parent composite
*/
private void createGenericVolumeGroup(Composite parent) {
Group genericVolumeGroup = new Group(parent, SWT.NONE);
genericVolumeGroup.setText(Messages.grpGenericVolInfo);
GridLayout layout = new GridLayout();
layout.numColumns = 4;
genericVolumeGroup.setLayout(layout);
GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
genericVolumeGroup.setLayoutData(gridData);
Label genericSizeLabel = new Label(genericVolumeGroup, SWT.LEFT | SWT.WRAP);
genericSizeLabel.setText(Messages.lblVolSize);
gridData = new GridData();
gridData.widthHint = 150;
genericSizeLabel.setLayoutData(gridData);
genericVolumeSizeText = new Text(genericVolumeGroup, SWT.BORDER);
genericVolumeSizeText.setTextLimit(20);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 3;
genericVolumeSizeText.setLayoutData(gridData);
genericVolumeSizeText.addFocusListener(new FocusListener() {
public void focusGained(FocusEvent event) {
genericVolumeSizeText.addModifyListener(GeneralInfoPage.this);
}
public void focusLost(FocusEvent event) {
genericVolumeSizeText.removeModifyListener(GeneralInfoPage.this);
}
});
Label genericVolumePathLabel = new Label(genericVolumeGroup, SWT.LEFT | SWT.WRAP);
genericVolumePathLabel.setText(Messages.lblGenericVolPath);
gridData = new GridData();
gridData.widthHint = 150;
genericVolumePathLabel.setLayoutData(gridData);
genericVolumePathText = new Text(genericVolumeGroup, SWT.BORDER);
gridData = new GridData(GridData.FILL_HORIZONTAL);
gridData.horizontalSpan = 2;
genericVolumePathText.setLayoutData(gridData);
Button selectDirectoryButton = new Button(genericVolumeGroup, SWT.NONE);
selectDirectoryButton.setText(Messages.btnBrowse);
selectDirectoryButton.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
selectDirectoryButton.addSelectionListener(new SelectionAdapter() {
public void widgetSelected(SelectionEvent event) {
DirectoryDialog dlg = new DirectoryDialog(getShell());
if (databasePath != null && databasePath.trim().length() > 0) {
dlg.setFilterPath(databasePath);
}
dlg.setText(Messages.msgSelectDir);
dlg.setMessage(Messages.msgSelectDir);
String dir = dlg.open();
if (dir != null) {
genericVolumePathText.setText(dir);
}
}
});
ServerInfo serverInfo = server.getServerInfo();
if (serverInfo != null && !serverInfo.isLocalServer()) {
selectDirectoryButton.setEnabled(false);
}
}
use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.
the class AddVolumeDialog method createDialogArea.
/**
* @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
* @param parent The parent composite to contain the dialog area
* @return the dialog area control
*/
protected Control createDialogArea(Composite parent) {
Composite parentComp = (Composite) super.createDialogArea(parent);
setTitle(Messages.dialogTitle);
setMessage(Messages.dialogMsg);
final Composite composite = new Composite(parentComp, SWT.RESIZE);
final GridData gdComposite = new GridData(SWT.FILL, SWT.CENTER, true, false);
gdComposite.widthHint = 500;
composite.setLayoutData(gdComposite);
final GridLayout gridLayout = new GridLayout();
gridLayout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
gridLayout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
gridLayout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
gridLayout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
composite.setLayout(gridLayout);
final Group group = new Group(composite, SWT.NONE);
group.setLayoutData(new GridData(SWT.FILL, SWT.DEFAULT, true, false));
final GridLayout gdGroup = new GridLayout();
gdGroup.verticalSpacing = 0;
group.setLayout(gdGroup);
final Composite pathComp = new Composite(group, SWT.RESIZE);
final GridLayout pathLayout = new GridLayout(3, false);
pathLayout.marginBottom = 0;
final GridData gdPathComp = new GridData(SWT.FILL, SWT.CENTER, true, false);
pathComp.setLayout(pathLayout);
pathComp.setLayoutData(gdPathComp);
final GridData gdLabel = new GridData(SWT.CENTER, SWT.CENTER, false, false, 1, 1);
gdLabel.widthHint = 100;
final Label pathLbl = new Label(pathComp, SWT.NONE);
pathLbl.setText(Messages.pathLblName);
pathLbl.setLayoutData(gdLabel);
pathText = new Text(pathComp, SWT.BORDER);
final GridData gdPathText = new GridData(SWT.FILL, SWT.CENTER, true, false);
pathText.setLayoutData(gdPathText);
pathText.setToolTipText(Messages.pathToolTip);
Button selectTargetDirBtn = new Button(pathComp, SWT.NONE);
selectTargetDirBtn.setText(Messages.btnBrowse);
selectTargetDirBtn.setLayoutData(CommonUITool.createGridData(1, 1, 80, -1));
selectTargetDirBtn.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 = selection.getServer().getServerInfo();
if (serverInfo != null && !serverInfo.isLocalServer()) {
selectTargetDirBtn.setEnabled(false);
}
final Composite purpComp = new Composite(group, SWT.RESIZE);
final GridLayout purpLayout = new GridLayout(2, false);
purpLayout.marginTop = 0;
purpLayout.verticalSpacing = 10;
final GridData gdPurtComp = new GridData(SWT.FILL, SWT.CENTER, true, false);
purpComp.setLayout(purpLayout);
purpComp.setLayoutData(gdPurtComp);
final Label purposeLbl = new Label(purpComp, SWT.NONE);
purposeLbl.setText(Messages.purposeLbllName);
purposeLbl.setLayoutData(gdLabel);
purposeCombo = new Combo(purpComp, SWT.BORDER | SWT.RIGHT | SWT.READ_ONLY);
if (purposeEnable) {
purposeCombo.setEnabled(true);
} else {
purposeCombo.setEnabled(false);
}
final GridData gdPurposeText = new GridData(SWT.FILL, SWT.CENTER, true, false);
purposeCombo.setLayoutData(gdPurposeText);
purposeCombo.setItems(itemsOfPurpose);
final Label volumeSizeLbl = new Label(purpComp, SWT.NONE);
volumeSizeLbl.setText(Messages.volumeSizeLblName);
volumeSizeLbl.setLayoutData(gdLabel);
volumeSizetext = new Text(purpComp, SWT.BORDER | SWT.RIGHT);
final GridData gdVolumeSizetext = new GridData(SWT.FILL, SWT.CENTER, true, false);
volumeSizetext.setLayoutData(gdVolumeSizetext);
volumeSizetext.setToolTipText(Messages.volumeSizeToolTip);
/*Initial the volume size*/
String volumeSize = ConfConstants.DEFAULT_DATA_VOLUME_SIZE;
String configVolumeSize = CompatibleUtil.getConfigGenericVolumeSize(selection.getServer().getServerInfo(), null);
if (!StringUtil.isEmpty(configVolumeSize)) {
Long bytes = StringUtil.getByteNumber(configVolumeSize);
if (bytes > -1) {
double value = StringUtil.convertToM(bytes);
NumberFormat nf = NumberFormat.getInstance();
nf.setGroupingUsed(false);
nf.setMaximumFractionDigits(3);
nf.setMinimumFractionDigits(3);
volumeSize = nf.format(value);
}
}
volumeSizetext.setText(volumeSize);
volumeSizetext.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent e) {
verify();
}
});
// Sets the initial value
pathText.setText(getAddVolumeStatusInfo.getVolpath());
purposeCombo.setText(purpose);
// Sets listener
pathText.addModifyListener(new ModifyListener() {
public void modifyText(ModifyEvent event) {
verify();
}
});
return parentComp;
}
use of org.eclipse.swt.widgets.DirectoryDialog in project cubrid-manager by CUBRID.
the class ExportConfigDialog method getSavedDir.
/**
*
* Get saved file
*
* @param shell Shell
* @return File
*/
private static File getSavedDir(Shell shell) {
DirectoryDialog dialog = new DirectoryDialog(shell, SWT.SAVE | SWT.APPLICATION_MODAL);
String 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(EXPORT_FILE_PATH_KEY, file.getParent());
}
return file;
}
}
Aggregations