Bonjour à tous,

j'ai un tableau qui est contenu dans une section d'une page de propriété. Le tableau est rempli en fonction d'actions utilisateurs et je souhaite fixer sa hauteur à 5 lignes, par exemple, pour qu'ensuite la scrollBar verticale apparaisse.

J'ai parcouru le net et le forum, essayé de multiples solutions et je n'arrive pas à fixer la hauteur de mon viewer. A chaque nouvelle ligne, il grandit et la section avec lui jusqu'à sortir par le bas de l'écran.

voici le code que j'utilise :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
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));
	}
J'espère que vous pourrez me dire ce que je fais de mal, ou que je ne fais pas. Car je suis complètement perdu.

Ogtraba