Search in sources :

Example 81 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent 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 82 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.

the class UserDetailTabItem method loadCertificatesLoginsPasswords.

private Widget loadCertificatesLoginsPasswords() {
    // set content
    final VerticalPanel attributesTable = new VerticalPanel();
    final TabMenu menu = new TabMenu();
    attributesTable.add(menu);
    attributesTable.setWidth("100%");
    final ScrollPanel sp = new ScrollPanel();
    sp.setStyleName("perun-tableScrollPanel");
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    sp.setWidth("100%");
    //attributesTable.setStyleName("userDetailTable");
    // clear logins when page refreshed
    userLoginAttrs.clear();
    // ids used for attribute handling
    Map<String, Integer> ids = new HashMap<String, Integer>();
    ids.put("user", userId);
    // attribute table
    final PerunAttributeTableWidget table = new PerunAttributeTableWidget(ids);
    table.setDescriptionShown(true);
    table.setDisplaySaveButton(false);
    // load data
    GetListOfAttributes attributes = new GetListOfAttributes(new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            userLoginAttrs.addAll(JsonUtils.<Attribute>jsoAsList(jso));
            userLoginAttrs = new TableSorter<Attribute>().sortByAttrNameTranslation(userLoginAttrs);
            for (Attribute a : userLoginAttrs) {
                if (a.getFriendlyName().equalsIgnoreCase("userCertificates")) {
                    table.add(a);
                } else if (a.getFriendlyName().equalsIgnoreCase("sshPublicKey")) {
                    table.add(a);
                } else if (a.getFriendlyName().equalsIgnoreCase("kerberosAdminPrincipal")) {
                    table.add(a);
                } else if (a.getFriendlyName().equalsIgnoreCase("sshPublicAdminKey")) {
                    table.add(a);
                }
            }
            // build attr table
            table.build();
            menu.addWidget(table.getSaveButton());
            // content
            VerticalPanel vpContent = new VerticalPanel();
            vpContent.add(table.asWidget());
            FlexTable innerTable = new FlexTable();
            innerTable.setCellPadding(5);
            vpContent.add(innerTable);
            // set content to page
            sp.add(vpContent);
            attributesTable.add(sp);
            int rowCount = 0;
            for (final Attribute a : userLoginAttrs) {
                if (a.getBaseFriendlyName().equalsIgnoreCase("login-namespace")) {
                    if (a.getValueAsObject() != null) {
                        // name
                        innerTable.setHTML(rowCount, 0, "<strong>" + a.getDisplayName() + "</strong>");
                        // value
                        innerTable.setHTML(rowCount, 1, a.getValue());
                        // change password
                        if (Utils.getSupportedPasswordNamespaces().contains(a.getFriendlyNameParameter())) {
                            CustomButton cb = new CustomButton("Change password…", SmallIcons.INSTANCE.keyIcon(), new ClickHandler() {

                                public void onClick(ClickEvent event) {
                                    session.getTabManager().addTabToCurrentTab(new SelfPasswordTabItem(user, a.getFriendlyNameParameter(), a.getValue(), SelfPasswordTabItem.Actions.CHANGE));
                                }
                            });
                            innerTable.setWidget(rowCount, 2, cb);
                        }
                        rowCount++;
                    }
                }
            }
        }
    });
    HashSet<String> set = new HashSet<String>();
    set.add("urn:perun:user:attribute-def:def:userCertificates");
    set.add("urn:perun:user:attribute-def:def:kerberosAdminPrincipal");
    set.add("urn:perun:user:attribute-def:def:sshPublicKey");
    set.add("urn:perun:user:attribute-def:def:sshPublicAdminKey");
    set.add("urn:perun:user:attribute-def:def:login-namespace:mu");
    set.add("urn:perun:user:attribute-def:def:login-namespace:einfra");
    set.add("urn:perun:user:attribute-def:def:login-namespace:sitola");
    set.add("urn:perun:user:attribute-def:def:login-namespace:egi-ui");
    set.add("urn:perun:user:attribute-def:def:login-namespace:cesnet");
    set.add("urn:perun:user:attribute-def:def:login-namespace:meta");
    set.add("urn:perun:user:attribute-def:def:login-namespace:einfra-services");
    set.add("urn:perun:user:attribute-def:def:login-namespace:shongo");
    // TODO - FIXME - must be dynamic !!
    for (String namespace : Utils.getSupportedPasswordNamespaces()) {
        set.add("urn:perun:user:attribute-def:def:login-namespace:" + namespace);
    }
    // TODO - remove SHONGO
    ArrayList<String> list = JsonUtils.setToList(set);
    attributes.getListOfAttributes(ids, list);
    return attributesTable;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) HashMap(java.util.HashMap) GetListOfAttributes(cz.metacentrum.perun.webgui.json.attributesManager.GetListOfAttributes) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) HashSet(java.util.HashSet)

Example 83 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent 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 84 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent 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)

Example 85 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.

the class TestDataGridTabItem method draw.

public Widget draw() {
    //contentWidget.setSize("100%", "100%");
    DockLayoutPanel ft = new DockLayoutPanel(Style.Unit.PX);
    contentWidget.setWidget(ft);
    final DataGrid gridTable = new DataGrid();
    gridTable.setSize("100%", "100%");
    final ArrayList<VirtualOrganization> vosList = new ArrayList<VirtualOrganization>();
    final GetVos getVos = new GetVos(new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            vosList.addAll(new TableSorter<VirtualOrganization>().sortByName(JsonUtils.<VirtualOrganization>jsoAsList(jso)));
            gridTable.setRowData(vosList);
            gridTable.redraw();
        }
    });
    getVos.retrieveData();
    gridTable.setSelectionModel(new MultiSelectionModel<VirtualOrganization>(new GeneralKeyProvider<VirtualOrganization>()));
    final SelectionModel<VirtualOrganization> selectionModel = gridTable.getSelectionModel();
    Column<VirtualOrganization, Boolean> checkBoxColumn = new Column<VirtualOrganization, Boolean>(new CheckboxCell(true, true)) {

        @Override
        public Boolean getValue(VirtualOrganization object) {
            // Get the value from the selection model.
            return selectionModel.isSelected(object);
        }
    };
    checkBoxColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, Boolean>() {

        @Override
        public void update(int i, VirtualOrganization virtualOrganization, Boolean aBoolean) {
            selectionModel.setSelected(virtualOrganization, aBoolean);
        }
    });
    // Checkbox column header
    CheckboxCell cb = new CheckboxCell();
    Header<Boolean> checkBoxHeader = new Header<Boolean>(cb) {

        public Boolean getValue() {
            //return true to see a checked checkbox.
            return false;
        }
    };
    checkBoxHeader.setUpdater(new ValueUpdater<Boolean>() {

        public void update(Boolean value) {
            // sets selected to all, if value = true, unselect otherwise
            for (VirtualOrganization obj : vosList) {
                selectionModel.setSelected(obj, value);
            }
        }
    });
    gridTable.addColumn(checkBoxColumn, checkBoxHeader, checkBoxHeader);
    gridTable.setColumnWidth(checkBoxColumn, 40.0, Style.Unit.PX);
    TextColumn<VirtualOrganization> idColumn = new TextColumn<VirtualOrganization>() {

        @Override
        public String getValue(VirtualOrganization object) {
            return String.valueOf(object.getId());
        }
    };
    gridTable.addColumn(idColumn, "Id", "Id");
    gridTable.setColumnWidth(idColumn, "90px");
    Column<VirtualOrganization, String> nameColumn = JsonUtils.addColumn(new JsonUtils.GetValue<VirtualOrganization, String>() {

        public String getValue(VirtualOrganization object) {
            return object.getName();
        }
    }, new FieldUpdater<VirtualOrganization, String>() {

        @Override
        public void update(int i, VirtualOrganization virtualOrganization, String s) {
            session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
        }
    });
    gridTable.addColumn(nameColumn, "Name", "Name");
    TextColumn<VirtualOrganization> shortnameColumn = new TextColumn<VirtualOrganization>() {

        @Override
        public String getValue(VirtualOrganization object) {
            return object.getShortName();
        }
    };
    gridTable.addColumn(shortnameColumn, "Short name", "Short name");
    shortnameColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, String>() {

        @Override
        public void update(int i, VirtualOrganization virtualOrganization, String s) {
            session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
        }
    });
    idColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, String>() {

        @Override
        public void update(int i, VirtualOrganization virtualOrganization, String s) {
            session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
        }
    });
    nameColumn.setFieldUpdater(new FieldUpdater<VirtualOrganization, String>() {

        @Override
        public void update(int i, VirtualOrganization virtualOrganization, String s) {
            session.getTabManager().addTab(new VoDetailTabItem(virtualOrganization));
        }
    });
    TabMenu tabMenu = new TabMenu();
    // CREATE & DELETE ONLY WITH PERUN ADMIN
    if (session.isPerunAdmin()) {
        tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, ButtonTranslation.INSTANCE.createVo(), new ClickHandler() {

            public void onClick(ClickEvent event) {
                session.getTabManager().addTabToCurrentTab(new CreateVoTabItem());
            }
        }));
        final cz.metacentrum.perun.webgui.widgets.CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteVo());
        removeButton.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                final ArrayList<VirtualOrganization> itemsToRemove = getVos.getTableSelectedList();
                if (UiElements.cantSaveEmptyListDialogBox(itemsToRemove)) {
                    VerticalPanel removePanel = new VerticalPanel();
                    removePanel.add(new Label("These VOs will be removed:"));
                    for (int i = 0; i < itemsToRemove.size(); i++) {
                        VirtualOrganization vo = itemsToRemove.get(i);
                        removePanel.add(new Label(" - " + vo.getName()));
                    }
                    // confirmation
                    Confirm c = new Confirm("Remove VOs", removePanel, new ClickHandler() {

                        public void onClick(ClickEvent event) {
                            for (int i = 0; i < itemsToRemove.size(); i++) {
                                DeleteVo request;
                                // if last, refresh
                                if (i == itemsToRemove.size() - 1) {
                                    request = new DeleteVo(JsonCallbackEvents.disableButtonEvents(removeButton));
                                } else {
                                    request = new DeleteVo(JsonCallbackEvents.disableButtonEvents(removeButton));
                                }
                                request.deleteVo(itemsToRemove.get(i).getId(), false);
                            }
                            getVos.clearTableSelectedSet();
                        }
                    }, true);
                    c.show();
                }
            }
        });
        tabMenu.addWidget(removeButton);
    }
    // filter
    tabMenu.addFilterWidget(new ExtendedSuggestBox(getVos.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            getVos.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterVo());
    ft.addNorth(tabMenu, 50);
    ft.add(gridTable);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) DataGrid(com.google.gwt.user.cellview.client.DataGrid) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) DeleteVo(cz.metacentrum.perun.webgui.json.vosManager.DeleteVo) TextColumn(com.google.gwt.user.cellview.client.TextColumn) Column(com.google.gwt.user.cellview.client.Column) JsonUtils(cz.metacentrum.perun.webgui.json.JsonUtils) CreateVoTabItem(cz.metacentrum.perun.webgui.tabs.vostabs.CreateVoTabItem) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) CheckboxCell(com.google.gwt.cell.client.CheckboxCell) TextColumn(com.google.gwt.user.cellview.client.TextColumn) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) GetVos(cz.metacentrum.perun.webgui.json.vosManager.GetVos) GeneralKeyProvider(cz.metacentrum.perun.webgui.json.keyproviders.GeneralKeyProvider) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) Header(com.google.gwt.user.cellview.client.Header) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) VoDetailTabItem(cz.metacentrum.perun.webgui.tabs.vostabs.VoDetailTabItem)

Aggregations

ClickEvent (com.google.gwt.event.dom.client.ClickEvent)385 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)382 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)161 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)135 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)124 ArrayList (java.util.ArrayList)117 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)105 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)76 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)42 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)41 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)40 PerunError (cz.metacentrum.perun.webgui.model.PerunError)36 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)32 HashMap (java.util.HashMap)32 Button (com.google.gwt.user.client.ui.Button)30 Image (com.google.gwt.user.client.ui.Image)28 HTML (com.google.gwt.user.client.ui.HTML)26 Button (org.gwtbootstrap3.client.ui.Button)26 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)25 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)23