Search in sources :

Example 81 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project cubrid-manager by CUBRID.

the class AddIndexDialog method createColumnTable.

/**
	 * Create the column table
	 * 
	 */
private void createColumnTable() {
    columnTable = new Table(group, SWT.FULL_SELECTION | SWT.BORDER | SWT.SINGLE | SWT.CHECK);
    {
        columnTable.setHeaderVisible(true);
        GridData gdColumnTable = new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1);
        gdColumnTable.heightHint = 200;
        columnTable.setLayoutData(gdColumnTable);
        columnTable.setLinesVisible(true);
    }
    columnTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            final TableItem item = (TableItem) event.item;
            if (event.detail == SWT.CHECK) {
                if (item.getChecked()) {
                    item.setForeground(ResourceManager.getColor(0, 0, 0));
                } else {
                    item.setForeground(ResourceManager.getColor(128, 128, 128));
                }
                columnTable.setSelection(new TableItem[] { item });
            }
            setBtnEnable();
            setHintMessage();
        }
    });
    CommonUITool.hackForYosemite(columnTable);
    TableColumn tblCol = new TableColumn(columnTable, SWT.LEFT);
    tblCol.setWidth(83);
    tblCol.setText(Messages.colUseColumn);
    tblCol = new TableColumn(columnTable, SWT.LEFT);
    tblCol.setWidth(123);
    tblCol.setText(Messages.colColumnName);
    tblCol = new TableColumn(columnTable, SWT.LEFT);
    tblCol.setWidth(196);
    tblCol.setText(Messages.colDataType);
    tblCol = new TableColumn(columnTable, SWT.LEFT);
    tblCol.setWidth(86);
    tblCol.setText(Messages.colOrder);
    if (isSupportPrefixLength) {
        tblCol = new TableColumn(columnTable, SWT.LEFT);
        tblCol.setWidth(196);
        tblCol.setText(Messages.colPrefixLength);
    }
    setTableEditor();
}
Also used : Table(org.eclipse.swt.widgets.Table) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableItem(org.eclipse.swt.widgets.TableItem) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 82 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project cubrid-manager by CUBRID.

the class TableDashboardComposite method createColumnsTable.

/**
	 * Create the column information table
	 *
	 */
private void createColumnsTable(Composite topComposite) {
    columnTableView = new TableViewer(topComposite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    Table columnsTable = columnTableView.getTable();
    columnsTable.setLinesVisible(true);
    columnsTable.setHeaderVisible(true);
    final GridData gdColumnsTable = new GridData(SWT.FILL, SWT.FILL, true, true);
    gdColumnsTable.heightHint = 189;
    columnsTable.setLayoutData(gdColumnsTable);
    // 0 PK
    TableColumn tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setAlignment(SWT.CENTER);
    tblCol.setWidth(WIDTH_PKCOLUMN);
    tblCol.setText(Messages.tblColumnPK);
    // 1 NAME
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_NAMECOLUMN);
    tblCol.setText(Messages.tblColumnName);
    // 2 MEMO
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_NAMECOLUMN);
    tblCol.setText(Messages.tblColumnMemo);
    // 3 DATATYPE
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_DATATYPECOLUMN);
    tblCol.setText(Messages.tblColumnDataType);
    // 4 DEFAULT
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(98);
    tblCol.setText(Messages.tblColumnDefault);
    // 5 AUTO INCREMENT
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setAlignment(SWT.CENTER);
    tblCol.setWidth(100);
    tblCol.setText(Messages.tblColumnAutoIncr);
    // 6 NOT NULL
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_NOTNULLCOLUMN);
    tblCol.setText(Messages.tblColumnNotNull);
    tblCol.setAlignment(SWT.CENTER);
    // 7 UK
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_UNIQUECOLUMN);
    tblCol.setText(Messages.tblColumnUnique);
    tblCol.setAlignment(SWT.CENTER);
    // 8 SHARED
    tblCol = new TableColumn(columnsTable, SWT.NONE);
    tblCol.setWidth(WIDTH_SHAREDCOLUMN);
    tblCol.setResizable(true);
    tblCol.setText(Messages.tblColumnShared);
    tblCol.setAlignment(SWT.CENTER);
    labelProvider = new TableDashboardDetailLabelProvider(null, null);
    columnTableView.setContentProvider(new TableDashboardDetailContentProvider());
    columnTableView.setLabelProvider(labelProvider);
    columnTableView.getTable().addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            if ((event.stateMask & SWT.CTRL) != 0 && event.keyCode == 'c') {
                copyTablesDetailToClipboard();
            } else if (event.keyCode == SWT.CR) {
                showEditDialog(columnTableView.getTable(), columnTableView.getTable().getSelectionIndex());
            }
        }
    });
    registerContextMenu();
}
Also used : KeyEvent(org.eclipse.swt.events.KeyEvent) Table(org.eclipse.swt.widgets.Table) KeyAdapter(org.eclipse.swt.events.KeyAdapter) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 83 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project cubrid-manager by CUBRID.

the class CreateViewDialog method createCommonTableViewer.

/**
	 * create Common Table Viewer
	 *
	 * @param parent Composite
	 * @param sorter ViewerSorter
	 * @param columnNameArr String[]
	 * @param gridData GridData
	 * @return TableViewer
	 */
public TableViewer createCommonTableViewer(Composite parent, ViewerSorter sorter, final String[] columnNameArr, GridData gridData) {
    final TableViewer tableViewer = new TableViewer(parent, SWT.V_SCROLL | SWT.MULTI | SWT.BORDER | SWT.H_SCROLL | SWT.FULL_SELECTION);
    tableViewer.setContentProvider(new TableContentProvider());
    tableViewer.setLabelProvider(new TableLabelProvider());
    if (sorter != null) {
        tableViewer.setSorter(sorter);
    }
    tableViewer.getTable().setLinesVisible(true);
    tableViewer.getTable().setHeaderVisible(true);
    tableViewer.getTable().setLayoutData(gridData);
    for (int i = 0; i < columnNameArr.length; i++) {
        final TableColumn tblColumn = new TableColumn(tableViewer.getTable(), SWT.LEFT | (isPropertyQuery ? SWT.NULL : SWT.READ_ONLY));
        tblColumn.setText(columnNameArr[i]);
        if (sorter != null) {
            tblColumn.addSelectionListener(new SelectionAdapter() {

                public void widgetSelected(SelectionEvent event) {
                    TableColumn column = (TableColumn) event.widget;
                    int j = 0;
                    for (j = 0; j < columnNameArr.length; j++) {
                        if (column.getText().equals(columnNameArr[j])) {
                            break;
                        }
                    }
                    TableViewerSorter sorter = ((TableViewerSorter) tableViewer.getSorter());
                    if (sorter == null) {
                        return;
                    }
                    sorter.doSort(j);
                    tableViewer.getTable().setSortColumn(column);
                    tableViewer.getTable().setSortDirection(sorter.isAsc() ? SWT.UP : SWT.DOWN);
                    tableViewer.refresh();
                    for (int k = 0; k < tableViewer.getTable().getColumnCount(); k++) {
                        tableViewer.getTable().getColumn(k).pack();
                    }
                }
            });
        }
        tblColumn.pack();
    }
    return tableViewer;
}
Also used : TableViewerSorter(com.cubrid.common.ui.spi.TableViewerSorter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) SelectionEvent(org.eclipse.swt.events.SelectionEvent) TableLabelProvider(com.cubrid.common.ui.spi.TableLabelProvider) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn)

Example 84 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project cubrid-manager by CUBRID.

the class ImportResultDialog method createDialogArea.

/**
	 * Create the dialog area
	 *
	 * @param parent Composite
	 * @return Control
	 */
protected Control createDialogArea(Composite parent) {
    Composite parentComp = (Composite) super.createDialogArea(parent);
    Composite composite = new Composite(parentComp, SWT.NONE);
    {
        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
        GridLayout layout = new GridLayout();
        layout.numColumns = 1;
        layout.marginHeight = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
        layout.marginWidth = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
        layout.verticalSpacing = convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
        layout.horizontalSpacing = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
        composite.setLayout(layout);
    }
    TableViewer tableViewer = new TableViewer(composite, SWT.BORDER | SWT.FULL_SELECTION | SWT.H_SCROLL | SWT.V_SCROLL | SWT.MULTI);
    table = tableViewer.getTable();
    {
        GridData gdData = new GridData(GridData.FILL_BOTH);
        gdData.heightHint = 400;
        gdData.widthHint = 500;
        table.setLayoutData(gdData);
    }
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    TableColumn tableColumn = new TableColumn(table, SWT.LEFT);
    tableColumn.setText(Messages.importColumnNO);
    tableColumn = new TableColumn(table, SWT.LEFT);
    tableColumn.setText(Messages.importColumnMessage);
    tableViewer.setLabelProvider(new TableLabelProvider(tableViewer, null));
    tableViewer.setContentProvider(new TableContentProvider());
    tableViewer.setInput(errorList);
    //Create the context menu
    MenuManager contextMenuManager = new MenuManager();
    contextMenuManager.setRemoveAllWhenShown(true);
    contextMenuManager.addMenuListener(new IMenuListener() {

        public void menuAboutToShow(IMenuManager manager) {
            //copy action
            Action copyAction = new Action(Messages.bind(Messages.contextCopy, "Ctrl+C")) {

                public void run() {
                    BusyIndicator.showWhile(Display.getDefault(), new Runnable() {

                        public void run() {
                            copyDataToClipboard();
                        }
                    });
                }
            };
            manager.add(copyAction);
        }
    });
    Menu contextMenu = contextMenuManager.createContextMenu(table);
    table.setMenu(contextMenu);
    //Add listener
    table.addKeyListener(new KeyAdapter() {

        public void keyPressed(KeyEvent event) {
            if ((event.stateMask & SWT.CTRL) != 0 && (event.stateMask & SWT.SHIFT) == 0 && event.keyCode == 'c') {
                copyDataToClipboard();
            }
        }
    });
    for (int i = 0; i < table.getColumnCount(); i++) {
        TableColumn tblColumn = table.getColumn(i);
        tblColumn.pack();
        if (tblColumn.getWidth() > 400) {
            tblColumn.setWidth(400);
        }
    }
    Label label = new Label(composite, SWT.LEFT);
    label.setForeground(ResourceManager.getColor(255, 0, 0));
    label.setText(message);
    return composite;
}
Also used : Action(org.eclipse.jface.action.Action) Composite(org.eclipse.swt.widgets.Composite) KeyAdapter(org.eclipse.swt.events.KeyAdapter) Label(org.eclipse.swt.widgets.Label) ITableLabelProvider(org.eclipse.jface.viewers.ITableLabelProvider) TableColumn(org.eclipse.swt.widgets.TableColumn) IMenuListener(org.eclipse.jface.action.IMenuListener) KeyEvent(org.eclipse.swt.events.KeyEvent) GridLayout(org.eclipse.swt.layout.GridLayout) GridData(org.eclipse.swt.layout.GridData) TableContentProvider(com.cubrid.common.ui.spi.TableContentProvider) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) Menu(org.eclipse.swt.widgets.Menu) TableViewer(org.eclipse.jface.viewers.TableViewer)

Example 85 with TableColumn

use of org.eclipse.swt.widgets.TableColumn in project cubrid-manager by CUBRID.

the class SchemaInfoEditorPart method createColumnsTable.

/**
	 * Create the column information table
	 * 
	 */
private void createColumnsTable() {
    Label colslabel = new Label(topComposite, SWT.LEFT | SWT.WRAP);
    colslabel.setText(Messages.lblColumns);
    colslabel.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_WHITE));
    columnTableView = new TableViewer(topComposite, SWT.FULL_SELECTION | SWT.SIMPLE | SWT.BORDER);
    Table columnsTable = columnTableView.getTable();
    {
        createContextMenu(columnsTable);
        columnsTable.setLinesVisible(true);
        columnsTable.setHeaderVisible(true);
        final GridData gdColumnsTable = new GridData(SWT.FILL, SWT.FILL, true, true);
        gdColumnsTable.heightHint = 189;
        columnsTable.setLayoutData(gdColumnsTable);
        // PK
        TableColumn tblCol = new TableColumn(columnsTable, SWT.NONE);
        tblCol.setAlignment(SWT.CENTER);
        tblCol.setWidth(WIDTH_PKCOLUMN);
        tblCol.setText(Messages.tblColumnPK);
        // NAME
        tblCol = new TableColumn(columnsTable, SWT.NONE);
        tblCol.setWidth(WIDTH_NAMECOLUMN);
        tblCol.setText(Messages.tblColumnName);
        // DATATYPE
        tblCol = new TableColumn(columnsTable, SWT.NONE);
        tblCol.setWidth(WIDTH_DATATYPECOLUMN);
        tblCol.setText(Messages.tblColumnDataType);
        // DEFAULT
        tblCol = new TableColumn(columnsTable, SWT.NONE);
        tblCol.setWidth(98);
        tblCol.setText(Messages.tblColumnDefault);
        // AUTO INCREMENT
        tblCol = new TableColumn(columnsTable, SWT.NONE);
        tblCol.setAlignment(SWT.CENTER);
        tblCol.setWidth(100);
        tblCol.setText(Messages.tblColumnAutoIncr);
        // NOT NULL
        tblCol = new TableColumn(columnsTable, SWT.NONE);
        tblCol.setWidth(WIDTH_NOTNULLCOLUMN);
        tblCol.setText(Messages.tblColumnNotNull);
        tblCol.setAlignment(SWT.CENTER);
        // UK
        tblCol = new TableColumn(columnsTable, SWT.NONE);
        tblCol.setWidth(WIDTH_UNIQUECOLUMN);
        tblCol.setText(Messages.tblColumnUnique);
        tblCol.setAlignment(SWT.CENTER);
        // SHARED
        tblCol = new TableColumn(columnsTable, SWT.NONE);
        tblCol.setWidth(WIDTH_SHAREDCOLUMN);
        tblCol.setResizable(true);
        tblCol.setText(Messages.tblColumnShared);
        tblCol.setAlignment(SWT.CENTER);
        // INHERIT
        tblCol = new TableColumn(columnsTable, SWT.NONE);
        tblCol.setAlignment(SWT.CENTER);
        tblCol.setWidth(90);
        tblCol.setResizable(true);
        tblCol.setText(Messages.tblColumnInherit);
        // CLASS
        tblCol = new TableColumn(columnsTable, SWT.NONE);
        tblCol.setWidth(90);
        tblCol.setResizable(true);
        tblCol.setText(Messages.tblColumnClass);
        tblCol.setAlignment(SWT.CENTER);
    }
    columnTableView.setContentProvider(new AttributeTableViewerContentProvider());
    columnTableView.setLabelProvider(new AttributeTableViewerLabelProvider(database, schemaInfo));
    CommonUITool.hackForYosemite(columnTableView.getTable());
    columnTableView.setInput(schemaInfo);
    setTableEditor(columnsTable, 1);
    setTableEditor(columnsTable, 2);
}
Also used : Table(org.eclipse.swt.widgets.Table) Label(org.eclipse.swt.widgets.Label) GridData(org.eclipse.swt.layout.GridData) TableViewer(org.eclipse.jface.viewers.TableViewer) TableColumn(org.eclipse.swt.widgets.TableColumn)

Aggregations

TableColumn (org.eclipse.swt.widgets.TableColumn)305 Table (org.eclipse.swt.widgets.Table)151 GridData (org.eclipse.swt.layout.GridData)105 TableViewer (org.eclipse.jface.viewers.TableViewer)94 Composite (org.eclipse.swt.widgets.Composite)92 SelectionEvent (org.eclipse.swt.events.SelectionEvent)87 GridLayout (org.eclipse.swt.layout.GridLayout)76 TableItem (org.eclipse.swt.widgets.TableItem)76 Point (org.eclipse.swt.graphics.Point)57 Label (org.eclipse.swt.widgets.Label)55 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)52 Button (org.eclipse.swt.widgets.Button)48 TableViewerColumn (org.eclipse.jface.viewers.TableViewerColumn)41 FillLayout (org.eclipse.swt.layout.FillLayout)37 Listener (org.eclipse.swt.widgets.Listener)37 Event (org.eclipse.swt.widgets.Event)35 Shell (org.eclipse.swt.widgets.Shell)35 Test (org.junit.Test)33 SelectionListener (org.eclipse.swt.events.SelectionListener)32 Text (org.eclipse.swt.widgets.Text)30