01: /*
02: * CONFIDENTIAL AND PROPRIETARY SOURCE CODE OF
03: * NETSCAPE COMMUNICATIONS CORPORATION
04: *
05: * Copyright (c) 1996 Netscape Communications Corporation.
06: * All Rights Reserved.
07: * Use of this Source Code is subject to the terms of the applicable
08: * license agreement from Netscape Communications Corporation.
09: */
10:
11: package components;
12:
13: import netscape.application.DragDestination;
14: import netscape.application.DragSession;
15: import netscape.application.ListItem;
16: import netscape.application.Popup;
17: import netscape.application.Rect;
18:
19: import util.BTreeNode;
20:
21: import soif.TaxonomyNode;
22:
23: /**
24: * A Popup that will accept a category drop.
25: */
26: public class SearchPopupField extends Popup implements DragDestination {
27: public SearchPopupField(int x, int y, int w, int h) {
28: super (x, y, w, h);
29: }
30:
31: public SearchPopupField(Rect rect) {
32: super (rect);
33: }
34:
35: /*******************/
36: /* DragDestination */
37: /*******************/
38:
39: public boolean dragEntered(DragSession ds) {
40: return true;
41: }
42:
43: public boolean dragMoved(DragSession ds) {
44: return true;
45: }
46:
47: public void dragExited(DragSession ds) {
48: return;
49: }
50:
51: public boolean dragDropped(DragSession ds) {
52: ListItem li = (ListItem) ds.data();
53: BTreeNode btn = (BTreeNode) li.data();
54: Object o = btn.getValue();
55:
56: if (o instanceof TaxonomyNode) {
57: removeItem(((TaxonomyNode) o).getId());
58: ListItem di = addItem(((TaxonomyNode) o).getId(),
59: ((TaxonomyNode) o).getId());
60: selectItem(di);
61: }
62:
63: return true;
64: }
65:
66: public DragDestination acceptsDrag(DragSession ds, int x, int y) {
67: return this;
68: }
69: }
|