Search in sources :

Example 1 with SecurityTeamDetailTabItem

use of cz.metacentrum.perun.webgui.tabs.securitytabs.SecurityTeamDetailTabItem in project perun by CESNET.

the class PerunWebSession method setActiveSecurityTeam.

/**
	 * Sets currently active SecurityTeam (refresh links in menu)
	 *
	 * @param securityTeam SecurityTeam which user is editing now
	 */
public void setActiveSecurityTeam(SecurityTeam securityTeam) {
    this.activeSecurityTeam = securityTeam;
    addObjectToEntitiesHistory(securityTeam.cast());
    getUiElements().getMenu().setMenuTabItem(MainMenu.SECURITY_ADMIN, new SecurityTeamDetailTabItem(securityTeam));
    getUiElements().getMenu().updateLinks(MainMenu.SECURITY_ADMIN);
}
Also used : SecurityTeamDetailTabItem(cz.metacentrum.perun.webgui.tabs.securitytabs.SecurityTeamDetailTabItem)

Example 2 with SecurityTeamDetailTabItem

use of cz.metacentrum.perun.webgui.tabs.securitytabs.SecurityTeamDetailTabItem in project perun by CESNET.

the class FacilitySecurityTeamsTabItem method draw.

public Widget draw() {
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Security teams");
    // main panel
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    final GetAssignedSecurityTeams securityTeams = new GetAssignedSecurityTeams(facilityId);
    // menu
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.assignSecurityTeam(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AssignSecurityTeamTabItem(facility), true);
        }
    }));
    // remove button
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeSelectedSecurityTeams());
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<SecurityTeam> list = securityTeams.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) {
                            RemoveSecurityTeam request = new RemoveSecurityTeam(JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(securityTeams)));
                            request.removeSecurityTeam(facilityId, list.get(i).getId());
                        } else {
                            RemoveSecurityTeam request = new RemoveSecurityTeam(JsonCallbackEvents.disableButtonEvents(removeButton));
                            request.removeSecurityTeam(facilityId, list.get(i).getId());
                        }
                    }
                }
            });
        }
    });
    menu.addWidget(removeButton);
    menu.addFilterWidget(new ExtendedSuggestBox(securityTeams.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            securityTeams.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterSecurityTeam());
    CellTable<SecurityTeam> table;
    if (session.isPerunAdmin() || session.isSecurityAdmin()) {
        table = securityTeams.getTable(new FieldUpdater<SecurityTeam, String>() {

            @Override
            public void update(int index, SecurityTeam object, String value) {
                session.getTabManager().addTab(new SecurityTeamDetailTabItem(object));
            }
        });
    } else {
        table = securityTeams.getTable();
    }
    // 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(menu);
    firstTabPanel.setCellHeight(menu, "30px");
    firstTabPanel.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : RemoveSecurityTeam(cz.metacentrum.perun.webgui.json.facilitiesManager.RemoveSecurityTeam) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) RemoveSecurityTeam(cz.metacentrum.perun.webgui.json.facilitiesManager.RemoveSecurityTeam) GetAssignedSecurityTeams(cz.metacentrum.perun.webgui.json.facilitiesManager.GetAssignedSecurityTeams) SecurityTeamDetailTabItem(cz.metacentrum.perun.webgui.tabs.securitytabs.SecurityTeamDetailTabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Aggregations

SecurityTeamDetailTabItem (cz.metacentrum.perun.webgui.tabs.securitytabs.SecurityTeamDetailTabItem)2 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 GetAssignedSecurityTeams (cz.metacentrum.perun.webgui.json.facilitiesManager.GetAssignedSecurityTeams)1 RemoveSecurityTeam (cz.metacentrum.perun.webgui.json.facilitiesManager.RemoveSecurityTeam)1 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)1 ArrayList (java.util.ArrayList)1