use of cz.metacentrum.perun.webgui.json.vosManager.GetVos in project perun by CESNET.
the class GroupsTabItem method draw.
public Widget draw() {
// main panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// Horizontal menu
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
//call
ArrayList<String> attrNames = new ArrayList<>();
attrNames.add("urn:perun:group:attribute-def:def:synchronizationEnabled");
attrNames.add("urn:perun:group:attribute-def:def:synchronizationInterval");
attrNames.add("urn:perun:group:attribute-def:def:lastSynchronizationState");
attrNames.add("urn:perun:group:attribute-def:def:lastSuccessSynchronizationTimestamp");
attrNames.add("urn:perun:group:attribute-def:def:lastSynchronizationTimestamp");
attrNames.add("urn:perun:group:attribute-def:def:authoritativeGroup");
final GetAllRichGroups groups = new GetAllRichGroups(voId, attrNames);
groups.setCheckable(false);
// listbox
final ListBoxWithObjects<VirtualOrganization> vos = new ListBoxWithObjects<VirtualOrganization>();
menu.addWidget(new HTML("<strong>Selected VO: </strong>"));
menu.addWidget(vos);
menu.addFilterWidget(new ExtendedSuggestBox(groups.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
groups.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterGroup());
menu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
menu.addWidget(new HTML("<strong>Select VO to see groups that you can manage.</strong>"));
final TabItem tab = this;
// groups table
CellTable<RichGroup> table = groups.getEmptyTable(new FieldUpdater<RichGroup, String>() {
public void update(int index, RichGroup group, String value) {
session.getTabManager().addTab(new GroupDetailTabItem(group));
// close group selection tab when group is selected
session.getTabManager().closeTab(tab, false);
}
});
// listbox change => load vo's groups
vos.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
groups.setVoId(vos.getSelectedObject().getId());
groups.clearTable();
groups.retrieveData();
}
});
// initial fill listbox and trigger groups loading
GetVos vosCall = new GetVos(new JsonCallbackEvents() {
public void onLoadingStart() {
vos.clear();
vos.addItem("Loading...");
}
public void onFinished(JavaScriptObject jso) {
vos.clear();
ArrayList<VirtualOrganization> returnedVos = JsonUtils.jsoAsList(jso);
returnedVos = new TableSorter<VirtualOrganization>().sortByName(returnedVos);
if (returnedVos == null || returnedVos.isEmpty()) {
vos.addItem("No VO available");
return;
}
// put and set selected
for (int i = 0; i < returnedVos.size(); i++) {
vos.addItem(returnedVos.get(i));
if (voId == returnedVos.get(i).getId()) {
vos.setSelected(returnedVos.get(i), true);
}
}
// trigger loading of groups for selected VO
groups.setVoId(vos.getSelectedObject().getId());
groups.clearTable();
groups.retrieveData();
}
public void onError(PerunError error) {
vos.clear();
vos.addItem("Error while loading");
}
;
});
vosCall.retrieveData();
// set width to 100%
table.setWidth("100%");
// add menu and table to the main panel
vp.add(menu);
vp.setCellHeight(menu, "30px");
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations