Search in sources :

Example 1 with ExtendedSuggestBox

use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.

the class AssignServiceTabItem method draw.

public Widget draw() {
    titleWidget.setText("Assign service");
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // menu
    TabMenu menu = new TabMenu();
    final GetServices services = new GetServices();
    final CellTable<Service> table = services.getEmptyTable(new FieldUpdater<Service, String>() {

        public void update(int index, Service object, String value) {
            session.getTabManager().addTab(new ResourceSettingsTabItem(resource, object));
        }
    });
    // remove already assigned services from offering
    JsonCallbackEvents localEvents = new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            // second callback
            final GetAssignedServices alreadyAssigned = new GetAssignedServices(resourceId, new JsonCallbackEvents() {

                public void onFinished(JavaScriptObject jso) {
                    JsArray<Service> srvToRemove = JsonUtils.jsoAsArray(jso);
                    for (int i = 0; i < srvToRemove.length(); i++) {
                        services.removeFromTable(srvToRemove.get(i));
                    }
                    if (services.getList().size() == 1) {
                        table.getSelectionModel().setSelected(services.getList().get(0), true);
                    }
                }
            });
            alreadyAssigned.retrieveData();
        }
    };
    services.setEvents(localEvents);
    final TabItem tab = this;
    // button
    final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignSelectedServicesToResource());
    assignButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            ArrayList<Service> servicesToAssign = services.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(servicesToAssign)) {
                AssignServices request = new AssignServices(JsonCallbackEvents.closeTabDisableButtonEvents(assignButton, tab, true));
                request.assignService(resourceId, servicesToAssign);
            }
        }
    });
    menu.addWidget(assignButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, isRefreshParentOnClose());
        }
    }));
    menu.addFilterWidget(new ExtendedSuggestBox(services.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            services.filterTable(text);
            if (services.getList().size() == 1) {
                table.getSelectionModel().setSelected(services.getList().get(0), true);
            }
        }
    }, "Filter services by name");
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    services.retrieveData();
    assignButton.setEnabled(false);
    JsonUtils.addTableManagedButton(services, table, assignButton);
    table.addStyleName("perun-table");
    table.setWidth("100%");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JsArray(com.google.gwt.core.client.JsArray) GetAssignedServices(cz.metacentrum.perun.webgui.json.resourcesManager.GetAssignedServices) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) AssignServices(cz.metacentrum.perun.webgui.json.resourcesManager.AssignServices) ArrayList(java.util.ArrayList) Service(cz.metacentrum.perun.webgui.model.Service) GetServices(cz.metacentrum.perun.webgui.json.servicesManager.GetServices) 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) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

Example 2 with ExtendedSuggestBox

use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.

the class ResourceAssignedGroupsTabItem method draw.

public Widget draw() {
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(resource.getName()) + ": manage assigned groups");
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    final GetAssignedGroups resourceGroups = new GetAssignedGroups(resourceId);
    final JsonCallbackEvents localEvents = JsonCallbackEvents.refreshTableEvents(resourceGroups);
    CustomButton assignGroupButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.assignGroupToResource(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AssignGroupTabItem(resource), true);
        }
    });
    final CustomButton removeGroupButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeGroupFromResource());
    removeGroupButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<Group> groupsForRemoving = resourceGroups.getTableSelectedList();
            String text = "Following groups will be removed from resource.";
            UiElements.showDeleteConfirm(groupsForRemoving, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    RemoveGroupsFromResource request = new RemoveGroupsFromResource(JsonCallbackEvents.disableButtonEvents(removeGroupButton, localEvents));
                    request.removeGroupsFromResource(groupsForRemoving, resource);
                }
            });
        }
    });
    if (!session.isVoAdmin(resource.getVoId())) {
        resourceGroups.setCheckable(false);
        assignGroupButton.setEnabled(false);
    }
    menu.addWidget(assignGroupButton);
    menu.addWidget(removeGroupButton);
    menu.addFilterWidget(new ExtendedSuggestBox(resourceGroups.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            resourceGroups.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterGroup());
    // display menu to vo admin only
    if (session.isVoAdmin(resource.getVoId())) {
        resourceGroups.setCheckable(true);
        vp.add(menu);
        vp.setCellHeight(menu, "30px");
    } else {
        resourceGroups.setCheckable(false);
    }
    // table with field updater which leads to group detail
    CellTable<Group> table = resourceGroups.getTable(new FieldUpdater<Group, String>() {

        public void update(int index, Group object, String value) {
            session.getTabManager().addTab(new GroupDetailTabItem(object));
        }
    });
    removeGroupButton.setEnabled(false);
    if (session.isVoAdmin(resource.getVoId()))
        JsonUtils.addTableManagedButton(resourceGroups, table, removeGroupButton);
    table.addStyleName("perun-table");
    table.setWidth("100%");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : GetAssignedGroups(cz.metacentrum.perun.webgui.json.resourcesManager.GetAssignedGroups) JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Group(cz.metacentrum.perun.webgui.model.Group) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) RemoveGroupsFromResource(cz.metacentrum.perun.webgui.json.resourcesManager.RemoveGroupsFromResource) ArrayList(java.util.ArrayList) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) GroupDetailTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

Example 3 with ExtendedSuggestBox

use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.

the class AddAutoRegGroupTabItem method draw.

@Override
public Widget draw() {
    titleWidget.setText("Add group for auto registration");
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // menu
    TabMenu menu = new TabMenu();
    menu.addWidget(new HTML(""));
    final GetAllGroups groups = new GetAllGroups(vo.getId());
    groups.setCoreGroupsCheckable(false);
    // remove already added union groups from offering
    JsonCallbackEvents localEvents = new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // second callback
            final GetAutoRegistrationGroups alreadySet = new GetAutoRegistrationGroups(vo.getId(), new JsonCallbackEvents() {

                public void onFinished(JavaScriptObject jso) {
                    JsArray<Group> esToRemove = JsonUtils.jsoAsArray(jso);
                    for (int i = 0; i < esToRemove.length(); i++) {
                        groups.removeFromTable(esToRemove.get(i));
                    }
                }
            });
            alreadySet.retrieveData();
        }
    };
    groups.setEvents(localEvents);
    final ExtendedSuggestBox box = new ExtendedSuggestBox(groups.getOracle());
    // button
    final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedExtSource());
    final TabItem tab = this;
    assignButton.addClickHandler(event -> {
        final ArrayList<Group> availableGroups = groups.getTableSelectedList();
        if (UiElements.cantSaveEmptyListDialogBox(availableGroups)) {
            AddAutoRegGroups request = new AddAutoRegGroups(JsonCallbackEvents.disableButtonEvents(assignButton, new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    // clear search
                    box.getSuggestBox().setText("");
                    groups.retrieveData();
                }
            }));
            request.setAutoRegGroups(availableGroups);
        }
    });
    menu.addFilterWidget(box, new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            groups.filterTable(text);
        }
    }, "Filter by name");
    menu.addWidget(assignButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", clickEvent -> session.getTabManager().closeTab(tab, isRefreshParentOnClose())));
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    CellTable<Group> table = groups.getTable();
    assignButton.setEnabled(false);
    JsonUtils.addTableManagedButton(groups, table, assignButton);
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    // do not use resizePerunTable() when tab is in overlay - wrong width is calculated
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ImageResource(com.google.gwt.resources.client.ImageResource) SmallIcons(cz.metacentrum.perun.webgui.client.resources.SmallIcons) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) AddAutoRegGroups(cz.metacentrum.perun.webgui.json.registrarManager.AddAutoRegGroups) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) HTML(com.google.gwt.user.client.ui.HTML) GetAllGroups(cz.metacentrum.perun.webgui.json.groupsManager.GetAllGroups) ArrayList(java.util.ArrayList) Label(com.google.gwt.user.client.ui.Label) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel) ButtonTranslation(cz.metacentrum.perun.webgui.client.localization.ButtonTranslation) UiElements(cz.metacentrum.perun.webgui.client.UiElements) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) GetAutoRegistrationGroups(cz.metacentrum.perun.webgui.json.registrarManager.GetAutoRegistrationGroups) Group(cz.metacentrum.perun.webgui.model.Group) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) MainMenu(cz.metacentrum.perun.webgui.client.mainmenu.MainMenu) PerunWebSession(cz.metacentrum.perun.webgui.client.PerunWebSession) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) JsArray(com.google.gwt.core.client.JsArray) Widget(com.google.gwt.user.client.ui.Widget) JsonUtils(cz.metacentrum.perun.webgui.json.JsonUtils) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ButtonType(cz.metacentrum.perun.webgui.client.resources.ButtonType) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization) CellTable(com.google.gwt.user.cellview.client.CellTable) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) Group(cz.metacentrum.perun.webgui.model.Group) JsArray(com.google.gwt.core.client.JsArray) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) HTML(com.google.gwt.user.client.ui.HTML) AddAutoRegGroups(cz.metacentrum.perun.webgui.json.registrarManager.AddAutoRegGroups) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetAllGroups(cz.metacentrum.perun.webgui.json.groupsManager.GetAllGroups) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) GetAutoRegistrationGroups(cz.metacentrum.perun.webgui.json.registrarManager.GetAutoRegistrationGroups) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 4 with ExtendedSuggestBox

use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.

the class AutoRegistrationGroupsTabItem method draw.

@Override
public Widget draw() {
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    TabMenu menu = new TabMenu();
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    menu.addWidget(UiElements.getRefreshButton(this));
    final GetAutoRegistrationGroups groups = new GetAutoRegistrationGroups(voId);
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(groups);
    if (!session.isVoAdmin(voId)) {
        groups.setCheckable(false);
    }
    CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addGroupToAutoReg(), event -> session.getTabManager().addTabToCurrentTab(new AddAutoRegGroupTabItem(vo), true));
    if (!session.isVoAdmin(voId))
        addButton.setEnabled(false);
    menu.addWidget(addButton);
    // remove selected groups button
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeGroupFromAutoReg());
    removeButton.addClickHandler(event -> {
        final ArrayList<Group> groupsToRemove = groups.getTableSelectedList();
        String text = "Following groups will be removed from the auto registration.";
        UiElements.showDeleteConfirm(groupsToRemove, text, clickEvent -> {
            RemoveGroupsFromAutoRegistration request = new RemoveGroupsFromAutoRegistration(JsonCallbackEvents.disableButtonEvents(removeButton, events));
            request.deleteGroups(groupsToRemove);
        });
    });
    menu.addWidget(removeButton);
    // filter box
    menu.addFilterWidget(new ExtendedSuggestBox(groups.getOracle()), new PerunSearchEvent() {

        public void searchFor(String text) {
            groups.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterGroup());
    // add a table with a onclick
    CellTable<Group> table = groups.getTable();
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(table);
    contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Group(cz.metacentrum.perun.webgui.model.Group) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) RemoveGroupsFromAutoRegistration(cz.metacentrum.perun.webgui.json.registrarManager.RemoveGroupsFromAutoRegistration) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) GetAutoRegistrationGroups(cz.metacentrum.perun.webgui.json.registrarManager.GetAutoRegistrationGroups) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 5 with ExtendedSuggestBox

use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox in project perun by CESNET.

the class AssignTagTabItem method draw.

public Widget draw() {
    titleWidget.setText("Add tag");
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // menu
    TabMenu menu = new TabMenu();
    final GetAllResourcesTags tags = new GetAllResourcesTags(PerunEntity.VIRTUAL_ORGANIZATION, resource.getVoId());
    final CellTable<ResourceTag> table = tags.getTable();
    final TabItem tab = this;
    // button
    final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignSelectedTagsToResource());
    assignButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            ArrayList<ResourceTag> tagsToAssign = tags.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(tagsToAssign)) {
                for (int i = 0; i < tagsToAssign.size(); i++) {
                    if (i != tagsToAssign.size() - 1) {
                        // call json normaly
                        AssignResourceTag request = new AssignResourceTag(resourceId, JsonCallbackEvents.disableButtonEvents(assignButton));
                        request.assignResourceTag(tagsToAssign.get(i));
                    } else {
                        // last change - call json with update
                        AssignResourceTag request = new AssignResourceTag(resourceId, JsonCallbackEvents.closeTabDisableButtonEvents(assignButton, tab, true));
                        request.assignResourceTag(tagsToAssign.get(i));
                    }
                }
            }
        }
    });
    menu.addWidget(assignButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, isRefreshParentOnClose());
        }
    }));
    menu.addFilterWidget(new ExtendedSuggestBox(tags.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            tags.filterTable(text);
            // if single group, select
            if (tags.getList().size() == 1) {
                table.getSelectionModel().setSelected(tags.getList().get(0), true);
            }
        }
    }, ButtonTranslation.INSTANCE.filterGroup());
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    assignButton.setEnabled(false);
    JsonUtils.addTableManagedButton(tags, table, assignButton);
    tags.retrieveData();
    table.addStyleName("perun-table");
    table.setWidth("100%");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : AssignResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.AssignResourceTag) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) GetAllResourcesTags(cz.metacentrum.perun.webgui.json.resourcesManager.GetAllResourcesTags) AssignResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.AssignResourceTag) ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

Aggregations

ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)50 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)50 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)41 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)41 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)41 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)41 ArrayList (java.util.ArrayList)41 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)26 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)15 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)15 Group (cz.metacentrum.perun.webgui.model.Group)8 JsArray (com.google.gwt.core.client.JsArray)5 VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)5 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)4 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)4 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)4 ScrollPanel (com.google.gwt.user.client.ui.ScrollPanel)4 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)4 GetAllGroups (cz.metacentrum.perun.webgui.json.groupsManager.GetAllGroups)4 GetVos (cz.metacentrum.perun.webgui.json.vosManager.GetVos)4