int index;
for (index = 0; index < jResponse.getRootItemsNum(); index++) {
final ContentText text = new ContentText(
data.getStringItemValue(
Params.DISCUSSION_TEXT.getParamName(),
index));
final String discussionId = jResponse
.getItemKeyValue(index);
VerticalPanel discussionItem = new VerticalPanel();
discussionItem.add(text);
final ActionLabel view = new ActionLabel(
prefsUtils.getMsg("gadgetLabelView"));
view.setTitle(prefsUtils.getMsg("gadgetLabelView"));
view.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// / view replay ....
gadgetState.setDiscussionId(discussionId);
gadgetState.setSingleDiscussion(true);
gadgetState.setDiscussionTitle(text.getText());
viewDiscussionsReplyQry
.setRequestItemkey(gadgetState
.getDiscussionId());
viewDiscussionsReplyQry
.setCustomtContentName("replay");
viewDiscussionReplys.makeRequest();
}
});
results.setWidget(index, 0, discussionItem);
results.setWidget(index, 1, view);
final ActionLabel deleteLabel = new ActionLabel(
prefsUtils.getMsg("gadgetLabelDelete"));
deleteLabel.setItemId(jResponse.getItemKeyValue(index));
if (data.isDeletePermitted(index)) {
deleteLabel.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
changeDiscussionsQry.clearParamList();
changeDiscussionsQry
.setRequestAction(ReqActionTypes.DELETE);
changeDiscussionsQry
.setRequestItemkey(discussionId);
addDeleteDiscussions.makeRequest();
}
});
} else {
// delete: "hide" sharing
deleteLabel.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
deleteLabel.mouseOff();
changeDiscussionsQry.clearParamList();
changeDiscussionsQry
.setRequestAction(ReqActionTypes.DELETE);
changeDiscussionsQry
.setCustomtContentName("sharing");
changeDiscussionsQry
.setRequestItemkey(discussionId);
addDeleteDiscussions.makeRequest();
changeDiscussionsQry
.setCustomtContentName(null);
}
});
}
results.setWidget(index, 2, deleteLabel);
if (data.isSharePermitted(index)) {
final ActionLabel shareWithLabel = new ActionLabel(
prefsUtils.getMsg("gadgetLabelShare"));
shareWithLabel.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
shareWithLabel.mouseOff();
ShareWithDialogPanel panel = ShareWithDialogPanel
.getShareWithDialogPanel();
panel.showShareWithDialogPanel(discussionId,
text.getText());
}
});