Search in sources :

Example 1 with AddOwner

use of cz.metacentrum.perun.webgui.json.facilitiesManager.AddOwner in project perun by CESNET.

the class AddFacilityOwnerTabItem method draw.

public Widget draw() {
    // TITLE
    titleWidget.setText("Add owner");
    // MAIN TAB PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu tabMenu = new TabMenu();
    // CALLBACK
    final GetOwners owners = new GetOwners();
    CellTable<Owner> table = owners.getTable();
    // ADD BUTTON
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addOwners());
    // tab to be closed
    final TabItem tab = this;
    addButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            // get
            ArrayList<Owner> list = owners.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                for (int i = 0; i < list.size(); i++) {
                    if (i == list.size() - 1) {
                        AddOwner request = new AddOwner(JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab));
                        request.addOwner(facilityId, list.get(i).getId());
                    } else {
                        AddOwner request = new AddOwner(JsonCallbackEvents.disableButtonEvents(addButton));
                        request.addOwner(facilityId, list.get(i).getId());
                    }
                }
            }
        }
    });
    tabMenu.addWidget(addButton);
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    tabMenu.addFilterWidget(new ExtendedSuggestBox(owners.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            owners.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterOwners());
    addButton.setEnabled(false);
    JsonUtils.addTableManagedButton(owners, table, addButton);
    // 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 menu and the table to the main panel
    firstTabPanel.add(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    firstTabPanel.add(sp);
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : Owner(cz.metacentrum.perun.webgui.model.Owner) AddOwner(cz.metacentrum.perun.webgui.json.facilitiesManager.AddOwner) AddOwner(cz.metacentrum.perun.webgui.json.facilitiesManager.AddOwner) GetOwners(cz.metacentrum.perun.webgui.json.ownersManager.GetOwners) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) 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 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)1 AddOwner (cz.metacentrum.perun.webgui.json.facilitiesManager.AddOwner)1 GetOwners (cz.metacentrum.perun.webgui.json.ownersManager.GetOwners)1 Owner (cz.metacentrum.perun.webgui.model.Owner)1 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)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