Search in sources :

Example 61 with GridData

use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.

the class SearchMetadataPage 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, CoreMessages.dialog_search_objects_label_object_name);
    searchText = new Combo(searchGroup, SWT.DROP_DOWN);
    searchText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    if (nameMask != null) {
        searchText.setText(nameMask);
    }
    for (String history : searchHistory) {
        searchText.add(history);
    }
    searchText.addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            nameMask = 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 sourceGroup = UIUtils.createControlGroup(optionsGroup, CoreMessages.dialog_search_objects_group_objects_source, 1, GridData.FILL_BOTH, 0);
        gd = new GridData(GridData.FILL_BOTH);
        //gd.heightHint = 300;
        sourceGroup.setLayoutData(gd);
        final DBNProject projectNode = core.getNavigatorModel().getRoot().getProject(core.getProjectRegistry().getActiveProject());
        DBNNode rootNode = projectNode == null ? core.getNavigatorModel().getRoot() : projectNode.getDatabases();
        dataSourceTree = new DatabaseNavigatorTree(sourceGroup, rootNode, SWT.SINGLE);
        gd = new GridData(GridData.FILL_BOTH);
        gd.heightHint = 300;
        dataSourceTree.setLayoutData(gd);
        dataSourceTree.getViewer().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);
                    }
                    if (element instanceof DBNLocalFolder || element instanceof DBNProjectDatabases || element instanceof DBNDataSource || (element instanceof DBSWrapper && ((DBSWrapper) element).getObject() instanceof DBSObjectContainer)) {
                        return true;
                    }
                }
                return false;
            }
        });
        dataSourceTree.getViewer().addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                fillObjectTypes();
                updateEnablement();
                IStructuredSelection structSel = (IStructuredSelection) event.getSelection();
                Object object = structSel.isEmpty() ? null : structSel.getFirstElement();
                if (object instanceof DBNNode) {
                    for (DBNNode node = (DBNNode) object; node != null; node = node.getParentNode()) {
                        if (node instanceof DBNDataSource) {
                            DBNDataSource dsNode = (DBNDataSource) node;
                            dsNode.initializeNode(null, new DBRProgressListener() {

                                @Override
                                public void onTaskFinished(IStatus status) {
                                    if (status.isOK()) {
                                        DBeaverUI.asyncExec(new Runnable() {

                                            @Override
                                            public void run() {
                                                if (!dataSourceTree.isDisposed()) {
                                                    fillObjectTypes();
                                                }
                                            }
                                        });
                                    }
                                }
                            });
                            break;
                        }
                    }
                }
            }
        });
    }
    {
        Group settingsGroup = UIUtils.createControlGroup(optionsGroup, "Settings", 2, GridData.FILL_BOTH, 0);
        gd = new GridData(GridData.FILL_BOTH);
        gd.heightHint = 300;
        settingsGroup.setLayoutData(gd);
        {
            //new Label(searchGroup, SWT.NONE);
            UIUtils.createControlLabel(settingsGroup, CoreMessages.dialog_search_objects_label_name_match);
            final Combo matchCombo = new Combo(settingsGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
            matchCombo.add(CoreMessages.dialog_search_objects_combo_starts_with, SearchMetadataConstants.MATCH_INDEX_STARTS_WITH);
            matchCombo.add(CoreMessages.dialog_search_objects_combo_contains, SearchMetadataConstants.MATCH_INDEX_CONTAINS);
            matchCombo.add(CoreMessages.dialog_search_objects_combo_like, SearchMetadataConstants.MATCH_INDEX_LIKE);
            matchCombo.select(0);
            matchCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            if (matchTypeIndex >= 0) {
                matchCombo.select(matchTypeIndex);
            }
            matchCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    matchTypeIndex = matchCombo.getSelectionIndex();
                }
            });
            matchCombo.setLayoutData(new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING));
            if (maxResults <= 0) {
                maxResults = 100;
            }
            final Spinner maxResultsSpinner = UIUtils.createLabelSpinner(settingsGroup, CoreMessages.dialog_search_objects_spinner_max_results, maxResults, 1, 10000);
            maxResultsSpinner.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
            maxResultsSpinner.addModifyListener(new ModifyListener() {

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

                @Override
                public void widgetSelected(SelectionEvent e) {
                    caseSensitive = caseCheckbox.getSelection();
                }
            });
            caseCheckbox.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        }
        Label otLabel = UIUtils.createControlLabel(settingsGroup, CoreMessages.dialog_search_objects_group_object_types);
        otLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
        typesTable = new Table(settingsGroup, SWT.CHECK | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION);
        typesTable.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                //checkedTypes.clear();
                for (TableItem item : typesTable.getItems()) {
                    DBSObjectType objectType = (DBSObjectType) item.getData();
                    if (item.getChecked()) {
                        checkedTypes.add(objectType);
                    } else {
                        checkedTypes.remove(objectType);
                    }
                }
                updateEnablement();
            }
        });
        typesTable.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDoubleClick(MouseEvent e) {
                TableItem tableItem = typesTable.getSelection()[0];
                tableItem.setChecked(!tableItem.getChecked());
            }
        });
        typesTable.setLayoutData(new GridData(GridData.FILL_BOTH));
        UIUtils.createTableColumn(typesTable, SWT.LEFT, CoreMessages.dialog_search_objects_column_type);
        UIUtils.createTableColumn(typesTable, SWT.LEFT, CoreMessages.dialog_search_objects_column_description);
    }
    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");
                    sourceNodes = loadTreeState(monitor, DBeaverCore.getGlobalPreferenceStore(), PROP_SOURCES);
                } finally {
                    monitor.done();
                }
            }
        });
    } catch (InvocationTargetException e) {
        UIUtils.showErrorDialog(getShell(), "Data sources load", "Error loading settings", e.getTargetException());
    }
    if (!sourceNodes.isEmpty()) {
        dataSourceTree.getViewer().setSelection(new StructuredSelection(sourceNodes));
        dataSourceTree.getViewer().reveal(NavigatorUtils.getDataSourceNode(sourceNodes.get(0)));
    } else {
        updateEnablement();
    }
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) GridLayout(org.eclipse.swt.layout.GridLayout) TreeLoadNode(org.jkiss.dbeaver.ui.navigator.database.load.TreeLoadNode) DBeaverCore(org.jkiss.dbeaver.core.DBeaverCore) DBRProgressListener(org.jkiss.dbeaver.model.runtime.DBRProgressListener) 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)

Example 62 with GridData

use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.

the class OracleCompilerDialog method createDialogArea.

@Override
protected Composite createDialogArea(Composite parent) {
    GridData gd;
    Composite composite = new Composite(parent, SWT.NONE);
    composite.setLayout(new GridLayout(2, false));
    composite.setLayoutData(new GridData(GridData.FILL_BOTH));
    {
        Composite unitsGroup = new Composite(composite, SWT.NONE);
        gd = new GridData(GridData.FILL_BOTH);
        gd.widthHint = 250;
        gd.heightHint = 200;
        gd.verticalIndent = 0;
        gd.horizontalIndent = 0;
        unitsGroup.setLayoutData(gd);
        unitsGroup.setLayout(new GridLayout(1, false));
        unitTable = new TableViewer(unitsGroup, SWT.BORDER | SWT.MULTI | SWT.V_SCROLL | SWT.H_SCROLL | SWT.FULL_SELECTION);
        {
            final Table table = unitTable.getTable();
            table.setLayoutData(new GridData(GridData.FILL_BOTH));
            table.setLinesVisible(true);
            table.setHeaderVisible(true);
        }
        ViewerColumnController columnController = new ViewerColumnController("OracleCompilerDialog", unitTable);
        columnController.addColumn(OracleMessages.views_oracle_compiler_dialog_column_name, null, SWT.NONE, true, true, new CellLabelProvider() {

            @Override
            public void update(ViewerCell cell) {
                DBSObject unit = (DBSObject) cell.getElement();
                final DBNDatabaseNode node = DBeaverCore.getInstance().getNavigatorModel().getNodeByObject(unit);
                if (node != null) {
                    cell.setText(node.getNodeName());
                    cell.setImage(DBeaverIcons.getImage(node.getNodeIconDefault()));
                } else {
                    cell.setText(unit.toString());
                }
            }
        });
        columnController.addColumn(OracleMessages.views_oracle_compiler_dialog_column_type, null, SWT.NONE, true, true, new CellLabelProvider() {

            @Override
            public void update(ViewerCell cell) {
                DBSObject unit = (DBSObject) cell.getElement();
                final DBNDatabaseNode node = DBeaverCore.getInstance().getNavigatorModel().getNodeByObject(unit);
                if (node != null) {
                    cell.setText(node.getNodeType());
                } else {
                    //$NON-NLS-1$
                    cell.setText("???");
                }
            }
        });
        columnController.createColumns();
        unitTable.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                IStructuredSelection selection = (IStructuredSelection) event.getSelection();
                getButton(COMPILE_ID).setEnabled(!selection.isEmpty());
            }
        });
        unitTable.addDoubleClickListener(new IDoubleClickListener() {

            @Override
            public void doubleClick(DoubleClickEvent event) {
                IStructuredSelection selection = (IStructuredSelection) event.getSelection();
                if (!selection.isEmpty()) {
                    OracleSourceObject unit = (OracleSourceObject) selection.getFirstElement();
                    NavigatorHandlerObjectOpen.openEntityEditor(unit);
                }
            }
        });
        unitTable.setContentProvider(new ListContentProvider());
        unitTable.setInput(compileUnits);
    }
    {
        Composite infoGroup = new Composite(composite, SWT.NONE);
        gd = new GridData(GridData.FILL_BOTH);
        gd.widthHint = 400;
        gd.heightHint = 200;
        gd.verticalIndent = 0;
        gd.horizontalIndent = 0;
        infoGroup.setLayoutData(gd);
        infoGroup.setLayout(new GridLayout(1, false));
        compileLog = new ObjectCompilerLogViewer(infoGroup, true);
    }
    return composite;
}
Also used : ViewerColumnController(org.jkiss.dbeaver.ui.controls.ViewerColumnController) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) GridLayout(org.eclipse.swt.layout.GridLayout) ListContentProvider(org.jkiss.dbeaver.ui.controls.ListContentProvider) GridData(org.eclipse.swt.layout.GridData) ObjectCompilerLogViewer(org.jkiss.dbeaver.ui.controls.ObjectCompilerLogViewer) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) OracleSourceObject(org.jkiss.dbeaver.ext.oracle.model.source.OracleSourceObject)

Example 63 with GridData

use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.

the class OracleConnectionPage method createClientHomeGroup.

private void createClientHomeGroup(Composite bottomControls) {
    oraHomeSelector = new ClientHomesSelector(bottomControls, SWT.NONE, OracleMessages.dialog_connection_ora_home) {

        @Override
        protected void handleHomeChange() {
            populateTnsNameCombo();
        }
    };
    GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
    gd.widthHint = 300;
    oraHomeSelector.getPanel().setLayoutData(gd);
    Label ph = new Label(bottomControls, SWT.NONE);
    ph.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
Also used : ClientHomesSelector(org.jkiss.dbeaver.ui.dialogs.connection.ClientHomesSelector) GridData(org.eclipse.swt.layout.GridData)

Example 64 with GridData

use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.

the class OracleConnectionPage method createCustomConnectionControls.

private void createCustomConnectionControls(TabFolder protocolFolder) {
    TabItem protocolTabCustom = new TabItem(protocolFolder, SWT.NONE);
    protocolTabCustom.setText(OracleMessages.dialog_connection_custom_tab);
    protocolTabCustom.setData(OracleConstants.ConnectionType.CUSTOM);
    Composite targetContainer = new Composite(protocolFolder, SWT.NONE);
    targetContainer.setLayout(new GridLayout(2, false));
    targetContainer.setLayoutData(new GridData(GridData.FILL_BOTH));
    protocolTabCustom.setControl(targetContainer);
    //$NON-NLS-1$
    final Label urlLabel = UIUtils.createControlLabel(targetContainer, "JDBC URL");
    urlLabel.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING));
    connectionUrlText = new Text(targetContainer, SWT.BORDER | SWT.MULTI | SWT.WRAP | SWT.V_SCROLL);
    connectionUrlText.setLayoutData(new GridData(GridData.FILL_BOTH));
    connectionUrlText.addModifyListener(controlModifyListener);
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData)

Example 65 with GridData

use of org.eclipse.swt.layout.GridData in project dbeaver by serge-rider.

the class OracleConnectionPage method createTNSConnectionControls.

private void createTNSConnectionControls(TabFolder protocolFolder) {
    TabItem protocolTabTNS = new TabItem(protocolFolder, SWT.NONE);
    protocolTabTNS.setText(OracleMessages.dialog_connection_tns_tab);
    protocolTabTNS.setData(OracleConstants.ConnectionType.TNS);
    Composite targetContainer = new Composite(protocolFolder, SWT.NONE);
    targetContainer.setLayout(new GridLayout(2, false));
    targetContainer.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    protocolTabTNS.setControl(targetContainer);
    UIUtils.createControlLabel(targetContainer, "Network Alias");
    tnsNameCombo = new Combo(targetContainer, SWT.DROP_DOWN);
    tnsNameCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    tnsNameCombo.addModifyListener(controlModifyListener);
    UIUtils.createControlLabel(targetContainer, "TNS names path");
    tnsPathText = new TextWithOpenFolder(targetContainer, "Oracle TNS names path");
    tnsPathText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    tnsPathText.setToolTipText("Path to TNSNAMES.ora file");
    tnsPathText.getTextControl().addModifyListener(new ModifyListener() {

        @Override
        public void modifyText(ModifyEvent e) {
            populateTnsNameCombo();
            updateUI();
        }
    });
}
Also used : GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) TextWithOpenFolder(org.jkiss.dbeaver.ui.controls.TextWithOpenFolder)

Aggregations

GridData (org.eclipse.swt.layout.GridData)2385 GridLayout (org.eclipse.swt.layout.GridLayout)1659 Composite (org.eclipse.swt.widgets.Composite)1448 Label (org.eclipse.swt.widgets.Label)982 Button (org.eclipse.swt.widgets.Button)732 SelectionEvent (org.eclipse.swt.events.SelectionEvent)719 Text (org.eclipse.swt.widgets.Text)578 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)577 Group (org.eclipse.swt.widgets.Group)509 Combo (org.eclipse.swt.widgets.Combo)234 ModifyListener (org.eclipse.swt.events.ModifyListener)225 ModifyEvent (org.eclipse.swt.events.ModifyEvent)214 SelectionListener (org.eclipse.swt.events.SelectionListener)213 Table (org.eclipse.swt.widgets.Table)196 Point (org.eclipse.swt.graphics.Point)167 TableViewer (org.eclipse.jface.viewers.TableViewer)162 FillLayout (org.eclipse.swt.layout.FillLayout)134 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)118 Control (org.eclipse.swt.widgets.Control)117 Image (org.eclipse.swt.graphics.Image)114