Community
Participate
Working Groups
When setting the Right alignment for a Tree Column in CheckboxTreeViewer ( Multiple Column ), the Header is right aligned but not the rows of that column.
Is this working in RCP?
(In reply to comment #1) > Is this working in RCP? > Yes.
Can you provide a snippet to reproduce it?
final Composite composite = new Composite ( parent, SWT.NONE ) ; composite.setLayoutData ( new GridData ( SWT.LEFT, SWT.CENTER, true, true ) ) ; final GridLayout gridLayout_2 = new GridLayout ( ) ; gridLayout_2.numColumns = 2 ; composite.setLayout ( gridLayout_2 ) ; final CheckboxTreeViewer viewer = new CheckboxTreeViewer ( composite, SWT.FULL_SELECTION ) ; final GridData gd_tree_1 = new GridData ( SWT.FILL, SWT.TOP, true, true, 2, 1 ) ; gd_tree_1.heightHint = 219 ; gd_tree_1.widthHint = 479 ; viewer.setContentProvider ( new MyTreeContentProvider ( ) ) ; viewer.setLabelProvider ( new MyTreeLabelProvider ( ) ) ; tree = viewer.getTree ( ) ; tree.setLayoutData ( gd_tree_1 ) ; tree.setHeaderVisible ( true ) ; tree.setLinesVisible ( true ) ; TreeColumn column1 = new TreeColumn ( tree, SWT.LEFT | SWT.FILL ) ; TreeColumn column2 = new TreeColumn ( tree, SWT.RIGHT | SWT.FILL ) ; TreeColumn column3 = new TreeColumn ( tree, SWT.RIGHT | SWT.FILL ) ; TreeColumn column4 = new TreeColumn ( tree, SWT.RIGHT | SWT.BORDER ) ; ...
Hi Walter, I've created a simple standalone SWT test case: ------------- Tree tree = new Tree( shell, SWT.FULL_SELECTION | SWT.CHECK ); for( int i = 0; i < 3; i++ ) { TreeItem ti = new TreeItem( tree, SWT.NONE ); ti.setText( "Item "+i ); for( int j = 0; j < 3; j++ ) { TreeItem sti = new TreeItem( ti, SWT.NONE ); sti.setText( "Subitem "+j+" of Item "+i ); } } tree.setSize( 800,600 ); tree.setHeaderVisible( true ); TreeColumn col1 = new TreeColumn( tree, SWT.RIGHT ); col1.setText( "Col 1" ); col1.setWidth( 250 ); TreeColumn col2 = new TreeColumn( tree, SWT.LEFT ); col2.setText( "Col 2" ); col2.setWidth( 250 ); ----------------------- Setting the tree column alignment to SWT.RIGHT does not affect the data alignment in SWT too - only header text is right aligned.
Created attachment 121806 [details] Checkbox Viewer which aligns the 2nd Column towards RIGHT By changing the line TreeColumn oc = new TreeColumn(tree, SWT.RIGHT) ; to TreeColumn oc = new TreeColumn(tree, SWT.LEFT) ; the 2nd column aligns towards left.
Thank you Walter, for providing this example. I've always looked at the first column with the checkboxes, which is always left justified.
Fixed in CVS HEAD. The column alignment is applied to tree item text too. First column tree item text is always right aligned as in SWT.