I've been looking to listen for when my E4 RCP application get's maximized by the user clicking the Windows 7, or Windows 10 maximize button in the upper right hand corner of the application window. Ultimately I want to resize my TreeColumns when my TreeViewer Layout is resized. I have a listener on a Tree that's in a treeViewer which listens for a change in size of the Tree - This uses a ControlListener using the controlResized(ControlEvent e) method. This works just fine if I click and drag resizing the Application's window. But when I click on the maximize button the layout changes size and the columns do not. I suspect the listener is too late and the resize is not getting detected before redraw occurs on the maximize / un-Maximize.
Also tried using Listener with Iconify and deIconify methods, they do not work here as they deal with Minimize and un-Minimize.
Also tried using an IPartListener for activity, visible etc.... this too happens where it is resized, but not triggering at the right time to redraw correctly like the same issue.
What I really would like is a solution that Maximizes the screen, checks the size of the layout (which is what I thought I was doing) and then calculates the column sizes accordingly. However this doesn't get triggered by clicking on Maximize or Un-Maximize, only successful through drag and resize. Maybe it's something simply I'm missing here. Thanks in advance for your suggestions.
Thank you kindly greg-449! Working great now....
In my class where the Tree is created, I use TreeColumnLayout
and where the columns are created passed the TreeColumnLayout using ColumnWeightData
to do the trick. (had to remove all other previously written listeners for resizing columns as they conflict and prevent this from working correctly.)
Of note in my situation, I used a "wrapper" composite for putting my CheckboxTreeViewer (may not be always necessary) as in:
Composite wrapper = new Composite(parent, SWT.NONE);
new CheckboxTreeViewer(wrapper, SWT.H_SCROLL | SWT.V_SCROLL | SWT.CHECK | SWT.BORDER | SWT.FULL_SELECTION);
TreeColumnLayout tcLayout = new TreeColumnLayout();
wrapper.setLayout(tcLayout);
As said earlier, I use the TreeColumnLayout in creation of all columns in the tree where I set the weight, minimal size, and resizable attributes of ColumnWeightData.
final TreeColumn column = viewerColumn.getColumn();
tcLayout.setColumnData(column, new ColumnWeightData(weight, minimumSize, resizable));
Hope that detailing this helps others...
Plenty of other examples of TreeColumnLayout and ColumnWeightData here: http://www.programcreek.com/java-api-examples/index.php?api=org.eclipse.jface.layout.TreeColumnLayout