while (true) {
final List<SplitterItem> items = this.getItems();
items.add(beforeIndex, item);
final Panel panel = this.getPanel();
final Widget widget = item.getWidget();
// if this is the only widget no need to add a splitter before or
// after...
if (items.size() == 1) {
panel.insert(widget, 0);
break;
}
int panelIndex = beforeIndex * 2;
// if its the new first widget insert the widget then a splitter
Widget first = widget;
Widget second = this.createSplitter();
if (beforeIndex > 0) {
// not the first widget insert the splitter then the widget...
Widget swap = first;
first = second;
second = swap;
panelIndex--;
}
panel.insert(first, panelIndex + 0);
panel.insert(second, panelIndex + 1);
break;
}
this.redraw();
}