Search in sources :

Example 1 with TableLayoutComposite

use of org.erlide.ui.internal.util.TableLayoutComposite in project erlide_eclipse by erlang.

the class ListDialogField method getListControl.

// ------ ui creation
/**
 * Returns the list control. When called the first time, the control will be created.
 *
 * @param parent
 *            The parent composite when called the first time, or <code>null</code>
 *            after.
 */
public Control getListControl(final Composite parent) {
    if (fTableControl == null) {
        assertCompositeNotNull(parent);
        if (fTableColumns == null) {
            fTable = createTableViewer(parent);
            final Table tableControl = fTable.getTable();
            fTableControl = tableControl;
            tableControl.setLayout(new TableLayout());
        } else {
            final TableLayoutComposite composite = new TableLayoutComposite(parent, SWT.NONE);
            fTableControl = composite;
            fTable = createTableViewer(composite);
            final Table tableControl = fTable.getTable();
            tableControl.setHeaderVisible(fTableColumns.fHeaders != null);
            tableControl.setLinesVisible(fTableColumns.fDrawLines);
            final ColumnLayoutData[] columns = fTableColumns.fColumns;
            for (int i = 0; i < columns.length; i++) {
                composite.addColumnData(columns[i]);
                final TableColumn column = new TableColumn(tableControl, SWT.NONE);
                // tableLayout.addColumnData(columns[i]);
                if (fTableColumns.fHeaders != null) {
                    column.setText(fTableColumns.fHeaders[i]);
                }
            }
        }
        fTable.getTable().addKeyListener(new KeyAdapter() {

            @Override
            public void keyPressed(final KeyEvent e) {
                handleKeyPressed(e);
            }
        });
        // fTableControl.setLayout(tableLayout);
        fTable.setContentProvider(fListViewerAdapter);
        fTable.setLabelProvider(fLabelProvider);
        fTable.addSelectionChangedListener(fListViewerAdapter);
        fTable.addDoubleClickListener(fListViewerAdapter);
        fTable.setInput(fParentElement);
        if (fViewerSorter != null) {
            fTable.setComparator(fViewerSorter);
        }
        fTableControl.setEnabled(isEnabled());
        if (fSelectionWhenEnabled != null) {
            postSetSelection(fSelectionWhenEnabled);
        }
    }
    return fTableControl;
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) Table(org.eclipse.swt.widgets.Table) TableLayoutComposite(org.erlide.ui.internal.util.TableLayoutComposite) KeyAdapter(org.eclipse.swt.events.KeyAdapter) ColumnLayoutData(org.eclipse.jface.viewers.ColumnLayoutData) TableLayout(org.eclipse.jface.viewers.TableLayout) TableColumn(org.eclipse.swt.widgets.TableColumn)

Aggregations

ColumnLayoutData (org.eclipse.jface.viewers.ColumnLayoutData)1 TableLayout (org.eclipse.jface.viewers.TableLayout)1 KeyAdapter (org.eclipse.swt.events.KeyAdapter)1 KeyEvent (org.eclipse.swt.events.KeyEvent)1 Table (org.eclipse.swt.widgets.Table)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1 TableLayoutComposite (org.erlide.ui.internal.util.TableLayoutComposite)1