830 { |
830 { |
831 ((ContainerPeer)newNativeContainer.getPeer()).restack(); |
831 ((ContainerPeer)newNativeContainer.getPeer()).restack(); |
832 } |
832 } |
833 if (!comp.isLightweight() && isLightweight()) { |
833 if (!comp.isLightweight() && isLightweight()) { |
834 // If component is heavyweight and one of the containers is lightweight |
834 // If component is heavyweight and one of the containers is lightweight |
835 // some NativeInLightFixer activity should be performed |
835 // the location of the component should be fixed. |
836 if (!curParent.isLightweight()) { |
836 comp.relocateComponent(); |
837 // Moving from heavyweight container to lightweight container - should create NativeInLightFixer |
|
838 // since addNotify does this |
|
839 comp.nativeInLightFixer = new NativeInLightFixer(); |
|
840 } else { |
|
841 // Component already has NativeInLightFixer - just reinstall it |
|
842 // because hierarchy changed and he needs to rebuild list of parents to listen. |
|
843 comp.nativeInLightFixer.install(this); |
|
844 } |
|
845 } |
837 } |
846 } |
838 } |
847 } |
839 } |
848 if (curParent != this) { |
840 if (curParent != this) { |
849 /* Notify the layout manager of the added component. */ |
841 /* Notify the layout manager of the added component. */ |
3951 ((Container)comp).recursiveApplyCurrentShape(); |
3943 ((Container)comp).recursiveApplyCurrentShape(); |
3952 } |
3944 } |
3953 } |
3945 } |
3954 } |
3946 } |
3955 |
3947 |
|
3948 private void recursiveShowHeavyweightChildren() { |
|
3949 if (!hasHeavyweightDescendants() || !isVisible()) { |
|
3950 return; |
|
3951 } |
|
3952 for (int index = 0; index < getComponentCount(); index++) { |
|
3953 Component comp = getComponent(index); |
|
3954 if (comp.isLightweight()) { |
|
3955 if (comp instanceof Container) { |
|
3956 ((Container)comp).recursiveShowHeavyweightChildren(); |
|
3957 } |
|
3958 } else { |
|
3959 if (comp.isVisible()) { |
|
3960 ComponentPeer peer = comp.getPeer(); |
|
3961 if (peer != null) { |
|
3962 peer.show(); |
|
3963 } |
|
3964 } |
|
3965 } |
|
3966 } |
|
3967 } |
|
3968 |
|
3969 private void recursiveHideHeavyweightChildren() { |
|
3970 if (!hasHeavyweightDescendants()) { |
|
3971 return; |
|
3972 } |
|
3973 for (int index = 0; index < getComponentCount(); index++) { |
|
3974 Component comp = getComponent(index); |
|
3975 if (comp.isLightweight()) { |
|
3976 if (comp instanceof Container) { |
|
3977 ((Container)comp).recursiveHideHeavyweightChildren(); |
|
3978 } |
|
3979 } else { |
|
3980 if (comp.isVisible()) { |
|
3981 ComponentPeer peer = comp.getPeer(); |
|
3982 if (peer != null) { |
|
3983 peer.hide(); |
|
3984 } |
|
3985 } |
|
3986 } |
|
3987 } |
|
3988 } |
|
3989 |
|
3990 private void recursiveRelocateHeavyweightChildren(Point origin) { |
|
3991 for (int index = 0; index < getComponentCount(); index++) { |
|
3992 Component comp = getComponent(index); |
|
3993 if (comp.isLightweight()) { |
|
3994 if (comp instanceof Container && |
|
3995 ((Container)comp).hasHeavyweightDescendants()) |
|
3996 { |
|
3997 final Point newOrigin = new Point(origin); |
|
3998 newOrigin.translate(comp.getX(), comp.getY()); |
|
3999 ((Container)comp).recursiveRelocateHeavyweightChildren(newOrigin); |
|
4000 } |
|
4001 } else { |
|
4002 ComponentPeer peer = comp.getPeer(); |
|
4003 if (peer != null) { |
|
4004 peer.setBounds(origin.x + comp.getX(), origin.y + comp.getY(), |
|
4005 comp.getWidth(), comp.getHeight(), |
|
4006 ComponentPeer.SET_LOCATION); |
|
4007 } |
|
4008 } |
|
4009 } |
|
4010 } |
|
4011 |
|
4012 /* |
|
4013 * Consider the heavyweight container hides or shows the HW descendants |
|
4014 * automatically. Therefore we care of LW containers' visibility only. |
|
4015 */ |
|
4016 private boolean isRecursivelyVisibleUpToHeavyweightContainer() { |
|
4017 if (!isLightweight()) { |
|
4018 return true; |
|
4019 } |
|
4020 return isVisible() && (getContainer() == null || |
|
4021 getContainer().isRecursivelyVisibleUpToHeavyweightContainer()); |
|
4022 } |
|
4023 |
|
4024 @Override |
3956 void mixOnShowing() { |
4025 void mixOnShowing() { |
3957 synchronized (getTreeLock()) { |
4026 synchronized (getTreeLock()) { |
3958 if (mixingLog.isLoggable(Level.FINE)) { |
4027 if (mixingLog.isLoggable(Level.FINE)) { |
3959 mixingLog.fine("this = " + this); |
4028 mixingLog.fine("this = " + this); |
3960 } |
4029 } |
3961 |
4030 |
3962 boolean isLightweight = isLightweight(); |
4031 boolean isLightweight = isLightweight(); |
3963 |
4032 |
|
4033 if (isLightweight && isRecursivelyVisibleUpToHeavyweightContainer()) { |
|
4034 recursiveShowHeavyweightChildren(); |
|
4035 } |
|
4036 |
3964 if (!isLightweight || (isLightweight && hasHeavyweightDescendants())) { |
4037 if (!isLightweight || (isLightweight && hasHeavyweightDescendants())) { |
3965 recursiveApplyCurrentShape(); |
4038 recursiveApplyCurrentShape(); |
3966 } |
4039 } |
3967 |
4040 |
3968 super.mixOnShowing(); |
4041 super.mixOnShowing(); |
3969 } |
4042 } |
3970 } |
4043 } |
3971 |
4044 |
|
4045 @Override |
|
4046 void mixOnHiding(boolean isLightweight) { |
|
4047 synchronized (getTreeLock()) { |
|
4048 if (mixingLog.isLoggable(Level.FINE)) { |
|
4049 mixingLog.fine("this = " + this + |
|
4050 "; isLightweight=" + isLightweight); |
|
4051 } |
|
4052 if (isLightweight) { |
|
4053 recursiveHideHeavyweightChildren(); |
|
4054 } |
|
4055 super.mixOnHiding(isLightweight); |
|
4056 } |
|
4057 } |
|
4058 |
|
4059 @Override |
|
4060 void mixOnReshaping() { |
|
4061 synchronized (getTreeLock()) { |
|
4062 if (mixingLog.isLoggable(Level.FINE)) { |
|
4063 mixingLog.fine("this = " + this); |
|
4064 } |
|
4065 if (isLightweight() && hasHeavyweightDescendants()) { |
|
4066 final Point origin = new Point(getX(), getY()); |
|
4067 for (Container cont = getContainer(); |
|
4068 cont != null && cont.isLightweight(); |
|
4069 cont = cont.getContainer()) |
|
4070 { |
|
4071 origin.translate(cont.getX(), cont.getY()); |
|
4072 } |
|
4073 |
|
4074 recursiveRelocateHeavyweightChildren(origin); |
|
4075 } |
|
4076 super.mixOnReshaping(); |
|
4077 } |
|
4078 } |
|
4079 |
|
4080 @Override |
3972 void mixOnZOrderChanging(int oldZorder, int newZorder) { |
4081 void mixOnZOrderChanging(int oldZorder, int newZorder) { |
3973 synchronized (getTreeLock()) { |
4082 synchronized (getTreeLock()) { |
3974 if (mixingLog.isLoggable(Level.FINE)) { |
4083 if (mixingLog.isLoggable(Level.FINE)) { |
3975 mixingLog.fine("this = " + this + |
4084 mixingLog.fine("this = " + this + |
3976 "; oldZ=" + oldZorder + "; newZ=" + newZorder); |
4085 "; oldZ=" + oldZorder + "; newZ=" + newZorder); |