Search in sources :

Example 1 with CreateThanks

use of cz.metacentrum.perun.webgui.json.cabinetManager.CreateThanks in project perun by CESNET.

the class CreateThanksTabItem method draw.

public Widget draw() {
    // MAIN PANEL
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // CALLBACK
    final GetOwners owners = new GetOwners();
    // MENU
    TabMenu menu = new TabMenu();
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    // add button
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, "Add acknowledgement for selected owner(s)");
    final TabItem tab = this;
    // click handler
    addButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            ArrayList<Owner> list = owners.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                for (int i = 0; i < list.size(); i++) {
                    final String name = list.get(i).getName();
                    // add name events
                    JsonCallbackEvents thanksEvents = new JsonCallbackEvents() {

                        public void onFinished(JavaScriptObject jso) {
                            updateAlreadyAdded(name);
                        }
                    };
                    // merge with refresh?
                    if (i == list.size() - 1 && events != null) {
                        thanksEvents = JsonCallbackEvents.mergeEvents(thanksEvents, events);
                    }
                    CreateThanks request = new CreateThanks(publicationId, JsonCallbackEvents.disableButtonEvents(addButton, thanksEvents));
                    request.createThanks(list.get(i).getId());
                    if (i == list.size() - 1) {
                        owners.clearTableSelectedSet();
                    }
                }
            }
        }
    });
    menu.addWidget(addButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            // trigger refresh of sub-tab via event
            events.onFinished(null);
            session.getTabManager().closeTab(tab, false);
        }
    }));
    // add already added
    vp.add(alreadyAddedOwners);
    vp.setCellHeight(alreadyAddedOwners, "30px");
    // TABLE
    // show only administrative contacts
    owners.setFilterByType("administrative");
    CellTable<Owner> table = owners.getTable();
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel();
    sp.add(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    // resize small tab panel to correct size on screen
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    addButton.setEnabled(false);
    JsonUtils.addTableManagedButton(owners, table, addButton);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Owner(cz.metacentrum.perun.webgui.model.Owner) GetOwners(cz.metacentrum.perun.webgui.json.ownersManager.GetOwners) 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) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) CreateThanks(cz.metacentrum.perun.webgui.json.cabinetManager.CreateThanks)

Aggregations

JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)1 CreateThanks (cz.metacentrum.perun.webgui.json.cabinetManager.CreateThanks)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 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)1 ArrayList (java.util.ArrayList)1