Show CreateStoryCardDialogBox.java syntax highlighted
package ucalgary.ebe.webui.client.ui;
import ucalgary.ebe.webui.client.WebUI2ServiceConnection;
import ucalgary.ebe.webui.client.data.StoryCardWeb;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.ClickListener;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.TextArea;
import com.google.gwt.user.client.ui.TextBox;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.HTMLTable.CellFormatter;
public class CreateStoryCardDialogBox extends DialogBox {
private WebUI2ServiceConnection con;
private TextBox name_box, best_box, actual_box, most_box, worst_box;
private TextArea desc_area;
private StoryCardParentListBox lb;
public CreateStoryCardDialogBox(WebUI2ServiceConnection con) {
super(false);
this.con = con;
int rootheight, rootwidth;
rootwidth = RootPanel.get().getOffsetWidth();
rootheight = RootPanel.get().getOffsetHeight();
int left, top;
//Center dialog box on rootpanel
//total width of dialogbox is
//2x1 (border) + 2x20 (spacing) + 2x200 (labels/textboxes) = 422
left = Math.round(rootwidth/2) - 221;
top = 150;
this.setPopupPosition(left, top);
this.setText("Create Storycard");
Grid g = new Grid(8, 2);
CellFormatter cf = g.getCellFormatter();
//STORYCARD NAME
Label name_label = new Label("Name:");
name_label.addStyleName("webui-CreateBoxLabel");
g.setWidget(0, 0, name_label);
name_box = new TextBox();
name_box.addStyleName("webui-CreateBoxTextBox");
name_box.setText(StoryCardWeb.DEFAULT_NAME);
g.setWidget(0, 1, name_box);
//STORYCARD DESCRIPTION
Label desc_label = new Label("Description:");
desc_label.addStyleName("webui-CreateBoxLabel");
cf.setAlignment(1, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_TOP);
g.setWidget(1, 0, desc_label);
desc_area = new TextArea();
desc_area.addStyleName("webui-CreateBoxTextArea");
desc_area.setText(StoryCardWeb.DEFAULT_DESC);
g.setWidget(1, 1, desc_area);
//STORYCARD BEST CASE
Label best_label = new Label("Best case:");
best_label.addStyleName("webui-CreateBoxLabel");
g.setWidget(2, 0, best_label);
best_box = new TextBox();
best_box.addStyleName("webui-CreateBoxTextBox");
best_box.setText(String.valueOf(StoryCardWeb.DEFAULT_ESTIMATE));
g.setWidget(2, 1, best_box);
//STORYCARD MOST LIKELY
Label most_label = new Label("Most likely:");
most_label.addStyleName("webui-CreateBoxLabel");
g.setWidget(3, 0, most_label);
most_box = new TextBox();
most_box.addStyleName("webui-CreateBoxTextBox");
most_box.setText(String.valueOf(StoryCardWeb.DEFAULT_ESTIMATE));
g.setWidget(3, 1, most_box);
//STORYCARD WORST CASE
Label worst_label = new Label("Worst case:");
g.setWidget(4, 0, worst_label);
worst_box = new TextBox();
worst_box.addStyleName("webui-CreateBoxTextBox");
worst_box.setText(String.valueOf(StoryCardWeb.DEFAULT_ESTIMATE));
g.setWidget(4, 1, worst_box);
//STORYCARD ACTUAL EFFORT
Label actual_label = new Label("Actual effort:");
actual_label.addStyleName("webui-CreateBoxLabel");
g.setWidget(5, 0, actual_label);
actual_box = new TextBox();
actual_box.addStyleName("webui-CreateBoxTextBox");
actual_box.setText(String.valueOf(StoryCardWeb.DEFAULT_ESTIMATE));
g.setWidget(5, 1, actual_box);
//STORYCARD PARENT
Label parent_label = new Label("Parent:");
parent_label.addStyleName("webui-CreateBoxLabel");
g.setWidget(6, 0, parent_label);
lb = new StoryCardParentListBox(getConnection());
g.setWidget(6, 1, lb);
Button commit_button = new Button("Commit");
commit_button.addClickListener(new ClickListener() {
public void onClick(Widget sender) {
try {
getConnection().createStoryCard(getNameText(),
getDescriptionText(), getParentId(),
getBest(), getMost(),
getWorst(), getActual());
getDialog().hide();
} catch (Exception e) {
e.printStackTrace();
}
}
});
cf.addStyleName(7, 0, "webui-CreateBoxButtonField");
g.setWidget(7, 0, commit_button);
Button cancel_button = new Button("Cancel");
cancel_button.addClickListener(new ClickListener() {
public void onClick(Widget arg0) {
getDialog().hide();
}
});
cf.addStyleName(7, 1, "webui-CreateBoxButtonField");
g.setWidget(7, 1, cancel_button);
this.setWidget(g);
RootPanel.get().add(this);
}
public WebUI2ServiceConnection getConnection() {
return this.con;
}
public CreateStoryCardDialogBox getDialog() {
return this;
}
public String getNameText() {
return this.name_box.getText();
}
public String getDescriptionText() {
return this.desc_area.getText();
}
public long getParentId() {
if(this.lb.getSelectedIndex() == -1) {
return (new Long(this.lb.getValue(0))).longValue();
} else {
return (new Long(this.lb.getValue(this.lb.getSelectedIndex()))).longValue();
}
}
public float getBest() {
return Float.valueOf(this.best_box.getText()).floatValue();
}
public float getMost() {
return Float.valueOf(this.most_box.getText()).floatValue();
}
public float getWorst() {
return Float.valueOf(this.worst_box.getText()).floatValue();
}
public float getActual() {
return Float.valueOf(this.actual_box.getText()).floatValue();
}
}
See more files for this project here