Search in sources :

Example 71 with ClickEvent

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

the class UserDetailTabItem method loadExternalIdentities.

private Widget loadExternalIdentities() {
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    TabMenu menu = new TabMenu();
    final GetUserExtSources extSources = new GetUserExtSources(user.getId());
    // reload tab events
    final TabItem tab = this;
    final JsonCallbackEvents reloadTabEvents = new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            session.getTabManager().reloadTab(tab);
        }
    };
    // buttons
    CustomButton addUserExtSourceButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, "Add new external identity to user", new ClickHandler() {

        public void onClick(ClickEvent event) {
            // when user click on add ext source btn
            session.getTabManager().addTabToCurrentTab(new AddUserExtSourceTabItem(user.getId()));
        }
    });
    final CustomButton removeUserExtSourceButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, "Removes selected external identities from this user");
    removeUserExtSourceButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<UserExtSource> list = extSources.getTableSelectedList();
            UiElements.showDeleteConfirm(list, "Following external identities will be removed from user.", new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    for (int i = 0; i < list.size(); i++) {
                        // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                        if (i == list.size() - 1) {
                            RemoveUserExtSource request = new RemoveUserExtSource(JsonCallbackEvents.disableButtonEvents(removeUserExtSourceButton, reloadTabEvents));
                            request.removeUserExtSource(user.getId(), list.get(i).getId());
                        } else {
                            RemoveUserExtSource request = new RemoveUserExtSource(JsonCallbackEvents.disableButtonEvents(removeUserExtSourceButton));
                            request.removeUserExtSource(user.getId(), list.get(i).getId());
                        }
                    }
                }
            });
        }
    });
    menu.addWidget(addUserExtSourceButton);
    menu.addWidget(removeUserExtSourceButton);
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    CellTable<UserExtSource> table = extSources.getTable(new FieldUpdater<UserExtSource, String>() {

        @Override
        public void update(int index, UserExtSource object, String value) {
            session.getTabManager().addTab(new UserExtSourceDetailTabItem(object));
        }
    });
    table.addStyleName("perun-table");
    table.setWidth("100%");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    vp.setCellHeight(sp, "100%");
    session.getUiElements().resizeSmallTabPanel(sp, 320, this);
    removeUserExtSourceButton.setEnabled(false);
    JsonUtils.addTableManagedButton(extSources, table, removeUserExtSourceButton);
    return vp;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) MemberDetailTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.MemberDetailTabItem) VoDetailTabItem(cz.metacentrum.perun.webgui.tabs.vostabs.VoDetailTabItem) UsersPublicationsTabItem(cz.metacentrum.perun.webgui.tabs.cabinettabs.UsersPublicationsTabItem) ResourceDetailTabItem(cz.metacentrum.perun.webgui.tabs.resourcestabs.ResourceDetailTabItem) SetNewAttributeTabItem(cz.metacentrum.perun.webgui.tabs.attributestabs.SetNewAttributeTabItem) FacilityDetailTabItem(cz.metacentrum.perun.webgui.tabs.facilitiestabs.FacilityDetailTabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 72 with ClickEvent

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

the class UserDetailTabItem method loadMemberSubContent.

private void loadMemberSubContent(final SimplePanel subContent, final Hyperlink voLabel, final ListBoxWithObjects<VirtualOrganization> listbox) {
    subContent.setWidget(new AjaxLoaderImage());
    final GetMemberByUser gmbu = new GetMemberByUser(listbox.getSelectedObject().getId(), user.getId());
    JsonCallbackEvents loadEvent = new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // get member
            final Member member = jso.cast();
            // create content panel and put it on page
            final VerticalPanel entryPanel = new VerticalPanel();
            entryPanel.setStyleName("perun-table");
            entryPanel.setSize("100%", "100%");
            subContent.setWidget(entryPanel);
            voLabel.setHTML(SafeHtmlUtils.fromSafeConstant("<h2>" + listbox.getSelectedObject().getName() + "</h2>"));
            voLabel.setTargetHistoryToken(session.getTabManager().getLinkForTab(new VoDetailTabItem(listbox.getSelectedObject())));
            // detail header
            Widget memberHeader = new HTML("<h2>" + "Member details" + "</h2>");
            entryPanel.add(memberHeader);
            entryPanel.setCellHeight(memberHeader, "30px");
            // detail content
            FlexTable layout = new FlexTable();
            layout.setCellSpacing(6);
            // Add some standard form options
            layout.setHTML(0, 0, "<strong>Member&nbsp;ID:</strong>");
            layout.setHTML(0, 1, String.valueOf(member.getId()));
            ImageResource ir = null;
            // member status
            if (member.getStatus().equalsIgnoreCase("VALID")) {
                ir = SmallIcons.INSTANCE.acceptIcon();
            } else if (member.getStatus().equalsIgnoreCase("INVALID")) {
                ir = SmallIcons.INSTANCE.flagRedIcon();
            } else if (member.getStatus().equalsIgnoreCase("SUSPENDED")) {
                ir = SmallIcons.INSTANCE.stopIcon();
            } else if (member.getStatus().equalsIgnoreCase("EXPIRED")) {
                ir = SmallIcons.INSTANCE.flagYellowIcon();
            } else if (member.getStatus().equalsIgnoreCase("DISABLED")) {
                ir = SmallIcons.INSTANCE.binClosedIcon();
            }
            HTML status = new HTML("<a>" + member.getStatus() + " " + new Image(ir) + "</a>");
            layout.setHTML(1, 0, "<strong>Member status: </strong>");
            layout.setWidget(1, 1, status);
            // member status - on click action
            status.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    FlexTable widget = new FlexTable();
                    final ListBox lb = new ListBox(false);
                    lb.addItem("VALID", "VALID");
                    lb.addItem("INVALID", "INVALID");
                    lb.addItem("SUSPENDED", "SUSPENDED");
                    lb.addItem("EXPIRED", "EXPIRED");
                    lb.addItem("DISABLED", "DISABLED");
                    widget.setHTML(0, 0, "<strong>Status: </strong>");
                    widget.setWidget(0, 1, lb);
                    // pick which one is already set
                    for (int i = 0; i < lb.getItemCount(); i++) {
                        if (lb.getItemText(i).equalsIgnoreCase(member.getStatus())) {
                            lb.setSelectedIndex(i);
                        }
                    }
                    Confirm conf = new Confirm("Change member's status", widget, true);
                    conf.setCancelButtonText("Cancel");
                    conf.setOkButtonText("Change status");
                    conf.setOkClickHandler(new ClickHandler() {

                        public void onClick(ClickEvent event) {
                            SetStatus call = new SetStatus(member.getId(), new JsonCallbackEvents() {

                                @Override
                                public void onLoadingStart() {
                                    subContent.setWidget(new AjaxLoaderImage());
                                }

                                public void onFinished(JavaScriptObject jso) {
                                    subContent.setWidget(entryPanel);
                                    gmbu.retrieveData();
                                }

                                public void onError(PerunError error) {
                                    subContent.setWidget(entryPanel);
                                    gmbu.retrieveData();
                                }
                            });
                            call.setStatus(lb.getValue(lb.getSelectedIndex()));
                        }
                    });
                    conf.show();
                }
            });
            final ListBoxWithObjects<Resource> resList = new ListBoxWithObjects<Resource>();
            GetAssignedResources res = new GetAssignedResources(member.getId(), PerunEntity.MEMBER, new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    resList.clear();
                    ArrayList<Resource> list = JsonUtils.jsoAsList(jso);
                    if (list == null || list.isEmpty()) {
                        resList.addItem("No resources found");
                    } else {
                        list = new TableSorter<Resource>().sortByName(list);
                        resList.addNotSelectedOption();
                        resList.addAllItems(list);
                    }
                }

                @Override
                public void onError(PerunError error) {
                    resList.clear();
                    resList.addItem("Error while loading");
                }

                @Override
                public void onLoadingStart() {
                    resList.clear();
                    resList.addItem("Loading...");
                }
            });
            res.retrieveData();
            // link to member's detail
            Hyperlink link = new Hyperlink();
            link.setText("View detail");
            layout.setHTML(2, 0, "<strong>Member's detail page:</strong>");
            layout.setWidget(2, 1, link);
            link.setTargetHistoryToken(session.getTabManager().getLinkForTab(new MemberDetailTabItem(member.getId(), 0)));
            // wrap the content in a DecoratorPanel
            DecoratorPanel decPanel = new DecoratorPanel();
            decPanel.setWidget(layout);
            entryPanel.add(decPanel);
            entryPanel.setCellHeight(decPanel, "50px");
            // tables
            // detail header
            Widget groupHeader = new HTML("<h2>" + "Member groups" + "</h2>");
            entryPanel.add(groupHeader);
            entryPanel.setCellHeight(groupHeader, "30px");
            final GetMemberGroups groups = new GetMemberGroups(member.getId());
            groups.setCheckable(false);
            groups.setEditable(false);
            CellTable<Group> table = groups.getTable();
            table.addStyleName("perun-table");
            table.setWidth("100%");
            entryPanel.add(table);
            // detail header
            Widget attrHeader = new HTML("<h2>" + "Member / Member-resource attributes" + "</h2>");
            entryPanel.add(attrHeader);
            entryPanel.setCellHeight(attrHeader, "30px");
            final GetAttributesV2 attributes = new GetAttributesV2();
            attributes.getMemberAttributes(member.getId());
            resList.addChangeHandler(new ChangeHandler() {

                @Override
                public void onChange(ChangeEvent event) {
                    if (resList.getSelectedIndex() == 0) {
                        attributes.getMemberAttributes(member.getId());
                        attributes.retrieveData();
                    } else {
                        attributes.getMemberResourceAttributes(member.getId(), resList.getSelectedObject().getId());
                        attributes.retrieveData();
                    }
                }
            });
            TabMenu menu = new TabMenu();
            final CustomButton saveAttrButton = TabMenu.getPredefinedButton(ButtonType.SAVE, "Save changes in attributes for member");
            saveAttrButton.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    ArrayList<Attribute> list = attributes.getTableSelectedList();
                    if (UiElements.cantSaveEmptyListDialogBox(list)) {
                        Map<String, Integer> ids = new HashMap<String, Integer>();
                        ids.put("member", member.getId());
                        if (resList.getSelectedIndex() > 0) {
                            ids.put("resource", resList.getSelectedObject().getId());
                        }
                        SetAttributes request = new SetAttributes(JsonCallbackEvents.disableButtonEvents(saveAttrButton, JsonCallbackEvents.refreshTableEvents(attributes)));
                        request.setAttributes(ids, list);
                    }
                }
            });
            menu.addWidget(saveAttrButton);
            menu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, "Set new attributes for member", new ClickHandler() {

                public void onClick(ClickEvent event) {
                    Map<String, Integer> ids = new HashMap<String, Integer>();
                    ids.put("member", member.getId());
                    if (resList.getSelectedIndex() > 0) {
                        ids.put("resource", resList.getSelectedObject().getId());
                    }
                    session.getTabManager().addTabToCurrentTab(new SetNewAttributeTabItem(ids, attributes.getList()), true);
                }
            }));
            final CustomButton removeAttrButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, "Remove attributes from member");
            removeAttrButton.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    ArrayList<Attribute> list = attributes.getTableSelectedList();
                    if (UiElements.cantSaveEmptyListDialogBox(list)) {
                        Map<String, Integer> ids = new HashMap<String, Integer>();
                        ids.put("member", member.getId());
                        if (resList.getSelectedIndex() > 0) {
                            ids.put("resource", resList.getSelectedObject().getId());
                        }
                        RemoveAttributes request = new RemoveAttributes(JsonCallbackEvents.disableButtonEvents(removeAttrButton, JsonCallbackEvents.refreshTableEvents(attributes)));
                        request.removeAttributes(ids, list);
                    }
                }
            });
            menu.addWidget(removeAttrButton);
            menu.addWidget(new HTML("<strong>Resource:</strong>"));
            menu.addWidget(resList);
            entryPanel.add(menu);
            CellTable<Attribute> attrTable = attributes.getTable();
            attrTable.addStyleName("perun-table");
            attrTable.setWidth("100%");
            entryPanel.add(attrTable);
        }

        @Override
        public void onError(PerunError error) {
            subContent.setWidget(new AjaxLoaderImage().loadingError(error));
        }
    };
    // set events & load data
    gmbu.setEvents(loadEvent);
    gmbu.retrieveData();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) HashMap(java.util.HashMap) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) SetAttributes(cz.metacentrum.perun.webgui.json.attributesManager.SetAttributes) MemberDetailTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.MemberDetailTabItem) ImageResource(com.google.gwt.resources.client.ImageResource) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) SetStatus(cz.metacentrum.perun.webgui.json.membersManager.SetStatus) SetNewAttributeTabItem(cz.metacentrum.perun.webgui.tabs.attributestabs.SetNewAttributeTabItem) GetAttributesV2(cz.metacentrum.perun.webgui.json.attributesManager.GetAttributesV2) ImageResource(com.google.gwt.resources.client.ImageResource) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetMemberByUser(cz.metacentrum.perun.webgui.json.membersManager.GetMemberByUser) VoDetailTabItem(cz.metacentrum.perun.webgui.tabs.vostabs.VoDetailTabItem) GetAssignedResources(cz.metacentrum.perun.webgui.json.resourcesManager.GetAssignedResources) HashMap(java.util.HashMap) Map(java.util.Map) GetMemberGroups(cz.metacentrum.perun.webgui.json.groupsManager.GetMemberGroups) RemoveAttributes(cz.metacentrum.perun.webgui.json.attributesManager.RemoveAttributes)

Example 73 with ClickEvent

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

the class AddSecurityTeamManagerTabItem method draw.

public Widget draw() {
    titleWidget.setText("Add member");
    final CustomButton searchButton = new CustomButton("Search", ButtonTranslation.INSTANCE.searchUsers(), SmallIcons.INSTANCE.findIcon());
    this.users = new FindCompleteRichUsers("", null, JsonCallbackEvents.disableButtonEvents(searchButton, new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // if found 1 item, select
            ArrayList<User> list = JsonUtils.jsoAsList(jso);
            if (list != null && list.size() == 1) {
                users.getSelectionModel().setSelected(list.get(0), true);
            }
        }
    }));
    // MAIN TAB PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu tabMenu = new TabMenu();
    // get the table
    final CellTable<User> table;
    if (session.isPerunAdmin()) {
        table = users.getTable(new FieldUpdater<User, String>() {

            public void update(int i, User user, String s) {
                session.getTabManager().addTab(new UserDetailTabItem(user));
            }
        });
    } else {
        table = users.getTable();
    }
    rebuildAlreadyAddedWidget();
    final CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.addSelectedManagersToSecurityTeam());
    final TabItem tab = this;
    // search textbox
    final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            startSearching(text);
            searchString = text;
        }
    }, searchButton);
    tabMenu.addWidget(addButton);
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, !alreadyAddedList.isEmpty());
        }
    }));
    addButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<User> list = users.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                for (int i = 0; i < list.size(); i++) {
                    // FIXME - Should have only one callback to core
                    final int n = i;
                    AddAdmin request = new AddAdmin(JsonCallbackEvents.disableButtonEvents(addButton, new JsonCallbackEvents() {

                        @Override
                        public void onFinished(JavaScriptObject jso) {
                            // put names to already added
                            alreadyAddedList.add(list.get(n));
                            rebuildAlreadyAddedWidget();
                            // unselect added person
                            users.getSelectionModel().setSelected(list.get(n), false);
                            // clear search
                            searchBox.getTextBox().setText("");
                        }
                    }));
                    request.addSecurityTeamAdmin(securityTeam, list.get(i));
                }
            }
        }
    });
    // if some text has been searched before
    if (!searchString.equals("")) {
        searchBox.getTextBox().setText(searchString);
        startSearching(searchString);
    }
    addButton.setEnabled(false);
    JsonUtils.addTableManagedButton(users, table, addButton);
    // 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 menu and the table to the main panel
    firstTabPanel.add(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    firstTabPanel.add(alreadyAdded);
    firstTabPanel.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FindCompleteRichUsers(cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers) ArrayList(java.util.ArrayList) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) AddAdmin(cz.metacentrum.perun.webgui.json.authzResolver.AddAdmin) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) 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)

Example 74 with ClickEvent

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

the class CreateSecurityTeamTabItem method draw.

public Widget draw() {
    VerticalPanel vp = new VerticalPanel();
    // textboxes which set the class data when updated
    final ExtendedTextBox nameTextBox = new ExtendedTextBox();
    final ExtendedTextBox descriptionTextBox = new ExtendedTextBox();
    nameTextBox.getTextBox().setMaxLength(128);
    final ExtendedTextBox.TextBoxValidator nameValidator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (!nameTextBox.getTextBox().getText().trim().isEmpty()) {
                nameTextBox.setOk();
                return true;
            } else {
                nameTextBox.setError("Name can't be empty.");
                return false;
            }
        }
    };
    nameTextBox.setValidator(nameValidator);
    // prepares layout
    FlexTable layout = new FlexTable();
    layout.setStyleName("inputFormFlexTable");
    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
    // close tab events
    final TabItem tab = this;
    TabMenu menu = new TabMenu();
    // send button
    final CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, buttonTranslation.createSecurityTeam());
    createButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (!nameValidator.validateTextBox())
                return;
            CreateSecurityTeam request = new CreateSecurityTeam(JsonCallbackEvents.closeTabDisableButtonEvents(createButton, tab, new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    // new SecTeam must be editable by user in GUI, because it is already in PERUN
                    SecurityTeam team = jso.cast();
                    session.addEditableSecurityTeam(team.getId());
                }
            }));
            request.createSecurityTeam(nameTextBox.getTextBox().getText().trim(), descriptionTextBox.getTextBox().getText().trim());
        }
    });
    // cancel button
    final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
    cancelButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    });
    // Add some standard form options
    layout.setHTML(0, 0, "Name:");
    layout.setWidget(0, 1, nameTextBox);
    layout.setHTML(1, 0, "Description:");
    layout.setWidget(1, 1, descriptionTextBox);
    for (int i = 0; i < layout.getRowCount(); i++) {
        cellFormatter.addStyleName(i, 0, "itemName");
    }
    menu.addWidget(createButton);
    menu.addWidget(cancelButton);
    vp.add(layout);
    vp.add(menu);
    vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) CreateSecurityTeam(cz.metacentrum.perun.webgui.json.securityTeamsManager.CreateSecurityTeam) SecurityTeam(cz.metacentrum.perun.webgui.model.SecurityTeam) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) CreateSecurityTeam(cz.metacentrum.perun.webgui.json.securityTeamsManager.CreateSecurityTeam) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 75 with ClickEvent

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

the class EditSecurityTeamDetailsTabItem method draw.

public Widget draw() {
    titleWidget = new Label("Edit Security Team");
    VerticalPanel vp = new VerticalPanel();
    // textboxes which set the class data when updated
    final ExtendedTextBox nameTextBox = new ExtendedTextBox();
    nameTextBox.getTextBox().setText(team.getName());
    nameTextBox.getTextBox().setMaxLength(128);
    final ExtendedTextBox.TextBoxValidator nameValidator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (!nameTextBox.getTextBox().getText().trim().isEmpty()) {
                nameTextBox.setOk();
                return true;
            } else {
                nameTextBox.setError("Name can't be empty.");
                return false;
            }
        }
    };
    nameTextBox.setValidator(nameValidator);
    final ExtendedTextBox descriptionTextBox = new ExtendedTextBox();
    descriptionTextBox.getTextBox().setText(team.getDescription());
    // prepares layout
    FlexTable layout = new FlexTable();
    layout.setStyleName("inputFormFlexTable");
    FlexCellFormatter cellFormatter = layout.getFlexCellFormatter();
    // close tab events
    final TabItem tab = this;
    TabMenu menu = new TabMenu();
    // send button
    final CustomButton saveButton = TabMenu.getPredefinedButton(ButtonType.SAVE, "Save changes of Security team name");
    saveButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (!nameValidator.validateTextBox())
                return;
            SecurityTeam team2 = JsonUtils.clone(team).cast();
            team2.setName(nameTextBox.getTextBox().getText().trim());
            team2.setDescription(descriptionTextBox.getTextBox().getText().trim());
            UpdateSecurityTeam request = new UpdateSecurityTeam(JsonCallbackEvents.closeTabDisableButtonEvents(saveButton, tab, events));
            request.updateSecurityTeam(team2);
        }
    });
    // cancel button
    final CustomButton cancelButton = TabMenu.getPredefinedButton(ButtonType.CANCEL, "");
    cancelButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    });
    // Add some standard form options
    layout.setHTML(0, 0, "Name:");
    layout.setWidget(0, 1, nameTextBox);
    layout.setHTML(1, 0, "Description:");
    layout.setWidget(1, 1, descriptionTextBox);
    for (int i = 0; i < layout.getRowCount(); i++) {
        cellFormatter.addStyleName(i, 0, "itemName");
    }
    menu.addWidget(saveButton);
    menu.addWidget(cancelButton);
    vp.add(layout);
    vp.add(menu);
    vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : UpdateSecurityTeam(cz.metacentrum.perun.webgui.json.securityTeamsManager.UpdateSecurityTeam) FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) UpdateSecurityTeam(cz.metacentrum.perun.webgui.json.securityTeamsManager.UpdateSecurityTeam) SecurityTeam(cz.metacentrum.perun.webgui.model.SecurityTeam) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

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