Search in sources :

Example 61 with DirectoryDialog

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());
}
Also used : PeriodGroup(com.cubrid.cubridmanager.ui.cubrid.jobauto.control.PeriodGroup) Group(org.eclipse.swt.widgets.Group) Composite(org.eclipse.swt.widgets.Composite) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 62 with DirectoryDialog

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);
                }
            }
        });
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 63 with DirectoryDialog

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);
    }
}
Also used : Group(org.eclipse.swt.widgets.Group) GridLayout(org.eclipse.swt.layout.GridLayout) Button(org.eclipse.swt.widgets.Button) ServerInfo(com.cubrid.cubridmanager.core.common.model.ServerInfo) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Text(org.eclipse.swt.widgets.Text) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 64 with DirectoryDialog

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);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) File(java.io.File) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 65 with DirectoryDialog

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);
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) ZipFile(java.util.zip.ZipFile) TarFile(org.eclipse.ui.internal.wizards.datatransfer.TarFile) File(java.io.File) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Aggregations

DirectoryDialog (org.eclipse.swt.widgets.DirectoryDialog)88 SelectionEvent (org.eclipse.swt.events.SelectionEvent)51 Button (org.eclipse.swt.widgets.Button)49 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)48 GridData (org.eclipse.swt.layout.GridData)48 GridLayout (org.eclipse.swt.layout.GridLayout)47 Text (org.eclipse.swt.widgets.Text)47 Composite (org.eclipse.swt.widgets.Composite)42 Label (org.eclipse.swt.widgets.Label)40 Group (org.eclipse.swt.widgets.Group)27 File (java.io.File)25 ModifyListener (org.eclipse.swt.events.ModifyListener)22 ModifyEvent (org.eclipse.swt.events.ModifyEvent)21 Combo (org.eclipse.swt.widgets.Combo)21 FileDialog (org.eclipse.swt.widgets.FileDialog)11 TableViewer (org.eclipse.jface.viewers.TableViewer)8 Table (org.eclipse.swt.widgets.Table)8 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)7 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)7 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)7