Search in sources :

Example 1 with Owner

use of cz.metacentrum.perun.webgui.model.Owner in project perun by CESNET.

the class GetFacilityOwners 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();
}
Also used : Owner(cz.metacentrum.perun.webgui.model.Owner)

Example 2 with Owner

use of cz.metacentrum.perun.webgui.model.Owner in project perun by CESNET.

the class GetFacilityOwners 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 facility owner matching '" + filter + "' found.");
    } else {
        loaderImage.setEmptyResultMessage("Facility has no owners.");
    }
    loaderImage.loadingFinished();
    dataProvider.flush();
    dataProvider.refresh();
}
Also used : Owner(cz.metacentrum.perun.webgui.model.Owner)

Example 3 with Owner

use of cz.metacentrum.perun.webgui.model.Owner in project perun by CESNET.

the class GetOwners method onFinished.

/**
	 * Called when loading successfully finishes.
	 */
public void onFinished(JavaScriptObject jso) {
    if (type.isEmpty()) {
        // don't filter
        setList(JsonUtils.<Owner>jsoAsList(jso));
    } else {
        // filter
        for (Owner o : JsonUtils.<Owner>jsoAsList(jso)) {
            if (type.equalsIgnoreCase(o.getType())) {
                addToTable(o);
            }
        }
    }
    sortTable();
    loaderImage.loadingFinished();
    session.getUiElements().setLogText("Owners loaded: " + list.size());
    events.onFinished(jso);
}
Also used : Owner(cz.metacentrum.perun.webgui.model.Owner)

Example 4 with Owner

use of cz.metacentrum.perun.webgui.model.Owner 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)

Example 5 with Owner

use of cz.metacentrum.perun.webgui.model.Owner 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

Owner (cz.metacentrum.perun.webgui.model.Owner)10 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)4 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)4 ArrayList (java.util.ArrayList)4 GetOwners (cz.metacentrum.perun.webgui.json.ownersManager.GetOwners)3 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)3 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)2 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)2 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 CreateThanks (cz.metacentrum.perun.webgui.json.cabinetManager.CreateThanks)1 AddOwner (cz.metacentrum.perun.webgui.json.facilitiesManager.AddOwner)1 GetFacilityOwners (cz.metacentrum.perun.webgui.json.facilitiesManager.GetFacilityOwners)1 RemoveOwner (cz.metacentrum.perun.webgui.json.facilitiesManager.RemoveOwner)1 DeleteOwner (cz.metacentrum.perun.webgui.json.ownersManager.DeleteOwner)1 Facility (cz.metacentrum.perun.webgui.model.Facility)1