use of cz.metacentrum.perun.webgui.model.Owner in project perun by CESNET.
the class FacilityOwnersTabItem method draw.
public Widget draw() {
// TITLE
titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Owners");
// CONTENT
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// MENU
TabMenu menu = new TabMenu();
// CALLBACK
final GetFacilityOwners jsonCallback = new GetFacilityOwners(facility);
// AUTHZ
vp.add(menu);
vp.setCellHeight(menu, "30px");
menu.addWidget(UiElements.getRefreshButton(this));
// add button
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addNewOwners());
addButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddFacilityOwnerTabItem(facility), true);
}
});
// remove button
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeSelectedOwners());
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<Owner> list = jsonCallback.getTableSelectedList();
UiElements.showDeleteConfirm(list, 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) {
RemoveOwner request = new RemoveOwner(JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(jsonCallback)));
request.removeFacilityOwner(facilityId, list.get(i).getId());
} else {
RemoveOwner request = new RemoveOwner(JsonCallbackEvents.disableButtonEvents(removeButton));
request.removeFacilityOwner(facilityId, list.get(i).getId());
}
}
}
});
}
});
menu.addWidget(addButton);
menu.addWidget(removeButton);
menu.addFilterWidget(new ExtendedSuggestBox(jsonCallback.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
jsonCallback.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterOwners());
// TABLE
CellTable<Owner> table = jsonCallback.getTable();
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(jsonCallback, table, removeButton);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.model.Owner in project perun by CESNET.
the class GetOwners method setList.
public void setList(ArrayList<Owner> list) {
clearTable();
this.list.addAll(list);
for (Owner o : list) {
oracle.add(o.getName());
oracle.add(o.getContact());
oracle.add(Owner.getTranslatedType(o.getType()));
}
dataProvider.flush();
dataProvider.refresh();
}
use of cz.metacentrum.perun.webgui.model.Owner in project perun by CESNET.
the class GetOwners method filterTable.
@Override
public void filterTable(String filter) {
// store list only for first time
if (backupList.isEmpty() || backupList == null) {
backupList.addAll(list);
}
// always clear selected items
selectionModel.clear();
list.clear();
if (filter.equalsIgnoreCase("")) {
list.addAll(backupList);
} else {
for (Owner o : backupList) {
// store owner by filter
if (o.getName().toLowerCase().contains(filter.toLowerCase()) || o.getContact().toLowerCase().contains(filter.toLowerCase()) || Owner.getTranslatedType(o.getType()).toLowerCase().startsWith(Owner.getTranslatedType(filter).toLowerCase())) {
list.add(o);
}
}
}
if (list.isEmpty() && !filter.isEmpty()) {
loaderImage.setEmptyResultMessage("No owner matching '" + filter + "' found.");
} else {
loaderImage.setEmptyResultMessage("No owners defined in Perun.");
}
loaderImage.loadingFinished();
dataProvider.flush();
dataProvider.refresh();
}
use of cz.metacentrum.perun.webgui.model.Owner in project perun by CESNET.
the class GetFacilities method setList.
public void setList(ArrayList<Facility> list) {
clearTable();
this.list.addAll(list);
for (Facility object : list) {
oracle.add(object.getName());
if (provideRich) {
// fill oracle with technical owners
JsArray<Owner> owners = object.getOwners();
for (int n = 0; n < owners.length(); n++) {
if ("technical".equals(owners.get(n).getType())) {
oracle.add(owners.get(n).getName());
}
}
}
}
dataProvider.flush();
dataProvider.refresh();
}
use of cz.metacentrum.perun.webgui.model.Owner in project perun by CESNET.
the class OwnersTabItem method draw.
public Widget draw() {
// tab content
final VerticalPanel mainTab = new VerticalPanel();
mainTab.setSize("100%", "100%");
// horizontal menu
TabMenu tabMenu = new TabMenu();
tabMenu.addWidget(UiElements.getRefreshButton(this));
final GetOwners owners = new GetOwners();
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(owners);
// create button
tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createOwner(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateOwnerTabItem());
}
}));
// remove button
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteOwner());
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<Owner> itemsToRemove = owners.getTableSelectedList();
String text = "Following owners will be removed.";
UiElements.showDeleteConfirm(itemsToRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < itemsToRemove.size(); i++) {
DeleteOwner request;
if (i == itemsToRemove.size() - 1) {
request = new DeleteOwner(JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new DeleteOwner(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.deleteOwner(itemsToRemove.get(i).getId());
}
}
});
}
});
tabMenu.addWidget(removeButton);
tabMenu.addFilterWidget(new ExtendedSuggestBox(owners.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
owners.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterOwners());
// adding menu to the page
mainTab.add(tabMenu);
mainTab.setCellHeight(tabMenu, "30px");
CellTable<Owner> table = owners.getTable();
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel();
sp.add(table);
sp.addStyleName("perun-tableScrollPanel");
mainTab.add(sp);
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(owners, table, removeButton);
// resize perun table to correct size on screen
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(mainTab);
return getWidget();
}
Aggregations