use of cz.metacentrum.perun.webgui.tabs.memberstabs.ChangeStatusTabItem 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.tabs.memberstabs.ChangeStatusTabItem 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));
}
Aggregations