Search in sources :

Example 16 with ModifyListener

use of org.eclipse.swt.events.ModifyListener in project dbeaver by serge-rider.

the class CreateProcedurePage method createPageContents.

@Override
protected Control createPageContents(Composite parent) {
    Composite propsGroup = new Composite(parent, SWT.NONE);
    propsGroup.setLayout(new GridLayout(2, false));
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    propsGroup.setLayoutData(gd);
    UIUtils.createLabelText(propsGroup, "Container", DBUtils.getObjectFullName(container, DBPEvaluationContext.UI)).setEditable(false);
    final Text nameText = UIUtils.createLabelText(propsGroup, CoreMessages.dialog_struct_create_procedure_label_name, null);
    nameText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            name = nameText.getText();
        }
    });
    final Combo typeCombo = UIUtils.createLabelCombo(propsGroup, CoreMessages.dialog_struct_create_procedure_combo_type, SWT.DROP_DOWN | SWT.READ_ONLY);
    typeCombo.add(DBSProcedureType.PROCEDURE.name());
    typeCombo.add(DBSProcedureType.FUNCTION.name());
    typeCombo.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            type = typeCombo.getSelectionIndex() == 0 ? DBSProcedureType.PROCEDURE : DBSProcedureType.FUNCTION;
            //$NON-NLS-1$ //$NON-NLS-2$
            nameText.setText(type == DBSProcedureType.PROCEDURE ? "NewProcedure" : "NewFunction");
        }
    });
    typeCombo.select(0);
    propsGroup.setTabList(new Control[] { nameText, typeCombo });
    return propsGroup;
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) GridData(org.eclipse.swt.layout.GridData) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo)

Example 17 with ModifyListener

use of org.eclipse.swt.events.ModifyListener in project dbeaver by serge-rider.

the class PostgreConnectionPage method createControl.

@Override
public void createControl(Composite composite) {
    //Composite group = new Composite(composite, SWT.NONE);
    //group.setLayout(new GridLayout(1, true));
    ModifyListener textListener = new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            if (activated) {
                saveSettings(site.getActiveDataSource());
                site.updateButtons();
            }
        }
    };
    Composite addrGroup = UIUtils.createPlaceholder(composite, 4);
    GridLayout gl = new GridLayout(4, false);
    addrGroup.setLayout(gl);
    GridData gd = new GridData(GridData.FILL_BOTH);
    addrGroup.setLayoutData(gd);
    Label hostLabel = UIUtils.createControlLabel(addrGroup, "Host");
    hostLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    hostText = new Text(addrGroup, SWT.BORDER);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.grabExcessHorizontalSpace = true;
    hostText.setLayoutData(gd);
    hostText.addModifyListener(textListener);
    Label portLabel = UIUtils.createControlLabel(addrGroup, "Port");
    gd = new GridData(GridData.HORIZONTAL_ALIGN_END);
    portLabel.setLayoutData(gd);
    portText = new Text(addrGroup, SWT.BORDER);
    gd = new GridData(GridData.VERTICAL_ALIGN_BEGINNING);
    gd.widthHint = 40;
    portText.setLayoutData(gd);
    portText.addVerifyListener(UIUtils.getIntegerVerifyListener(Locale.getDefault()));
    portText.addModifyListener(textListener);
    Label dbLabel = UIUtils.createControlLabel(addrGroup, "Database");
    dbLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    dbText = new Text(addrGroup, SWT.BORDER);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 3;
    dbText.setLayoutData(gd);
    dbText.addModifyListener(textListener);
    Label usernameLabel = UIUtils.createControlLabel(addrGroup, "User");
    usernameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    usernameText = new Text(addrGroup, SWT.BORDER);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.grabExcessHorizontalSpace = true;
    usernameText.setLayoutData(gd);
    usernameText.addModifyListener(textListener);
    Label passwordLabel = UIUtils.createControlLabel(addrGroup, "Password");
    passwordLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    passwordText = new Text(addrGroup, SWT.BORDER | SWT.PASSWORD);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.grabExcessHorizontalSpace = true;
    passwordText.setLayoutData(gd);
    passwordText.addModifyListener(textListener);
    {
        Composite buttonsGroup = new Composite(addrGroup, SWT.NONE);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 2;
        buttonsGroup.setLayoutData(gd);
        buttonsGroup.setLayout(new GridLayout(2, false));
        homesSelector = new ClientHomesSelector(buttonsGroup, SWT.NONE, "Local Client");
        gd = new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING);
        homesSelector.getPanel().setLayoutData(gd);
    }
    {
        Group secureGroup = new Group(addrGroup, SWT.NONE);
        secureGroup.setText("Settings");
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.horizontalSpan = 4;
        secureGroup.setLayoutData(gd);
        secureGroup.setLayout(new GridLayout(2, false));
        hideNonDefault = UIUtils.createLabelCheckbox(secureGroup, "Show non-default databases", true);
    }
    createDriverPanel(addrGroup);
    setControl(addrGroup);
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ClientHomesSelector(org.jkiss.dbeaver.ui.dialogs.connection.ClientHomesSelector) ModifyListener(org.eclipse.swt.events.ModifyListener) GridData(org.eclipse.swt.layout.GridData)

Example 18 with ModifyListener

use of org.eclipse.swt.events.ModifyListener in project dbeaver by serge-rider.

the class WMIConnectionPage method createControl.

@Override
public void createControl(Composite composite) {
    //Composite group = new Composite(composite, SWT.NONE);
    //group.setLayout(new GridLayout(1, true));
    setImageDescriptor(logoImage);
    ModifyListener textListener = new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            evaluateURL();
        }
    };
    Composite addrGroup = new Composite(composite, SWT.NONE);
    GridLayout gl = new GridLayout(4, false);
    gl.marginHeight = 10;
    gl.marginWidth = 10;
    addrGroup.setLayout(gl);
    GridData gd = new GridData(GridData.FILL_BOTH);
    addrGroup.setLayoutData(gd);
    Label hostLabel = UIUtils.createControlLabel(addrGroup, "Host");
    hostLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    hostText = new Text(addrGroup, SWT.BORDER);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.grabExcessHorizontalSpace = true;
    hostText.setLayoutData(gd);
    hostText.addModifyListener(textListener);
    Label domainLabel = UIUtils.createControlLabel(addrGroup, "Domain");
    domainLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    domainText = new Text(addrGroup, SWT.BORDER);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.grabExcessHorizontalSpace = true;
    domainText.setLayoutData(gd);
    domainText.addModifyListener(textListener);
    Label namespaceLabel = UIUtils.createControlLabel(addrGroup, "Namespace");
    namespaceLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
    namespaceCombo = new Combo(addrGroup, SWT.BORDER);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 3;
    namespaceCombo.setLayoutData(gd);
    namespaceCombo.addModifyListener(textListener);
    Label divLabel = new Label(addrGroup, SWT.SEPARATOR | SWT.SHADOW_OUT | SWT.HORIZONTAL);
    gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.grabExcessHorizontalSpace = true;
    gd.horizontalSpan = 4;
    divLabel.setLayoutData(gd);
    {
        Label usernameLabel = UIUtils.createControlLabel(addrGroup, "User");
        usernameLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
        usernameText = new Text(addrGroup, SWT.BORDER);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.grabExcessHorizontalSpace = true;
        usernameText.setLayoutData(gd);
        usernameText.addModifyListener(textListener);
        Label passwordLabel = UIUtils.createControlLabel(addrGroup, "Password");
        passwordLabel.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_END));
        passwordText = new Text(addrGroup, SWT.BORDER | SWT.PASSWORD);
        gd = new GridData(GridData.FILL_HORIZONTAL);
        gd.grabExcessHorizontalSpace = true;
        passwordText.setLayoutData(gd);
        passwordText.addModifyListener(textListener);
    }
    setControl(addrGroup);
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyListener(org.eclipse.swt.events.ModifyListener) Composite(org.eclipse.swt.widgets.Composite) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Text(org.eclipse.swt.widgets.Text) Combo(org.eclipse.swt.widgets.Combo)

Example 19 with ModifyListener

use of org.eclipse.swt.events.ModifyListener in project dbeaver by serge-rider.

the class EditMavenArtifactDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    getShell().setText("Edit Maven Artifact");
    Composite composite = (Composite) super.createDialogArea(parent);
    ((GridLayout) composite.getLayout()).numColumns = 2;
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.widthHint = 200;
    groupText = UIUtils.createLabelText(composite, "Group Id", artifact.getGroupId());
    groupText.setLayoutData(gd);
    artifactText = UIUtils.createLabelText(composite, "Artifact Id", artifact.getArtifactId());
    artifactText.setLayoutData(gd);
    classifierText = UIUtils.createLabelText(composite, "Classifier", CommonUtils.notEmpty(artifact.getClassifier()));
    classifierText.setLayoutData(gd);
    versionText = UIUtils.createLabelCombo(composite, "Version", SWT.DROP_DOWN | SWT.BORDER);
    versionText.setLayoutData(gd);
    versionText.setText(artifact.getVersion());
    versionText.add(MavenArtifactReference.VERSION_PATTERN_RELEASE);
    versionText.add(MavenArtifactReference.VERSION_PATTERN_LATEST);
    ModifyListener ml = new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            updateButtons();
        }
    };
    groupText.addModifyListener(ml);
    artifactText.addModifyListener(ml);
    classifierText.addModifyListener(ml);
    versionText.addModifyListener(ml);
    return composite;
}
Also used : ModifyEvent(org.eclipse.swt.events.ModifyEvent) ModifyListener(org.eclipse.swt.events.ModifyListener) GridData(org.eclipse.swt.layout.GridData)

Example 20 with ModifyListener

use of org.eclipse.swt.events.ModifyListener in project dbeaver by serge-rider.

the class SearchDataPage method createControl.

@Override
public void createControl(Composite parent) {
    super.createControl(parent);
    initializeDialogUnits(parent);
    Composite searchGroup = new Composite(parent, SWT.NONE);
    searchGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
    searchGroup.setLayout(new GridLayout(3, false));
    setControl(searchGroup);
    UIUtils.createControlLabel(searchGroup, "String");
    searchText = new Combo(searchGroup, SWT.DROP_DOWN);
    searchText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if (params.searchString != null) {
        searchText.setText(params.searchString);
    }
    for (String history : searchHistory) {
        searchText.add(history);
    }
    searchText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            params.searchString = searchText.getText();
            updateEnablement();
        }
    });
    Composite optionsGroup = new SashForm(searchGroup, SWT.NONE);
    GridLayout layout = new GridLayout(2, true);
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    optionsGroup.setLayout(layout);
    GridData gd = new GridData(GridData.FILL_BOTH);
    gd.horizontalSpan = 3;
    optionsGroup.setLayoutData(gd);
    {
        final DBeaverCore core = DBeaverCore.getInstance();
        Group databasesGroup = UIUtils.createControlGroup(optionsGroup, "Databases", 1, GridData.FILL_BOTH, 0);
        gd = new GridData(GridData.FILL_BOTH);
        //gd.heightHint = 300;
        databasesGroup.setLayoutData(gd);
        final DBNProject projectNode = core.getNavigatorModel().getRoot().getProject(core.getProjectRegistry().getActiveProject());
        DBNNode rootNode = projectNode == null ? core.getNavigatorModel().getRoot() : projectNode.getDatabases();
        dataSourceTree = new DatabaseNavigatorTree(databasesGroup, rootNode, SWT.SINGLE | SWT.CHECK);
        gd = new GridData(GridData.FILL_BOTH);
        gd.heightHint = 300;
        dataSourceTree.setLayoutData(gd);
        final CheckboxTreeViewer viewer = (CheckboxTreeViewer) dataSourceTree.getViewer();
        viewer.addFilter(new ViewerFilter() {

            @Override
            public boolean select(Viewer viewer, Object parentElement, Object element) {
                if (element instanceof TreeLoadNode) {
                    return true;
                }
                if (element instanceof DBNNode) {
                    if (element instanceof DBNDatabaseFolder) {
                        DBNDatabaseFolder folder = (DBNDatabaseFolder) element;
                        Class<? extends DBSObject> folderItemsClass = folder.getChildrenClass();
                        return folderItemsClass != null && (DBSObjectContainer.class.isAssignableFrom(folderItemsClass) || DBSEntity.class.isAssignableFrom(folderItemsClass));
                    }
                    if (element instanceof DBNLocalFolder || element instanceof DBNProjectDatabases || element instanceof DBNDataSource) {
                        return true;
                    }
                    if (element instanceof DBSWrapper) {
                        DBSObject obj = ((DBSWrapper) element).getObject();
                        if (obj instanceof DBSObjectContainer)
                            return true;
                        if (obj instanceof DBSDataContainer && obj instanceof DBSEntity) {
                            if ((((DBSDataContainer) obj).getSupportedFeatures() & DBSDataContainer.DATA_SEARCH) != 0) {
                                return true;
                            }
                        }
                    }
                }
                return false;
            }
        });
        checkboxTreeManager = new CheckboxTreeManager(viewer, new Class[] { DBSDataContainer.class });
        viewer.addCheckStateListener(new ICheckStateListener() {

            @Override
            public void checkStateChanged(CheckStateChangedEvent event) {
                updateEnablement();
            }
        });
    }
    {
        //new Label(searchGroup, SWT.NONE);
        Composite optionsGroup2 = UIUtils.createControlGroup(optionsGroup, "Settings", 2, GridData.FILL_HORIZONTAL, 0);
        optionsGroup2.setLayoutData(new GridData(GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.VERTICAL_ALIGN_BEGINNING));
        if (params.maxResults <= 0) {
            params.maxResults = 10;
        }
        final Spinner maxResultsSpinner = UIUtils.createLabelSpinner(optionsGroup2, "Sample rows", params.maxResults, 1, Integer.MAX_VALUE);
        maxResultsSpinner.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        maxResultsSpinner.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                params.maxResults = maxResultsSpinner.getSelection();
            }
        });
        final Button caseCheckbox = UIUtils.createLabelCheckbox(optionsGroup2, CoreMessages.dialog_search_objects_case_sensitive, params.caseSensitive);
        caseCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        caseCheckbox.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                params.caseSensitive = caseCheckbox.getSelection();
            }
        });
        final Button fastSearchCheckbox = UIUtils.createLabelCheckbox(optionsGroup2, "Fast search (indexed)", params.fastSearch);
        fastSearchCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        fastSearchCheckbox.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                params.fastSearch = fastSearchCheckbox.getSelection();
            }
        });
        final Button searchNumbersCheckbox = UIUtils.createLabelCheckbox(optionsGroup2, "Search in numbers", params.searchNumbers);
        searchNumbersCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        searchNumbersCheckbox.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                params.searchNumbers = searchNumbersCheckbox.getSelection();
            }
        });
        final Button searchLOBCheckbox = UIUtils.createLabelCheckbox(optionsGroup2, "Search in LOBs", params.searchLOBs);
        searchLOBCheckbox.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
        searchLOBCheckbox.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                params.searchLOBs = searchNumbersCheckbox.getSelection();
            }
        });
    }
    final List<DBNNode> checkedNodes = new ArrayList<>();
    dataSourceTree.setEnabled(false);
    try {
        DBeaverUI.runInProgressDialog(new DBRRunnableWithProgress() {

            @Override
            public void run(DBRProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                monitor.beginTask("Load database nodes", 1);
                try {
                    monitor.subTask("Load tree state");
                    checkedNodes.addAll(loadTreeState(monitor, store, PROP_SOURCES));
                } finally {
                    monitor.done();
                }
            }
        });
    } catch (InvocationTargetException e) {
        UIUtils.showErrorDialog(getShell(), "Data sources load", "Error loading settings", e.getTargetException());
    }
    if (!checkedNodes.isEmpty()) {
        boolean first = true;
        for (DBNNode node : checkedNodes) {
            ((CheckboxTreeViewer) dataSourceTree.getViewer()).setChecked(node, true);
            if (first) {
                dataSourceTree.getViewer().reveal(NavigatorUtils.getDataSourceNode(node));
                first = false;
            }
        }
        checkboxTreeManager.updateCheckStates();
    }
    updateEnablement();
    dataSourceTree.setEnabled(true);
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) ArrayList(java.util.ArrayList) GridLayout(org.eclipse.swt.layout.GridLayout) ModifyEvent(org.eclipse.swt.events.ModifyEvent) TreeLoadNode(org.jkiss.dbeaver.ui.navigator.database.load.TreeLoadNode) DBeaverCore(org.jkiss.dbeaver.core.DBeaverCore) SelectionEvent(org.eclipse.swt.events.SelectionEvent) CheckboxTreeManager(org.jkiss.dbeaver.ui.navigator.database.CheckboxTreeManager) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) DatabaseNavigatorTree(org.jkiss.dbeaver.ui.navigator.database.DatabaseNavigatorTree) InvocationTargetException(java.lang.reflect.InvocationTargetException) SashForm(org.eclipse.swt.custom.SashForm) GridData(org.eclipse.swt.layout.GridData) DBRRunnableWithProgress(org.jkiss.dbeaver.model.runtime.DBRRunnableWithProgress) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor)

Aggregations

ModifyEvent (org.eclipse.swt.events.ModifyEvent)269 ModifyListener (org.eclipse.swt.events.ModifyListener)269 GridData (org.eclipse.swt.layout.GridData)179 Text (org.eclipse.swt.widgets.Text)160 GridLayout (org.eclipse.swt.layout.GridLayout)159 Composite (org.eclipse.swt.widgets.Composite)148 SelectionEvent (org.eclipse.swt.events.SelectionEvent)141 Label (org.eclipse.swt.widgets.Label)140 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)120 Button (org.eclipse.swt.widgets.Button)87 Combo (org.eclipse.swt.widgets.Combo)54 Group (org.eclipse.swt.widgets.Group)42 SelectionListener (org.eclipse.swt.events.SelectionListener)30 File (java.io.File)27 KeyEvent (org.eclipse.swt.events.KeyEvent)23 StyledText (org.eclipse.swt.custom.StyledText)21 DirectoryDialog (org.eclipse.swt.widgets.DirectoryDialog)21 FileDialog (org.eclipse.swt.widgets.FileDialog)18 FocusEvent (org.eclipse.swt.events.FocusEvent)17 List (java.util.List)16