Search in sources :

Example 6 with ExtendedTextBox

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

the class CreateVoTabItem method draw.

public Widget draw() {
    VerticalPanel vp = new VerticalPanel();
    // textboxes which set the class data when updated
    final ExtendedTextBox nameTextBox = new ExtendedTextBox();
    final ExtendedTextBox shortNameTextBox = new ExtendedTextBox();
    nameTextBox.getTextBox().setMaxLength(128);
    shortNameTextBox.getTextBox().setMaxLength(32);
    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;
            }
        }
    };
    final ExtendedTextBox.TextBoxValidator shortNameValidator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (shortNameTextBox.getTextBox().getText().trim().isEmpty()) {
                shortNameTextBox.setError("Short name can't be empty.");
            } else if (!shortNameTextBox.getTextBox().getText().trim().matches(Utils.VO_SHORT_NAME_MATCHER)) {
                shortNameTextBox.setError("Short name can contain only letters, numbers, dash and underscore.");
            } else {
                shortNameTextBox.setOk();
                return true;
            }
            return false;
        }
    };
    nameTextBox.setValidator(nameValidator);
    shortNameTextBox.setValidator(shortNameValidator);
    // 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.createVo());
    createButton.addClickHandler(new ClickHandler() {

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

                @Override
                public void onFinished(JavaScriptObject jso) {
                    // new VO must be editable by user in GUI, because it is already in PERUN
                    VirtualOrganization vo = jso.cast();
                    session.addEditableVo(vo.getId());
                }
            }));
            request.createVo(nameTextBox.getTextBox().getText().trim(), shortNameTextBox.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, "Full name:");
    layout.setWidget(0, 1, nameTextBox);
    layout.setHTML(1, 0, "Short name:");
    layout.setWidget(1, 1, shortNameTextBox);
    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) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) CreateVo(cz.metacentrum.perun.webgui.json.vosManager.CreateVo) 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) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 7 with ExtendedTextBox

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

the class ConnectServiceIdentityTabItem method draw.

public Widget draw() {
    titleWidget.setText("Connect identity");
    VerticalPanel content = new VerticalPanel();
    content.setSize("100%", "100%");
    final TabItem tab = this;
    // add button
    final CustomButton addButton;
    if (user.isServiceUser() || user.isSponsoredUser()) {
        addButton = new CustomButton("Connect", "Add selected users to this identity", SmallIcons.INSTANCE.addIcon());
    } else {
        addButton = new CustomButton("Connect", "Add selected identities to user", SmallIcons.INSTANCE.addIcon());
    }
    TabMenu menu = new TabMenu();
    menu.addWidget(addButton);
    content.add(menu);
    content.setCellHeight(menu, "30px");
    final FindCompleteRichUsers call = new FindCompleteRichUsers("", null);
    if (user.isServiceUser()) {
        call.hideService(true);
    }
    if (user.isSponsoredUser()) {
        call.hideSponsored(true);
        call.hideService(true);
    }
    if (!user.isSpecificUser()) {
        call.hidePerson(true);
    }
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        public void onClick(ClickEvent clickEvent) {
            // close tab and refresh
            session.getTabManager().closeTab(tab, true);
        }
    }));
    // search textbox
    ExtendedTextBox searchBox = menu.addSearchWidget(new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            call.searchFor(text);
        }
    }, "");
    addButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent clickEvent) {
            ArrayList<User> list = call.getTableSelectedList();
            for (int i = 0; i < list.size(); i++) {
                // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                AddSpecificUserOwner req;
                if (i == list.size() - 1) {
                    req = new AddSpecificUserOwner(JsonCallbackEvents.closeTabDisableButtonEvents(addButton, tab));
                } else {
                    req = new AddSpecificUserOwner(JsonCallbackEvents.disableButtonEvents(addButton));
                }
                if (user.isServiceUser() || user.isSponsoredUser()) {
                    // service user adds user
                    req.addSpecificUser(list.get(i), user);
                } else {
                    // user adds service users
                    req.addSpecificUser(user, list.get(i));
                }
            }
        }
    });
    FieldUpdater<User, String> fieldUpdater = null;
    if (session.isPerunAdmin()) {
        fieldUpdater = new FieldUpdater<User, String>() {

            public void update(int i, User user, String s) {
                session.getTabManager().addTab(new UserDetailTabItem(user));
            }
        };
    }
    CellTable<User> table = call.getTable(fieldUpdater);
    table.addStyleName("perun-table");
    table.setWidth("100%");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    addButton.setEnabled(false);
    JsonUtils.addTableManagedButton(call, table, addButton);
    content.add(sp);
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    this.contentWidget.setWidget(new SimplePanel(content));
    return getWidget();
}
Also used : User(cz.metacentrum.perun.webgui.model.User) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FindCompleteRichUsers(cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers) ArrayList(java.util.ArrayList) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) AddSpecificUserOwner(cz.metacentrum.perun.webgui.json.usersManager.AddSpecificUserOwner) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 8 with ExtendedTextBox

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

the class InviteUserTabItem method draw.

public Widget draw() {
    VerticalPanel vp = new VerticalPanel();
    final FlexTable ft = new FlexTable();
    ft.setWidth("350px");
    ft.setStyleName("inputFormFlexTable");
    if (groupId == 0) {
        ft.setHTML(0, 0, "Person you are inviting will receive an email with link to VOs application form. You can set up an email template in: Vo manager (advanced) -> Application form -> Notifications.");
    } else {
        ft.setHTML(0, 0, "Person you are inviting will receive an email with link to groups application form. You can set up an email template in: Group manager (advanced) -> Application form -> Notifications.");
    }
    ft.getFlexCellFormatter().setColSpan(0, 0, 2);
    ft.getFlexCellFormatter().addStyleName(0, 0, "inputFormInlineComment");
    ft.setHTML(1, 0, "Name:");
    ft.setHTML(2, 0, "Email:");
    ft.setHTML(3, 0, "Language:");
    ft.getFlexCellFormatter().setStyleName(1, 0, "itemName");
    ft.getFlexCellFormatter().setStyleName(2, 0, "itemName");
    ft.getFlexCellFormatter().setStyleName(3, 0, "itemName");
    final ListBox languages = new ListBox();
    languages.setWidth("200px");
    //languages.addItem("Czech", "cs");
    languages.addItem("English", "en");
    languages.setSelectedIndex(1);
    if (!Utils.getNativeLanguage().isEmpty()) {
        languages.addItem(Utils.getNativeLanguage().get(2), Utils.getNativeLanguage().get(0));
    }
    final ExtendedTextBox name = new ExtendedTextBox();
    final ExtendedTextBox email = new ExtendedTextBox();
    final ExtendedTextBox.TextBoxValidator nameValidator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (name.getTextBox().getText().trim().isEmpty()) {
                name.setError("Name can't be empty.");
                return false;
            } else {
                name.setOk();
                return true;
            }
        }
    };
    final ExtendedTextBox.TextBoxValidator emailValidator = new ExtendedTextBox.TextBoxValidator() {

        @Override
        public boolean validateTextBox() {
            if (email.getTextBox().getText().trim().isEmpty()) {
                email.setError("Email can't be empty.");
                return false;
            } else if (!JsonUtils.isValidEmail(email.getTextBox().getText().trim())) {
                email.setError("Not valid email address format.");
                return false;
            } else {
                email.setOk();
                return true;
            }
        }
    };
    // Name is now optional
    // name.setValidator(nameValidator);
    email.setValidator(emailValidator);
    ft.setWidget(1, 1, name);
    ft.setWidget(2, 1, email);
    ft.setWidget(3, 1, languages);
    vp.add(ft);
    final TabItem tab = this;
    final CustomButton sendInvitationButton = new CustomButton("Send invitation", SmallIcons.INSTANCE.emailIcon());
    sendInvitationButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            //if (!nameValidator.validateTextBox() || !emailValidator.validateTextBox()) return;
            if (!emailValidator.validateTextBox())
                return;
            SendInvitation invite = new SendInvitation(vo.getId(), groupId, JsonCallbackEvents.closeTabDisableButtonEvents(sendInvitationButton, tab));
            invite.inviteUser(email.getTextBox().getText().trim(), name.getTextBox().getText().trim(), languages.getValue(languages.getSelectedIndex()));
        }
    });
    TabMenu menu = new TabMenu();
    vp.add(menu);
    vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
    menu.addWidget(sendInvitationButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    contentWidget.setWidget(vp);
    return getWidget();
}
Also used : ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) 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) SendInvitation(cz.metacentrum.perun.webgui.json.registrarManager.SendInvitation)

Example 9 with ExtendedTextBox

use of cz.metacentrum.perun.webgui.widgets.ExtendedTextBox 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 10 with ExtendedTextBox

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

Aggregations

ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)32 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)32 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)31 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)31 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)31 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)29 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)17 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)17 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)14 ArrayList (java.util.ArrayList)12 PerunError (cz.metacentrum.perun.webgui.model.PerunError)8 User (cz.metacentrum.perun.webgui.model.User)8 FindCompleteRichUsers (cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers)7 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)6 UserDetailTabItem (cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem)5 AddAdmin (cz.metacentrum.perun.webgui.json.authzResolver.AddAdmin)4 AjaxLoaderImage (cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage)4 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)3 FindCompleteRichMembers (cz.metacentrum.perun.webgui.json.membersManager.FindCompleteRichMembers)3 GetCompleteRichMembers (cz.metacentrum.perun.webgui.json.membersManager.GetCompleteRichMembers)3