import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.ListBox;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.VerticalPanel;
public class YearWeekInput extends Composite{
ListBox listBox;
YearWeekPanel fromPanel;
YearWeekPanel toPanel;
public YearWeekInput() {
HorizontalPanel mainPanel = new HorizontalPanel();
mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
mainPanel.setSpacing(5);
mainPanel.add(getListBox());
mainPanel.add(getFromPanel());
mainPanel.add(getToPanel());
initWidget(mainPanel);
setStyleName("year-week-input");
}
private ListBox getListBox(){
if(listBox == null){
listBox = new ListBox(false);
listBox.setVisibleItemCount(1);
listBox.addItem( "Year/Week Single");
listBox.addItem("Year/Week Range");
}
return listBox;
}
private YearWeekPanel getFromPanel(){
if(fromPanel == null){
fromPanel = new YearWeekPanel("From");
}
return fromPanel;
}
private YearWeekPanel getToPanel(){
if(toPanel == null){
toPanel = new YearWeekPanel("To");
}
return toPanel;
}
private class YearWeekPanel extends Composite {
private TextBox year;
private TextBox week;
public YearWeekPanel(String title) {
VerticalPanel mainPanel = new VerticalPanel();
mainPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
mainPanel.setBorderWidth(0);
mainPanel.add(new Label(title));
mainPanel.add(getTextFields());
initWidget(mainPanel);
setStyleName(title + "-year-week-panel");
}
private Panel getTextFields(){
HorizontalPanel hPanel = new HorizontalPanel();
hPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_BOTTOM);
hPanel.setSpacing(2);
hPanel.add(getYearTextBox());
hPanel.add(getWeekTextBox());
return hPanel;
}
private TextBox getYearTextBox(){
if(year == null){
year = new TextBox();
year.setWidth("4em");
}
return year;
}
private TextBox getWeekTextBox(){
if(week == null){
week = new TextBox();
week.setWidth("2.5em");
}
return week;
}
}
}
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment