Search in sources :

Example 1 with ItemListControl

use of org.jkiss.dbeaver.ui.controls.itemlist.ItemListControl in project dbeaver by dbeaver.

the class ExasolCreateForeignKeyDialog method createPageContents.

@Override
protected Control createPageContents(Composite parent) {
    final Composite panel = UIUtils.createPlaceholder(parent, 1, 5);
    panel.setLayoutData(new GridData(GridData.FILL_BOTH));
    {
        final Composite tableGroup = UIUtils.createPlaceholder(panel, 2, 5);
        tableGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        UIUtils.createLabelText(tableGroup, CoreMessages.dialog_struct_edit_fk_label_table, ownTable.getFullyQualifiedName(DBPEvaluationContext.UI), SWT.READ_ONLY | SWT.BORDER);
        final Text fkName = UIUtils.createLabelText(tableGroup, ExasolMessages.dialog_struct_edit_fk_label_fk_name, "NEW_FOREIGN_KEY");
        name = fkName.getText();
        fkName.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent arg0) {
                name = fkName.getText();
            }
        });
        if (ownerTableNode != null) {
            try {
                createSchemaSelector(tableGroup);
            } catch (Throwable e) {
                log.debug("Can't create schema selector", e);
            }
        }
    }
    {
        DBNNode rootNode = ownerTableNode == null ? DBeaverCore.getInstance().getNavigatorModel().getRoot() : ownerTableNode.getParentNode();
        UIUtils.createControlLabel(panel, CoreMessages.dialog_struct_edit_fk_label_ref_table);
        tableList = new ItemListControl(panel, SWT.SINGLE | SWT.SHEET | SWT.BORDER, null, rootNode, null);
        tableList.loadData();
        final GridData gd = new GridData(GridData.FILL_BOTH);
        gd.widthHint = 500;
        gd.heightHint = 150;
        tableList.setLayoutData(gd);
        tableList.getSelectionProvider().addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                handleRefTableSelect(event.getSelection());
            }
        });
    }
    final Composite pkGroup = UIUtils.createPlaceholder(panel, 2);
    {
        pkGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        uniqueKeyCombo = UIUtils.createLabelCombo(pkGroup, CoreMessages.dialog_struct_edit_fk_combo_unik, SWT.DROP_DOWN | SWT.READ_ONLY);
        uniqueKeyCombo.setEnabled(false);
        uniqueKeyCombo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                handleUniqueKeySelect();
            }
        });
    }
    {
        UIUtils.createControlLabel(panel, CoreMessages.dialog_struct_edit_fk_label_columns);
        columnsTable = new Table(panel, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
        columnsTable.setHeaderVisible(true);
        columnsTable.setLinesVisible(true);
        final GridData gd = new GridData(GridData.FILL_BOTH);
        gd.widthHint = 500;
        gd.heightHint = 100;
        columnsTable.setLayoutData(gd);
        UIUtils.createTableColumn(columnsTable, SWT.LEFT, CoreMessages.dialog_struct_edit_fk_column_column);
        UIUtils.createTableColumn(columnsTable, SWT.LEFT, CoreMessages.dialog_struct_edit_fk_column_col_type);
        UIUtils.createTableColumn(columnsTable, SWT.LEFT, CoreMessages.dialog_struct_edit_fk_column_ref_col);
        UIUtils.createTableColumn(columnsTable, SWT.LEFT, CoreMessages.dialog_struct_edit_fk_column_ref_col_type);
        UIUtils.packColumns(columnsTable);
        final TableEditor tableEditor = new TableEditor(columnsTable);
        tableEditor.horizontalAlignment = SWT.CENTER;
        tableEditor.verticalAlignment = SWT.TOP;
        tableEditor.grabHorizontal = true;
        tableEditor.minimumWidth = 50;
        columnsTable.addMouseListener(new ColumnsMouseListener(tableEditor, columnsTable));
    }
    final Composite cascadeGroup = UIUtils.createPlaceholder(panel, 4, 5);
    {
        // Cascades
        cascadeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        final Button enabled = UIUtils.createCheckbox(cascadeGroup, "Enable Constraint", false);
        enabled.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                constEnabled = enabled.getSelection();
            }
        });
    }
    return panel;
}
Also used : ExasolTable(org.jkiss.dbeaver.ext.exasol.model.ExasolTable) DBSTable(org.jkiss.dbeaver.model.struct.rdb.DBSTable) Table(org.eclipse.swt.widgets.Table) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Text(org.eclipse.swt.widgets.Text) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) ItemListControl(org.jkiss.dbeaver.ui.controls.itemlist.ItemListControl) TableEditor(org.eclipse.swt.custom.TableEditor) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 2 with ItemListControl

use of org.jkiss.dbeaver.ui.controls.itemlist.ItemListControl in project dbeaver by dbeaver.

the class TabbedFolderPageNode method createControl.

@Override
public void createControl(Composite parent) {
    itemControl = new ItemListControl(parent, SWT.SHEET, mainEditor.getSite(), node, metaNode);
    // itemControl.getLayout().marginHeight = 0;
    // itemControl.getLayout().marginWidth = 0;
    ProgressPageControl progressControl = null;
    if (mainEditor instanceof IProgressControlProvider) {
        progressControl = ((IProgressControlProvider) mainEditor).getProgressControl();
    }
    if (progressControl != null) {
        itemControl.substituteProgressPanel(progressControl);
    } else {
        itemControl.createProgressPanel();
    }
    parent.layout();
    // Activate items control on focus
    itemControl.getItemsViewer().getControl().addFocusListener(new FocusListener() {

        @Override
        public void focusGained(FocusEvent e) {
            // Update selection provider and selection
            final ISelectionProvider selectionProvider = itemControl.getSelectionProvider();
            if (mainEditor.getSite().getSelectionProvider() != selectionProvider) {
                mainEditor.getSite().setSelectionProvider(selectionProvider);
                selectionProvider.setSelection(selectionProvider.getSelection());
            }
            itemControl.activate(true);
            // We need it to update search actions and other contributions provided by node editor
            if (mainEditor.getSite() instanceof MultiPageEditorSite) {
                MultiPageEditorPart multiPageEditor = ((MultiPageEditorSite) mainEditor.getSite()).getMultiPageEditor();
                if (multiPageEditor.getSelectedPage() != mainEditor) {
                    multiPageEditor.setActiveEditor(mainEditor);
                }
            }
        }

        @Override
        public void focusLost(FocusEvent e) {
            itemControl.activate(false);
        }
    });
}
Also used : ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ProgressPageControl(org.jkiss.dbeaver.ui.controls.ProgressPageControl) MultiPageEditorPart(org.eclipse.ui.part.MultiPageEditorPart) IProgressControlProvider(org.jkiss.dbeaver.ui.IProgressControlProvider) ItemListControl(org.jkiss.dbeaver.ui.controls.itemlist.ItemListControl) FocusListener(org.eclipse.swt.events.FocusListener) FocusEvent(org.eclipse.swt.events.FocusEvent) MultiPageEditorSite(org.eclipse.ui.part.MultiPageEditorSite)

Example 3 with ItemListControl

use of org.jkiss.dbeaver.ui.controls.itemlist.ItemListControl in project dbeaver by dbeaver.

the class EditForeignKeyPage method createPageContents.

@Override
protected Control createPageContents(Composite parent) {
    final Composite panel = UIUtils.createPlaceholder(parent, 1, 5);
    panel.setLayoutData(new GridData(GridData.FILL_BOTH));
    {
        final Composite tableGroup = UIUtils.createPlaceholder(panel, 2, 5);
        tableGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        UIUtils.createLabelText(tableGroup, CoreMessages.dialog_struct_edit_fk_label_table, ownTable.getFullyQualifiedName(DBPEvaluationContext.UI), SWT.READ_ONLY | SWT.BORDER);
        if (ownerTableNode != null) {
            try {
                createSchemaSelector(tableGroup);
            } catch (Throwable e) {
                log.debug("Can't create schema selector", e);
            }
        }
    }
    {
        DBNNode rootNode = ownerTableNode == null ? DBeaverCore.getInstance().getNavigatorModel().getRoot() : ownerTableNode.getParentNode();
        UIUtils.createControlLabel(panel, CoreMessages.dialog_struct_edit_fk_label_ref_table);
        tableList = new ItemListControl(panel, SWT.SINGLE | SWT.SHEET | SWT.BORDER, null, rootNode, null);
        tableList.loadData();
        final GridData gd = new GridData(GridData.FILL_BOTH);
        gd.widthHint = 500;
        gd.heightHint = 150;
        tableList.setLayoutData(gd);
        tableList.getSelectionProvider().addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                handleRefTableSelect(event.getSelection());
            }
        });
    }
    final Composite pkGroup = UIUtils.createPlaceholder(panel, 2);
    {
        pkGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        uniqueKeyCombo = UIUtils.createLabelCombo(pkGroup, CoreMessages.dialog_struct_edit_fk_combo_unik, SWT.DROP_DOWN | SWT.READ_ONLY);
        uniqueKeyCombo.setEnabled(false);
        uniqueKeyCombo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                handleUniqueKeySelect();
            }
        });
    }
    {
        UIUtils.createControlLabel(panel, CoreMessages.dialog_struct_edit_fk_label_columns);
        columnsTable = new Table(panel, SWT.SINGLE | SWT.FULL_SELECTION | SWT.BORDER);
        columnsTable.setHeaderVisible(true);
        columnsTable.setLinesVisible(true);
        final GridData gd = new GridData(GridData.FILL_BOTH);
        gd.widthHint = 500;
        gd.heightHint = 100;
        columnsTable.setLayoutData(gd);
        UIUtils.createTableColumn(columnsTable, SWT.LEFT, CoreMessages.dialog_struct_edit_fk_column_column);
        UIUtils.createTableColumn(columnsTable, SWT.LEFT, CoreMessages.dialog_struct_edit_fk_column_col_type);
        UIUtils.createTableColumn(columnsTable, SWT.LEFT, CoreMessages.dialog_struct_edit_fk_column_ref_col);
        UIUtils.createTableColumn(columnsTable, SWT.LEFT, CoreMessages.dialog_struct_edit_fk_column_ref_col_type);
        UIUtils.packColumns(columnsTable);
        final TableEditor tableEditor = new TableEditor(columnsTable);
        tableEditor.horizontalAlignment = SWT.CENTER;
        tableEditor.verticalAlignment = SWT.TOP;
        tableEditor.grabHorizontal = true;
        tableEditor.minimumWidth = 50;
        columnsTable.addMouseListener(new ColumnsMouseListener(tableEditor, columnsTable));
    }
    final Composite cascadeGroup = UIUtils.createPlaceholder(panel, 4, 5);
    {
        // Cascades
        cascadeGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        final Combo onDeleteCombo = UIUtils.createLabelCombo(cascadeGroup, CoreMessages.dialog_struct_edit_fk_combo_on_delete, SWT.DROP_DOWN | SWT.READ_ONLY);
        onDeleteCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        final Combo onUpdateCombo = UIUtils.createLabelCombo(cascadeGroup, CoreMessages.dialog_struct_edit_fk_combo_on_update, SWT.DROP_DOWN | SWT.READ_ONLY);
        onUpdateCombo.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
        for (DBSForeignKeyModifyRule modifyRule : supportedModifyRules) {
            onDeleteCombo.add(modifyRule.getName());
            onUpdateCombo.add(modifyRule.getName());
        }
        onDeleteCombo.select(0);
        onUpdateCombo.select(0);
        onDeleteRule = onUpdateRule = supportedModifyRules[0];
        onDeleteCombo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                onDeleteRule = supportedModifyRules[onDeleteCombo.getSelectionIndex()];
            }
        });
        onUpdateCombo.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                onUpdateRule = supportedModifyRules[onUpdateCombo.getSelectionIndex()];
            }
        });
    }
    return panel;
}
Also used : DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) CCombo(org.eclipse.swt.custom.CCombo) CSmartCombo(org.jkiss.dbeaver.ui.controls.CSmartCombo) ItemListControl(org.jkiss.dbeaver.ui.controls.itemlist.ItemListControl) TableEditor(org.eclipse.swt.custom.TableEditor) GridData(org.eclipse.swt.layout.GridData)

Aggregations

ItemListControl (org.jkiss.dbeaver.ui.controls.itemlist.ItemListControl)3 TableEditor (org.eclipse.swt.custom.TableEditor)2 GridData (org.eclipse.swt.layout.GridData)2 DBNNode (org.jkiss.dbeaver.model.navigator.DBNNode)2 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 CCombo (org.eclipse.swt.custom.CCombo)1 FocusEvent (org.eclipse.swt.events.FocusEvent)1 FocusListener (org.eclipse.swt.events.FocusListener)1 ModifyEvent (org.eclipse.swt.events.ModifyEvent)1 ModifyListener (org.eclipse.swt.events.ModifyListener)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 Button (org.eclipse.swt.widgets.Button)1 Composite (org.eclipse.swt.widgets.Composite)1 Table (org.eclipse.swt.widgets.Table)1 Text (org.eclipse.swt.widgets.Text)1 MultiPageEditorPart (org.eclipse.ui.part.MultiPageEditorPart)1 MultiPageEditorSite (org.eclipse.ui.part.MultiPageEditorSite)1