editBT.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Popup pop = new Popup();
ArticleEditor articleEditor = new ArticleEditor(currentArticle.getId(), pop);
pop.setContent(articleEditor);
pop.center();
}
});
removeBT.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
removeArticle(currentArticle.getId());
}
});
articleTable.setWidget(i, 0, nameLabel);
articleTable.setWidget(i, 1, amountLabel);
articleTable.setWidget(i, 2, amountTB);
articleTable.setWidget(i, 3, removeBT);
articleTable.setWidget(i, 4, editBT);
articleTable.setCellSpacing(4);
}
}
});
mainPanel.add(articleTable);
initWidget(mainPanel);
mainPanel.setSize("558px", "126px");
this.newArticleCptPanel = new CaptionPanel("Add a new article");
mainPanel.add(this.newArticleCptPanel);
this.horizontalPanel = new HorizontalPanel();
this.newArticleCptPanel.setContentWidget(this.horizontalPanel);
this.horizontalPanel.setSize("506px", "55px");
this.newNameLabel = new Label("Article Name :");
this.horizontalPanel.add(this.newNameLabel);
this.newNameLabel.setWidth("90px");
this.newNameTB = new TextBox();
this.horizontalPanel.add(this.newNameTB);
this.newNameTB.setSize("109px", "18px");
this.newAmountLabel = new Label("Amount in stock :");
this.horizontalPanel.add(this.newAmountLabel);
this.newAmountTB = new IntegerBox();
this.horizontalPanel.add(this.newAmountTB);
this.newAmountTB.setSize("30px", "18px");
this.addBt = new Button("Add");
this.addBt.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (newNameTB.getText() != null && newAmountTB.getValue() != null) {
Article article = new Article(newNameTB.getText(), newAmountTB.getValue());
storeService.addArticle(article, new AsyncCallback<Object>() {
@Override
public void onFailure(Throwable caught) {
Window.alert(caught.getLocalizedMessage());
}
@Override
public void onSuccess(Object result) {
ContentContainer.setContent(new StoreForm2(), "content");
}
});
} else
Window.alert("Cannot add article, please enter valids parameters");
}
});
this.horizontalPanel.add(this.addBt);
this.openInPopupBt = new Button("Open the store in a popup");
this.openInPopupBt.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
Popup pop = new Popup("The Official Store !!");
// do not forget a store is a Content and a content is an
// extension of Widget.
pop.setContent(new StoreForm2());
pop.center();
}
});
mainPanel.add(this.openInPopupBt);