use of cz.metacentrum.perun.webgui.model.RichMember in project perun by CESNET.
the class VoMembersTabItem method draw.
public Widget draw() {
// SET TAB NAME
titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": members");
// MAIN PANEL
final VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// MENU
TabMenu tabMenu = new TabMenu();
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
// DISABLED CHECKBOX
final CheckBox disabled = new CheckBox(WidgetTranslation.INSTANCE.showDisabledMembers());
disabled.setTitle(WidgetTranslation.INSTANCE.showDisabledMembersTitle());
disabled.setValue(wasDisabled);
disabled.setVisible(false);
// CALLBACKS
final GetCompleteRichMembers members = new GetCompleteRichMembers(PerunEntity.VIRTUAL_ORGANIZATION, voId, null);
final FindCompleteRichMembers findMembers = new FindCompleteRichMembers(PerunEntity.VIRTUAL_ORGANIZATION, voId, "", null);
members.excludeDisabled(!wasDisabled);
final CustomButton searchButton = TabMenu.getPredefinedButton(ButtonType.SEARCH, ButtonTranslation.INSTANCE.searchMemberInVo());
final CustomButton listAllButton = TabMenu.getPredefinedButton(ButtonType.LIST_ALL_MEMBERS, ButtonTranslation.INSTANCE.listAllMembersInVo());
if (!session.isVoAdmin(voId))
findMembers.setCheckable(false);
final CellTable<RichMember> table = findMembers.getEmptyTable(new FieldUpdater<RichMember, RichMember>() {
// when user click on a row -> open new tab
public void update(int index, RichMember object, RichMember value) {
session.getTabManager().addTab(new MemberDetailTabItem(object.getId(), 0));
}
});
// refresh
tabMenu.addWidget(UiElements.getRefreshButton(this));
// ADD
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addMemberToVo(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddMemberToVoTabItem(voId), true);
}
});
if (!session.isVoAdmin(voId))
addButton.setEnabled(false);
tabMenu.addWidget(addButton);
// REMOVE
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeMemberFromVo());
if (!session.isVoAdmin(voId))
removeButton.setEnabled(false);
tabMenu.addWidget(removeButton);
/*
final CustomButton addServiceButton = new CustomButton(ButtonTranslation.INSTANCE.createServiceMemberButton(), ButtonTranslation.INSTANCE.createServiceMember(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new CreateServiceMemberInVoTabItem(vo));
}
});
if (!session.isVoAdmin(voId)) addServiceButton.setEnabled(false);
tabMenu.addWidget(addServiceButton);
*/
// refreshMembers
final JsonCallbackEvents refreshEvent = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
if (search) {
findMembers.searchFor(searchString);
} else {
findMembers.clearTable();
members.retrieveData();
}
}
};
// add click handler for remove button
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// state specific events
final ArrayList<RichMember> membersForRemoving = findMembers.getTableSelectedList();
String text = "Following members will be removed from VO and their settings will be lost.<p>You can consider changing their status to \"DISABLED\", which will prevent them from accessing VO resources.";
UiElements.showDeleteConfirm(membersForRemoving, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < membersForRemoving.size(); i++) {
DeleteMember request;
if (i == membersForRemoving.size() - 1) {
request = new DeleteMember(JsonCallbackEvents.disableButtonEvents(removeButton, refreshEvent));
} else {
request = new DeleteMember(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.deleteMember(membersForRemoving.get(i).getId());
}
}
});
}
});
final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {
public void searchFor(String text) {
searchString = text;
search = true;
findMembers.searchFor(text);
}
}, searchButton);
searchBox.getTextBox().setText(searchString);
// checkbox click handler
disabled.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
wasDisabled = disabled.getValue();
if (search) {
// case when update but not triggered by button
searchString = searchBox.getTextBox().getText();
members.excludeDisabled(!disabled.getValue());
} else {
members.excludeDisabled(!disabled.getValue());
members.retrieveData();
}
}
});
findMembers.setEvents(JsonCallbackEvents.mergeEvents(JsonCallbackEvents.disableButtonEvents(searchButton, JsonCallbackEvents.disableCheckboxEvents(disabled)), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
searchBox.getTextBox().setEnabled(true);
listAllButton.setEnabled(true);
}
@Override
public void onError(PerunError error) {
searchBox.getTextBox().setEnabled(true);
listAllButton.setEnabled(true);
}
@Override
public void onLoadingStart() {
searchBox.getTextBox().setEnabled(false);
listAllButton.setEnabled(false);
disabled.setVisible(false);
}
}));
members.setEvents(JsonCallbackEvents.mergeEvents(JsonCallbackEvents.disableButtonEvents(listAllButton, JsonCallbackEvents.disableCheckboxEvents(disabled)), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// pass data to table handling callback
findMembers.onFinished(jso);
((AjaxLoaderImage) table.getEmptyTableWidget()).setEmptyResultMessage("VO has no members.");
searchBox.getTextBox().setEnabled(true);
searchButton.setEnabled(true);
}
@Override
public void onError(PerunError error) {
// pass data to table handling callback
findMembers.onError(error);
searchBox.getTextBox().setEnabled(true);
searchButton.setEnabled(true);
}
@Override
public void onLoadingStart() {
searchBox.getTextBox().setEnabled(false);
searchButton.setEnabled(false);
disabled.setVisible(true);
// to show progress when reloading
((AjaxLoaderImage) table.getEmptyTableWidget()).loadingStart();
}
}));
// LIST ALL BUTTON
listAllButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
search = false;
searchString = "";
searchBox.getTextBox().setText("");
findMembers.clearTable();
members.retrieveData();
}
});
tabMenu.addWidget(listAllButton);
tabMenu.addWidget(disabled);
/* WHEN TAB RELOADS, CHECK THE STATE */
if (search) {
findMembers.searchFor(searchString);
} else {
members.excludeDisabled(!disabled.getValue());
members.retrieveData();
}
ScrollPanel tableWrapper = new ScrollPanel();
table.addStyleName("perun-table");
tableWrapper.setWidget(table);
tableWrapper.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(tableWrapper, 350, this);
// add menu and the table to the main panel
firstTabPanel.add(tableWrapper);
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(findMembers, table, removeButton);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.model.RichMember in project perun by CESNET.
the class PerunStatusWidget method getChangeStatusButton.
/**
* Changing status button
* @return the widget
*/
private Widget getChangeStatusButton() {
Anchor button = new Anchor("change");
button.setTitle("Change status for " + objectName + ".");
button.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
RichMember member = object.cast();
JsonCallbackEvents newEvent = JsonCallbackEvents.mergeEvents(events, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
Member m = jso.cast();
object.setStatus(m.getStatus());
build();
}
});
PerunWebSession.getInstance().getTabManager().addTabToCurrentTab(new ChangeStatusTabItem(member, newEvent));
}
});
return button;
}
use of cz.metacentrum.perun.webgui.model.RichMember in project perun by CESNET.
the class AddRemoveItemsTable method buildWidget.
/**
* Rebuild widget GUI
*/
private void buildWidget() {
FlexTable ft = new FlexTable();
ft.setStyleName("perun-table");
widget.clear();
widget.add(ft);
if (list.isEmpty()) {
ft.setHTML(0, 0, "<strong>No items found.</strong>");
ft.getFlexCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_TOP);
}
int row = 0;
int column = 0;
for (final T object : list) {
GeneralObject go = object.cast();
String name = "";
if ("User".equalsIgnoreCase(go.getObjectType())) {
User u = go.cast();
name = u.getFullNameWithTitles();
} else if ("RichUser".equalsIgnoreCase(go.getObjectType())) {
User u = go.cast();
name = u.getFullNameWithTitles();
} else if ("RichMember".equalsIgnoreCase(go.getObjectType())) {
RichMember m = go.cast();
name = m.getUser().getFullNameWithTitles();
} else {
name = ((GeneralObject) object).getName();
}
CustomButton rb = new CustomButton("", "Remove item", SmallIcons.INSTANCE.deleteIcon());
rb.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
removeItem(object);
}
});
if (vertical) {
ft.setHTML(row, 0, name);
ft.setWidget(row, 1, rb);
row++;
} else {
ft.setHTML(row, column, name);
ft.setWidget(row, column + 1, rb);
column = column + 2;
}
}
widget.setSize("100%", "100%");
widget.setStyleName("perun-tableScrollPanel", true);
UiElements.runResizeCommands(true);
}
use of cz.metacentrum.perun.webgui.model.RichMember in project perun by CESNET.
the class MemberColumnProvider method addStatusColumn.
public void addStatusColumn(IsClickableCell authz, int width) {
// Status column
final Column<RichMember, String> statusColumn = new Column<RichMember, String>(new PerunStatusCell()) {
@Override
public String getValue(RichMember object) {
return object.getStatus();
}
};
// own onClick tab for changing member's status
statusColumn.setFieldUpdater(new FieldUpdater<RichMember, String>() {
@Override
public void update(final int index, final RichMember object, final String value) {
PerunWebSession.getInstance().getTabManager().addTabToCurrentTab(new ChangeStatusTabItem(object, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
Member m = jso.cast();
// set status to object in cell to change rendered value
object.setStatus(m.getStatus());
// because they are not updated during .update() on cell
for (RichMember rm : dataProvider.getList()) {
if (rm.getId() == m.getId()) {
rm.setStatus(m.getStatus());
}
}
if (backupList != null) {
for (RichMember rm : backupList) {
if (rm.getId() == m.getId()) {
rm.setStatus(m.getStatus());
}
}
}
dataProvider.refresh();
dataProvider.flush();
}
}));
}
});
// add column
table.addColumn(statusColumn, "Status");
if (width != 0) {
table.setColumnWidth(statusColumn, width, Style.Unit.PX);
}
// status column sortable
statusColumn.setSortable(true);
table.getColumnSortHandler().setComparator(statusColumn, new GeneralComparator<RichMember>(GeneralComparator.Column.STATUS));
}
use of cz.metacentrum.perun.webgui.model.RichMember in project perun by CESNET.
the class MemberColumnProvider method addOrganizationColumn.
public void addOrganizationColumn(IsClickableCell authz, int width) {
// create column
Column<RichMember, RichMember> organizationColumn = JsonUtils.addColumn(new CustomClickableTextCellWithAuthz<RichMember>(authz, "organization"), new JsonUtils.GetValue<RichMember, RichMember>() {
@Override
public RichMember getValue(RichMember object) {
return object;
}
}, fieldUpdater);
// add column
table.addColumn(organizationColumn, "Organization");
if (width != 0) {
table.setColumnWidth(organizationColumn, width, Style.Unit.PX);
}
// sort column
organizationColumn.setSortable(true);
table.getColumnSortHandler().setComparator(organizationColumn, new RichMemberComparator(RichMemberComparator.Column.ORGANIZATION));
}
Aggregations