View Javadoc

1   /*--------------------------------------------------------------------------
2    *  Copyright 2007 utgenome.org
3    *
4    *  Licensed under the Apache License, Version 2.0 (the "License");
5    *  you may not use this file except in compliance with the License.
6    *  You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   *  Unless required by applicable law or agreed to in writing, software
11   *  distributed under the License is distributed on an "AS IS" BASIS,
12   *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   *  See the License for the specific language governing permissions and
14   *  limitations under the License.
15   *--------------------------------------------------------------------------*/
16  //--------------------------------------
17  // GenomeBrowser Project
18  //
19  // OldUTGBAddTrackTrack.java
20  // Since: 2007/06/20
21  //
22  // $URL$ 
23  // $Author$
24  //--------------------------------------
25  package org.utgenome.gwt.utgb.client.track.lib.old;
26  
27  import org.utgenome.gwt.utgb.client.track.Track;
28  import org.utgenome.gwt.utgb.client.track.TrackBase;
29  import org.utgenome.gwt.utgb.client.track.TrackFrame;
30  import org.utgenome.gwt.utgb.client.track.TrackGroup;
31  
32  import com.google.gwt.event.dom.client.ClickEvent;
33  import com.google.gwt.event.dom.client.ClickHandler;
34  import com.google.gwt.user.client.ui.Button;
35  import com.google.gwt.user.client.ui.HorizontalPanel;
36  import com.google.gwt.user.client.ui.TextBox;
37  import com.google.gwt.user.client.ui.Widget;
38  
39  /**
40   * @author ssksn
41   * 
42   */
43  public class OldUTGBAddTrackTrack extends TrackBase implements ClickHandler {
44  
45  	public static TrackFactory factory() {
46  		return new TrackFactory() {
47  			public Track newInstance() {
48  				return new OldUTGBAddTrackTrack();
49  			}
50  		};
51  	}
52  
53  	private final HorizontalPanel _panel = new HorizontalPanel();
54  	private final Button addButton = new Button("Add");
55  	private final TextBox descriptionXMLURLBox = new TextBox();
56  
57  	public OldUTGBAddTrackTrack() {
58  		super("Add Track with Desc XML");
59  
60  		_panel.setSize("100%", "50px");
61  		_panel.setHorizontalAlignment(HorizontalPanel.ALIGN_CENTER);
62  		_panel.setVerticalAlignment(HorizontalPanel.ALIGN_MIDDLE);
63  		_panel.setStyleName("utgb-addtrack");
64  		descriptionXMLURLBox.setVisibleLength(100);
65  
66  		_panel.add(addButton);
67  		_panel.add(descriptionXMLURLBox);
68  
69  		addButton.addClickHandler(this);
70  	}
71  
72  	public Widget getWidget() {
73  		return _panel;
74  	}
75  
76  	public int getMinimumWindowHeight() {
77  		return 50;
78  	}
79  
80  	public void setUp(TrackFrame trackFrame, TrackGroup group) {
81  		trackFrame.pack();
82  	}
83  
84  	public void onClick(ClickEvent e) {
85  		final String descriptionXMLURL = descriptionXMLURLBox.getText();
86  
87  		if (descriptionXMLURL != null && descriptionXMLURL.length() > 0) {
88  			final OldUTGBTrack newTrack = new OldUTGBTrack();
89  			newTrack.setDescriptionXML(descriptionXMLURL);
90  
91  			_trackGroup.addTrack(newTrack);
92  		}
93  	}
94  
95  }