1. How to remove last vestigial column from TableViewer
You might have seen that there is dummy or vestigial column in the TableViewer (as marked by the red oval in the below figure) which is annoying at times because not only it look ugly but more so it occupy;s the precious real state from your component/control like shown in figure below:
Solution: You can use TableColumnLayout from org.eclipse.jface.layout package inside org.eclipse.jface plugin which allows to layout the columns in your TableViewer in essentially two ways:
You might have seen that there is dummy or vestigial column in the TableViewer (as marked by the red oval in the below figure) which is annoying at times because not only it look ugly but more so it occupy;s the precious real state from your component/control like shown in figure below:
Solution: You can use TableColumnLayout from org.eclipse.jface.layout package inside org.eclipse.jface plugin which allows to layout the columns in your TableViewer in essentially two ways:
- Firstly via mentioning the width in pixel for each column present in the Viewer
- Secondly, we could mentioned weights
The data could be supplied to the layout via of the implementation of ColumnLayoutData. The following snippet shows how to achieve it:
tableColumnLayout.setColumnData(tableColumn, new ColumnWeightData(1));
Explanation of the above line:
tableColumnLayout.setColumnData(tableColumn, new ColumnWeightData(1));
Explanation of the above line:
- tableColumnLayout is instance of ColumnLayoutData
- tableColumn is the column on which LayoutData need to be set in the Viewer
- ColumnWeightData(1) assign the weight of 1 to the column (this weight comes in to play when Viewer is resized so e.g. if two columns are there with weight's 2 & 1 they shrink or expand in the same ration)
- Instead of ColumnWeightData we could also use ColumnPixelData which will be the fixed width of the column
Comments
Post a Comment