Show ProjectListBox.java syntax highlighted
package ucalgary.ebe.webui.client.ui;
import java.util.Vector;
import ucalgary.ebe.webui.client.WebUI2ServiceConnection;
import com.google.gwt.user.client.ui.ChangeListener;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Widget;
public class ProjectListBox extends Grid implements ChangeListener {
WebUI2ServiceConnection con;
ListBox lb;
//TODO can fetch project names all by itself via con
//changelistener loads project via con.loadProject(getItemText(getSelectedIndex())
public ProjectListBox(WebUI2ServiceConnection con, Vector names) {
super(2, 1);
this.con = con;
this.setWidget(0, 0, new Label("Projects"));
this.lb = new ListBox();
for(int i = 0; i < names.size(); i++) {
lb.addItem((String)names.get(i));
}
lb.setVisibleItemCount(1);
lb.addChangeListener(this);
this.setWidget(1, 0, lb);
this.setWidth("100%");
this.con.loadProject(this.lb.getItemText(0));
}
public WebUI2ServiceConnection getConnection() {
return this.con;
}
private ListBox getListBox() {
return this.lb;
}
public void onChange(Widget sender) {
this.con.loadProject(this.lb.getItemText(this.lb.getSelectedIndex()));
}
}
See more files for this project here