String href;
for (index = 0; index < jResponse.getRootItemsNum(); index++) {
final Anchor link ;
/* remove line style
if (index%2==0)
rowStyle = "gridRowShadow";
else
rowStyle = "gridRowNoShadow";
results.getRowFormatter().setStyleName(index, rowStyle);
*/
href = data.getStringItemValue(
Params.BOOKMARK_URL.getParamName(), index);
link = new Anchor();
if(!href.startsWith("http:") && !href.startsWith("https:") && !href.startsWith("ftp:"))
href = "http://"+href;
link.setHref(href);
link.setText(data.getStringItemValue(
Params.BOOKMARK_TITLE.getParamName(), index));
link.setTarget("_blank");
final String noteId = jResponse.getItemKeyValue(index);
VerticalPanel bookMarkItem= new VerticalPanel();
bookMarkItem.add(link);
final TextBox bookMarkUrlEdit = new TextBox();
final TextBox bookMarkTitleEdit = new TextBox();
if(data.isUpdatePermitted(index)){
bookMarkUrlEdit.setWidth("500px");
bookMarkUrlEdit.setVisible(false);
bookMarkUrlEdit.setText(jResponse.getStringItemValue(
Params.BOOKMARK_URL.getParamName(), index));
bookMarkItem.add(bookMarkUrlEdit);
bookMarkTitleEdit.setWidth("500px");
bookMarkTitleEdit.setVisible(false);
bookMarkTitleEdit.setText(jResponse.getStringItemValue(
Params.BOOKMARK_TITLE.getParamName(), index));
bookMarkItem.add(bookMarkTitleEdit);
bookMarkUrlEdit.addBlurHandler(new BlurHandler(){
@Override
public void onBlur(BlurEvent event) {
// ignore empty
if(bookMarkUrlEdit.getText().length()==0){
bookMarkUrlEdit.setVisible(false);
bookMarkTitleEdit.setVisible(false);
link.setVisible(true);
bookMarkUrlEdit.setText(link.getHref());
}
else
{
bookMarkUrlEdit.setVisible(false);
bookMarkTitleEdit.setVisible(false);
link.setHref(bookMarkUrlEdit.getText());
link.setVisible(true);
changeBookMarkQry.clearParamList();
changeBookMarkQry
.setRequestAction(ReqActionTypes.UPDATE);
changeBookMarkQry
.setRequestItemkey(noteId);
changeBookMarkQry.addParam(Params.BOOKMARK_TITLE.getParamName(),
bookMarkTitleEdit.getText());
changeBookMarkQry.addParam(Params.BOOKMARK_URL.getParamName(),
bookMarkUrlEdit.getText());
changeBookMarkRequest.makeRequest();
}
}});
bookMarkTitleEdit.addBlurHandler(new BlurHandler(){
@Override
public void onBlur(BlurEvent event) {
// ignore empty
if(bookMarkTitleEdit.getText().trim().length()==0){
bookMarkUrlEdit.setVisible(false);
bookMarkTitleEdit.setVisible(false);
link.setVisible(true);
bookMarkTitleEdit.setText(link.getText());
}
else
{
bookMarkUrlEdit.setVisible(false);
bookMarkTitleEdit.setVisible(false);
link.setText(bookMarkTitleEdit.getText());
link.setVisible(true);
changeBookMarkQry.clearParamList();
changeBookMarkQry
.setRequestAction(ReqActionTypes.UPDATE);
changeBookMarkQry
.setRequestItemkey(noteId);
changeBookMarkQry.addParam(Params.BOOKMARK_TITLE.getParamName(),
bookMarkTitleEdit.getText());
changeBookMarkQry.addParam(Params.BOOKMARK_URL.getParamName(),
bookMarkUrlEdit.getText());
changeBookMarkRequest.makeRequest();
}
}});
final ActionLabel edit = new ActionLabel(prefsUtils.getMsg("gadgetLabelEdit"));
edit.setTitle(prefsUtils.getMsg("gadgetLabelEdit"));
edit.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
edit.mouseOff();
link.setVisible(false);
bookMarkUrlEdit.setVisible(true);
bookMarkTitleEdit.setVisible(true);
}