use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents in project perun by CESNET.
the class DeleteMembers method deleteMembers.
/**
* Attempts to delete members from VO
*
* @param members Members which should be deleted
*/
public void deleteMembers(final ArrayList<RichMember> members) {
this.members = members;
// test arguments
if (!this.testAdding()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Deleting " + members.size() + " members failed.");
events.onError(error);
}
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText(members.size() + " members deleted!");
events.onFinished(jso);
}
public void onLoadingStart() {
events.onLoadingStart();
}
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, prepareJSONObject());
}
use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents in project perun by CESNET.
the class SendPasswordResetLinkEmail method sendEmail.
/**
* Send password reset gui link to member's email
*
* @param member
*/
public void sendEmail(final RichMember member, String namespace, String attribute, String language) {
this.member = member;
this.namespace = namespace;
this.mailAttributeURN = attribute;
this.language = language;
// test arguments
if (!this.testAdding()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
events.onError(error);
}
public void onFinished(JavaScriptObject jso) {
events.onFinished(jso);
}
public void onLoadingStart() {
events.onLoadingStart();
}
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, prepareJSONObject());
}
use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents in project perun by CESNET.
the class GetFormItems method prepareErrorSettings.
private void prepareErrorSettings(PerunError error) {
FlexTable ft = new FlexTable();
ft.setWidth("100%");
ft.setCellPadding(8);
FlexCellFormatter fcf = ft.getFlexCellFormatter();
ft.addStyleName("borderTable");
ft.setHTML(0, 0, "<strong>Short name</strong>");
ft.setHTML(0, 1, "<strong>Type</strong>");
ft.setHTML(0, 2, "<strong>Disabled</strong>");
ft.setHTML(0, 3, "<strong>Hidden</strong>");
ft.setHTML(0, 4, "<strong>Preview</strong>");
ft.setHTML(0, 5, "<strong>Edit</strong>");
fcf.setStyleName(0, 0, "header");
fcf.setStyleName(0, 1, "header");
fcf.setStyleName(0, 2, "header");
fcf.setStyleName(0, 3, "header");
fcf.setStyleName(0, 4, "header");
fcf.setStyleName(0, 5, "header");
if (error != null && error.getName().equalsIgnoreCase("FormNotExistsException")) {
// no form, add create button
final CustomButton create = new CustomButton("Create empty form", ButtonTranslation.INSTANCE.createEmptyApplicationForm(), SmallIcons.INSTANCE.addIcon());
create.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
// disable button event with refresh page on finished
CreateApplicationForm request = new CreateApplicationForm(entity, id, JsonCallbackEvents.disableButtonEvents(create, new JsonCallbackEvents() {
private TabItem item = null;
@Override
public void onFinished(JavaScriptObject jso) {
if (item != null) {
item.draw();
}
}
@Override
public void onLoadingStart() {
item = session.getTabManager().getActiveTab();
}
}));
request.createApplicationForm();
}
});
if (PerunEntity.VIRTUAL_ORGANIZATION.equals(entity) && !session.isVoAdmin(id)) {
create.setEnabled(false);
} else if (PerunEntity.GROUP.equals(entity) && !session.isGroupAdmin(id) && !session.isVoAdmin(group.getVoId())) {
create.setEnabled(false);
}
loaderImage.setEmptyResultMessage("Application form doesn't exists.");
loaderImage.loadingFinished();
ft.setWidget(1, 0, loaderImage);
ft.getFlexCellFormatter().addStyleName(1, 0, "noBorder");
ft.getFlexCellFormatter().setColSpan(1, 0, 6);
ft.setWidget(2, 0, create);
ft.getFlexCellFormatter().addStyleName(2, 0, "noBorder");
ft.getFlexCellFormatter().setColSpan(2, 0, 6);
ft.getFlexCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_MIDDLE);
ft.getFlexCellFormatter().setHorizontalAlignment(2, 0, HasHorizontalAlignment.ALIGN_CENTER);
ft.getFlexCellFormatter().setVerticalAlignment(2, 0, HasVerticalAlignment.ALIGN_MIDDLE);
} else {
// standard error
ft.setWidget(1, 0, loaderImage);
fcf.setColSpan(1, 0, 6);
}
contents.setWidget(ft);
}
use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents in project perun by CESNET.
the class UpdateFormItems method updateFormItems.
/**
* Updates form items in DB by passed list of them
*
* @param formItems
*/
public void updateFormItems(ArrayList<ApplicationFormItem> formItems) {
this.formItems = formItems;
;
// test arguments
if (!this.testCreating()) {
return;
}
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Updating form items failed.");
events.onError(error);
}
public void onFinished(JavaScriptObject jso) {
session.getUiElements().setLogSuccessText("Form items updated.");
events.onFinished(jso);
}
public void onLoadingStart() {
events.onLoadingStart();
}
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, prepareJSONObject());
}
use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents in project perun by CESNET.
the class UpdateGroup method updateGroup.
/**
* Updates group details
* @param group Group with updated details
*/
public void updateGroup(Group group) {
if (group == null) {
Window.alert("Group can't be null");
return;
}
// GROUP OBJECT
JSONObject oldGroup = new JSONObject(group);
// RECONSTRUCT OBJECT
JSONObject newGroup = new JSONObject();
newGroup.put("id", oldGroup.get("id"));
// fake new group short name as name in order to update
newGroup.put("name", oldGroup.get("shortName"));
newGroup.put("description", oldGroup.get("description"));
newGroup.put("voId", oldGroup.get("voId"));
newGroup.put("parentGroupId", oldGroup.get("parentGroupId"));
newGroup.put("beanName", oldGroup.get("beanName"));
newGroup.put("createdAt", oldGroup.get("createdAt"));
newGroup.put("createdBy", oldGroup.get("createdBy"));
newGroup.put("modifiedAt", oldGroup.get("modifiedAt"));
newGroup.put("modifiedBy", oldGroup.get("modifiedBy"));
// whole JSON query
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("group", newGroup);
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Updating group failed.");
events.onError(error);
}
public void onFinished(JavaScriptObject jso) {
Group gp = jso.cast();
session.getUiElements().setLogSuccessText("Group " + gp.getName() + " successfully updated!");
events.onFinished(jso);
}
public void onLoadingStart() {
events.onLoadingStart();
}
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, jsonQuery);
}
Aggregations