1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 package org.utgenome.gwt.widget.client.impl;
26
27 import java.util.Iterator;
28
29 import org.utgenome.gwt.widget.client.TrackFrame;
30 import org.utgenome.gwt.widget.client.TrackPanel;
31
32 import com.allen_sauer.gwt.dnd.client.DragContext;
33 import com.allen_sauer.gwt.dnd.client.drop.AbstractDropController;
34 import com.google.gwt.user.client.ui.TabPanel;
35 import com.google.gwt.user.client.ui.Widget;
36
37
38
39
40
41
42
43 public class TabDropController extends AbstractDropController {
44
45 private final TabPanel tabPanel;
46 private int tabIndex;
47
48 public TabDropController(Widget dropTarget, TabPanel tabPanel, int tabIndex) {
49 super(dropTarget);
50 this.tabPanel = tabPanel;
51 this.tabIndex = tabIndex;
52 }
53
54 @SuppressWarnings("unchecked")
55 @Override
56 public void onDrop(DragContext context) {
57
58 TrackPanel tab = (TrackPanel) tabPanel.getWidget(tabIndex);
59
60 for (Iterator it = context.selectedWidgets.iterator(); it.hasNext();) {
61 TrackFrame widget = (TrackFrame) it.next();
62 tab.add(widget);
63 }
64 super.onDrop(context);
65 }
66
67 @Override
68 public void onEnter(DragContext context) {
69 super.onEnter(context);
70 tabPanel.selectTab(tabIndex);
71 context.dragController.resetCache();
72 }
73
74 }