addComponent(new Button("Swap sources", new Button.ClickListener() {
@Override
public void buttonClick(ClickEvent event) {
if (source1.getParent() != null) {
horizontalLayout.replaceComponent(source1, source2);
} else {
horizontalLayout.replaceComponent(source2, source1);
}
target.markAsDirty();
}