Search in sources :

Example 6 with Owner

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();
}
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)

Example 7 with Owner

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

Example 8 with Owner

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

Example 9 with Owner

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

Example 10 with Owner

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();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Owner(cz.metacentrum.perun.webgui.model.Owner) DeleteOwner(cz.metacentrum.perun.webgui.json.ownersManager.DeleteOwner) DeleteOwner(cz.metacentrum.perun.webgui.json.ownersManager.DeleteOwner) 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) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

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