mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-04 12:17:41 +08:00
SplitPanel programmatic usage is confusing #PL-5083
This commit is contained in:
parent
99a590e8b4
commit
7f9ade7960
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user