Search in sources :

Example 1 with RelationMapColumnLabelProvider

use of com.cubrid.common.ui.er.editor.RelationMapColumnLabelProvider in project cubrid-manager by CUBRID.

the class SetPhysicalLogicaMapDialog method createTableComposite.

private void createTableComposite(Composite composite, Group group, PhysicalLogicRelation.MapType type) {
    group.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridLayout layout = new GridLayout();
    layout.numColumns = 1;
    group.setLayout(layout);
    ScrolledComposite scrolledComposite = new ScrolledComposite(group, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
    scrolledComposite.setLayoutData(new GridData(GridData.FILL_BOTH));
    scrolledComposite.setExpandHorizontal(true);
    scrolledComposite.setExpandVertical(true);
    final TableViewer tableViewer = new TableViewer(scrolledComposite, SWT.FULL_SELECTION | SWT.MULTI | SWT.BORDER);
    columnDataTableView = tableViewer;
    tableViewer.setColumnProperties(columnProperites);
    final Table widgetTable = tableViewer.getTable();
    scrolledComposite.setContent(widgetTable);
    scrolledComposite.setMinSize(widgetTable.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    final GridData gdFkTable = new GridData(SWT.FILL, SWT.FILL, true, true, 4, 1);
    widgetTable.setLayoutData(gdFkTable);
    widgetTable.setLinesVisible(true);
    widgetTable.setHeaderVisible(true);
    //empty column
    final TableColumn emptyColumn = new TableColumn(widgetTable, SWT.NONE);
    emptyColumn.setWidth(0);
    //flag column
    final TableColumn flagColumn = new TableColumn(widgetTable, SWT.LEFT_TO_RIGHT);
    flagColumn.setWidth(20);
    //physical column
    TableColumn tblCol = new TableColumn(widgetTable, SWT.NONE);
    tblCol.setWidth(120);
    tblCol.setText(Messages.tblcolumnPhysical);
    //logical column
    tblCol = new TableColumn(widgetTable, SWT.NONE);
    tblCol.setWidth(120);
    tblCol.setText(Messages.tblcolumnLogical);
    attrContentProvider = new AttributeContentProvider();
    attrLabelProvider = new RelationMapColumnLabelProvider(this);
    tableViewer.setContentProvider(attrContentProvider);
    tableViewer.setLabelProvider(attrLabelProvider);
    CellEditor[] cellEditor = new CellEditor[columnProperites.length];
    {
        int index = 0;
        //Empty
        cellEditor[index++] = null;
        //Flag
        cellEditor[index++] = null;
        //Physical
        cellEditor[index++] = new TextCellEditor(widgetTable);
        //Logical
        cellEditor[index++] = new TextCellEditor(widgetTable);
    }
    tableViewer.setCellEditors(cellEditor);
    tableViewer.setCellModifier(new ModelRelationCellModifier(this, type));
    loadTableInput(type);
    final Button delBtn = new Button(group, SWT.PUSH);
    delBtn.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
    delBtn.setText(Messages.btnDelItem);
    delBtn.setData(type);
    delBtn.setEnabled(false);
    delBtn.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent e) {
            deleteColumn(delBtn);
        }
    });
    widgetTable.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            handleSelectionChangeInTable(widgetTable, delBtn);
        }
    });
}
Also used : Table(org.eclipse.swt.widgets.Table) ERTable(com.cubrid.common.ui.er.model.ERTable) AttributeContentProvider(com.cubrid.common.ui.cubrid.table.editor.AttributeContentProvider) CellEditor(org.eclipse.jface.viewers.CellEditor) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) TableColumn(org.eclipse.swt.widgets.TableColumn) GridLayout(org.eclipse.swt.layout.GridLayout) RelationMapColumnLabelProvider(com.cubrid.common.ui.er.editor.RelationMapColumnLabelProvider) Button(org.eclipse.swt.widgets.Button) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ScrolledComposite(org.eclipse.swt.custom.ScrolledComposite) TextCellEditor(org.eclipse.jface.viewers.TextCellEditor) ModelRelationCellModifier(com.cubrid.common.ui.er.editor.ModelRelationCellModifier) TableViewer(org.eclipse.jface.viewers.TableViewer)

Aggregations

AttributeContentProvider (com.cubrid.common.ui.cubrid.table.editor.AttributeContentProvider)1 ModelRelationCellModifier (com.cubrid.common.ui.er.editor.ModelRelationCellModifier)1 RelationMapColumnLabelProvider (com.cubrid.common.ui.er.editor.RelationMapColumnLabelProvider)1 ERTable (com.cubrid.common.ui.er.model.ERTable)1 CellEditor (org.eclipse.jface.viewers.CellEditor)1 TableViewer (org.eclipse.jface.viewers.TableViewer)1 TextCellEditor (org.eclipse.jface.viewers.TextCellEditor)1 ScrolledComposite (org.eclipse.swt.custom.ScrolledComposite)1 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)1 SelectionEvent (org.eclipse.swt.events.SelectionEvent)1 GridData (org.eclipse.swt.layout.GridData)1 GridLayout (org.eclipse.swt.layout.GridLayout)1 Button (org.eclipse.swt.widgets.Button)1 Table (org.eclipse.swt.widgets.Table)1 TableColumn (org.eclipse.swt.widgets.TableColumn)1