Search in sources :

Example 16 with TableItem

use of org.eclipse.swt.widgets.TableItem in project dbeaver by serge-rider.

the class GenerateMultiSQLDialog method createObjectsSelector.

protected void createObjectsSelector(Composite parent) {
    if (selectedObjects.size() < 2) {
        // Don't need it for a single object
        return;
    }
    UIUtils.createControlLabel(parent, "Tables");
    objectsTable = new Table(parent, SWT.BORDER | SWT.CHECK);
    GridData gd = new GridData(GridData.FILL_HORIZONTAL);
    gd.heightHint = 100;
    objectsTable.setLayoutData(gd);
    for (T table : selectedObjects) {
        TableItem item = new TableItem(objectsTable, SWT.NONE);
        item.setText(DBUtils.getObjectFullName(table, DBPEvaluationContext.UI));
        item.setImage(DBeaverIcons.getImage(DBIcon.TREE_TABLE));
        item.setChecked(true);
        item.setData(table);
    }
    objectsTable.addSelectionListener(SQL_CHANGE_LISTENER);
    objectsTable.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent e) {
            boolean hasChecked = !getCheckedObjects().isEmpty();
            getButton(IDialogConstants.OK_ID).setEnabled(hasChecked);
            getButton(IDialogConstants.DETAILS_ID).setEnabled(hasChecked);
        }
    });
}
Also used : Table(org.eclipse.swt.widgets.Table) SWT(org.eclipse.swt.SWT) TableItem(org.eclipse.swt.widgets.TableItem) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent)

Example 17 with TableItem

use of org.eclipse.swt.widgets.TableItem in project dbeaver by serge-rider.

the class StatusDetailsDialog method createDialogArea.

@Override
protected Composite createDialogArea(Composite parent) {
    Composite composite = super.createDialogArea(parent);
    if (!CommonUtils.isEmpty(warnings)) {
        // Create warnings table
        UIUtils.createControlLabel(composite, "Warnings");
        warnTable = new Table(composite, SWT.BORDER | SWT.FULL_SELECTION);
        TableColumn exColumn = UIUtils.createTableColumn(warnTable, SWT.NONE, "Exception");
        TableColumn msgColumn = UIUtils.createTableColumn(warnTable, SWT.NONE, "Message");
        warnTable.setLinesVisible(true);
        GridData gd = new GridData(GridData.FILL_BOTH);
        gd.minimumHeight = 100;
        warnTable.setLayoutData(gd);
        for (Throwable ex : warnings) {
            TableItem warnItem = new TableItem(warnTable, SWT.NONE);
            warnItem.setText(0, ex.getClass().getName());
            if (ex.getMessage() != null) {
                warnItem.setText(1, ex.getMessage());
            }
            warnItem.setData(ex);
        }
        exColumn.pack();
        msgColumn.pack();
        warnTable.addMouseListener(new MouseAdapter() {

            @Override
            public void mouseDoubleClick(MouseEvent e) {
                openWarning();
            }
        });
        warnTable.addTraverseListener(new TraverseListener() {

            @Override
            public void keyTraversed(TraverseEvent e) {
                if (e.detail == SWT.TRAVERSE_RETURN) {
                    openWarning();
                    e.doit = false;
                }
            }
        });
    }
    return composite;
}
Also used : Table(org.eclipse.swt.widgets.Table) MouseEvent(org.eclipse.swt.events.MouseEvent) TraverseEvent(org.eclipse.swt.events.TraverseEvent) Composite(org.eclipse.swt.widgets.Composite) TraverseListener(org.eclipse.swt.events.TraverseListener) TableItem(org.eclipse.swt.widgets.TableItem) GridData(org.eclipse.swt.layout.GridData) MouseAdapter(org.eclipse.swt.events.MouseAdapter) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 18 with TableItem

use of org.eclipse.swt.widgets.TableItem in project dbeaver by serge-rider.

the class StatusDetailsDialog method openWarning.

private void openWarning() {
    TableItem[] selection = warnTable.getSelection();
    if (selection.length == 0) {
        return;
    }
    Throwable error = (Throwable) selection[0].getData();
    ViewExceptionDialog veDialog = new ViewExceptionDialog(getShell(), error);
    veDialog.open();
}
Also used : ViewExceptionDialog(org.jkiss.dbeaver.ui.dialogs.ViewExceptionDialog) TableItem(org.eclipse.swt.widgets.TableItem)

Example 19 with TableItem

use of org.eclipse.swt.widgets.TableItem in project dbeaver by serge-rider.

the class ConfigImportWizardPage method setVisible.

@Override
public void setVisible(boolean visible) {
    if (visible) {
        connectionTable.removeAll();
        importData = new ImportData();
        boolean loaded = false;
        try {
            loadConnections(importData);
            loaded = true;
        } catch (DBException e) {
            setMessage(e.getMessage(), IMessageProvider.ERROR);
        }
        getContainer().updateButtons();
        if (loaded) {
            if (CommonUtils.isEmpty(importData.getConnections())) {
                setMessage("Connection list is empty", IMessageProvider.WARNING);
            } else {
                for (ImportConnectionInfo connectionInfo : importData.getConnections()) {
                    TableItem item = new TableItem(connectionTable, SWT.NONE);
                    item.setImage(0, DBeaverIcons.getImage(DBIcon.TREE_DATABASE));
                    item.setText(0, connectionInfo.getAlias());
                    item.setText(1, connectionInfo.getDriverInfo().getName());
                    String url = connectionInfo.getUrl();
                    if (CommonUtils.isEmpty(url)) {
                        url = connectionInfo.getHost();
                    }
                    item.setText(2, url);
                    item.setData(connectionInfo);
                }
            }
        }
        UIUtils.packColumns(connectionTable);
    }
    super.setVisible(visible);
}
Also used : DBException(org.jkiss.dbeaver.DBException) TableItem(org.eclipse.swt.widgets.TableItem)

Example 20 with TableItem

use of org.eclipse.swt.widgets.TableItem in project translationstudio8 by heartsome.

the class ConfigureColumnsAction method createColumnControlPanel.

/**
     * Create the dialog area. TODO can be done much nicer ... but works for the first draft
     * 
     * @param parent parent composite
     * @return initialized control
     */
private Control createColumnControlPanel(Composite parent) {
    Composite panel = new Composite(parent, SWT.NULL);
    panel.setLayout(new RowLayout());
    Label l = new Label(panel, SWT.NULL);
    l.setText("Configure the columns");
    Table table = new Table(parent, SWT.CHECK | SWT.MULTI | SWT.FULL_SELECTION | SWT.BORDER | SWT.V_SCROLL);
    _chkBoxViewer = new CheckboxTableViewer(table);
    _chkBoxViewer.setContentProvider(new ColTableContentProvider());
    _chkBoxViewer.setLabelProvider(new ColTableLabelProvider());
    TableColumn column = new TableColumn(_chkBoxViewer.getTable(), SWT.LEFT);
    column.setText("Column");
    column.setWidth(100);
    _chkBoxViewer.getTable().setHeaderVisible(true);
    _chkBoxViewer.setInput("x");
    final int firstColIdx = _allowFixedColumns ? 0 : _table.getFixedColumns();
    for (int i = 0; i < _table.getTableModel().getColumnCount(); i++) {
        IColumn col = _table.getTableModel().getColumn(i);
        _chkBoxViewer.setChecked(col, _tvs.getColumnVisible(col));
    }
    table.getColumn(0).pack();
    table.addListener(SWT.Selection, new Listener() {

        public void handleEvent(Event event) {
            if (event.detail == SWT.CHECK) {
                TableItem item = (TableItem) event.item;
                IColumn col = (IColumn) item.getData();
                int idx = _tvs.getSortedColumns().indexOf(col);
                if (_allowFixedColumns || idx >= _table.getFixedColumns()) {
                    _tvs.setColumnVisible(col, item.getChecked());
                } else {
                    _chkBoxViewer.setChecked(col, _tvs.getColumnVisible(col));
                }
            }
        }
    });
    Button upButton = new Button(panel, SWT.PUSH);
    upButton.setText("up");
    upButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent arg0) {
            if (_chkBoxViewer.getTable().getSelectionCount() > 0) {
                TableItem item = _chkBoxViewer.getTable().getItem(_chkBoxViewer.getTable().getSelectionIndex());
                IColumn col = (IColumn) item.getData();
                int idx = _tvs.getSortedColumns().indexOf(col);
                if (idx > firstColIdx) {
                    _tvs.getSortedColumns().remove(col);
                    _tvs.getSortedColumns().add(idx - 1, col);
                    _table.updateColumnList();
                    _table.redraw();
                    _chkBoxViewer.refresh();
                }
            }
        }

        public void widgetDefaultSelected(SelectionEvent arg0) {
        }
    });
    Button downButton = new Button(panel, SWT.PUSH);
    downButton.setText("down");
    downButton.addSelectionListener(new SelectionListener() {

        public void widgetSelected(SelectionEvent arg0) {
            if (_chkBoxViewer.getTable().getSelectionCount() > 0) {
                TableItem item = _chkBoxViewer.getTable().getItem(_chkBoxViewer.getTable().getSelectionIndex());
                IColumn col = (IColumn) item.getData();
                int idx = _tvs.getSortedColumns().indexOf(col);
                if (idx < _tvs.getSortedColumns().size() - 1) {
                    _tvs.getSortedColumns().remove(col);
                    _tvs.getSortedColumns().add(idx + 1, col);
                    _table.updateColumnList();
                    _table.redraw();
                    _chkBoxViewer.refresh();
                }
            }
        }

        public void widgetDefaultSelected(SelectionEvent arg0) {
        }
    });
    return panel;
}
Also used : Table(org.eclipse.swt.widgets.Table) JaretTable(de.jaret.util.ui.table.JaretTable) Listener(org.eclipse.swt.widgets.Listener) ILabelProviderListener(org.eclipse.jface.viewers.ILabelProviderListener) SelectionListener(org.eclipse.swt.events.SelectionListener) Composite(org.eclipse.swt.widgets.Composite) CheckboxTableViewer(org.eclipse.jface.viewers.CheckboxTableViewer) TableItem(org.eclipse.swt.widgets.TableItem) Label(org.eclipse.swt.widgets.Label) TableColumn(org.eclipse.swt.widgets.TableColumn) IColumn(de.jaret.util.ui.table.model.IColumn) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Event(org.eclipse.swt.widgets.Event) SelectionEvent(org.eclipse.swt.events.SelectionEvent) SelectionListener(org.eclipse.swt.events.SelectionListener)

Aggregations

TableItem (org.eclipse.swt.widgets.TableItem)323 Point (org.eclipse.swt.graphics.Point)76 Table (org.eclipse.swt.widgets.Table)58 SelectionEvent (org.eclipse.swt.events.SelectionEvent)56 ArrayList (java.util.ArrayList)46 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)40 GridData (org.eclipse.swt.layout.GridData)40 Composite (org.eclipse.swt.widgets.Composite)34 HashMap (java.util.HashMap)33 GridLayout (org.eclipse.swt.layout.GridLayout)33 Map (java.util.Map)31 TableColumn (org.eclipse.swt.widgets.TableColumn)31 List (java.util.List)27 HashSet (java.util.HashSet)25 Rectangle (org.eclipse.swt.graphics.Rectangle)23 Button (org.eclipse.swt.widgets.Button)23 Label (org.eclipse.swt.widgets.Label)22 TreeItem (org.eclipse.swt.widgets.TreeItem)17 Constraint (com.cubrid.common.core.common.model.Constraint)16 TableEditor (org.eclipse.swt.custom.TableEditor)16