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  // MenuOperationItem.java
20  // Since: 2007/06/14
21  //
22  // $URL$ 
23  // $Author$
24  //--------------------------------------
25  package org.utgenome.gwt.utgb.client.track.operation;
26  
27  import org.utgenome.gwt.utgb.client.track.lib.old.Utilities;
28  
29  import com.google.gwt.event.dom.client.ClickEvent;
30  import com.google.gwt.event.dom.client.ClickHandler;
31  import com.google.gwt.user.client.ui.Button;
32  import com.google.gwt.user.client.ui.PopupPanel;
33  import com.google.gwt.user.client.ui.Widget;
34  import com.google.gwt.xml.client.Node;
35  
36  /**
37   * @author ssksn
38   * 
39   */
40  public class MenuOperationItem extends EventImpl implements ClickHandler {
41  	public String caption;
42  	private PopupPanel _popupPanel;
43  
44  	public MenuOperationItem(final Node menuItemNode) {
45  		this(Utilities.getAttributeValue(menuItemNode, "caption"));
46  	}
47  
48  	public MenuOperationItem(final String caption) {
49  		this.caption = caption;
50  	}
51  
52  	public Widget getWidget(final PopupPanel popupPanel) {
53  		final Button widget = new Button(caption);
54  		widget.addClickHandler(this);
55  
56  		_popupPanel = popupPanel;
57  
58  		return widget;
59  	}
60  
61  	public void onClick(ClickEvent e) {
62  		final int operationSize = operations.size();
63  		for (int i = 0; i < operationSize; i++) {
64  			final Operation operation = (Operation) (operations.get(i));
65  			operation.execute((Widget) e.getSource(), -1, -1);
66  		}
67  
68  		_popupPanel.hide();
69  	}
70  }