if (b1.width < DRAG_MINIMUM || b2.width < DRAG_MINIMUM) { event.x = b1.x + DRAG_MINIMUM; event.doit = false; return;
if (b1.width < DRAG_MINIMUM) { b1.width = DRAG_MINIMUM; b2.x = b1.x + b1.width + sashBounds.x; b2.width = area.width - DRAG_MINIMUM - sashBounds.width; event.x = b1.x + b1.width; } if (b2.width < DRAG_MINIMUM) { b1.width = area.width - DRAG_MINIMUM - sashBounds.width; b2.x = b1.x + b1.width + sashBounds.x; b2.width = DRAG_MINIMUM; event.x = b1.x + b1.width;
void onDragSash(Event event) {	Sash sash = (Sash)event.widget;	int sashIndex = -1;	for (int i= 0; i < sashes.length; i++) {		if (sashes[i] == sash) {			sashIndex = i;			break;		}	}	if (sashIndex == -1) return;	Control c1 = controls[sashIndex];	Control c2 = controls[sashIndex + 1];	Rectangle b1 = c1.getBounds();	Rectangle b2 = c2.getBounds();		Rectangle sashBounds = sash.getBounds();	Rectangle area = getClientArea();	if (getOrientation() == SWT.HORIZONTAL) {		int shift = event.x - sashBounds.x;		b1.width += shift;		b2.x += shift;		b2.width -= shift;		if (b1.width < DRAG_MINIMUM || b2.width < DRAG_MINIMUM) {			event.x = b1.x + DRAG_MINIMUM;			event.doit = false;			return;		}		Object data1 = c1.getLayoutData();		if (data1 == null || !(data1 instanceof SashFormData)) {			data1 = new SashFormData();			c1.setLayoutData(data1);		}		Object data2 = c2.getLayoutData();		if (data2 == null || !(data2 instanceof SashFormData)) {			data2 = new SashFormData();			c2.setLayoutData(data2);		}		((SashFormData)data1).weight = (((long)b1.width << 16) + area.width - 1) / area.width;		((SashFormData)data2).weight = (((long)b2.width << 16) + area.width - 1) / area.width;	} else {		int shift = event.y - sashBounds.y;		b1.height += shift;		b2.y += shift;		b2.height -= shift;		if (b1.height < DRAG_MINIMUM || b2.height < DRAG_MINIMUM) {			event.y = b1.y + DRAG_MINIMUM;			event.doit = false;			return;		}		Object data1 = c1.getLayoutData();		if (data1 == null || !(data1 instanceof SashFormData)) {			data1 = new SashFormData();			c1.setLayoutData(data1);		}		Object data2 = c2.getLayoutData();		if (data2 == null || !(data2 instanceof SashFormData)) {			data2 = new SashFormData();			c2.setLayoutData(data2);		}		((SashFormData)data1).weight = (((long)b1.height << 16) + area.height - 1) / area.height;		((SashFormData)data2).weight = (((long)b2.height << 16) + area.height - 1) / area.height;	}	if (event.detail != SWT.DRAG) {		c1.setBounds(b1);		sash.setBounds(event.x, event.y, event.width, event.height);		c2.setBounds(b2);	}}