Search in sources :

Example 31 with CustomButton

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

the class VoManagersTabItem method fillContentUsers.

private Widget fillContentUsers(final GetRichAdminsWithAttributes admins, TabMenu menu) {
    admins.clearTableSelectedSet();
    // refresh
    menu.addWidget(0, UiElements.getRefreshButton(this));
    // Events for reloading when finished
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(admins);
    CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerToVo(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AddVoManagerTabItem(vo), true);
        }
    });
    if (!session.isVoAdmin(voId))
        addButton.setEnabled(false);
    menu.addWidget(1, addButton);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerFromVo());
    menu.addWidget(2, removeButton);
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<User> adminsForRemoving = admins.getTableSelectedList();
            String text = "Following users won't be VO managers anymore.";
            UiElements.showDeleteConfirm(adminsForRemoving, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < adminsForRemoving.size(); i++) {
                        RemoveAdmin request;
                        if (i == adminsForRemoving.size() - 1) {
                            request = new RemoveAdmin(PerunEntity.VIRTUAL_ORGANIZATION, JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        } else {
                            request = new RemoveAdmin(PerunEntity.VIRTUAL_ORGANIZATION, JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.removeVoAdmin(vo, adminsForRemoving.get(i));
                    }
                }
            });
        }
    });
    // get the table
    CellTable<User> table;
    if (session.isPerunAdmin()) {
        table = admins.getTable(new FieldUpdater<User, String>() {

            public void update(int i, User user, String s) {
                session.getTabManager().addTab(new UserDetailTabItem(user));
            }
        });
    } else {
        table = admins.getTable();
    }
    // add a class to the table and wrap it into scroll panel
    table.addStyleName("perun-table");
    removeButton.setEnabled(false);
    if (session.isVoAdmin(voId))
        JsonUtils.addTableManagedButton(admins, table, removeButton);
    return table;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) RemoveAdmin(cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)

Example 32 with CustomButton

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

the class VoOverviewTabItem method draw.

public Widget draw() {
    // main panel
    ScrollPanel scroll = new ScrollPanel();
    final VerticalPanel vp2 = new VerticalPanel();
    vp2.setStyleName("perun-table");
    scroll.setWidget(vp2);
    scroll.setStyleName("perun-tableScrollPanel");
    vp2.setSpacing(5);
    // tools panel
    final DisclosurePanel tools = new DisclosurePanel();
    tools.setWidth("100%");
    tools.setOpen(true);
    FlexTable toolsHeader = new FlexTable();
    toolsHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.settingToolsIcon()));
    toolsHeader.setWidget(0, 1, new HTML("<h3>Quick tools</h3>"));
    toolsHeader.setTitle("Click to show/hide VO quick tools");
    tools.setHeader(toolsHeader);
    // tools panel content
    FlexTable toolsLayout = new FlexTable();
    toolsLayout.setSize("100%", "100%");
    toolsLayout.setCellSpacing(5);
    tools.setContent(toolsLayout);
    toolsLayout.getFlexCellFormatter().setWidth(0, 0, "220px");
    toolsLayout.getFlexCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(1, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(1, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(2, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(2, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(3, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(3, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(4, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(4, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(5, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(5, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(6, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    toolsLayout.getFlexCellFormatter().setAlignment(6, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
    CustomButton addMember = new CustomButton(ButtonTranslation.INSTANCE.addMemberButton() + "…", ButtonTranslation.INSTANCE.addMemberToVo(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().addTabToCurrentTab(new AddMemberToVoTabItem(vo), true);
        }
    });
    CustomButton addServiceMember = new CustomButton(ButtonTranslation.INSTANCE.createServiceMemberButton() + "…", ButtonTranslation.INSTANCE.createServiceMember(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().addTabToCurrentTab(new CreateServiceMemberInVoTabItem(vo));
        }
    });
    CustomButton inviteUser = new CustomButton("Invite member…", "Invite person to become member of your Virtual organization.", SmallIcons.INSTANCE.emailAddIcon(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().addTabToCurrentTab(new InviteUserTabItem(vo, null));
        }
    });
    CustomButton addManager = new CustomButton(ButtonTranslation.INSTANCE.addManagerButton() + "…", ButtonTranslation.INSTANCE.addManagerToVo(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().addTabToCurrentTab(new AddVoManagerTabItem(vo), true);
        }
    });
    CustomButton createGroup = new CustomButton(ButtonTranslation.INSTANCE.createGroupButton() + "…", ButtonTranslation.INSTANCE.createGroup(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().addTabToCurrentTab(new CreateGroupTabItem(vo));
        }
    });
    CustomButton addToResource = new CustomButton(ButtonTranslation.INSTANCE.addMemberToResourceButton() + "…", ButtonTranslation.INSTANCE.addMemberToResource(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().addTabToCurrentTab(new AddMemberToResourceTabItem(vo), true);
        }
    });
    toolsLayout.setWidget(0, 0, addMember);
    toolsLayout.setWidget(1, 0, addServiceMember);
    toolsLayout.setWidget(2, 0, inviteUser);
    toolsLayout.setWidget(3, 0, addManager);
    toolsLayout.setWidget(4, 0, createGroup);
    toolsLayout.setWidget(5, 0, addToResource);
    if (!session.isVoAdmin(voId))
        addMember.setEnabled(false);
    if (!session.isVoAdmin(voId))
        addServiceMember.setEnabled(false);
    if (!session.isVoAdmin(voId))
        inviteUser.setEnabled(false);
    if (!session.isVoAdmin(voId))
        addManager.setEnabled(false);
    if (!session.isVoAdmin(voId))
        createGroup.setEnabled(false);
    if (!session.isVoAdmin(voId))
        addToResource.setEnabled(false);
    toolsLayout.setHTML(0, 1, "Add new member into your VO. Candidates can be searched for in VO's external sources or among user already existing in Perun.");
    toolsLayout.setHTML(1, 1, "Create new member which represent service account (account usually used by more users with separate login and password).");
    toolsLayout.setHTML(2, 1, "Invite person to become member of your Virtual organization.");
    toolsLayout.setHTML(3, 1, "Add new manager which can manage your VO in Perun.");
    toolsLayout.setHTML(4, 1, "Create new group in your VO.");
    toolsLayout.setHTML(5, 1, "Add selected member to specific resource (grant some type of access to Facility resources).");
    vp2.add(tools);
    // statistics - json
    // call the request for number of members
    final GetMembersCount countMembers = new GetMembersCount(vo.getId(), null);
    final GetMembersCount countValidMembers = new GetMembersCount(vo.getId(), PerunStatus.VALID);
    final GetMembersCount countInvalidMembers = new GetMembersCount(vo.getId(), PerunStatus.INVALID);
    final GetMembersCount countSuspendedMembers = new GetMembersCount(vo.getId(), PerunStatus.SUSPENDED);
    final GetMembersCount countExpiredMembers = new GetMembersCount(vo.getId(), PerunStatus.EXPIRED);
    final GetMembersCount countDisabledMembers = new GetMembersCount(vo.getId(), PerunStatus.DISABLED);
    // call the request for number of resources
    final GetResourcesCount countResources = new GetResourcesCount(vo.getId());
    // call the request for number of groups
    final GetGroupsCount countGroups = new GetGroupsCount(vo.getId());
    // statistics
    final DisclosurePanel statistics = new DisclosurePanel();
    statistics.setWidth("100%");
    //statistics.setOpen(true);
    FlexTable statHeader = new FlexTable();
    statHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.statisticsIcon()));
    statHeader.setWidget(0, 1, new HTML("<h3>Statistics</h3>"));
    statHeader.setTitle("Click to show/hide VO statistics");
    statistics.setHeader(statHeader);
    final FlexTable vosTable = new FlexTable();
    vosTable.addStyleName("statisticsTable");
    statHeader.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (statistics.getContent() == null) {
                countMembers.retrieveData();
                countValidMembers.retrieveData();
                countInvalidMembers.retrieveData();
                countSuspendedMembers.retrieveData();
                countExpiredMembers.retrieveData();
                countDisabledMembers.retrieveData();
                countResources.retrieveData();
                countGroups.retrieveData();
                statistics.setContent(vosTable);
            }
        }
    });
    vosTable.setWidget(0, 0, new HTML("<strong>" + "Members" + "</strong>"));
    vosTable.setWidget(0, 1, countMembers.getMembersCountLabel());
    vosTable.setWidget(1, 0, new HTML(" - valid"));
    vosTable.setWidget(1, 1, countValidMembers.getMembersCountLabel());
    vosTable.setWidget(2, 0, new HTML(" - invalid"));
    vosTable.setWidget(2, 1, countInvalidMembers.getMembersCountLabel());
    vosTable.setWidget(3, 0, new HTML(" - suspended"));
    vosTable.setWidget(3, 1, countSuspendedMembers.getMembersCountLabel());
    vosTable.setWidget(4, 0, new HTML(" - expired"));
    vosTable.setWidget(4, 1, countExpiredMembers.getMembersCountLabel());
    vosTable.setWidget(5, 0, new HTML(" - disabled"));
    vosTable.setWidget(5, 1, countDisabledMembers.getMembersCountLabel());
    vosTable.setWidget(6, 0, new HTML("<strong>" + "Resources" + "</strong>"));
    vosTable.setWidget(6, 1, countResources.getResourcesCountLabel());
    vosTable.setWidget(7, 0, new HTML("<strong>" + "Groups" + "</strong>"));
    vosTable.setWidget(7, 1, countGroups.getGroupsCountLabel());
    vp2.add(statistics);
    session.getUiElements().resizeSmallTabPanel(scroll, 350, this);
    contentWidget.setWidget(scroll);
    return getWidget();
}
Also used : GetGroupsCount(cz.metacentrum.perun.webgui.json.groupsManager.GetGroupsCount) CreateServiceMemberInVoTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.CreateServiceMemberInVoTabItem) AddMemberToResourceTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.AddMemberToResourceTabItem) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) CreateGroupTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.CreateGroupTabItem) InviteUserTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.InviteUserTabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) GetMembersCount(cz.metacentrum.perun.webgui.json.membersManager.GetMembersCount) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) AddMemberToVoTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.AddMemberToVoTabItem) GetResourcesCount(cz.metacentrum.perun.webgui.json.resourcesManager.GetResourcesCount)

Example 33 with CustomButton

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

the class CreateVoResourceTagTabItem method draw.

public Widget draw() {
    VerticalPanel vp = new VerticalPanel();
    // textboxes which set the class data when updated
    final ExtendedTextBox nameTextBox = 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.createResourceTag());
    createButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (!nameValidator.validateTextBox())
                return;
            CreateResourceTag request = new CreateResourceTag(JsonCallbackEvents.closeTabDisableButtonEvents(createButton, tab));
            request.createResourceTag(nameTextBox.getTextBox().getText().trim(), voId);
        }
    });
    // 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, "Tag name:");
    layout.setWidget(0, 1, nameTextBox);
    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 : FlexCellFormatter(com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) CreateResourceTag(cz.metacentrum.perun.webgui.json.resourcesManager.CreateResourceTag) 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)

Example 34 with CustomButton

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

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

Aggregations

CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)174 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)161 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)161 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)132 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)115 ArrayList (java.util.ArrayList)113 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)98 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)71 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)38 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)32 PerunError (cz.metacentrum.perun.webgui.model.PerunError)30 HashMap (java.util.HashMap)29 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)21 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)20 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)20 Map (java.util.Map)20 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)19 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)19 Group (cz.metacentrum.perun.webgui.model.Group)17 User (cz.metacentrum.perun.webgui.model.User)17