use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class MemberGroupsTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(member.getUser().getFullNameWithTitles().trim()) + ": groups");
// main widget panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
final GetMemberGroups groupsCall = new GetMemberGroups(memberId);
menu.addWidget(UiElements.getRefreshButton(this));
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, "Add member to new group", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new MemberAddToGroupTabItem(member), true);
}
});
if (session.isVoObserver(member.getVoId()) && !session.isVoAdmin(member.getVoId())) {
addButton.setEnabled(false);
groupsCall.setCheckable(false);
}
menu.addWidget(addButton);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, "Remove member from selected group(s)", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
final ArrayList<Group> list = groupsCall.getTableSelectedList();
String confirmText = member.getUser().getFullName() + " will be removed from following groups.";
UiElements.showDeleteConfirm(list, confirmText, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - should have only one callback to core
for (int i = 0; i < list.size(); i++) {
if (i == list.size() - 1) {
RemoveMember request = new RemoveMember(JsonCallbackEvents.refreshTableEvents(groupsCall));
request.removeMemberFromGroup(list.get(i), member);
} else {
RemoveMember request = new RemoveMember();
request.removeMemberFromGroup(list.get(i), member);
}
}
}
});
}
});
removeButton.setEnabled(false);
menu.addWidget(removeButton);
menu.addFilterWidget(new ExtendedSuggestBox(groupsCall.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
groupsCall.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterGroup());
CellTable<Group> table = groupsCall.getTable(new FieldUpdater<Group, String>() {
@Override
public void update(int i, Group group, String s) {
if (session.isVoAdmin(group.getVoId()) || session.isVoObserver(group.getVoId()) || session.isGroupAdmin(group.getId())) {
session.getTabManager().addTab(new GroupDetailTabItem(group));
} else {
UiElements.generateInfo("Not privileged", "You are not manager of selected group or it's VO.");
}
}
});
if (session.isVoAdmin(member.getVoId()) || session.isGroupAdmin(groupId))
JsonUtils.addTableManagedButton(groupsCall, table, removeButton);
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(sp, 350, this);
vp.add(sp);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class VosTabItem method draw.
public Widget draw() {
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// Get vos request
final GetVos getVos = new GetVos();
// Events for reloading when finished
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(getVos);
// create new VO button
TabMenu tabMenu = new TabMenu();
tabMenu.addWidget(UiElements.getRefreshButton(this));
// add menu to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, buttonTranslation.createVo(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateVoTabItem());
}
}));
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, buttonTranslation.deleteVo());
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<VirtualOrganization> itemsToRemove = getVos.getTableSelectedList();
UiElements.showDeleteConfirm(itemsToRemove, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < itemsToRemove.size(); i++) {
DeleteVo request;
if (i == itemsToRemove.size() - 1) {
request = new DeleteVo(JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new DeleteVo(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.deleteVo(itemsToRemove.get(i).getId(), false);
}
}
});
}
});
tabMenu.addWidget(removeButton);
// filter
tabMenu.addFilterWidget(new ExtendedSuggestBox(getVos.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
getVos.filterTable(text);
}
}, buttonTranslation.filterVo());
// get the table with custom onclick
CellTable<VirtualOrganization> table = getVos.getTable(new FieldUpdater<VirtualOrganization, VirtualOrganization>() {
@Override
public void update(int index, VirtualOrganization object, VirtualOrganization value) {
session.getTabManager().addTab(new VoDetailTabItem(object));
}
});
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(getVos, table, removeButton);
// 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");
// add the table to the main panel
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, 0, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class ResourceAssignedServicesTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(resource.getName()) + ": manage assigned services");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
final GetAssignedServices resourceServices = new GetAssignedServices(resourceId);
final JsonCallbackEvents localEvents = JsonCallbackEvents.refreshTableEvents(resourceServices);
CustomButton assignServicesButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.assignServiceToResource(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AssignServiceTabItem(resourceId), true);
}
});
final CustomButton removeServicesButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeServiceFromResource());
removeServicesButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<Service> servicesForRemoving = resourceServices.getTableSelectedList();
String text = "Following services will be removed from resource.";
UiElements.showDeleteConfirm(servicesForRemoving, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD USE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < servicesForRemoving.size(); i++) {
if (i == servicesForRemoving.size() - 1) {
RemoveService request = new RemoveService(JsonCallbackEvents.disableButtonEvents(removeServicesButton, localEvents));
request.removeService(servicesForRemoving.get(i).getId(), resourceId);
} else {
RemoveService request = new RemoveService(JsonCallbackEvents.disableButtonEvents(removeServicesButton));
request.removeService(servicesForRemoving.get(i).getId(), resourceId);
}
}
}
});
}
});
menu.addWidget(assignServicesButton);
menu.addWidget(removeServicesButton);
menu.addFilterWidget(new ExtendedSuggestBox(resourceServices.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
resourceServices.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterServices());
// display menu only to facility admin
if (session.isFacilityAdmin(resource.getFacilityId())) {
resourceServices.setCheckable(true);
vp.add(menu);
vp.setCellHeight(menu, "30px");
} else {
resourceServices.setCheckable(false);
}
CellTable<Service> table;
if (session.isPerunAdmin()) {
table = resourceServices.getTable(new FieldUpdater<Service, String>() {
public void update(int index, Service object, String value) {
// load detail only for perun admin
session.getTabManager().addTab(new ServiceDetailTabItem(object));
}
});
} else {
// not clickable
table = resourceServices.getTable();
}
removeServicesButton.setEnabled(false);
JsonUtils.addTableManagedButton(resourceServices, table, removeServicesButton);
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
session.getUiElements().resizePerunTable(sp, 400, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox 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();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class SubgroupsTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": subgroups");
// main panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// if members group, hide
if (group.isCoreGroup()) {
vp.add(new HTML("<h2>Members group cannot have subgroups.</h2>"));
this.contentWidget.setWidget(vp);
return getWidget();
}
// GROUP TABLE with onclick
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:lastSynchronizationTimestamp");
attrNames.add("urn:perun:group:attribute-def:def:lastSuccessSynchronizationTimestamp");
attrNames.add("urn:perun:group:attribute-def:def:authoritativeGroup");
final GetAllRichSubGroups subgroups = new GetAllRichSubGroups(groupId, attrNames);
// Events for reloading when group is created
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(subgroups);
// menu
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createSubGroup(), new ClickHandler() {
public void onClick(ClickEvent event) {
// creates a new form
session.getTabManager().addTabToCurrentTab(new CreateGroupTabItem(group));
}
});
if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId())) {
createButton.setEnabled(false);
subgroups.setCheckable(false);
}
menu.addWidget(createButton);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteSubGroup());
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<RichGroup> itemsToRemove = subgroups.getTableSelectedList();
String text = "Following groups (including all sub-groups) will be deleted.";
UiElements.showDeleteConfirm(itemsToRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
DeleteGroups request = new DeleteGroups(JsonCallbackEvents.disableButtonEvents(removeButton, events));
request.deleteGroups(itemsToRemove);
}
});
}
});
menu.addWidget(removeButton);
// filter box
menu.addFilterWidget(new ExtendedSuggestBox(subgroups.getOracle()), new PerunSearchEvent() {
public void searchFor(String text) {
subgroups.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterGroup());
// add menu to the main panel
vp.add(menu);
vp.setCellHeight(menu, "30px");
CellTable<RichGroup> table = subgroups.getTable(new FieldUpdater<RichGroup, String>() {
@Override
public void update(int arg0, RichGroup group, String arg2) {
session.getTabManager().addTab(new GroupDetailTabItem(group.getId()));
}
});
removeButton.setEnabled(false);
if (session.isGroupAdmin(groupId) || session.isVoAdmin(group.getVoId()))
JsonUtils.addTableManagedButton(subgroups, table, removeButton);
// adds the table into the panel
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