Search in sources :

Example 1 with RemoveExtSource

use of cz.metacentrum.perun.webgui.json.extSourcesManager.RemoveExtSource 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 2 with RemoveExtSource

use of cz.metacentrum.perun.webgui.json.extSourcesManager.RemoveExtSource in project perun by CESNET.

the class GroupExtSourcesTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": " + "ext sources");
    // 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 GetGroupExtSources extSources = new GetGroupExtSources(groupId);
    // 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 AddGroupExtSourceTabItem(groupId), true);
        }
    });
    if (session.isVoAdmin(voId)) {
        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 Group. 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.removeGroupExtSource(groupId, extSourcesToRemove.get(i).getId());
                    }
                }
            });
        }
    });
    if (session.isVoAdmin(voId)) {
        menu.addWidget(removeButton);
    }
    // authorization - enable buttons for vo admin only.
    if (!session.isVoAdmin(voId)) {
        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.isVoAdmin(voId)) {
        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) 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) GetGroupExtSources(cz.metacentrum.perun.webgui.json.extSourcesManager.GetGroupExtSources) RemoveExtSource(cz.metacentrum.perun.webgui.json.extSourcesManager.RemoveExtSource)

Aggregations

ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)2 RemoveExtSource (cz.metacentrum.perun.webgui.json.extSourcesManager.RemoveExtSource)2 ExtSource (cz.metacentrum.perun.webgui.model.ExtSource)2 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)2 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)2 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)2 ArrayList (java.util.ArrayList)2 GetGroupExtSources (cz.metacentrum.perun.webgui.json.extSourcesManager.GetGroupExtSources)1 GetVoExtSources (cz.metacentrum.perun.webgui.json.extSourcesManager.GetVoExtSources)1