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.utgb.client.track.lib;
26
27 import java.util.ArrayList;
28 import java.util.Iterator;
29
30 import org.utgenome.gwt.utgb.client.track.Track;
31 import org.utgenome.gwt.utgb.client.track.TrackBase;
32 import org.utgenome.gwt.utgb.client.track.TrackFrame;
33 import org.utgenome.gwt.utgb.client.track.TrackGroup;
34 import org.utgenome.gwt.utgb.client.track.lib.debug.DebugToolBoxTrack;
35
36 import com.google.gwt.event.dom.client.ClickEvent;
37 import com.google.gwt.event.dom.client.ClickHandler;
38 import com.google.gwt.user.client.ui.Anchor;
39 import com.google.gwt.user.client.ui.FlowPanel;
40 import com.google.gwt.user.client.ui.Widget;
41
42
43
44
45
46
47
48
49 public class ToolBoxTrack extends TrackBase {
50 public static TrackFactory factory() {
51 return new TrackFactory() {
52 public Track newInstance() {
53 return new ToolBoxTrack();
54 }
55 };
56 }
57
58 private FlowPanel _panel = new FlowPanel();
59 private ArrayList<TrackLink> trackTable = new ArrayList<TrackLink>();
60 private Track _self = this;
61
62 class TrackLink extends Anchor implements ClickHandler {
63 TrackFactory trackFactory;
64
65 public TrackLink(String label, TrackFactory trackFactory) {
66 super(label, label);
67 this.trackFactory = trackFactory;
68 setStyleName("selector-item");
69 addClickHandler(this);
70 }
71
72 public void onClick(ClickEvent e) {
73 int trackIndex = getTrackGroup().getTrackIndex(_self);
74 Track newTrackInstance = trackFactory.newInstance();
75 getTrackGroup().insertTrack(newTrackInstance, trackIndex + 1);
76 }
77 }
78
79 public ToolBoxTrack() {
80 super("Tool Box");
81 init();
82 }
83
84 public ToolBoxTrack(String trackName) {
85 super(trackName);
86 init();
87 }
88
89 private void init() {
90 _panel.setWidth("600px");
91 _panel.setStyleName("selector");
92 this.setupToolbox();
93 }
94
95
96
97
98 public void setupToolbox() {
99
100 addTrackFactory("Scroll Button", ScrollButtonTrack.factory());
101 addTrackFactory("Window Controller", WindowControlTrack.factory());
102 addTrackFactory("Sequence Ruler", SequenceRulerTrack.factory());
103 addTrackFactory("Track Ruler", RulerTrack.factory());
104 addTrackFactory("Debug Toolbox", DebugToolBoxTrack.factory());
105
106 }
107
108 public void addTrackFactory(String label, TrackFactory trackFactory) {
109 trackTable.add(new TrackLink(label, trackFactory));
110 }
111
112 public int getDefaultWindowHeight() {
113 return 15;
114 }
115
116 public Widget getWidget() {
117 return _panel;
118 }
119
120 public void draw() {
121 _panel.clear();
122 for (Iterator<TrackLink> it = trackTable.iterator(); it.hasNext();) {
123 TrackLink tl = it.next();
124 _panel.add(tl);
125 }
126 }
127
128 public void setUp(TrackFrame trackFrame, TrackGroup group) {
129
130 }
131
132 }