SplitPanel programmatic usage is confusing #PL-5083

This commit is contained in:
Yuriy Artamonov 2015-03-20 12:48:22 +00:00
parent 99a590e8b4
commit 7f9ade7960

View File

@ -40,25 +40,7 @@ public class WebSplitPanel extends WebAbstractComponent<AbstractSplitPanel> impl
}
if (component == null) {
if (orientation == SplitPanel.ORIENTATION_HORIZONTAL) {
component = new CubaHorizontalSplitPanel() {
@Override
protected void onPositionUpdate(float previousPosition, float newPosition) {
super.onPositionUpdate(previousPosition, newPosition);
firePositionUpdateListener(previousPosition, newPosition);
}
};
} else {
component = new VerticalSplitPanel() {
@Override
protected void onPositionUpdate(float previousPosition, float newPosition) {
super.onPositionUpdate(previousPosition, newPosition);
firePositionUpdateListener(previousPosition, newPosition);
}
};
}
createComponentImpl();
}
if (getId() != null) {
component.setCubaId(getId());
@ -88,6 +70,28 @@ public class WebSplitPanel extends WebAbstractComponent<AbstractSplitPanel> impl
childComponent.setParent(this);
}
protected void createComponentImpl() {
if (orientation == SplitPanel.ORIENTATION_HORIZONTAL) {
component = new CubaHorizontalSplitPanel() {
@Override
protected void onPositionUpdate(float previousPosition, float newPosition) {
super.onPositionUpdate(previousPosition, newPosition);
firePositionUpdateListener(previousPosition, newPosition);
}
};
} else {
component = new VerticalSplitPanel() {
@Override
protected void onPositionUpdate(float previousPosition, float newPosition) {
super.onPositionUpdate(previousPosition, newPosition);
firePositionUpdateListener(previousPosition, newPosition);
}
};
}
}
protected void firePositionUpdateListener(float previousPosition, float newPosition) {
if (positionListener != null) {
positionListener.updatePosition(previousPosition, newPosition);
@ -192,6 +196,10 @@ public class WebSplitPanel extends WebAbstractComponent<AbstractSplitPanel> impl
@Override
public void setOrientation(int orientation) {
this.orientation = orientation;
if (component == null) {
createComponentImpl();
}
}
@Override