Search in sources :

Example 1 with GridTableViewer

use of org.eclipse.nebula.jface.gridviewer.GridTableViewer in project tdq-studio-se by Talend.

the class PatternsSelectPage method createControl.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
     */
public void createControl(Composite parent) {
    GridLayout parentGridLayout = new GridLayout();
    GridData data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.verticalAlignment = GridData.FILL;
    data.grabExcessHorizontalSpace = true;
    data.grabExcessVerticalSpace = true;
    parent.setLayout(parentGridLayout);
    List<ModelElement> analysisColumns = this.selectPatternsWizard.getSsIndicator().getAnalyzedColumns();
    // add tableView
    // MOD msjian TDQ-4631 2012-2-10: add horizontal scroll bar
    GridTableViewer tableView = new GridTableViewer(parent, SWT.H_SCROLL);
    // TDQ-4631~
    this.table = tableView.getGrid();
    this.table.setLayoutData(data);
    table.setHeaderVisible(true);
    table.setLinesVisible(true);
    for (ModelElement element : analysisColumns) {
        GridColumn tableCum = new GridColumn(table, SWT.CHECK);
        String elementName = MetadataConnectionUtils.getMetadataColumnName(element);
        if (elementName != null) {
            tableCum.setText(elementName);
        }
    }
    tableView.setContentProvider(new PatternSelectContentProvider());
    tableView.setLabelProvider(new PatternSelectLabelProvider());
    this.tableInputList = organizeTableInput();
    tableView.setInput(tableInputList);
    for (GridColumn tableCum : table.getColumns()) {
        tableCum.pack();
    }
    // add data filter section.
    initDataFilterSection(parent);
    inItitemCheck();
    this.setControl(parent);
    this.setPageComplete(true);
}
Also used : ModelElement(orgomg.cwm.objectmodel.core.ModelElement) GridLayout(org.eclipse.swt.layout.GridLayout) GridTableViewer(org.eclipse.nebula.jface.gridviewer.GridTableViewer) GridData(org.eclipse.swt.layout.GridData) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn)

Example 2 with GridTableViewer

use of org.eclipse.nebula.jface.gridviewer.GridTableViewer in project archi by archimatetool.

the class RelationshipsMatrixDialog method createDialogArea.

@Override
protected Control createDialogArea(Composite parent) {
    // Help
    PlatformUI.getWorkbench().getHelpSystem().setHelp(parent, HELP_ID);
    setTitle(Messages.RelationshipsMatrixDialog_0);
    setMessage(Messages.RelationshipsMatrixDialog_1);
    Composite composite = (Composite) super.createDialogArea(parent);
    Composite client = new Composite(composite, SWT.NULL);
    GridLayout layout = new GridLayout(2, false);
    client.setLayout(layout);
    client.setLayoutData(new GridData(GridData.FILL_BOTH));
    GridData gd;
    GridTableViewer viewer = new GridTableViewer(client);
    gd = new GridData(GridData.FILL_BOTH);
    gd.widthHint = 800;
    gd.heightHint = 500;
    viewer.getControl().setLayoutData(gd);
    viewer.getGrid().setHeaderVisible(true);
    viewer.getGrid().setRowHeaderVisible(true);
    viewer.getGrid().setRowsResizeable(true);
    viewer.getGrid().setCellSelectionEnabled(true);
    // viewer.setColumnProperties(new String[] {"1", "2", "3"});
    viewer.setRowHeaderLabelProvider(new CellLabelProvider() {

        @Override
        public void update(ViewerCell cell) {
            cell.setText(ArchiLabelProvider.INSTANCE.getDefaultName((EClass) cell.getElement()));
            cell.setImage(ArchiLabelProvider.INSTANCE.getImage(cell.getElement()));
        }
    });
    GC gc = new GC(viewer.getGrid());
    // $NON-NLS-1$
    int columnWidth = gc.textExtent("acfginorstv").x + 8;
    gc.dispose();
    for (EClass eClass : getData()) {
        GridColumn column = new GridColumn(viewer.getGrid(), SWT.NONE);
        column.setWidth(columnWidth);
        column.setImage(ArchiLabelProvider.INSTANCE.getImage(eClass));
        column.setHeaderTooltip(ArchiLabelProvider.INSTANCE.getDefaultName(eClass));
    }
    viewer.setContentProvider(new IStructuredContentProvider() {

        @Override
        public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
        }

        @Override
        public void dispose() {
        }

        @Override
        public Object[] getElements(Object inputElement) {
            return getData().toArray();
        }
    });
    viewer.setLabelProvider(new MyLabelProvider());
    // hookContextMenu(viewer);
    viewer.setInput(getData());
    // $NON-NLS-1$
    String text = "";
    for (Entry<EClass, Character> entry : RelationshipsMatrix.INSTANCE.getRelationshipsValueMap().entrySet()) {
        // $NON-NLS-1$ //$NON-NLS-2$
        text += entry.getValue() + ": " + ArchiLabelProvider.INSTANCE.getDefaultName(entry.getKey()) + "\n";
    }
    Label label = new Label(client, SWT.NULL);
    label.setText(text);
    label.setLayoutData(new GridData(SWT.TOP, SWT.TOP, false, true));
    return composite;
}
Also used : Composite(org.eclipse.swt.widgets.Composite) GridTableViewer(org.eclipse.nebula.jface.gridviewer.GridTableViewer) Label(org.eclipse.swt.widgets.Label) Viewer(org.eclipse.jface.viewers.Viewer) GridTableViewer(org.eclipse.nebula.jface.gridviewer.GridTableViewer) ViewerCell(org.eclipse.jface.viewers.ViewerCell) Point(org.eclipse.swt.graphics.Point) GridLayout(org.eclipse.swt.layout.GridLayout) EClass(org.eclipse.emf.ecore.EClass) GridData(org.eclipse.swt.layout.GridData) IStructuredContentProvider(org.eclipse.jface.viewers.IStructuredContentProvider) GridColumn(org.eclipse.nebula.widgets.grid.GridColumn) GC(org.eclipse.swt.graphics.GC) CellLabelProvider(org.eclipse.jface.viewers.CellLabelProvider)

Aggregations

GridTableViewer (org.eclipse.nebula.jface.gridviewer.GridTableViewer)2 GridColumn (org.eclipse.nebula.widgets.grid.GridColumn)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 EClass (org.eclipse.emf.ecore.EClass)1 CellLabelProvider (org.eclipse.jface.viewers.CellLabelProvider)1 IStructuredContentProvider (org.eclipse.jface.viewers.IStructuredContentProvider)1 Viewer (org.eclipse.jface.viewers.Viewer)1 ViewerCell (org.eclipse.jface.viewers.ViewerCell)1 GC (org.eclipse.swt.graphics.GC)1 Point (org.eclipse.swt.graphics.Point)1 Composite (org.eclipse.swt.widgets.Composite)1 Label (org.eclipse.swt.widgets.Label)1 ModelElement (orgomg.cwm.objectmodel.core.ModelElement)1