[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[news.eclipse.platform.swt] Re: Expanding Column Widths to fit table

I did something similar with a ControlListenet, but on a single column and it is working pretty well...

I guess this is the best way to handle it because, if I'm not wring, the table size changes dynamically between the time it gets created (createPartControl) and the time that it gets displayed in the Eclipse IDe (plug-in or RCP)...

your_table.addControlListener(new ControlAdapter(){
	public void controlResized(ControlEvent event){
		if(your_table.getClientArea().width > 0)
			// Do whatever you want with the extra width
			// your_table.getClientArea().width
		}
	}
});

Jason Bergbower wrote:
Ok, here is what I am trying to do. I have a table that I am using to fill a view (in RCP). I do the following to make the table fill the view:

composite.setLayout(new GridLayout(1, false));
Table t = new Table()
//populate table here
t.setLayoutData(new GridData(GridData.FILL_BOTH));

This works like a charm. Now what I want to do is use pack() on the columns to make sure I get the proper minimum width for each column...ok, I'm good to this point.

The last thing I want to do is calculate how wide the table is, determine how much width is not being used by the table (by subtracting the width of the table minus the width of the columns currently) and then re-distribute evenly the extra width to each column so that the end effect is that the table's columns fill the entire table without any empty whitespace columns. There is probably an easier way to do what I described, but that is why I am here.

This could be an RCP question just as much as SWT, because I don't understand the behavior yet. But if I try to acquire the table's size, it comes back as (0,0)...I think because it hasn't been rendered yet. If I try to acquire the size of the parent composite, I get the same result. How can I get the size of the table so that I can make these calculations (or am I just going about it all wrong)?

Keep in mind, this is an RCP app, so I'm trying to do this in a View class within the createPartControl() method...