Search in sources :

Example 1 with SecurityTeam

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

the class GetAssignedSecurityTeams method setList.

public void setList(ArrayList<SecurityTeam> list) {
    clearTable();
    this.list.addAll(list);
    for (SecurityTeam vo : list) {
        oracle.add(vo.getName());
    }
    dataProvider.flush();
    dataProvider.refresh();
}
Also used : SecurityTeam(cz.metacentrum.perun.webgui.model.SecurityTeam)

Example 2 with SecurityTeam

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

the class GetSecurityTeams method setList.

public void setList(ArrayList<SecurityTeam> list) {
    clearTable();
    this.list.addAll(list);
    for (SecurityTeam vo : list) {
        oracle.add(vo.getName());
    }
    dataProvider.flush();
    dataProvider.refresh();
}
Also used : SecurityTeam(cz.metacentrum.perun.webgui.model.SecurityTeam)

Example 3 with SecurityTeam

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

the class GetSecurityTeams method filterTable.

@Override
public void filterTable(String filter) {
    // store list only for first time
    if (fullBackup.isEmpty() || fullBackup == null) {
        fullBackup.addAll(list);
    }
    // always clear selected items
    selectionModel.clear();
    list.clear();
    if (filter.equalsIgnoreCase("")) {
        list.addAll(fullBackup);
    } else {
        for (SecurityTeam vo : fullBackup) {
            // store facility by filter
            if (vo.getName().toLowerCase().contains(filter.toLowerCase())) {
                list.add(vo);
            }
        }
    }
    if (list.isEmpty() && !filter.isEmpty()) {
        loaderImage.setEmptyResultMessage("No Security Team matching '" + filter + "' found.");
    } else {
        if (forceAll) {
            loaderImage.setEmptyResultMessage("No Security Teams found.");
        } else {
            loaderImage.setEmptyResultMessage("You are not member of any Security Team.");
        }
    }
    dataProvider.flush();
    dataProvider.refresh();
    loaderImage.loadingFinished();
}
Also used : SecurityTeam(cz.metacentrum.perun.webgui.model.SecurityTeam)

Example 4 with SecurityTeam

use of cz.metacentrum.perun.webgui.model.SecurityTeam 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));
                        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, false);
        }
    }));
    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)

Example 5 with SecurityTeam

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

the class CreateSecurityTeamTabItem method draw.

public Widget draw() {
    VerticalPanel vp = new VerticalPanel();
    // textboxes which set the class data when updated
    final ExtendedTextBox nameTextBox = new ExtendedTextBox();
    final ExtendedTextBox descriptionTextBox = new ExtendedTextBox();
    nameTextBox.getTextBox().setMaxLength(128);
    final ExtendedTextBox.TextBoxValidator nameValidator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (!nameTextBox.getTextBox().getText().trim().isEmpty()) {
                nameTextBox.setOk();
                return true;
            } else {
                nameTextBox.setError("Name can't be empty.");
                return false;
            }
        }
    };
    nameTextBox.setValidator(nameValidator);
    // prepares layout
    FlexTable layout = new FlexTable();
    layout.setStyleName("inputFormFlexTable");
    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
    // close tab events
    final TabItem tab = this;
    TabMenu menu = new TabMenu();
    // send button
    final CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, buttonTranslation.createSecurityTeam());
    createButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (!nameValidator.validateTextBox())
                return;
            CreateSecurityTeam request = new CreateSecurityTeam(JsonCallbackEvents.closeTabDisableButtonEvents(createButton, tab, new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    // new SecTeam must be editable by user in GUI, because it is already in PERUN
                    SecurityTeam team = jso.cast();
                    session.addEditableSecurityTeam(team.getId());
                }
            }));
            request.createSecurityTeam(nameTextBox.getTextBox().getText().trim(), descriptionTextBox.getTextBox().getText().trim());
        }
    });
    // cancel button
    final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
    cancelButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    });
    // Add some standard form options
    layout.setHTML(0, 0, "Name:");
    layout.setWidget(0, 1, nameTextBox);
    layout.setHTML(1, 0, "Description:");
    layout.setWidget(1, 1, descriptionTextBox);
    for (int i = 0; i < layout.getRowCount(); i++) {
        cellFormatter.addStyleName(i, 0, "itemName");
    }
    menu.addWidget(createButton);
    menu.addWidget(cancelButton);
    vp.add(layout);
    vp.add(menu);
    vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) CreateSecurityTeam(cz.metacentrum.perun.webgui.json.securityTeamsManager.CreateSecurityTeam) SecurityTeam(cz.metacentrum.perun.webgui.model.SecurityTeam) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) CreateSecurityTeam(cz.metacentrum.perun.webgui.json.securityTeamsManager.CreateSecurityTeam) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Aggregations

SecurityTeam (cz.metacentrum.perun.webgui.model.SecurityTeam)8 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 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)3 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)3 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)3 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)2 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)2 GetSecurityTeams (cz.metacentrum.perun.webgui.json.securityTeamsManager.GetSecurityTeams)2 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)2 ArrayList (java.util.ArrayList)2 AssignSecurityTeam (cz.metacentrum.perun.webgui.json.facilitiesManager.AssignSecurityTeam)1 CreateSecurityTeam (cz.metacentrum.perun.webgui.json.securityTeamsManager.CreateSecurityTeam)1 DeleteSecurityTeam (cz.metacentrum.perun.webgui.json.securityTeamsManager.DeleteSecurityTeam)1 UpdateSecurityTeam (cz.metacentrum.perun.webgui.json.securityTeamsManager.UpdateSecurityTeam)1 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)1