@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>();
if (postAlignment instanceof Trailing || postAlignment instanceof Bilateral) {
int postTrail;
if (postAlignment instanceof Trailing)
postTrail = ((Trailing) postAlignment).getTrailing();
else
postTrail = ((Bilateral) postAlignment).getTrailing();
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);
Alignment alignment = constraints.getHorizontal();
if (alignment instanceof Trailing) {
Trailing trailing = (Trailing) alignment.clone();
trailing.setTrailing(postTrail);
constraints = new Constraints(trailing, constraints.getVertical());
} else if (alignment instanceof Bilateral) {
Bilateral bilateral = (Bilateral) alignment.clone();
bilateral.setTrailing(postTrail);
constraints = new Constraints(bilateral, constraints.getVertical());
} else if (alignment instanceof Leading) {
Bilateral bilateral = new Bilateral(((Leading)alignment).getLeading(), postTrail, ((Leading) alignment).getSize());
constraints = new Constraints(bilateral, constraints.getVertical());
}
layout.setConstraints(child, constraints);
}
} else if (postAlignment instanceof Leading) {
Leading postLeading = (Leading) postAlignment;
int postLead = postLeading.getLeading() + postChild.getWidth();
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);