983 } |
983 } |
984 |
984 |
985 // DropTargetPeer Method |
985 // DropTargetPeer Method |
986 @Override |
986 @Override |
987 public void addDropTarget(DropTarget dt) { |
987 public void addDropTarget(DropTarget dt) { |
988 synchronized (dropTargetLock){ |
988 LWWindowPeer winPeer = getWindowPeerOrSelf(); |
989 // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only |
989 if (winPeer != null && winPeer != this) { |
990 // if it's the first (or last) one for the component. Otherwise this call is a no-op. |
990 // We need to register the DropTarget in the |
991 if (++fNumDropTargets == 1) { |
991 // peer of the window ancestor of the component |
992 // Having a non-null drop target would be an error but let's check just in case: |
992 winPeer.addDropTarget(dt); |
993 if (fDropTarget != null) |
993 } else { |
994 System.err.println("CComponent.addDropTarget(): current drop target is non-null."); |
994 synchronized (dropTargetLock) { |
995 |
995 // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only |
996 // Create a new drop target: |
996 // if it's the first (or last) one for the component. Otherwise this call is a no-op. |
997 fDropTarget = CDropTarget.createDropTarget(dt, target, this); |
997 if (++fNumDropTargets == 1) { |
|
998 // Having a non-null drop target would be an error but let's check just in case: |
|
999 if (fDropTarget != null) |
|
1000 System.err.println("CComponent.addDropTarget(): current drop target is non-null."); |
|
1001 |
|
1002 // Create a new drop target: |
|
1003 fDropTarget = CDropTarget.createDropTarget(dt, target, this); |
|
1004 } |
998 } |
1005 } |
999 } |
1006 } |
1000 } |
1007 } |
1001 |
1008 |
1002 // DropTargetPeer Method |
1009 // DropTargetPeer Method |
1003 @Override |
1010 @Override |
1004 public void removeDropTarget(DropTarget dt) { |
1011 public void removeDropTarget(DropTarget dt) { |
1005 synchronized (dropTargetLock){ |
1012 LWWindowPeer winPeer = getWindowPeerOrSelf(); |
1006 // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only |
1013 if (winPeer != null && winPeer != this) { |
1007 // if it's the first (or last) one for the component. Otherwise this call is a no-op. |
1014 // We need to unregister the DropTarget in the |
1008 if (--fNumDropTargets == 0) { |
1015 // peer of the window ancestor of the component |
1009 // Having a null drop target would be an error but let's check just in case: |
1016 winPeer.removeDropTarget(dt); |
1010 if (fDropTarget != null) { |
1017 } else { |
1011 // Dispose of the drop target: |
1018 synchronized (dropTargetLock){ |
1012 fDropTarget.dispose(); |
1019 // 10-14-02 VL: Windows WComponentPeer would add (or remove) the drop target only |
1013 fDropTarget = null; |
1020 // if it's the first (or last) one for the component. Otherwise this call is a no-op. |
1014 } else |
1021 if (--fNumDropTargets == 0) { |
1015 System.err.println("CComponent.removeDropTarget(): current drop target is null."); |
1022 // Having a null drop target would be an error but let's check just in case: |
|
1023 if (fDropTarget != null) { |
|
1024 // Dispose of the drop target: |
|
1025 fDropTarget.dispose(); |
|
1026 fDropTarget = null; |
|
1027 } else |
|
1028 System.err.println("CComponent.removeDropTarget(): current drop target is null."); |
|
1029 } |
1016 } |
1030 } |
1017 } |
1031 } |
1018 } |
1032 } |
1019 |
1033 |
1020 // ---- PEER NOTIFICATIONS ---- // |
1034 // ---- PEER NOTIFICATIONS ---- // |