@Override
public IStatus execute(IProgressMonitor monitor, IAdaptable info) throws ExecutionException {
GroupLayout layout = (GroupLayout) container.getLayout();
CompositeAdapter containerAdapter = (CompositeAdapter) WidgetAdapter.getWidgetAdapter(container);
WidgetAdapter post = widgets.get(0);
Component postChild = post.getWidget();
Constraints postConstraints = layout.getConstraints(postChild);
Alignment postAlignment = postConstraints.getHorizontal();
compcons = new ArrayList<CompCons>();
Insets insets = container.getInsets();
int innerWidth = container.getWidth() - insets.left - insets.right;
if (postAlignment instanceof Leading) {
Leading postLeading = (Leading)postAlignment;
int postCenter = postLeading.getLeading() + postChild.getWidth() / 2;
for (int i = 1; i < widgets.size(); i++) {
WidgetAdapter adapter = widgets.get(i);
Component child = adapter.getWidget();
Constraints constraints = layout.getConstraints(child);
CompCons cons = new CompCons();
cons.component = child;
cons.constraints = constraints;
compcons.add(cons);
int l = postCenter - child.getWidth() / 2;
int t = innerWidth - postCenter - child.getWidth() / 2;
Leading leading = new Leading(l, child.getWidth(), 10, t);
constraints = new Constraints(leading, constraints.getVertical());
layout.setConstraints(child, constraints);
}
} else if (postAlignment instanceof Bilateral) {
Bilateral postBilateral = (Bilateral) postAlignment;
int postCenter = postBilateral.getLeading() + postChild.getWidth() / 2;
for (int i = 1; i < widgets.size(); i++) {
WidgetAdapter adapter = widgets.get(i);
Component child = adapter.getWidget();
Constraints constraints = layout.getConstraints(child);
CompCons cons = new CompCons();
cons.component = child;
cons.constraints = constraints;
compcons.add(cons);
int l = postCenter - child.getWidth() / 2;
int t = innerWidth - postCenter - child.getWidth()/2;
Bilateral bilateral = new Bilateral(l, t, 10);
constraints = new Constraints(bilateral, constraints.getVertical());
layout.setConstraints(child, constraints);
}
} else if (postAlignment instanceof Trailing) {
int postCenter = postChild.getX() + postChild.getWidth() / 2 - insets.left;
for (int i = 1; i < widgets.size(); i++) {
WidgetAdapter adapter = widgets.get(i);
Component child = adapter.getWidget();
Constraints constraints = layout.getConstraints(child);
CompCons cons = new CompCons();
cons.component = child;
cons.constraints = constraints;
compcons.add(cons);