Search in sources :

Example 6 with DirectoryDialog

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);
    }
}
Also used : DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 7 with DirectoryDialog

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

Example 8 with DirectoryDialog

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

Example 9 with DirectoryDialog

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();
}
Also used : Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree) DBNResource(org.jkiss.dbeaver.model.navigator.DBNResource) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IContainer(org.eclipse.core.resources.IContainer) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Example 10 with DirectoryDialog

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) {
        }
    });
}
Also used : LocalFile(org.eclipse.core.internal.filesystem.local.LocalFile) IFile(org.eclipse.core.resources.IFile) CoreException(org.eclipse.core.runtime.CoreException) ViewerFilter(org.eclipse.jface.viewers.ViewerFilter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Viewer(org.eclipse.jface.viewers.Viewer) FileFolderSelectionDialog(net.heartsome.cat.common.ui.dialog.FileFolderSelectionDialog) SelectionListener(org.eclipse.swt.events.SelectionListener) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Aggregations

DirectoryDialog (org.eclipse.swt.widgets.DirectoryDialog)68 SelectionEvent (org.eclipse.swt.events.SelectionEvent)48 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)46 GridData (org.eclipse.swt.layout.GridData)43 Button (org.eclipse.swt.widgets.Button)43 Text (org.eclipse.swt.widgets.Text)43 GridLayout (org.eclipse.swt.layout.GridLayout)42 Composite (org.eclipse.swt.widgets.Composite)38 Label (org.eclipse.swt.widgets.Label)36 Group (org.eclipse.swt.widgets.Group)23 File (java.io.File)21 ModifyEvent (org.eclipse.swt.events.ModifyEvent)21 ModifyListener (org.eclipse.swt.events.ModifyListener)21 Combo (org.eclipse.swt.widgets.Combo)18 TableViewer (org.eclipse.jface.viewers.TableViewer)8 ServerInfo (com.cubrid.cubridmanager.core.common.model.ServerInfo)7 FileDialog (org.eclipse.swt.widgets.FileDialog)7 Table (org.eclipse.swt.widgets.Table)7 ArrayContentProvider (org.eclipse.jface.viewers.ArrayContentProvider)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)6