}
@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();
int postSize = postChild.getWidth();
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) {
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 Leading) {
Leading leading = (Leading) alignment.clone();
leading.setSize(postSize);
constraints = new Constraints(leading, constraints.getVertical());
} else if (alignment instanceof Bilateral) {
Bilateral bilateral = (Bilateral) alignment;
int lead = bilateral.getLeading();
Leading leading = new Leading(lead, postSize, 10, innerWidth - postSize - lead);
constraints = new Constraints(leading, constraints.getVertical());
} else if (alignment instanceof Trailing) {
Trailing trailing = (Trailing) alignment.clone();
trailing.setSize(postSize);
constraints = new Constraints(trailing, constraints.getVertical());
}
layout.setConstraints(child, constraints);
glAdapter.adjustLayout(child);
}
} else if (postAlignment instanceof Trailing) {
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 Leading) {
Leading leading = (Leading) alignment.clone();
leading.setSize(postSize);
constraints = new Constraints(leading, constraints.getVertical());
} else if (alignment instanceof Bilateral) {
Bilateral bilateral = (Bilateral) alignment;
int trail = bilateral.getTrailing();
Trailing leading = new Trailing(trail, postSize, 10, innerWidth - postSize - trail);
constraints = new Constraints(leading, constraints.getVertical());
} else if (alignment instanceof Trailing) {
Trailing trailing = (Trailing) alignment.clone();
trailing.setSize(postSize);
constraints = new Constraints(trailing, constraints.getVertical());
}
layout.setConstraints(child, constraints);
glAdapter.adjustLayout(child);
}
} else if (postAlignment instanceof Bilateral) {
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 Leading) {
Leading leading = (Leading) alignment;
Bilateral bilateral = (Bilateral) postAlignment.clone();
bilateral.setLeading(leading.getLeading());
bilateral.setTrailing(innerWidth - leading.getLeading() - child.getWidth());
constraints = new Constraints(bilateral, constraints.getVertical());
} else if (alignment instanceof Bilateral) {
Bilateral leading = (Bilateral) alignment;
Bilateral bilateral = (Bilateral) postAlignment.clone();
bilateral.setTrailing(leading.getTrailing());
bilateral.setLeading(leading.getLeading());
constraints = new Constraints(bilateral, constraints.getVertical());
} else if (alignment instanceof Trailing) {
Trailing trailing = (Trailing) alignment;
Bilateral bilateral = (Bilateral) postAlignment.clone();
bilateral.setTrailing(trailing.getTrailing());
bilateral.setLeading(innerWidth - trailing.getTrailing() - child.getWidth());
constraints = new Constraints(bilateral, constraints.getVertical());
}
layout.setConstraints(child, constraints);
glAdapter.adjustLayout(child);
}
}
container.invalidate();
containerAdapter.doLayout();
containerAdapter.setDirty(true);
containerAdapter.repaintDesigner();
return Status.OK_STATUS;
}