use of cz.metacentrum.perun.webgui.json.vosManager.GetVos in project perun by CESNET.
the class CreateFacilityResourceTabItem method draw.
public Widget draw() {
titleWidget.setText("Create resource");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// form inputs
final ExtendedTextBox nameTextBox = new ExtendedTextBox();
final TextBox descriptionTextBox = new TextBox();
final ListBoxWithObjects<VirtualOrganization> vosDropDown = new ListBoxWithObjects<VirtualOrganization>();
// send button
final CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createResource());
// local events fills the listbox of Vos and Slds
JsonCallbackEvents event = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// fill VOs listbox
vosDropDown.clear();
ArrayList<VirtualOrganization> vos = JsonUtils.jsoAsList(jso);
vos = new TableSorter<VirtualOrganization>().sortByName(vos);
for (VirtualOrganization vo : vos) {
vosDropDown.addItem(vo);
}
if (!vos.isEmpty())
createButton.setEnabled(true);
}
@Override
public void onLoadingStart() {
vosDropDown.clear();
vosDropDown.addItem("Loading...");
createButton.setEnabled(false);
}
@Override
public void onError(PerunError error) {
vosDropDown.clear();
vosDropDown.addItem("Error while loading");
createButton.setEnabled(false);
}
};
// load available VOs
final GetVos vos = new GetVos(event);
vos.setForceAll(true);
vos.retrieveData();
// layout
FlexTable layout = new FlexTable();
layout.setStyleName("inputFormFlexTable");
FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
// Add some standard form options
layout.setHTML(0, 0, "On facility:");
layout.setHTML(0, 1, SafeHtmlUtils.fromString((facility.getName() != null) ? facility.getName() : "").asString());
layout.setHTML(1, 0, "For VO:");
layout.setWidget(1, 1, vosDropDown);
layout.setHTML(2, 0, "Name:");
layout.setWidget(2, 1, nameTextBox);
layout.setHTML(3, 0, "Description:");
layout.setWidget(3, 1, descriptionTextBox);
for (int i = 0; i < layout.getRowCount(); i++) {
cellFormatter.addStyleName(i, 0, "itemName");
}
layout.setWidth("350px");
TabMenu menu = new TabMenu();
final ExtendedTextBox.TextBoxValidator validator = new ExtendedTextBox.TextBoxValidator() {
@Override
public boolean validateTextBox() {
if (nameTextBox.getTextBox().getText().trim().isEmpty()) {
nameTextBox.setError("Name can't be empty.");
return false;
}
nameTextBox.setOk();
return true;
}
};
nameTextBox.setValidator(validator);
createButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// loads new tab when creating successful, also disable button
JsonCallbackEvents localEvents = new JsonCallbackEvents() {
public void onLoadingStart() {
(JsonCallbackEvents.disableButtonEvents(createButton)).onLoadingStart();
}
public void onFinished(JavaScriptObject jso) {
(JsonCallbackEvents.disableButtonEvents(createButton)).onFinished(jso);
Resource res = (Resource) jso;
session.getTabManager().addTabToCurrentTab(new CreateFacilityResourceManageServicesTabItem(facility, res), true);
}
public void onError(PerunError error) {
(JsonCallbackEvents.disableButtonEvents(createButton)).onError(error);
}
};
if (validator.validateTextBox()) {
// request
CreateResource request = new CreateResource(localEvents);
request.createResource(nameTextBox.getTextBox().getText().trim(), descriptionTextBox.getText().trim(), facility.getId(), vosDropDown.getSelectedObject().getId());
}
}
});
menu.addWidget(createButton);
final TabItem tab = this;
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, isRefreshParentOnClose());
}
}));
vp.add(layout);
vp.add(menu);
vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.json.vosManager.GetVos in project perun by CESNET.
the class StatisticsTabItem method draw.
public Widget draw() {
// PAGE CONTENTS
ScrollPanel scroll = new ScrollPanel();
final VerticalPanel vp = new VerticalPanel();
vp.setStyleName("perun-table");
vp.setSpacing(5);
scroll.setWidget(vp);
scroll.setStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(scroll, 350, this);
final DisclosurePanel vosStatistics = new DisclosurePanel();
vosStatistics.setWidth("100%");
// vosStatistics.setOpen(true);
FlexTable vosHeader = new FlexTable();
vosHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.buildingIcon()));
vosHeader.setWidget(0, 1, new HTML("<h3>Virtual Organizations</h3>"));
vosHeader.setTitle("Click to show/hide VOs statistics");
vosStatistics.setHeader(vosHeader);
vp.add(vosStatistics);
// the general statistics table
final FlexTable statisticsTable = new FlexTable();
statisticsTable.addStyleName("statisticsTable");
// the VOs table
final FlexTable vosTable = new FlexTable();
vosTable.addStyleName("statisticsTable");
vosTable.setWidget(0, 0, new HTML("<strong>" + "VO name" + "</strong>"));
vosTable.setWidget(0, 1, new HTML("<strong>" + "Members" + "</strong>"));
vosTable.setWidget(0, 2, new HTML("<strong>" + "Valid members" + "</strong>"));
vosTable.setWidget(0, 3, new HTML("<strong>" + "Invalid members" + "</strong>"));
vosTable.setWidget(0, 4, new HTML("<strong>" + "Expired members" + "</strong>"));
vosTable.setWidget(0, 5, new HTML("<strong>" + "Disabled members" + "</strong>"));
vosTable.setWidget(0, 6, new HTML("<strong>" + "Groups" + "</strong>"));
vosTable.setWidget(0, 7, new HTML("<strong>" + "Resources" + "</strong>"));
// vos events - adds the VOs to the table and calls how many members the VO has
JsonCallbackEvents vosEvents = new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
// conversion
ArrayList<VirtualOrganization> vos = JsonUtils.jsoAsList(jso);
vos = new TableSorter<VirtualOrganization>().sortByName(vos);
// iterating VOs
for (int i = 0; i < vos.size(); i++) {
VirtualOrganization vo = vos.get(i);
// call the request for number of members
GetMembersCount countMembers = new GetMembersCount(vo.getId(), null);
countMembers.retrieveData();
GetMembersCount countValidMembers = new GetMembersCount(vo.getId(), PerunStatus.VALID);
countValidMembers.retrieveData();
GetMembersCount countInvalidMembers = new GetMembersCount(vo.getId(), PerunStatus.INVALID);
countInvalidMembers.retrieveData();
GetMembersCount countExpiredMembers = new GetMembersCount(vo.getId(), PerunStatus.EXPIRED);
countExpiredMembers.retrieveData();
GetMembersCount countDisabledMembers = new GetMembersCount(vo.getId(), PerunStatus.DISABLED);
countDisabledMembers.retrieveData();
// call the request for number of resources
GetResourcesCount countResources = new GetResourcesCount(vo.getId());
countResources.retrieveData();
GetGroupsCount countGroups = new GetGroupsCount(vo.getId());
countGroups.retrieveData();
// adds the VO to the table
vosTable.setText(i + 1, 0, vo.getName());
vosTable.setWidget(i + 1, 1, countMembers.getMembersCountHyperlink());
vosTable.setWidget(i + 1, 2, countValidMembers.getMembersCountHyperlink());
vosTable.setWidget(i + 1, 3, countInvalidMembers.getMembersCountHyperlink());
vosTable.setWidget(i + 1, 4, countExpiredMembers.getMembersCountHyperlink());
vosTable.setWidget(i + 1, 5, countDisabledMembers.getMembersCountHyperlink());
vosTable.setWidget(i + 1, 6, countGroups.getGroupsCountHyperlink());
vosTable.setWidget(i + 1, 7, countResources.getResourcesCountHyperlink());
}
}
};
// requests
final GetVos vos = new GetVos(vosEvents);
vosHeader.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (vosStatistics.getContent() == null) {
// retrieve data
vosStatistics.setContent(vosTable);
vos.retrieveData();
}
}
});
this.contentWidget.setWidget(scroll);
return getWidget();
}
use of cz.metacentrum.perun.webgui.json.vosManager.GetVos in project perun by CESNET.
the class SearcherTabItem method loadMembersTab.
private Widget loadMembersTab() {
// request
final GetMembers request = new GetMembers(0);
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
PerunSearchParametersWidget params = new PerunSearchParametersWidget(PerunEntity.MEMBER, new PerunSearchParametersWidget.SearchEvent() {
public void search(Map<String, String> map) {
request.clearParameters();
for (Map.Entry<String, String> entry : map.entrySet()) {
request.addSearchParameter(entry.getKey(), entry.getValue());
}
request.search();
}
});
final ListBoxWithObjects<VirtualOrganization> vos = new ListBoxWithObjects<VirtualOrganization>();
vos.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
request.setVoId(vos.getSelectedObject().getId());
}
});
// 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;
}
vos.addAllItems(returnedVos);
request.setVoId(vos.getSelectedObject().getId());
}
public void onError(PerunError error) {
vos.clear();
vos.addItem("Error while loading");
}
});
vosCall.retrieveData();
TabMenu menu = new TabMenu();
menu.addWidget(new HTML("<strong>Selected VO:</strong>"));
menu.addWidget(vos);
firstTabPanel.add(menu);
firstTabPanel.add(params);
// get the table
final CellTable<Member> table = request.getEmptyTable(new FieldUpdater<Member, String>() {
public void update(int index, Member object, String value) {
// opens the tab
session.getTabManager().addTab(new MemberDetailTabItem(object.getId(), object.getSourceGroupId()));
}
});
// add a class to the table and wrap it into scroll panel
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
return firstTabPanel;
}
use of cz.metacentrum.perun.webgui.json.vosManager.GetVos in project perun by CESNET.
the class AddGroupManagerGroupTabItem method draw.
public Widget draw() {
titleWidget.setText("Add manager group");
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
final TabMenu tabMenu = new TabMenu();
final ListBoxWithObjects<VirtualOrganization> box = new ListBoxWithObjects<VirtualOrganization>();
// pass empty items to menu to ensure drawing of rest
tabMenu.addWidget(UiElements.getRefreshButton(this));
tabMenu.addWidget(new HTML(""));
tabMenu.addWidget(new HTML(""));
tabMenu.addWidget(3, new HTML("<strong>Select VO:</strong>"));
tabMenu.addWidget(4, box);
// get the table
final ScrollPanel sp = new ScrollPanel();
sp.addStyleName("perun-tableScrollPanel");
box.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
sp.setWidget(fillGroupsContent(new GetAllGroups(box.getSelectedObject().getId()), tabMenu, box));
}
});
if (box.getAllObjects().isEmpty()) {
GetVos vos = new GetVos(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
box.clear();
ArrayList<VirtualOrganization> list = new TableSorter<VirtualOrganization>().sortByName(JsonUtils.<VirtualOrganization>jsoAsList(jso));
if (list != null && !list.isEmpty()) {
box.addAllItems(list);
sp.setWidget(fillGroupsContent(new GetAllGroups(box.getSelectedObject().getId()), tabMenu, box));
} else {
box.addItem("No VOs found");
}
}
@Override
public void onError(PerunError error) {
box.clear();
box.addItem("Error while loading");
}
@Override
public void onLoadingStart() {
box.clear();
box.addItem("Loading...");
}
});
vos.retrieveData();
}
final TabItem tab = this;
tabMenu.addWidget(2, TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, isRefreshParentOnClose());
}
}));
// add menu and the table to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.json.vosManager.GetVos in project perun by CESNET.
the class AddFacilityManagerGroupTabItem method draw.
public Widget draw() {
titleWidget.setText("Add manager group");
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
final TabMenu tabMenu = new TabMenu();
final ListBoxWithObjects<VirtualOrganization> box = new ListBoxWithObjects<VirtualOrganization>();
// pass empty items to menu to ensure drawing of rest
tabMenu.addWidget(new HTML(""));
tabMenu.addWidget(new HTML(""));
tabMenu.addWidget(2, new HTML("<strong>Select VO:</strong>"));
tabMenu.addWidget(3, box);
// get the table
final ScrollPanel sp = new ScrollPanel();
sp.addStyleName("perun-tableScrollPanel");
box.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent event) {
sp.setWidget(fillGroupsContent(new GetAllGroups(box.getSelectedObject().getId()), tabMenu, box));
}
});
if (box.getAllObjects().isEmpty()) {
GetVos vos = new GetVos(new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
box.clear();
ArrayList<VirtualOrganization> list = new TableSorter<VirtualOrganization>().sortByName(JsonUtils.<VirtualOrganization>jsoAsList(jso));
if (list != null && !list.isEmpty()) {
box.addAllItems(list);
sp.setWidget(fillGroupsContent(new GetAllGroups(box.getSelectedObject().getId()), tabMenu, box));
} else {
box.addItem("No VOs found");
}
}
@Override
public void onError(PerunError error) {
box.clear();
box.addItem("Error while loading");
}
@Override
public void onLoadingStart() {
box.clear();
box.addItem("Loading...");
}
});
vos.retrieveData();
}
final TabItem tab = this;
tabMenu.addWidget(1, TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// if (refreshEvents != null) refreshEvents.onFinished(null);
session.getTabManager().closeTab(tab, isRefreshParentOnClose());
}
}));
// add menu and the table to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
Aggregations