1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
public void createControls(Composite parent,
TabbedPropertySheetPage aTabbedPropertySheetPage) {
super.createControls(parent, aTabbedPropertySheetPage);
//create section
Section section = getWidgetFactory().createSection(parent, ExpandableComposite.TITLE_BAR | ExpandableComposite.TWISTIE | ExpandableComposite.EXPANDED);
section.setText("Dashboard");
//create root compoiste
Composite rootParentComposite = getWidgetFactory().createFlatFormComposite(section);
//set layout to the root composite
TableColumnLayout tableColumnLayout = new TableColumnLayout();
rootParentComposite.setLayout(tableColumnLayout);
section.setClient(rootParentComposite);
//create the table
compareTable = new TableViewer(rootParentComposite, SWT.BORDER | SWT.V_SCROLL);
compareTable.getTable().setHeaderVisible(true);
compareTable.getTable().setLinesVisible(true);
//set the height to the table
int desiredHeight = compareTable.getTable().getItemHeight() * 5 + compareTable.getTable().getHeaderHeight();
GridData layoutData = new GridData(SWT.FILL, SWT.FILL, true, true);
layoutData.heightHint = desiredHeight;
rootParentComposite.setLayoutData(layoutData);
//create the columns
createTablecolumn("", "", 250, tableColumnLayout);
createTablecolumn("Budget","Reference",150,tableColumnLayout);
createTablecolumn("Budget consolidated","",150,tableColumnLayout);
createTablecolumn("Estimate","",150,tableColumnLayout);
createTablecolumn("Estimate consolidated","",150,tableColumnLayout);
//set providers
compareTable.setContentProvider(new DashboardContentProvider(MyAdapterFactory.getAdapterFactory()));
compareTable.setLabelProvider(new DashboardLabelProvider(MyAdapterFactory.getAdapterFactory()));
}
private void createTablecolumn(String header, String toolTipText, int width, TableColumnLayout tableColumnLayout) {
TableViewerColumn columnViewer = new TableViewerColumn(compareTable, SWT.NONE);
columnViewer.getColumn().setResizable(false);
columnViewer.getColumn().setMoveable(false);
columnViewer.getColumn().setText(header);
columnViewer.getColumn().setToolTipText(toolTipText);
columnViewer.getColumn().setAlignment(SWT.CENTER);
tableColumnLayout.setColumnData(columnViewer.getColumn(), new ColumnPixelData(width));
} |
Partager