Search in sources :

Example 36 with TabMenu

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

the class ServicePackageDetailTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(servicesPackage.getName()) + ": assigned services");
    // create widget for the whole page
    HorizontalPanel mainTab = new HorizontalPanel();
    mainTab.setSize("100%", "100%");
    // get services
    final GetServices services = new GetServices();
    final GetServicesFromServicesPackage assignedServices = new GetServicesFromServicesPackage(servicePackageId);
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(services);
    final JsonCallbackEvents events2 = JsonCallbackEvents.refreshTableEvents(assignedServices);
    // get the table of services with custom field updater (lines are clickable and open service details)
    CellTable<Service> table = services.getTable(new FieldUpdater<Service, String>() {

        // when user click on a row -> open new tab
        public void update(int index, Service object, String value) {
            session.getTabManager().addTab(new ServiceDetailTabItem(object));
        }
    });
    // get the table of services with custom field updater (lines are clickable and open service details)
    CellTable<Service> table2 = assignedServices.getTable(new FieldUpdater<Service, String>() {

        // when user click on a row -> open new tab
        public void update(int index, Service object, String value) {
            session.getTabManager().addTab(new ServiceDetailTabItem(object));
        }
    });
    // add styling to table with services
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    VerticalPanel vp1 = new VerticalPanel();
    vp1.setSize("100%", "100%");
    TabMenu menu1 = new TabMenu();
    menu1.addFilterWidget(new ExtendedSuggestBox(services.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            services.filterTable(text);
        }
    }, "Filter services by name");
    vp1.add(menu1);
    vp1.setCellHeight(menu1, "30px");
    vp1.add(sp);
    mainTab.add(vp1);
    mainTab.setCellWidth(vp1, "50%");
    // middle content
    final CustomButton add = new CustomButton("Add", "Add services to package", SmallIcons.INSTANCE.arrowRightIcon());
    add.setImageAlign(true);
    add.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<Service> list = services.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                for (int i = 0; i < list.size(); i++) {
                    AddServiceToServicesPackage request;
                    final int ii = i;
                    if (i == list.size() - 1) {
                        request = new AddServiceToServicesPackage(JsonCallbackEvents.disableButtonEvents(add, JsonCallbackEvents.mergeEvents(new JsonCallbackEvents() {

                            @Override
                            public void onFinished(JavaScriptObject jso) {
                                services.getSelectionModel().setSelected(list.get(ii), false);
                            }
                        }, events2)));
                    } else {
                        request = new AddServiceToServicesPackage(JsonCallbackEvents.disableButtonEvents(add, new JsonCallbackEvents() {

                            @Override
                            public void onFinished(JavaScriptObject jso) {
                                services.getSelectionModel().setSelected(list.get(ii), false);
                            }
                        }));
                    }
                    request.addServiceToServicesPackage(servicePackageId, list.get(i).getId());
                }
            }
        }
    });
    final CustomButton remove = new CustomButton("Remove", "Remove services from package", SmallIcons.INSTANCE.arrowLeftIcon());
    remove.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            ArrayList<Service> list = assignedServices.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                for (int i = 0; i < list.size(); i++) {
                    RemoveServiceFromServicesPackage request;
                    if (i == list.size() - 1) {
                        request = new RemoveServiceFromServicesPackage(JsonCallbackEvents.disableButtonEvents(remove, events2));
                    } else {
                        request = new RemoveServiceFromServicesPackage(JsonCallbackEvents.disableButtonEvents(remove));
                    }
                    request.removeServiceFromServicesPackage(servicePackageId, list.get(i).getId());
                }
            }
        }
    });
    final TabItem tab = this;
    CustomButton close = TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            session.getTabManager().closeTab(tab);
        }
    });
    FlexTable ft = new FlexTable();
    ft.setWidget(0, 0, add);
    ft.setWidget(1, 0, remove);
    ft.setWidget(2, 0, close);
    ft.getFlexCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
    ft.getFlexCellFormatter().setAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
    ft.getFlexCellFormatter().setAlignment(2, 0, HasHorizontalAlignment.ALIGN_CENTER, HasVerticalAlignment.ALIGN_MIDDLE);
    ft.setWidth("130px");
    ft.setCellSpacing(10);
    mainTab.add(ft);
    mainTab.setCellVerticalAlignment(ft, HasVerticalAlignment.ALIGN_MIDDLE);
    // add styling to table2 with assigned services
    table2.addStyleName("perun-table");
    ScrollPanel sp2 = new ScrollPanel(table2);
    sp2.addStyleName("perun-tableScrollPanel");
    VerticalPanel vp2 = new VerticalPanel();
    vp2.setSize("100%", "100%");
    TabMenu menu2 = new TabMenu();
    menu2.addFilterWidget(new ExtendedSuggestBox(assignedServices.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            assignedServices.filterTable(text);
        }
    }, "Filter services by name");
    vp2.add(menu2);
    vp2.setCellHeight(menu2, "30px");
    vp2.add(sp2);
    mainTab.add(vp2);
    mainTab.setCellWidth(vp2, "50%");
    add.setEnabled(false);
    JsonUtils.addTableManagedButton(services, table, add);
    remove.setEnabled(false);
    JsonUtils.addTableManagedButton(assignedServices, table2, remove);
    session.getUiElements().resizeSmallTabPanel(mainTab, 350, this);
    session.getUiElements().resizePerunTable(sp, 350, this);
    session.getUiElements().resizePerunTable(sp2, 350, this);
    this.contentWidget.setWidget(mainTab);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) GetServicesFromServicesPackage(cz.metacentrum.perun.webgui.json.servicesManager.GetServicesFromServicesPackage) GetServices(cz.metacentrum.perun.webgui.json.servicesManager.GetServices) RemoveServiceFromServicesPackage(cz.metacentrum.perun.webgui.json.servicesManager.RemoveServiceFromServicesPackage) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) AddServiceToServicesPackage(cz.metacentrum.perun.webgui.json.servicesManager.AddServiceToServicesPackage) Service(cz.metacentrum.perun.webgui.model.Service) 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)

Example 37 with TabMenu

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

the class ServicePackagesTabItem method draw.

public Widget draw() {
    // create widget for the whole page
    VerticalPanel mainTab = new VerticalPanel();
    mainTab.setSize("100%", "100%");
    // create widget for menu on page
    TabMenu tabMenu = new TabMenu();
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    // get services
    final GetServicesPackages services = new GetServicesPackages();
    services.setEditable(true);
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(services);
    // get the table of services with custom field updater (lines are clickable and open service details)
    CellTable<ServicesPackage> table = services.getTable(new FieldUpdater<ServicesPackage, String>() {

        // when user click on a row -> open new tab
        public void update(int index, ServicesPackage object, String value) {
            session.getTabManager().addTabToCurrentTab(new ServicePackageDetailTabItem(object), true);
        }
    });
    // create button
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createServicePackage(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().addTabToCurrentTab(new CreateServicePackageTabItem());
        }
    }));
    final CustomButton deleteButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteSelectedServicePackages());
    deleteButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            // get selected items
            final ArrayList<ServicesPackage> itemsToRemove = services.getTableSelectedList();
            UiElements.showDeleteConfirm(itemsToRemove, "Following services packages will be deleted.", new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                    for (int i = 0; i < itemsToRemove.size(); i++) {
                        DeleteServicePackage request;
                        if (i == itemsToRemove.size() - 1) {
                            request = new DeleteServicePackage(JsonCallbackEvents.disableButtonEvents(deleteButton, events));
                        } else {
                            request = new DeleteServicePackage(JsonCallbackEvents.disableButtonEvents(deleteButton));
                        }
                        request.deleteServicePackage(itemsToRemove.get(i).getId());
                    }
                }
            });
        }
    });
    tabMenu.addWidget(deleteButton);
    tabMenu.addFilterWidget(new ExtendedSuggestBox(services.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            services.filterTable(text);
        }
    }, "Filter service package by name");
    final CustomButton save = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveChangesInServicesPackages());
    save.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            // get selected items
            final ArrayList<ServicesPackage> itemsToUpdate = services.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(itemsToUpdate)) {
                // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                for (int i = 0; i < itemsToUpdate.size(); i++) {
                    UpdateServicePackage request;
                    if (i == itemsToUpdate.size() - 1) {
                        request = new UpdateServicePackage(JsonCallbackEvents.disableButtonEvents(save, events));
                    } else {
                        request = new UpdateServicePackage(JsonCallbackEvents.disableButtonEvents(save));
                    }
                    request.updateServicePackage(itemsToUpdate.get(i));
                }
            }
        }
    });
    tabMenu.addWidget(save);
    // add menu to page itself
    mainTab.add(tabMenu);
    mainTab.setCellHeight(tabMenu, "30px");
    // add styling to table with services
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    mainTab.add(sp);
    deleteButton.setEnabled(false);
    save.setEnabled(false);
    JsonUtils.addTableManagedButton(services, table, deleteButton);
    JsonUtils.addTableManagedButton(services, table, save);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(mainTab);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) DeleteServicePackage(cz.metacentrum.perun.webgui.json.servicesManager.DeleteServicePackage) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) GetServicesPackages(cz.metacentrum.perun.webgui.json.servicesManager.GetServicesPackages) UpdateServicePackage(cz.metacentrum.perun.webgui.json.servicesManager.UpdateServicePackage) 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) ServicesPackage(cz.metacentrum.perun.webgui.model.ServicesPackage)

Example 38 with TabMenu

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

the class ServiceRequiredAttributesTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(service.getName()) + ": Required attributes");
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // create new json call for required attributes of service with id=?
    final GetServiceRequiredAttributes servReqAttr = new GetServiceRequiredAttributes(serviceId);
    // menu
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    // custom event
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(servReqAttr);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addRequiredAttribute(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().addTabToCurrentTab(new AddRequiredAttributesTabItem(service), true);
        }
    }));
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeSelectedRequiredAttributes());
    removeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            final ArrayList<AttributeDefinition> attrsForRemoving = servReqAttr.getTableSelectedList();
            UiElements.showDeleteConfirm(attrsForRemoving, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                    for (int i = 0; i < attrsForRemoving.size(); i++) {
                        if (i == attrsForRemoving.size() - 1) {
                            RemoveRequiredAttribute request = new RemoveRequiredAttribute(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                            request.removeRequiredAttribute(serviceId, attrsForRemoving.get(i).getId());
                        } else {
                            RemoveRequiredAttribute request = new RemoveRequiredAttribute(JsonCallbackEvents.disableButtonEvents(removeButton));
                            request.removeRequiredAttribute(serviceId, attrsForRemoving.get(i).getId());
                        }
                    }
                }
            });
        }
    });
    menu.addWidget(removeButton);
    final ExtendedSuggestBox box = new ExtendedSuggestBox(servReqAttr.getOracle());
    menu.addFilterWidget(box, new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            servReqAttr.filterTable(text);
        }
    }, "Filter required attributes by name");
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    // get table = make call
    CellTable<AttributeDefinition> reqAttrTable = servReqAttr.getTable();
    // create scroll panel for table
    reqAttrTable.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(reqAttrTable);
    sp.addStyleName("perun-tableScrollPanel");
    sp.setWidth("100%");
    vp.add(sp);
    vp.setCellHeight(sp, "100%");
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(servReqAttr, reqAttrTable, removeButton);
    session.getUiElements().resizePerunTable(sp, 350, this);
    // add tabs to the main panel
    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) AttributeDefinition(cz.metacentrum.perun.webgui.model.AttributeDefinition) GetServiceRequiredAttributes(cz.metacentrum.perun.webgui.json.attributesManager.GetServiceRequiredAttributes) RemoveRequiredAttribute(cz.metacentrum.perun.webgui.json.servicesManager.RemoveRequiredAttribute) 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)

Example 39 with TabMenu

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

the class UserExtSourceSettingsTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(userExtSource.getLogin().trim()));
    // MAIN TAB PANEL
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // MENU
    TabMenu menu = new TabMenu();
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    final GetAttributesV2 callback = new GetAttributesV2(true);
    callback.getUserExtSourceAttributes(userExtSource.getId());
    final CellTable<Attribute> table = callback.getEmptyTable();
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(sp, 350, this);
    menu.addWidget(UiElements.getRefreshButton(this));
    // save changes in attributes
    final CustomButton saveChangesButton = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveChangesInAttributes());
    saveChangesButton.setEnabled(false);
    saveChangesButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (UiElements.cantSaveEmptyListDialogBox(callback.getTableSelectedList())) {
                SetAttributes request = new SetAttributes(JsonCallbackEvents.disableButtonEvents(saveChangesButton, new JsonCallbackEvents() {

                    public void onFinished(JavaScriptObject jso) {
                        callback.clearTable();
                        callback.getUserExtSourceAttributes(userExtSourceId);
                        callback.retrieveData();
                    }
                }));
                final Map<String, Integer> ids = new HashMap<String, Integer>();
                ids.put("userExtSource", userExtSourceId);
                request.setAttributes(ids, callback.getTableSelectedList());
            }
        }
    });
    menu.addWidget(saveChangesButton);
    // buttons
    CustomButton setNewMemberAttributeButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.setNewAttributes(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            Map<String, Integer> ids = new HashMap<String, Integer>();
            ids.put("userExtSource", userExtSource.getId());
            session.getTabManager().addTabToCurrentTab(new SetNewAttributeTabItem(ids), true);
        }
    });
    menu.addWidget(setNewMemberAttributeButton);
    // REMOVE ATTRIBUTES BUTTON
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeAttributes());
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            // if selected
            if (UiElements.cantSaveEmptyListDialogBox(callback.getTableSelectedList())) {
                Map<String, Integer> ids = new HashMap<String, Integer>();
                ids.put("userExtSource", userExtSource.getId());
                RemoveAttributes request = new RemoveAttributes(JsonCallbackEvents.disableButtonEvents(removeButton, new JsonCallbackEvents() {

                    public void onFinished(JavaScriptObject jso) {
                        callback.clearTable();
                        callback.getUserExtSourceAttributes(userExtSource.getId());
                        callback.retrieveData();
                    }
                }));
                // make removeAttributes call
                request.removeAttributes(ids, callback.getTableSelectedList());
            }
        }
    });
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(callback, table, removeButton);
    menu.addWidget(removeButton);
    callback.retrieveData();
    // ATTRIBUTES TABLE
    vp.add(sp);
    vp.setCellHeight(sp, "100%");
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Attribute(cz.metacentrum.perun.webgui.model.Attribute) GetAttributesV2(cz.metacentrum.perun.webgui.json.attributesManager.GetAttributesV2) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) SetAttributes(cz.metacentrum.perun.webgui.json.attributesManager.SetAttributes) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) SetNewAttributeTabItem(cz.metacentrum.perun.webgui.tabs.attributestabs.SetNewAttributeTabItem) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel) HashMap(java.util.HashMap) Map(java.util.Map) RemoveAttributes(cz.metacentrum.perun.webgui.json.attributesManager.RemoveAttributes)

Example 40 with TabMenu

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

the class AddVoExtSourceTabItem method draw.

public Widget draw() {
    titleWidget.setText("Add external source");
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // menu
    TabMenu menu = new TabMenu();
    final GetExtSources extSources = new GetExtSources();
    // remove already assigned ext sources from offering
    JsonCallbackEvents localEvents = new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // second callback
            final GetVoExtSources alreadyAssigned = new GetVoExtSources(voId, new JsonCallbackEvents() {

                public void onFinished(JavaScriptObject jso) {
                    JsArray<ExtSource> esToRemove = JsonUtils.jsoAsArray(jso);
                    for (int i = 0; i < esToRemove.length(); i++) {
                        extSources.removeFromTable(esToRemove.get(i));
                    }
                }
            });
            alreadyAssigned.retrieveData();
        }
    };
    extSources.setEvents(localEvents);
    extSources.setExtSourceTypeFilter("cz.metacentrum.perun.core.impl.ExtSourceX509");
    extSources.setExtSourceTypeFilter("cz.metacentrum.perun.core.impl.ExtSourceKerberos");
    extSources.setExtSourceTypeFilter("cz.metacentrum.perun.core.impl.ExtSourceIdp");
    final ExtendedSuggestBox box = new ExtendedSuggestBox(extSources.getOracle());
    // button
    final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedExtSource());
    final TabItem tab = this;
    assignButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<ExtSource> extSourcesToAdd = extSources.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(extSourcesToAdd)) {
                // FIXME - Should have only one callback to core
                for (int i = 0; i < extSourcesToAdd.size(); i++) {
                    final int n = i;
                    AddExtSource request = new AddExtSource(JsonCallbackEvents.disableButtonEvents(assignButton, new JsonCallbackEvents() {

                        @Override
                        public void onFinished(JavaScriptObject jso) {
                            // unselect added person
                            extSources.getSelectionModel().setSelected(extSourcesToAdd.get(n), false);
                            alreadyAddedList.add(extSourcesToAdd.get(n));
                            rebuildAlreadyAddedWidget();
                            // clear search
                            box.getSuggestBox().setText("");
                        }
                    }));
                    request.addExtSource(voId, extSourcesToAdd.get(i).getId());
                }
            }
        }
    });
    menu.addFilterWidget(box, new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            extSources.filterTable(text);
        }
    }, "Filter by ext source name or type");
    menu.addWidget(assignButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
        }
    }));
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    vp.add(alreadyAdded);
    CellTable<ExtSource> table = extSources.getTable();
    assignButton.setEnabled(false);
    JsonUtils.addTableManagedButton(extSources, table, assignButton);
    table.addStyleName("perun-table");
    table.setWidth("100%");
    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().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) GetExtSources(cz.metacentrum.perun.webgui.json.extSourcesManager.GetExtSources) 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) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) AddExtSource(cz.metacentrum.perun.webgui.json.extSourcesManager.AddExtSource) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtSource(cz.metacentrum.perun.webgui.model.ExtSource) AddExtSource(cz.metacentrum.perun.webgui.json.extSourcesManager.AddExtSource)

Aggregations

TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)143 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)124 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)124 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)115 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)99 ArrayList (java.util.ArrayList)89 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)68 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)67 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)48 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)33 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)27 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)27 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)27 PerunError (cz.metacentrum.perun.webgui.model.PerunError)27 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)21 HashMap (java.util.HashMap)20 User (cz.metacentrum.perun.webgui.model.User)18 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)17 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)17 Attribute (cz.metacentrum.perun.webgui.model.Attribute)15