contentDTO.setRoleList(ContentEditor.this.visibleTo.getSelectedRoles());
ContentEditor.this.contentService.add(pageEncoded, contentDTO, new AsyncCallbackWithMsg<Void>(){
@Override
public void onCallSuccess(Void result) {
Alert alert = new Alert("Success !", "Content Created Successfully !");
alert.addButton("Add Another Content", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Window.Location.assign("/_ah/content/add?page=" + pageEncoded);
}
});
alert.addButton("Done", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Window.Location.assign("/_ah/content?page=" + pageEncoded);
}
});
alert.show();
};
@Override
public void onCallFailure(Throwable caught) {
Alert alert = new Alert(caught);
alert.addHideButton();
alert.show();
ContentEditor.this.form.setEnabled(true);
}
});
}
});
this.contentService.getLocations(pageEncoded, new AsyncCallback<String[][]>() {
@Override
public void onSuccess(String[][] locations) {
for(String[] loc : locations)
ContentEditor.this.location.addItem(loc[0], loc[1]);
ContentEditor.this.location.setStateAsDefault();
}
@Override
public void onFailure(Throwable caught) {
Alert alert = new Alert(caught);
alert.addButton("Reload Page", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Window.Location.reload();
}
});
alert.addHideButton();
alert.show();
}
});
this.contentService.getRoles(new AsyncCallbackWithMsg<String[][]>() {
@Override
public void onCallSuccess(String[][] roleList) {
for(String[] role : roleList)
ContentEditor.this.visibleTo.addRole(role[1], role[0]);
ContentEditor.this.visibleTo.setSelection(0);
ContentEditor.this.visibleTo.setStateAsDefault();
}
@Override
public void onCallFailure(Throwable caught) {
Alert alert = new Alert(caught);
alert.addButton("Reload Page", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
Window.Location.reload();
}
});
alert.addHideButton();
alert.show();
}
});
}