Search in sources :

Example 6 with ExtendedSuggestBox

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

the class GroupResourcesTabItem method draw.

public Widget draw() {
    // set title
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": " + "resources");
    // main panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    // get VO resources
    final GetAssignedRichResources resources = new GetAssignedRichResources(groupId, PerunEntity.GROUP);
    if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
        resources.setCheckable(false);
    // custom events for viewResource
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(resources);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeGroupFromSelectedResources());
    // add / remove resource from group can be done by vo / perun admin only.
    if (session.isVoAdmin(group.getVoId())) {
        menu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.assignGroupToResources(), new ClickHandler() {

            public void onClick(ClickEvent event) {
                session.getTabManager().addTabToCurrentTab(new AssignGroupTabItem(group, resources.getList()), true);
            }
        }));
        removeButton.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                final ArrayList<RichResource> toRemove = resources.getTableSelectedList();
                String text = "Following resources will be removed from group and it's members won't have access to them anymore.";
                UiElements.showDeleteConfirm(toRemove, text, new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent clickEvent) {
                        RemoveGroupFromResources request = new RemoveGroupFromResources(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        request.removeGroupFromResources(group, toRemove);
                    }
                });
            }
        });
        menu.addWidget(removeButton);
    }
    // filter box
    menu.addFilterWidget(new ExtendedSuggestBox(resources.getOracle()), new PerunSearchEvent() {

        public void searchFor(String text) {
            resources.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterResources());
    // add menu to the main panel
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    CellTable<RichResource> table;
    // perun / vo admin can set attributes
    if (session.isVoAdmin(group.getVoId()) || session.isVoObserver(group.getVoId())) {
        table = resources.getTable(new FieldUpdater<RichResource, String>() {

            public void update(int index, RichResource object, String value) {
                session.getTabManager().addTab(new ResourceDetailTabItem(object, 0));
            }
        });
    } else {
        table = resources.getTable();
    }
    removeButton.setEnabled(false);
    if (session.isGroupAdmin(groupId) || session.isVoAdmin(group.getVoId()))
        JsonUtils.addTableManagedButton(resources, table, removeButton);
    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 : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) RichResource(cz.metacentrum.perun.webgui.model.RichResource) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) RemoveGroupFromResources(cz.metacentrum.perun.webgui.json.resourcesManager.RemoveGroupFromResources) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) GetAssignedRichResources(cz.metacentrum.perun.webgui.json.resourcesManager.GetAssignedRichResources) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) ResourceDetailTabItem(cz.metacentrum.perun.webgui.tabs.resourcestabs.ResourceDetailTabItem)

Example 7 with ExtendedSuggestBox

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

the class GroupRelationsTabItem method draw.

@Override
public Widget draw() {
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": unions");
    // main panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // if members group, hide
    if (group.isCoreGroup()) {
        vp.add(new HTML("<h2>Members group cannot have unions.</h2>"));
        this.contentWidget.setWidget(vp);
        return getWidget();
    }
    final GetGroupUnions unions = new GetGroupUnions(group, false);
    // Events for reloading when group is created
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(unions);
    // menu
    TabMenu menu = new TabMenu();
    final CheckBox subGroupsCheckBox = new CheckBox("Show sub-groups");
    final ListBox reverseDropdown = new ListBox();
    reverseDropdown.addItem("Normal");
    reverseDropdown.addItem("Reverse");
    reverseDropdown.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            switch(reverseDropdown.getSelectedIndex()) {
                case 1:
                    unions.setReverseAndRefresh(true);
                    subGroupsCheckBox.setVisible(false);
                    break;
                default:
                    unions.setReverseAndRefresh(false);
                    subGroupsCheckBox.setVisible(true);
            }
        }
    });
    menu.addWidget(UiElements.getRefreshButton(this));
    CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addGroupUnion(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            // creates a new form
            session.getTabManager().addTabToCurrentTab(new AddGroupUnionTabItem(group), true);
        }
    });
    if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId())) {
        createButton.setEnabled(false);
        unions.setCheckable(false);
    }
    menu.addWidget(createButton);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeGroupUnion());
    removeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<Group> itemsToRemove = unions.getTableSelectedList();
            String text = "Following group unions will be deleted.";
            UiElements.showDeleteConfirm(itemsToRemove, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    RemoveGroupUnions request = new RemoveGroupUnions(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                    if (unions.isReverse()) {
                        request.deleteGroupUnions(itemsToRemove, group);
                    } else {
                        request.deleteGroupUnions(group, itemsToRemove);
                    }
                }
            });
        }
    });
    menu.addWidget(removeButton);
    // filter box
    final ExtendedSuggestBox box = new ExtendedSuggestBox(unions.getOracle());
    menu.addFilterWidget(box, new PerunSearchEvent() {

        public void searchFor(String text) {
            unions.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterGroup());
    subGroupsCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> valueChangeEvent) {
            unions.setShowSubgroupsAndRefresh(valueChangeEvent.getValue(), box.getSuggestBox().getText());
        }
    });
    menu.addWidget(new HTML("<strong>Direction: </strong>"));
    menu.addWidget(reverseDropdown);
    menu.addWidget(subGroupsCheckBox);
    // add menu to the main panel
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    CellTable<Group> table = unions.getTable(new FieldUpdater<Group, String>() {

        @Override
        public void update(int arg0, Group group, String arg2) {
            if (session.isGroupAdmin(group.getId()) || session.isVoAdmin(group.getId())) {
                session.getTabManager().addTab(new GroupDetailTabItem(group.getId()));
            } else {
                UiElements.generateInfo("Not privileged", "You are not manager of selected group or its VO.");
            }
        }
    });
    removeButton.setEnabled(false);
    if (session.isGroupAdmin(groupId) || session.isVoAdmin(group.getVoId()))
        JsonUtils.addTableManagedButton(unions, table, removeButton);
    // adds the table into the panel
    table.addStyleName("perun-table");
    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 : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Group(cz.metacentrum.perun.webgui.model.Group) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) HTML(com.google.gwt.user.client.ui.HTML) ValueChangeHandler(com.google.gwt.event.logical.shared.ValueChangeHandler) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) RemoveGroupUnions(cz.metacentrum.perun.webgui.json.groupsManager.RemoveGroupUnions) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ValueChangeEvent(com.google.gwt.event.logical.shared.ValueChangeEvent) CheckBox(com.google.gwt.user.client.ui.CheckBox) GetGroupUnions(cz.metacentrum.perun.webgui.json.groupsManager.GetGroupUnions) ListBox(com.google.gwt.user.client.ui.ListBox) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 8 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 9 with ExtendedSuggestBox

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

the class VoExtSourcesTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": " + "ext sources");
    // main panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    // refresh
    menu.addWidget(UiElements.getRefreshButton(this));
    // get VO resources
    final GetVoExtSources extSources = new GetVoExtSources(voId);
    // refresh table event
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(extSources);
    // create ext source button
    CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addExtSource(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AddVoExtSourceTabItem(voId), true);
        }
    });
    menu.addWidget(addButton);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeExtSource());
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<ExtSource> extSourcesToRemove = extSources.getTableSelectedList();
            String text = "Following external sources will be removed from VO. You won't be able to import members from them anymore.";
            UiElements.showDeleteConfirm(extSourcesToRemove, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < extSourcesToRemove.size(); i++) {
                        RemoveExtSource request;
                        if (i == extSourcesToRemove.size() - 1) {
                            request = new RemoveExtSource(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        } else {
                            request = new RemoveExtSource(JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.removeVoExtSource(voId, extSourcesToRemove.get(i).getId());
                    }
                }
            });
        }
    });
    menu.addWidget(removeButton);
    // authorization - enable buttons for perun admin only.
    if (!session.isPerunAdmin()) {
        addButton.setEnabled(false);
        removeButton.setEnabled(false);
        extSources.setCheckable(false);
    }
    menu.addFilterWidget(new ExtendedSuggestBox(extSources.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            extSources.filterTable(text);
        }
    }, "Filter external sources by name or type");
    // add menu to the main panel
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    CellTable<ExtSource> table = extSources.getTable();
    if (session.isPerunAdmin()) {
        removeButton.setEnabled(false);
        JsonUtils.addTableManagedButton(extSources, table, removeButton);
    }
    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 : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) GetVoExtSources(cz.metacentrum.perun.webgui.json.extSourcesManager.GetVoExtSources) ArrayList(java.util.ArrayList) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) ExtSource(cz.metacentrum.perun.webgui.model.ExtSource) RemoveExtSource(cz.metacentrum.perun.webgui.json.extSourcesManager.RemoveExtSource) RemoveExtSource(cz.metacentrum.perun.webgui.json.extSourcesManager.RemoveExtSource)

Example 10 with ExtendedSuggestBox

use of cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox 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)

Aggregations

ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)48 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)48 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)40 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)40 ArrayList (java.util.ArrayList)39 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)38 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)38 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)24 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)14 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)13 Group (cz.metacentrum.perun.webgui.model.Group)6 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)4 JsArray (com.google.gwt.core.client.JsArray)4 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)4 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)4 GetVos (cz.metacentrum.perun.webgui.json.vosManager.GetVos)4 ExtSource (cz.metacentrum.perun.webgui.model.ExtSource)4 Service (cz.metacentrum.perun.webgui.model.Service)4 VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)4 GetVoExtSources (cz.metacentrum.perun.webgui.json.extSourcesManager.GetVoExtSources)3