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);
}
});
}
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;
}
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();
}
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);
}
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;
}
Aggregations