Search in sources :

Example 1 with VirtualOrganization

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

the class GetAllowedGroups method getEmptyTable.

/**
	 * Returns table with groups in hierarchical structure and with custom field updater
	 *
	 * @return table widget
	 */
public CellTable<Group> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<Group>(list);
    // Cell table
    table = new PerunTable<Group>(list);
    table.setHyperlinksAllowed(false);
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<Group> columnSortHandler = new ListHandler<Group>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Group>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("No groups are allowed to access/use this facility.");
    if (checkable) {
        table.addCheckBoxColumn();
    }
    table.addIdColumn("Group ID", tableFieldUpdater);
    table.addNameColumn(tableFieldUpdater);
    table.addDescriptionColumn(tableFieldUpdater);
    Column<Group, String> vosColumn = new Column<Group, String>(new CustomClickableTextCell()) {

        @Override
        public String getValue(Group group) {
            for (VirtualOrganization v : vos) {
                if (group.getVoId() == v.getId()) {
                    return v.getName();
                }
            }
            return String.valueOf(group.getVoId());
        }
    };
    vosColumn.setFieldUpdater(tableFieldUpdater);
    columnSortHandler.setComparator(vosColumn, new Comparator<Group>() {

        @Override
        public int compare(Group o1, Group o2) {
            return o1.getVoId() - o2.getVoId();
        }
    });
    vosColumn.setSortable(true);
    table.addColumn(vosColumn, "Virtual organization");
    return table;
}
Also used : CustomClickableTextCell(cz.metacentrum.perun.webgui.widgets.cells.CustomClickableTextCell) Group(cz.metacentrum.perun.webgui.model.Group) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) Column(com.google.gwt.user.cellview.client.Column) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization)

Example 2 with VirtualOrganization

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

the class CreateFacilityResourceTabItem method draw.

public Widget draw() {
    titleWidget.setText("Create resource");
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // form inputs
    final ExtendedTextBox nameTextBox = new ExtendedTextBox();
    final TextBox descriptionTextBox = new TextBox();
    final ListBoxWithObjects<VirtualOrganization> vosDropDown = new ListBoxWithObjects<VirtualOrganization>();
    // send button
    final CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createResource());
    // local events fills the listbox of Vos and Slds
    JsonCallbackEvents event = new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // fill VOs listbox
            vosDropDown.clear();
            ArrayList<VirtualOrganization> vos = JsonUtils.jsoAsList(jso);
            vos = new TableSorter<VirtualOrganization>().sortByName(vos);
            for (VirtualOrganization vo : vos) {
                vosDropDown.addItem(vo);
            }
            if (!vos.isEmpty())
                createButton.setEnabled(true);
        }

        @Override
        public void onLoadingStart() {
            vosDropDown.clear();
            vosDropDown.addItem("Loading...");
            createButton.setEnabled(false);
        }

        @Override
        public void onError(PerunError error) {
            vosDropDown.clear();
            vosDropDown.addItem("Error while loading");
            createButton.setEnabled(false);
        }
    };
    // load available VOs
    final GetVos vos = new GetVos(event);
    vos.setForceAll(true);
    vos.retrieveData();
    // layout
    FlexTable layout = new FlexTable();
    layout.setStyleName("inputFormFlexTable");
    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
    // Add some standard form options
    layout.setHTML(0, 0, "On facility:");
    layout.setHTML(0, 1, facility.getName());
    layout.setHTML(1, 0, "For VO:");
    layout.setWidget(1, 1, vosDropDown);
    layout.setHTML(2, 0, "Name:");
    layout.setWidget(2, 1, nameTextBox);
    layout.setHTML(3, 0, "Description:");
    layout.setWidget(3, 1, descriptionTextBox);
    for (int i = 0; i < layout.getRowCount(); i++) {
        cellFormatter.addStyleName(i, 0, "itemName");
    }
    layout.setWidth("350px");
    TabMenu menu = new TabMenu();
    final ExtendedTextBox.TextBoxValidator validator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (nameTextBox.getTextBox().getText().trim().isEmpty()) {
                nameTextBox.setError("Name can't be empty.");
                return false;
            }
            nameTextBox.setOk();
            return true;
        }
    };
    nameTextBox.setValidator(validator);
    createButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            // loads new tab when creating successful, also disable button
            JsonCallbackEvents localEvents = new JsonCallbackEvents() {

                public void onLoadingStart() {
                    (JsonCallbackEvents.disableButtonEvents(createButton)).onLoadingStart();
                }

                public void onFinished(JavaScriptObject jso) {
                    (JsonCallbackEvents.disableButtonEvents(createButton)).onFinished(jso);
                    Resource res = (Resource) jso;
                    session.getTabManager().addTabToCurrentTab(new CreateFacilityResourceManageServicesTabItem(facility, res), true);
                }

                public void onError(PerunError error) {
                    (JsonCallbackEvents.disableButtonEvents(createButton)).onError(error);
                }
            };
            if (validator.validateTextBox()) {
                // request
                CreateResource request = new CreateResource(localEvents);
                request.createResource(nameTextBox.getTextBox().getText().trim(), descriptionTextBox.getText().trim(), facility.getId(), vosDropDown.getSelectedObject().getId());
            }
        }
    });
    menu.addWidget(createButton);
    final TabItem tab = this;
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    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) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) ListBoxWithObjects(cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) CreateResource(cz.metacentrum.perun.webgui.json.resourcesManager.CreateResource) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ImageResource(com.google.gwt.resources.client.ImageResource) Resource(cz.metacentrum.perun.webgui.model.Resource) CreateResource(cz.metacentrum.perun.webgui.json.resourcesManager.CreateResource) GetVos(cz.metacentrum.perun.webgui.json.vosManager.GetVos) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) 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) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 3 with VirtualOrganization

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

the class StatisticsTabItem method draw.

public Widget draw() {
    // PAGE CONTENTS
    ScrollPanel scroll = new ScrollPanel();
    final VerticalPanel vp = new VerticalPanel();
    vp.setStyleName("perun-table");
    vp.setSpacing(5);
    scroll.setWidget(vp);
    scroll.setStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(scroll, 350, this);
    final DisclosurePanel vosStatistics = new DisclosurePanel();
    vosStatistics.setWidth("100%");
    //vosStatistics.setOpen(true);
    FlexTable vosHeader = new FlexTable();
    vosHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.buildingIcon()));
    vosHeader.setWidget(0, 1, new HTML("<h3>Virtual Organizations</h3>"));
    vosHeader.setTitle("Click to show/hide VOs statistics");
    vosStatistics.setHeader(vosHeader);
    vp.add(vosStatistics);
    // the general statistics table
    final FlexTable statisticsTable = new FlexTable();
    statisticsTable.addStyleName("statisticsTable");
    // the VOs table
    final FlexTable vosTable = new FlexTable();
    vosTable.addStyleName("statisticsTable");
    vosTable.setWidget(0, 0, new HTML("<strong>" + "VO name" + "</strong>"));
    vosTable.setWidget(0, 1, new HTML("<strong>" + "Members" + "</strong>"));
    vosTable.setWidget(0, 2, new HTML("<strong>" + "Valid members" + "</strong>"));
    vosTable.setWidget(0, 3, new HTML("<strong>" + "Invalid members" + "</strong>"));
    vosTable.setWidget(0, 4, new HTML("<strong>" + "Suspended members" + "</strong>"));
    vosTable.setWidget(0, 5, new HTML("<strong>" + "Expired members" + "</strong>"));
    vosTable.setWidget(0, 6, new HTML("<strong>" + "Disabled members" + "</strong>"));
    vosTable.setWidget(0, 7, new HTML("<strong>" + "Groups" + "</strong>"));
    vosTable.setWidget(0, 8, new HTML("<strong>" + "Resources" + "</strong>"));
    // vos events - adds the VOs to the table and calls how many members the VO has
    JsonCallbackEvents vosEvents = new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            // conversion
            ArrayList<VirtualOrganization> vos = JsonUtils.jsoAsList(jso);
            vos = new TableSorter<VirtualOrganization>().sortByName(vos);
            // iterating VOs
            for (int i = 0; i < vos.size(); i++) {
                VirtualOrganization vo = vos.get(i);
                // call the request for number of members
                GetMembersCount countMembers = new GetMembersCount(vo.getId(), null);
                countMembers.retrieveData();
                GetMembersCount countValidMembers = new GetMembersCount(vo.getId(), PerunStatus.VALID);
                countValidMembers.retrieveData();
                GetMembersCount countInvalidMembers = new GetMembersCount(vo.getId(), PerunStatus.INVALID);
                countInvalidMembers.retrieveData();
                GetMembersCount countSuspendedMembers = new GetMembersCount(vo.getId(), PerunStatus.SUSPENDED);
                countSuspendedMembers.retrieveData();
                GetMembersCount countExpiredMembers = new GetMembersCount(vo.getId(), PerunStatus.EXPIRED);
                countExpiredMembers.retrieveData();
                GetMembersCount countDisabledMembers = new GetMembersCount(vo.getId(), PerunStatus.DISABLED);
                countDisabledMembers.retrieveData();
                // call the request for number of resources
                GetResourcesCount countResources = new GetResourcesCount(vo.getId());
                countResources.retrieveData();
                GetGroupsCount countGroups = new GetGroupsCount(vo.getId());
                countGroups.retrieveData();
                //adds the VO to the table
                vosTable.setText(i + 1, 0, vo.getName());
                vosTable.setWidget(i + 1, 1, countMembers.getMembersCountHyperlink());
                vosTable.setWidget(i + 1, 2, countValidMembers.getMembersCountHyperlink());
                vosTable.setWidget(i + 1, 3, countInvalidMembers.getMembersCountHyperlink());
                vosTable.setWidget(i + 1, 4, countSuspendedMembers.getMembersCountHyperlink());
                vosTable.setWidget(i + 1, 5, countExpiredMembers.getMembersCountHyperlink());
                vosTable.setWidget(i + 1, 6, countDisabledMembers.getMembersCountHyperlink());
                vosTable.setWidget(i + 1, 7, countGroups.getGroupsCountHyperlink());
                vosTable.setWidget(i + 1, 8, countResources.getResourcesCountHyperlink());
            }
        }
    };
    // requests
    final GetVos vos = new GetVos(vosEvents);
    vosHeader.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (vosStatistics.getContent() == null) {
                // retrieve data
                vosStatistics.setContent(vosTable);
                vos.retrieveData();
            }
        }
    });
    this.contentWidget.setWidget(scroll);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) TableSorter(cz.metacentrum.perun.webgui.client.resources.TableSorter) GetGroupsCount(cz.metacentrum.perun.webgui.json.groupsManager.GetGroupsCount) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization) GetVos(cz.metacentrum.perun.webgui.json.vosManager.GetVos) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetMembersCount(cz.metacentrum.perun.webgui.json.membersManager.GetMembersCount) GetResourcesCount(cz.metacentrum.perun.webgui.json.resourcesManager.GetResourcesCount)

Example 4 with VirtualOrganization

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

the class VosSelectTabItem method draw.

public Widget draw() {
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // Get vos request
    final GetVos getVos = new GetVos();
    getVos.setCheckable(false);
    TabMenu tabMenu = new TabMenu();
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    // add menu to the main panel
    firstTabPanel.add(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    if (session.isVoAdmin()) {
        // do not display to VO observer
        tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createVo(), new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                session.getTabManager().addTabToCurrentTab(new CreateVoTabItem());
            }
        }));
    }
    // filter
    tabMenu.addFilterWidget(new ExtendedSuggestBox(getVos.getOracle()), new PerunSearchEvent() {

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

        @Override
        public void update(int i, VirtualOrganization virtualOrganization, VirtualOrganization virtualOrganization2) {
            session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
            session.getTabManager().closeTab(tab, false);
        }
    });
    // 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 : PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) GetVos(cz.metacentrum.perun.webgui.json.vosManager.GetVos) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

Example 5 with VirtualOrganization

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

the class CreateVoTabItem method draw.

public Widget draw() {
    VerticalPanel vp = new VerticalPanel();
    // textboxes which set the class data when updated
    final ExtendedTextBox nameTextBox = new ExtendedTextBox();
    final ExtendedTextBox shortNameTextBox = new ExtendedTextBox();
    nameTextBox.getTextBox().setMaxLength(128);
    shortNameTextBox.getTextBox().setMaxLength(32);
    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;
            }
        }
    };
    final ExtendedTextBox.TextBoxValidator shortNameValidator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (shortNameTextBox.getTextBox().getText().trim().isEmpty()) {
                shortNameTextBox.setError("Short name can't be empty.");
            } else if (!shortNameTextBox.getTextBox().getText().trim().matches(Utils.VO_SHORT_NAME_MATCHER)) {
                shortNameTextBox.setError("Short name can contain only letters, numbers, dash and underscore.");
            } else {
                shortNameTextBox.setOk();
                return true;
            }
            return false;
        }
    };
    nameTextBox.setValidator(nameValidator);
    shortNameTextBox.setValidator(shortNameValidator);
    // 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.createVo());
    createButton.addClickHandler(new ClickHandler() {

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

                @Override
                public void onFinished(JavaScriptObject jso) {
                    // new VO must be editable by user in GUI, because it is already in PERUN
                    VirtualOrganization vo = jso.cast();
                    session.addEditableVo(vo.getId());
                }
            }));
            request.createVo(nameTextBox.getTextBox().getText().trim(), shortNameTextBox.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, "Full name:");
    layout.setWidget(0, 1, nameTextBox);
    layout.setHTML(1, 0, "Short name:");
    layout.setWidget(1, 1, shortNameTextBox);
    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) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) CreateVo(cz.metacentrum.perun.webgui.json.vosManager.CreateVo) 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)

Aggregations

VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)20 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)12 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)12 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)12 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)11 GetVos (cz.metacentrum.perun.webgui.json.vosManager.GetVos)11 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)10 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)10 ArrayList (java.util.ArrayList)8 PerunError (cz.metacentrum.perun.webgui.model.PerunError)7 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)7 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)6 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)6 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)6 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)5 GetAllGroups (cz.metacentrum.perun.webgui.json.groupsManager.GetAllGroups)5 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)4 VoColumnProvider (cz.metacentrum.perun.webgui.json.columnProviders.VoColumnProvider)4 GeneralObject (cz.metacentrum.perun.webgui.model.GeneralObject)4 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)4