use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class SecurityTeamBlacklistTabItem method draw.
public Widget draw() {
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(securityTeam.getName()) + ": " + "blacklist");
// Get vos request
final GetBlacklistWithDescription teams = new GetBlacklistWithDescription(PerunEntity.SECURITY_TEAM, securityTeamId);
// Events for reloading when finished
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(teams);
TabMenu tabMenu = new TabMenu();
// add menu to the main panel
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
tabMenu.addWidget(UiElements.getRefreshButton(this));
// do not display to sec admins only
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addUsersToBlacklist(), new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddUserToBlacklistTabItem(securityTeam), true);
}
}));
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, buttonTranslation.removeSelectedUsersFromBlacklist());
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<Pair<User, String>> itemsToRemove = teams.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++) {
RemoveUserFromBlacklist request;
if (i == itemsToRemove.size() - 1) {
request = new RemoveUserFromBlacklist(securityTeamId, JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new RemoveUserFromBlacklist(securityTeamId, JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.removeUserFromBlacklist(itemsToRemove.get(i).getLeft().getId());
}
}
});
}
});
tabMenu.addWidget(removeButton);
// filter
tabMenu.addFilterWidget(new ExtendedSuggestBox(teams.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
teams.filterTable(text);
}
}, buttonTranslation.filterBlacklist());
final TabItem tab = this;
CellTable<Pair<User, String>> table;
if (session.isPerunAdmin()) {
// get the table with custom onclick
table = teams.getTable(new FieldUpdater<Pair<User, String>, String>() {
@Override
public void update(int i, Pair<User, String> pair, String string) {
session.getTabManager().addTab(new UserDetailTabItem(pair.getLeft()));
session.getTabManager().closeTab(tab, false);
}
});
} else {
table = teams.getTable();
}
// 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 ServicesTabItem method draw.
public Widget draw() {
// create widget for the whole page
VerticalPanel mainTab = new VerticalPanel();
mainTab.setSize("100%", "100%");
// create widget for menu on page
TabMenu tabMenu = new TabMenu();
tabMenu.addWidget(UiElements.getRefreshButton(this));
// get services
final GetServices services = new GetServices();
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(services);
// get the table of services with custom field updater (lines are clickable and open service details)
CellTable<Service> table = services.getTable(new FieldUpdater<Service, String>() {
// when user click on a row -> open new tab
public void update(int index, Service object, String value) {
session.getTabManager().addTab(new ServiceDetailTabItem(object));
}
});
// create button
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createService(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new CreateServiceTabItem());
}
}));
final CustomButton deleteButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteSelectedServices());
deleteButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// get selected items
final ArrayList<Service> itemsToRemove = services.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++) {
DeleteService request;
if (i == itemsToRemove.size() - 1) {
request = new DeleteService(JsonCallbackEvents.disableButtonEvents(deleteButton, events));
} else {
request = new DeleteService(JsonCallbackEvents.disableButtonEvents(deleteButton));
}
request.deleteService(itemsToRemove.get(i).getId());
}
}
});
}
});
tabMenu.addWidget(deleteButton);
tabMenu.addFilterWidget(new ExtendedSuggestBox(services.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
services.filterTable(text);
}
}, "Filter services by name");
// add menu to page itself
mainTab.add(tabMenu);
mainTab.setCellHeight(tabMenu, "30px");
// add styling to table with services
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
mainTab.add(sp);
deleteButton.setEnabled(false);
JsonUtils.addTableManagedButton(services, table, deleteButton);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(mainTab);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class ResourceTagsTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(resource.getName()) + ": manage assigned tags");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
final GetAllResourcesTags tags = new GetAllResourcesTags(PerunEntity.RESOURCE, resourceId);
final JsonCallbackEvents localEvents = JsonCallbackEvents.refreshTableEvents(tags);
CustomButton assignTagsButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.assignTagsToResource(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AssignTagTabItem(resource), true);
}
});
final CustomButton removeTagsButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeSelectedTagsFromResource());
removeTagsButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<ResourceTag> tagsToRemove = tags.getTableSelectedList();
String text = "Following groups will be removed from resource.";
UiElements.showDeleteConfirm(tagsToRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD USE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < tagsToRemove.size(); i++) {
if (i == tagsToRemove.size() - 1) {
RemoveResourceTag request = new RemoveResourceTag(resource.getId(), JsonCallbackEvents.disableButtonEvents(removeTagsButton, localEvents));
request.removeResourceTag(tagsToRemove.get(i));
} else {
RemoveResourceTag request = new RemoveResourceTag(resource.getId(), JsonCallbackEvents.disableButtonEvents(removeTagsButton));
request.removeResourceTag(tagsToRemove.get(i));
}
}
}
});
}
});
if (!session.isVoAdmin(resource.getVoId())) {
assignTagsButton.setEnabled(false);
removeTagsButton.setEnabled(false);
tags.setCheckable(false);
}
menu.addWidget(assignTagsButton);
menu.addWidget(removeTagsButton);
menu.addFilterWidget(new ExtendedSuggestBox(tags.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
tags.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterTags());
// display menu to vo admin only
vp.add(menu);
vp.setCellHeight(menu, "30px");
// table with field updater which leads to group detail
CellTable<ResourceTag> table = tags.getTable();
removeTagsButton.setEnabled(false);
JsonUtils.addTableManagedButton(tags, table, removeTagsButton);
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 AddRequiredAttributesTabItem method draw.
public Widget draw() {
titleWidget.setText("Add required attributes");
VerticalPanel mainTab = new VerticalPanel();
mainTab.setSize("100%", "100%");
final GetAttributesDefinition attrDefs = new GetAttributesDefinition();
attrDefs.setEditable(false);
CellTable<AttributeDefinition> table = attrDefs.getTable();
TabMenu menu = new TabMenu();
final TabItem tab = this;
final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedRequiredAttribute());
final ExtendedSuggestBox box = new ExtendedSuggestBox(attrDefs.getOracle());
menu.addFilterWidget(box, new PerunSearchEvent() {
@Override
public void searchFor(String text) {
attrDefs.filterTable(text);
if (attrDefs.getList().size() == 1) {
attrDefs.getSelectionModel().setSelected(attrDefs.getList().get(0), true);
}
}
}, ButtonTranslation.INSTANCE.filterAttributeDefinition());
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<AttributeDefinition> attributesToAdd = attrDefs.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(attributesToAdd)) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
for (int i = 0; i < attributesToAdd.size(); i++) {
final int n = i;
AddRequiredAttribute request = new AddRequiredAttribute(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// unselect added attribute
attrDefs.getSelectionModel().setSelected(attributesToAdd.get(n), false);
alreadyAddedList.add(attributesToAdd.get(n));
rebuildAlreadyAddedWidget();
// clear search
box.getSuggestBox().setText("");
}
}));
request.addRequiredAttribute(serviceId, attributesToAdd.get(i).getId());
}
}
}
});
menu.addWidget(addButton);
// cancel button
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
}
}));
addButton.setEnabled(false);
JsonUtils.addTableManagedButton(attrDefs, table, addButton);
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizeSmallTabPanel(sp, 350, this);
mainTab.add(menu);
mainTab.setCellHeight(menu, "30px");
mainTab.add(alreadyAdded);
mainTab.add(sp);
mainTab.setCellHeight(sp, "100%");
// add tabs to the main panel
this.contentWidget.setWidget(mainTab);
return getWidget();
}
use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.
the class MemberApplicationsTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(member.getUser().getFullNameWithTitles().trim()) + ": applications");
// main widget panel
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
menu.addWidget(UiElements.getRefreshButton(this));
// set proper request
if (session.isVoAdmin(member.getVoId())) {
applicationsRequest = new GetApplicationsForMember(memberId, 0);
} else if (session.isGroupAdmin(groupId)) {
// group admin can see only apps for his group
applicationsRequest = new GetApplicationsForMember(memberId, groupId);
} else if (session.isVoObserver(member.getVoId())) {
applicationsRequest = new GetApplicationsForMember(memberId, 0);
}
applicationsRequest.setCheckable(false);
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(applicationsRequest);
/*
// verify button
final CustomButton verify = TabMenu.getPredefinedButton(ButtonType.VERIFY, ButtonTranslation.INSTANCE.verifyApplication());
verify.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify));
request.verifyApplication(list.get(i).getId());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify, events));
request.verifyApplication(list.get(i).getId());
}
}
}
}
});
// accept button
final CustomButton approve = TabMenu.getPredefinedButton(ButtonType.APPROVE, ButtonTranslation.INSTANCE.approveApplication());
approve.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve));
request.approveApplication(list.get(i));
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve, events));
request.approveApplication(list.get(i));
}
}
}
}
});
//reject button
final CustomButton reject = TabMenu.getPredefinedButton(ButtonType.REJECT, ButtonTranslation.INSTANCE.rejectApplication());
reject.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
// confirm content
FlexTable content = new FlexTable();
content.setCellSpacing(10);
content.setHTML(0, 0, "Please specify reason of rejection to let user know why was application rejected.");
content.getFlexCellFormatter().setColSpan(0, 0, 2);
final TextArea reason = new TextArea();
reason.setSize("300px", "150px");
content.setHTML(1, 0, "<strong>Reason: </strong>");
content.setWidget(1, 1, reason);
Confirm c = new Confirm("Specify reason", content, new ClickHandler(){
public void onClick(ClickEvent event) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject));
request.rejectApplication(list.get(i).getId(), reason.getText());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject, events));
request.rejectApplication(list.get(i).getId(), reason.getText());
}
}
}
}, true);
c.show();
}
}
});
// delete button
final CustomButton delete = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteApplication());
delete.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
ArrayList<Application> list = applicationsRequest.getTableSelectedList();
if (UiElements.cantSaveEmptyListDialogBox(list)) {
for (int i=0; i<list.size(); i++) {
if (i != list.size()-1) {
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete));
request.deleteApplication(list.get(i).getId());
} else {
// refresh table on last call
HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete, events));
request.deleteApplication(list.get(i).getId());
}
}
}
}
});
menu.addWidget(verify);
menu.addWidget(approve);
menu.addWidget(reject);
menu.addWidget(delete);
*/
menu.addFilterWidget(new ExtendedSuggestBox(applicationsRequest.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
applicationsRequest.filterTable(text);
}
}, "Filter by group");
CellTable<Application> table = applicationsRequest.getTable(new FieldUpdater<Application, String>() {
@Override
public void update(int i, Application application, String s) {
session.getTabManager().addTabToCurrentTab(new ApplicationDetailTabItem(application), true);
}
});
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(sp, 350, this);
vp.add(sp);
/*
verify.setEnabled(false);
approve.setEnabled(false);
reject.setEnabled(false);
delete.setEnabled(false);
if (session.isVoAdmin(member.getVoId()) || session.isGroupAdmin(groupId)) {
JsonUtils.addTableManagedButton(applicationsRequest, table, verify);
JsonUtils.addTableManagedButton(applicationsRequest, table, approve);
JsonUtils.addTableManagedButton(applicationsRequest, table, reject);
JsonUtils.addTableManagedButton(applicationsRequest, table, delete);
}
*/
this.contentWidget.setWidget(vp);
return getWidget();
}
Aggregations