use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class GroupResourcesTabItem method draw.
public Widget draw() {
// set title
titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": " + "resources");
// main panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
// get VO resources
final GetAssignedRichResources resources = new GetAssignedRichResources(groupId, PerunEntity.GROUP);
if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
resources.setCheckable(false);
// custom events for viewResource
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(resources);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeGroupFromSelectedResources());
// add / remove resource from group can be done by vo / perun admin only.
if (session.isVoAdmin(group.getVoId())) {
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.assignGroupToResources(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AssignGroupTabItem(group, resources.getList()), true);
}
}));
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<RichResource> toRemove = resources.getTableSelectedList();
String text = "Following resources will be removed from group and it's members won't have access to them anymore.";
UiElements.showDeleteConfirm(toRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
RemoveGroupFromResources request = new RemoveGroupFromResources(JsonCallbackEvents.disableButtonEvents(removeButton, events));
request.removeGroupFromResources(group, toRemove);
}
});
}
});
menu.addWidget(removeButton);
}
// filter box
menu.addFilterWidget(new ExtendedSuggestBox(resources.getOracle()), new PerunSearchEvent() {
public void searchFor(String text) {
resources.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterResources());
// add menu to the main panel
vp.add(menu);
vp.setCellHeight(menu, "30px");
CellTable<RichResource> table;
// perun / vo admin can set attributes
if (session.isVoAdmin(group.getVoId()) || session.isVoObserver(group.getVoId())) {
table = resources.getTable(new FieldUpdater<RichResource, String>() {
public void update(int index, RichResource object, String value) {
session.getTabManager().addTab(new ResourceDetailTabItem(object, 0));
}
});
} else {
table = resources.getTable();
}
removeButton.setEnabled(false);
if (session.isGroupAdmin(groupId) || session.isVoAdmin(group.getVoId()))
JsonUtils.addTableManagedButton(resources, table, removeButton);
table.addStyleName("perun-table");
table.setWidth("100%");
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 GroupRelationsTabItem method draw.
@Override
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": unions");
// 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 unions.</h2>"));
this.contentWidget.setWidget(vp);
return getWidget();
}
final GetGroupUnions unions = new GetGroupUnions(group, false);
// Events for reloading when group is created
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(unions);
// menu
TabMenu menu = new TabMenu();
final CheckBox subGroupsCheckBox = new CheckBox("Show sub-groups");
final ListBox reverseDropdown = new ListBox();
reverseDropdown.addItem("Normal");
reverseDropdown.addItem("Reverse");
reverseDropdown.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
switch(reverseDropdown.getSelectedIndex()) {
case 1:
unions.setReverseAndRefresh(true);
subGroupsCheckBox.setVisible(false);
break;
default:
unions.setReverseAndRefresh(false);
subGroupsCheckBox.setVisible(true);
}
}
});
menu.addWidget(UiElements.getRefreshButton(this));
CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addGroupUnion(), new ClickHandler() {
public void onClick(ClickEvent event) {
// creates a new form
session.getTabManager().addTabToCurrentTab(new AddGroupUnionTabItem(group), true);
}
});
if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId())) {
createButton.setEnabled(false);
unions.setCheckable(false);
}
menu.addWidget(createButton);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeGroupUnion());
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<Group> itemsToRemove = unions.getTableSelectedList();
String text = "Following group unions will be deleted.";
UiElements.showDeleteConfirm(itemsToRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
RemoveGroupUnions request = new RemoveGroupUnions(JsonCallbackEvents.disableButtonEvents(removeButton, events));
if (unions.isReverse()) {
request.deleteGroupUnions(itemsToRemove, group);
} else {
request.deleteGroupUnions(group, itemsToRemove);
}
}
});
}
});
menu.addWidget(removeButton);
// filter box
final ExtendedSuggestBox box = new ExtendedSuggestBox(unions.getOracle());
menu.addFilterWidget(box, new PerunSearchEvent() {
public void searchFor(String text) {
unions.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterGroup());
subGroupsCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
unions.setShowSubgroupsAndRefresh(valueChangeEvent.getValue(), box.getSuggestBox().getText());
}
});
menu.addWidget(new HTML("<strong>Direction: </strong>"));
menu.addWidget(reverseDropdown);
menu.addWidget(subGroupsCheckBox);
// add menu to the main panel
vp.add(menu);
vp.setCellHeight(menu, "30px");
CellTable<Group> table = unions.getTable(new FieldUpdater<Group, String>() {
@Override
public void update(int arg0, Group group, String arg2) {
if (session.isGroupAdmin(group.getId()) || session.isVoAdmin(group.getId())) {
session.getTabManager().addTab(new GroupDetailTabItem(group.getId()));
} else {
UiElements.generateInfo("Not privileged", "You are not manager of selected group or its VO.");
}
}
});
removeButton.setEnabled(false);
if (session.isGroupAdmin(groupId) || session.isVoAdmin(group.getVoId()))
JsonUtils.addTableManagedButton(unions, 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();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class ResourceAssignedGroupsTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(resource.getName()) + ": manage assigned groups");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
final GetAssignedGroups resourceGroups = new GetAssignedGroups(resourceId);
final JsonCallbackEvents localEvents = JsonCallbackEvents.refreshTableEvents(resourceGroups);
CustomButton assignGroupButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.assignGroupToResource(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AssignGroupTabItem(resource), true);
}
});
final CustomButton removeGroupButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeGroupFromResource());
removeGroupButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<Group> groupsForRemoving = resourceGroups.getTableSelectedList();
String text = "Following groups will be removed from resource.";
UiElements.showDeleteConfirm(groupsForRemoving, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
RemoveGroupsFromResource request = new RemoveGroupsFromResource(JsonCallbackEvents.disableButtonEvents(removeGroupButton, localEvents));
request.removeGroupsFromResource(groupsForRemoving, resource);
}
});
}
});
if (!session.isVoAdmin(resource.getVoId())) {
resourceGroups.setCheckable(false);
assignGroupButton.setEnabled(false);
}
menu.addWidget(assignGroupButton);
menu.addWidget(removeGroupButton);
menu.addFilterWidget(new ExtendedSuggestBox(resourceGroups.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
resourceGroups.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterGroup());
// display menu to vo admin only
if (session.isVoAdmin(resource.getVoId())) {
resourceGroups.setCheckable(true);
vp.add(menu);
vp.setCellHeight(menu, "30px");
} else {
resourceGroups.setCheckable(false);
}
// table with field updater which leads to group detail
CellTable<Group> table = resourceGroups.getTable(new FieldUpdater<Group, String>() {
public void update(int index, Group object, String value) {
session.getTabManager().addTab(new GroupDetailTabItem(object));
}
});
removeGroupButton.setEnabled(false);
if (session.isVoAdmin(resource.getVoId()))
JsonUtils.addTableManagedButton(resourceGroups, table, removeGroupButton);
table.addStyleName("perun-table");
table.setWidth("100%");
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 VoExtSourcesTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": " + "ext sources");
// main panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu menu = new TabMenu();
// refresh
menu.addWidget(UiElements.getRefreshButton(this));
// get VO resources
final GetVoExtSources extSources = new GetVoExtSources(voId);
// refresh table event
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(extSources);
// create ext source button
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addExtSource(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddVoExtSourceTabItem(voId), true);
}
});
menu.addWidget(addButton);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeExtSource());
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<ExtSource> extSourcesToRemove = extSources.getTableSelectedList();
String text = "Following external sources will be removed from VO. You won't be able to import members from them anymore.";
UiElements.showDeleteConfirm(extSourcesToRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < extSourcesToRemove.size(); i++) {
RemoveExtSource request;
if (i == extSourcesToRemove.size() - 1) {
request = new RemoveExtSource(JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new RemoveExtSource(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.removeVoExtSource(voId, extSourcesToRemove.get(i).getId());
}
}
});
}
});
menu.addWidget(removeButton);
// authorization - enable buttons for perun admin only.
if (!session.isPerunAdmin()) {
addButton.setEnabled(false);
removeButton.setEnabled(false);
extSources.setCheckable(false);
}
menu.addFilterWidget(new ExtendedSuggestBox(extSources.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
extSources.filterTable(text);
}
}, "Filter external sources by name or type");
// add menu to the main panel
vp.add(menu);
vp.setCellHeight(menu, "30px");
CellTable<ExtSource> table = extSources.getTable();
if (session.isPerunAdmin()) {
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(extSources, table, removeButton);
}
table.addStyleName("perun-table");
table.setWidth("100%");
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 VosSelectTabItem method draw.
public Widget draw() {
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// Get vos request
final GetVos getVos = new GetVos();
getVos.setCheckable(false);
TabMenu tabMenu = new TabMenu();
tabMenu.addWidget(UiElements.getRefreshButton(this));
// add menu to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
if (session.isVoAdmin()) {
// do not display to VO observer
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createVo(), new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateVoTabItem());
}
}));
}
// filter
tabMenu.addFilterWidget(new ExtendedSuggestBox(getVos.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
getVos.filterTable(text);
}
}, buttonTranslation.filterVo());
tabMenu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
tabMenu.addWidget(new HTML("<strong>Please select VO you want to manage.</strong>"));
final TabItem tab = this;
// get the table with custom onclick
CellTable<VirtualOrganization> table = getVos.getTable(new FieldUpdater<VirtualOrganization, VirtualOrganization>() {
@Override
public void update(int i, VirtualOrganization virtualOrganization, VirtualOrganization virtualOrganization2) {
session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
session.getTabManager().closeTab(tab, false);
}
});
// 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();
}
Aggregations