*/
public class SashControl {
public static void createVerticalSash(final int limit,int init_percent, final Composite parent,final Composite composite1,final Composite composite2) {
final Sash sash = new Sash (parent, SWT.VERTICAL | SWT.BORDER);
FormData composite1_data = new FormData ();
composite1_data.left = new FormAttachment (0,0);
composite1_data.right = new FormAttachment (sash,0);
composite1_data.top = new FormAttachment (0,0);
composite1_data.bottom = new FormAttachment (100,0);
composite1.setLayoutData(composite1_data);
FormData composite2_data = new FormData ();
composite2_data.left = new FormAttachment (sash, 0);
composite2_data.right = new FormAttachment (100, 0);
composite2_data.top = new FormAttachment (0, 0);
composite2_data.bottom = new FormAttachment (100, 0);
composite2.setLayoutData (composite2_data);
final FormData sash_data = new FormData ();
sash_data.left = new FormAttachment (init_percent,0);
sash_data.top = new FormAttachment (0,0);
sash_data.bottom = new FormAttachment (100,0);
sash.setLayoutData(sash_data);
sash.addListener (SWT.Selection, new Listener () {
public void handleEvent (Event e) {
Rectangle sashRect = sash.getBounds ();
Rectangle shellRect = parent.getClientArea ();
int right = shellRect.width - sashRect.width - limit;
e.x = Math.max (Math.min (e.x, right), limit);
if (e.x != sashRect.x) {
sash_data.left = new FormAttachment (0, e.x);
//sashData_messages.right = new FormAttachment (0, e.x+4);
// parent.layout();
// composite1.layout();
// composite2.layout();
}
}
});
sash.addListener(SWT.MouseUp, new Listener () {
public void handleEvent (Event e) {
parent.layout();
composite1.layout();
composite2.layout();