Search in sources :

Example 1 with GetSecurityTeams

use of cz.metacentrum.perun.webgui.json.securityTeamsManager.GetSecurityTeams in project perun by CESNET.

the class SecurityTeamSelectTabItem method draw.

public Widget draw() {
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // Get vos request
    final GetSecurityTeams teams = new GetSecurityTeams();
    if (!session.isPerunAdmin()) {
        teams.setCheckable(false);
    }
    // Events for reloading when finished
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(teams);
    TabMenu tabMenu = new TabMenu();
    // add menu to the main panel
    firstTabPanel.add(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createSecurityTeam(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new CreateSecurityTeamTabItem());
        }
    }));
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, buttonTranslation.deleteSecurityTeam());
    removeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<SecurityTeam> itemsToRemove = teams.getTableSelectedList();
            UiElements.showDeleteConfirm(itemsToRemove, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < itemsToRemove.size(); i++) {
                        DeleteSecurityTeam request;
                        if (i == itemsToRemove.size() - 1) {
                            request = new DeleteSecurityTeam(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        } else {
                            request = new DeleteSecurityTeam(JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.deleteSecurityTeam(itemsToRemove.get(i).getId(), false);
                    }
                }
            });
        }
    });
    tabMenu.addWidget(removeButton);
    // filter
    tabMenu.addFilterWidget(new ExtendedSuggestBox(teams.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            teams.filterTable(text);
        }
    }, buttonTranslation.filterSecurityTeam());
    tabMenu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
    tabMenu.addWidget(new HTML("<strong>Please select Team you want to manage.</strong>"));
    final TabItem tab = this;
    // get the table with custom onclick
    CellTable<SecurityTeam> table = teams.getTable(new FieldUpdater<SecurityTeam, String>() {

        @Override
        public void update(int i, SecurityTeam securityTeam, String string) {
            session.getTabManager().addTab(new SecurityTeamDetailTabItem(securityTeam));
            session.getTabManager().closeTab(tab, isRefreshParentOnClose());
        }
    });
    // 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 the table to the main panel
    firstTabPanel.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, 0, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) GetSecurityTeams(cz.metacentrum.perun.webgui.json.securityTeamsManager.GetSecurityTeams) SecurityTeam(cz.metacentrum.perun.webgui.model.SecurityTeam) DeleteSecurityTeam(cz.metacentrum.perun.webgui.json.securityTeamsManager.DeleteSecurityTeam) DeleteSecurityTeam(cz.metacentrum.perun.webgui.json.securityTeamsManager.DeleteSecurityTeam) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 2 with GetSecurityTeams

use of cz.metacentrum.perun.webgui.json.securityTeamsManager.GetSecurityTeams in project perun by CESNET.

the class AssignSecurityTeamTabItem method draw.

public Widget draw() {
    // TITLE
    titleWidget.setText("Add security team");
    // MAIN TAB PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu tabMenu = new TabMenu();
    // CALLBACK
    final GetSecurityTeams secTeams = new GetSecurityTeams();
    secTeams.setEvents(new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            if (secTeams.getList().size() == 1) {
                secTeams.getSelectionModel().setSelected(secTeams.getList().get(0), true);
            }
        }
    });
    secTeams.setForceAll(true);
    CellTable<SecurityTeam> table = secTeams.getTable();
    // ADD BUTTON
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignSecurityTeam());
    // tab to be closed
    final TabItem tab = this;
    addButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            // get
            ArrayList<SecurityTeam> list = secTeams.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) {
                        AssignSecurityTeam request = new AssignSecurityTeam(JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab, true));
                        request.assignSecurityTeam(facilityId, list.get(i).getId());
                    } else {
                        AssignSecurityTeam request = new AssignSecurityTeam(JsonCallbackEvents.disableButtonEvents(addButton));
                        request.assignSecurityTeam(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, isRefreshParentOnClose());
        }
    }));
    tabMenu.addFilterWidget(new ExtendedSuggestBox(secTeams.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            secTeams.filterTable(text);
            if (secTeams.getList().size() == 1) {
                secTeams.getSelectionModel().setSelected(secTeams.getList().get(0), true);
            }
        }
    }, ButtonTranslation.INSTANCE.filterSecurityTeam());
    addButton.setEnabled(false);
    JsonUtils.addTableManagedButton(secTeams, 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 : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) GetSecurityTeams(cz.metacentrum.perun.webgui.json.securityTeamsManager.GetSecurityTeams) AssignSecurityTeam(cz.metacentrum.perun.webgui.json.facilitiesManager.AssignSecurityTeam) SecurityTeam(cz.metacentrum.perun.webgui.model.SecurityTeam) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) AssignSecurityTeam(cz.metacentrum.perun.webgui.json.facilitiesManager.AssignSecurityTeam) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

Aggregations

ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)2 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)2 GetSecurityTeams (cz.metacentrum.perun.webgui.json.securityTeamsManager.GetSecurityTeams)2 SecurityTeam (cz.metacentrum.perun.webgui.model.SecurityTeam)2 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)2 ArrayList (java.util.ArrayList)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 AssignSecurityTeam (cz.metacentrum.perun.webgui.json.facilitiesManager.AssignSecurityTeam)1 DeleteSecurityTeam (cz.metacentrum.perun.webgui.json.securityTeamsManager.DeleteSecurityTeam)1 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)1 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)1 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)1