1 | public void dropActionChanged(DropTargetDragEvent event) {↵ | | 1 | public void dropActionChanged(DropTargetDragEvent event) {↵
|
2 | }↵ | | 2 | }↵
|
|
3 | /**↵ | | 3 | /**↵
|
4 | * a drag gesture has been initiated↵ | | 4 | * a drag gesture has been initiated↵
|
5 | * ↵ | | 5 | * ↵
|
6 | */↵ | | 6 | */↵
|
7 | public void dragGestureRecognized(DragGestureEvent event) {↵ | | 7 | public void dragGestureRecognized(DragGestureEvent event) {↵
|
8 | if (dndAction == false) {↵ | | 8 | if (dndAction == false) {↵
|
9 | /*↵ | | 9 | /*↵
|
10 | * HeaderItem[] items = new HeaderItem[selection1.length]; items =↵ | | 10 | * HeaderItem[] items = new HeaderItem[selection1.length]; items =↵
|
11 | * selection1;↵ | | 11 | * selection1;↵
|
12 | * HeaderItemDNDManager.getInstance().setHeaderItemList(items);↵ | | 12 | * HeaderItemDNDManager.getInstance().setHeaderItemList(items);↵
|
13 | */↵ | | 13 | */↵
|
14 | if (selection1 == null) {↵ | | 14 | if (selection1 == null) {↵
|
15 | IBasicModelPartial[] items = new IBasicModelPartial[1];↵ | | 15 | IHeaderItem[] items = new IHeaderItem[1];↵
|
16 | items[0] = (IBasicModelPartial) getSelectedValue();↵ | | 16 | items[0] = (IHeaderItem) getSelectedValue();↵
|
|
17 | HeaderItemDNDManager.getInstance().setHeaderItemList(items);↵ | | 17 | HeaderItemDNDManager.getInstance().setHeaderItemList(items);↵
|
18 | } else if (selection1.length != 0) {↵ | | 18 | } else if (selection1.length != 0) {↵
|
19 | IBasicModelPartial[] items = new IBasicModelPartial[selection1.length];↵ | | 19 | IHeaderItem[] items = new IHeaderItem[selection1.length];↵
|
20 | items = selection1;↵ | | 20 | items = selection1;↵
|
21 | HeaderItemDNDManager.getInstance().setHeaderItemList(items);↵ | | 21 | HeaderItemDNDManager.getInstance().setHeaderItemList(items);↵
|
22 | }↵ | | 22 | }↵
|
|
23 | /*↵ | | 23 | /*↵
|
24 | * else {↵ | | 24 | * else {↵
|
25 | * ↵ | | 25 | * ↵
|
26 | * HeaderItem[] items = new HeaderItem[1]; items[0] = (HeaderItem)↵ | | 26 | * HeaderItem[] items = new HeaderItem[1]; items[0] = (HeaderItem)↵
|
27 | * getSelectedValue();↵ | | 27 | * getSelectedValue();↵
|
28 | * HeaderItemDNDManager.getInstance().setHeaderItemList(items); }↵ | | 28 | * HeaderItemDNDManager.getInstance().setHeaderItemList(items); }↵
|
29 | */↵ | | 29 | */↵
|
30 | } else {↵ | | 30 | } else {↵
|
31 | /*↵ | | 31 | /*↵
|
32 | * HeaderItem[] items = new HeaderItem[selection2.length]; items =↵ | | 32 | * HeaderItem[] items = new HeaderItem[selection2.length]; items =↵
|
33 | * selection2;↵ | | 33 | * selection2;↵
|
34 | * HeaderItemDNDManager.getInstance().setHeaderItemList(items);↵ | | 34 | * HeaderItemDNDManager.getInstance().setHeaderItemList(items);↵
|
35 | */↵ | | 35 | */↵
|
36 | if (selection2.length != 0) {↵ | | 36 | if (selection2.length != 0) {↵
|
37 | IBasicModelPartial[] items = new IBasicModelPartial[selection2.length];↵ | | 37 | IHeaderItem[] items = new IHeaderItem[selection2.length];↵
|
38 | items = selection2;↵ | | 38 | items = selection2;↵
|
39 | HeaderItemDNDManager.getInstance().setHeaderItemList(items);↵ | | 39 | HeaderItemDNDManager.getInstance().setHeaderItemList(items);↵
|
40 | } else {↵ | | 40 | } else {↵
|
41 | IBasicModelPartial[] items = new IBasicModelPartial[1];↵ | | 41 | IHeaderItem[] items = new IHeaderItem[1];↵
|
42 | items[0] = (IBasicModelPartial) getSelectedValue();↵ | | 42 | items[0] = (IHeaderItem) getSelectedValue();↵
|
|
43 | HeaderItemDNDManager.getInstance().setHeaderItemList(items);↵ | | 43 | HeaderItemDNDManager.getInstance().setHeaderItemList(items);↵
|
44 | }↵ | | 44 | }↵
|
45 | }↵ | | 45 | }↵
|
|
46 | /*↵ | | 46 | /*↵
|
47 | * dragSource.startDrag( event, new Cursor(Cursor.DEFAULT_CURSOR),↵ | | 47 | * dragSource.startDrag( event, new Cursor(Cursor.DEFAULT_CURSOR),↵
|
48 | * ImageLoader.getImageIcon("contact_small","Add16").getImage(), new↵ | | 48 | * ImageLoader.getImageIcon("contact_small","Add16").getImage(), new↵
|
49 | * Point(5, 5), new StringSelection("contact"), this);↵ | | 49 | * Point(5, 5), new StringSelection("contact"), this);↵
|
50 | */↵ | | 50 | */↵
|
51 | StringSelection text = new StringSelection("contact");↵ | | 51 | StringSelection text = new StringSelection("contact");↵
|
|
52 | dragSource.startDrag(event, DragSource.DefaultMoveDrop, text, this);↵ | | 52 | dragSource.startDrag(event, DragSource.DefaultMoveDrop, text, this);↵
|
|
53 | clearSelection();↵ | | 53 | clearSelection();↵
|
54 | }↵ | | 54 | }↵
|
|
55 | /**↵ | | 55 | /**↵
|
56 | * this message goes to DragSourceListener, informing it that the dragging↵ | | 56 | * this message goes to DragSourceListener, informing it that the dragging↵
|
57 | * has ended↵ | | 57 | * has ended↵
|
58 | * ↵ | | 58 | * ↵
|
59 | */↵ | | 59 | */↵
|
60 | public void dragDropEnd(DragSourceDropEvent event) {↵ | | 60 | public void dragDropEnd(DragSourceDropEvent event) {↵
|
61 | if (event.getDropSuccess()) {↵ | | 61 | if (event.getDropSuccess()) {↵
|
62 | if (acceptDrop == true) {↵ | | 62 | if (acceptDrop == true) {↵
|
63 | IBasicModelPartial[] items = HeaderItemDNDManager.getInstance()↵ | | 63 | IHeaderItem[] items = HeaderItemDNDManager.getInstance()↵
|
64 | .getHeaderItemList();↵ | | 64 | .getHeaderItemList();↵
|
|
65 | for (int i = 0; i < items.length; i++) {↵ | | 65 | for (int i = 0; i < items.length; i++) {↵
|
66 | ((AddressbookListModel) getModel()).removeElement(items[i]);↵ | | 66 | ((ContactListModel) getModel()).removeElement(items[i]);↵
|
67 | }↵ | | 67 | }↵
|
|
68 | // removeElement();↵ | | 68 | // removeElement();↵
|
69 | }↵ | | 69 | }↵
|
70 | }↵ | | 70 | }↵
|
71 | }↵ | | 71 | }↵
|
|
72 | /**↵ | | 72 | /**↵
|
73 | * this message goes to DragSourceListener, informing it that the dragging↵ | | 73 | * this message goes to DragSourceListener, informing it that the dragging↵
|
74 | * has entered the DropSite↵ | | 74 | * has entered the DropSite↵
|
75 | * ↵ | | 75 | * ↵
|
76 | */↵ | | 76 | */↵
|
77 | public void dragEnter(DragSourceDragEvent event) {↵ | | 77 | public void dragEnter(DragSourceDragEvent event) {↵
|
78 | }↵ | | 78 | }↵
|
|
79 | /**↵ | | 79 | /**↵
|
80 | * this message goes to DragSourceListener, informing it that the dragging↵ | | 80 | * this message goes to DragSourceListener, informing it that the dragging↵
|
81 | * has exited the DropSite↵ | | 81 | * has exited the DropSite↵
|
82 | * ↵ | | 82 | * ↵
|
83 | */↵ | | 83 | */↵
|
84 | public void dragExit(DragSourceEvent event) {↵ | | 84 | public void dragExit(DragSourceEvent event) {↵
|
85 | }↵ | | 85 | }↵
|
|
86 | /**↵ | | 86 | /**↵
|
87 | * this message goes to DragSourceListener, informing it that the dragging↵ | | 87 | * this message goes to DragSourceListener, informing it that the dragging↵
|
88 | * is currently ocurring over the DropSite↵ | | 88 | * is currently ocurring over the DropSite↵
|
89 | * ↵ | | 89 | * ↵
|
90 | */↵ | | 90 | */↵
|
91 | public void dragOver(DragSourceDragEvent event) {↵ | | 91 | public void dragOver(DragSourceDragEvent event) {↵
|
92 | }↵ | | 92 | }↵
|
|
93 | /**↵ | | 93 | /**↵
|
94 | * is invoked when the user changes the dropAction↵ | | 94 | * is invoked when the user changes the dropAction↵
|
95 | * ↵ | | 95 | * ↵
|
96 | */↵ | | 96 | */↵
|
97 | public void dropActionChanged(DragSourceDragEvent event) {↵ | | 97 | public void dropActionChanged(DragSourceDragEvent event) {↵
|
98 | }↵ | | 98 | }↵
|
|
99 | /**↵ | | 99 | /**↵
|
100 | * adds elements to itself↵ | | 100 | * adds elements to itself↵
|
101 | * ↵ | | 101 | * ↵
|
102 | */↵ | | 102 | */↵
|
103 | /**↵ | | 103 | /**↵
|
104 | * removes an element from itself↵ | | 104 | * removes an element from itself↵
|
105 | */↵ | | 105 | */↵
|
106 | public void removeElement() {↵ | | 106 | public void removeElement() {↵
|
107 | ((AddressbookListModel) getModel())↵ | | 107 | ((ContactListModel) getModel())↵
|
108 | .removeElement((IBasicModelPartial) getSelectedValue());↵ | | 108 | .removeElement((IHeaderItem) getSelectedValue());↵
|
109 | }↵ | | 109 | }↵
|
|
110 | public void valueChanged(ListSelectionEvent e) {↵ | | 110 | public void valueChanged(ListSelectionEvent e) {↵
|
111 | if (dndAction == true) {↵ | | 111 | if (dndAction == true) {↵
|
112 | Object[] list = getSelectedValues();↵ | | 112 | Object[] list = getSelectedValues();↵
|
|
113 | selection1 = new IBasicModelPartial[list.length];↵ | | 113 | selection1 = new IHeaderItem[list.length];↵
|
|
114 | for (int i = 0; i < list.length; i++) {↵ | | 114 | for (int i = 0; i < list.length; i++) {↵
|
115 | selection1[i] = (IBasicModelPartial) list[i];↵ | | 115 | selection1[i] = (IHeaderItem) list[i];↵
|
116 | }↵ | | 116 | }↵
|
|
117 | dndAction = false;↵ | | 117 | dndAction = false;↵
|
118 | } else {↵ | | 118 | } else {↵
|
119 | Object[] list = getSelectedValues();↵ | | 119 | Object[] list = getSelectedValues();↵
|
|
120 | selection2 = new IBasicModelPartial[list.length];↵ | | 120 | selection2 = new IHeaderItem[list.length];↵
|
|
121 | for (int i = 0; i < list.length; i++) {↵ | | 121 | for (int i = 0; i < list.length; i++) {↵
|
122 | selection2[i] = (IBasicModelPartial) list[i];↵ | | 122 | selection2[i] = (IHeaderItem) list[i];↵
|
123 | }↵ | | 123 | }↵
|
|
124 | dndAction = true; | | 124 | dndAction = true;
|