Search in sources :

Example 1 with GetFacilityOwners

use of cz.metacentrum.perun.webgui.json.facilitiesManager.GetFacilityOwners 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();
}
Also used : Owner(cz.metacentrum.perun.webgui.model.Owner) RemoveOwner(cz.metacentrum.perun.webgui.json.facilitiesManager.RemoveOwner) RemoveOwner(cz.metacentrum.perun.webgui.json.facilitiesManager.RemoveOwner) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) GetFacilityOwners(cz.metacentrum.perun.webgui.json.facilitiesManager.GetFacilityOwners) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

Aggregations

ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 GetFacilityOwners (cz.metacentrum.perun.webgui.json.facilitiesManager.GetFacilityOwners)1 RemoveOwner (cz.metacentrum.perun.webgui.json.facilitiesManager.RemoveOwner)1 Owner (cz.metacentrum.perun.webgui.model.Owner)1 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)1 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)1 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)1 ArrayList (java.util.ArrayList)1