Search in sources :

Example 76 with TabMenu

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

the class VoApplicationsTabItem method draw.

public Widget draw() {
    // request
    final GetApplicationsForVo applicationsRequest = new GetApplicationsForVo(vo.getId());
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(applicationsRequest);
    applicationsRequest.setCheckable(false);
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": " + "applications");
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    firstTabPanel.add(menu);
    firstTabPanel.setCellHeight(menu, "30px");
    // refresh
    menu.addWidget(UiElements.getRefreshButton(this));
    /*

		// verify button
		final CustomButton verify = TabMenu.getPredefinedButton(ButtonType.VERIFY, ButtonTranslation.INSTANCE.verifyApplication());
		verify.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				ArrayList<Application> list = applicationsRequest.getTableSelectedList();
				if (UiElements.cantSaveEmptyListDialogBox(list)) {
					for (int i=0; i<list.size(); i++) {
						if (i != list.size()-1) {
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify));
							request.verifyApplication(list.get(i).getId());
						} else {
							// refresh table on last call
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(verify, events));
							request.verifyApplication(list.get(i).getId());
						}
					}
				}
			}
		});

		// accept button
		final CustomButton approve = TabMenu.getPredefinedButton(ButtonType.APPROVE, ButtonTranslation.INSTANCE.approveApplication());
		approve.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				ArrayList<Application> list = applicationsRequest.getTableSelectedList();
				if (UiElements.cantSaveEmptyListDialogBox(list)) {
					for (int i=0; i<list.size(); i++) {
						if (i != list.size()-1) {
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve));
							request.approveApplication(list.get(i));
						} else {
							// refresh table on last call
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(approve, events));
							request.approveApplication(list.get(i));
						}
					}
				}
			}
		});

		//reject button
		final CustomButton reject = TabMenu.getPredefinedButton(ButtonType.REJECT, ButtonTranslation.INSTANCE.rejectApplication());
		reject.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				final ArrayList<Application> list = applicationsRequest.getTableSelectedList();
				if (UiElements.cantSaveEmptyListDialogBox(list)) {
					// confirm content
					FlexTable content = new FlexTable();
					content.setCellSpacing(10);
					content.setHTML(0, 0, "Please specify reason of rejection to let user know why was application rejected.");
					content.getFlexCellFormatter().setColSpan(0, 0, 2);
					final TextArea reason = new TextArea();
					reason.setSize("300px", "150px");
					content.setHTML(1, 0, "<strong>Reason: </strong>");
					content.setWidget(1, 1, reason);

					Confirm c = new Confirm("Specify reason", content, new ClickHandler(){
						public void onClick(ClickEvent event) {

							for (int i=0; i<list.size(); i++) {
								if (i != list.size()-1) {
									HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject));
									request.rejectApplication(list.get(i).getId(), reason.getText());
								} else {
									// refresh table on last call
									HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(reject, events));
									request.rejectApplication(list.get(i).getId(), reason.getText());
								}
							}

						}
					}, true);
					c.show();
				}
			}
		});

		// delete button
		final CustomButton delete = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteApplication());
		delete.addClickHandler(new ClickHandler() {
			public void onClick(ClickEvent event) {
				ArrayList<Application> list = applicationsRequest.getTableSelectedList();
				if (UiElements.cantSaveEmptyListDialogBox(list)) {
					for (int i=0; i<list.size(); i++) {
						if (i != list.size()-1) {
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete));
							request.deleteApplication(list.get(i).getId());
						} else {
							// refresh table on last call
							HandleApplication request = new HandleApplication(JsonCallbackEvents.disableButtonEvents(delete, events));
							request.deleteApplication(list.get(i).getId());
						}
					}
				}
			}
		});

		menu.addWidget(verify);
		menu.addWidget(approve);
		menu.addWidget(reject);
		menu.addWidget(delete);

		*/
    // FILTER
    menu.addWidget(new HTML("<strong>State: </strong>"));
    // state
    final ListBox stateListBox = new ListBox();
    stateListBox.addItem(WidgetTranslation.INSTANCE.listboxAll(), "");
    stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateNew(), "NEW");
    stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateVerified(), "VERIFIED");
    stateListBox.addItem("Pending", "NEW,VERIFIED");
    stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateApproved(), "APPROVED");
    stateListBox.addItem(ObjectTranslation.INSTANCE.applicationStateRejected(), "REJECTED");
    stateListBox.setSelectedIndex(selectedIndex);
    menu.addWidget(stateListBox);
    stateListBox.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            selectedIndex = stateListBox.getSelectedIndex();
            applicationsRequest.setState(stateListBox.getValue(stateListBox.getSelectedIndex()));
            applicationsRequest.clearTable();
            applicationsRequest.retrieveData();
        }
    });
    // FILTER 2
    menu.addWidget(new HTML("<strong>Submitted&nbsp;by: </strong>"));
    menu.addFilterWidget(new ExtendedSuggestBox(applicationsRequest.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            applicationsRequest.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterApplications());
    // TABLE
    applicationsRequest.setState(stateListBox.getValue(stateListBox.getSelectedIndex()));
    CellTable<Application> table = applicationsRequest.getTable(new FieldUpdater<Application, String>() {

        public void update(int index, Application object, String value) {
            session.getTabManager().addTabToCurrentTab(new ApplicationDetailTabItem(object), true);
        }
    });
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    /*
		verify.setEnabled(false);
		approve.setEnabled(false);
		reject.setEnabled(false);
		delete.setEnabled(false);

		if (session.isVoAdmin(voId)) {
			JsonUtils.addTableManagedButton(applicationsRequest, table, approve);
			JsonUtils.addTableManagedButton(applicationsRequest, table, reject);
			JsonUtils.addTableManagedButton(applicationsRequest, table, delete);
		}
		if (session.isPerunAdmin()) {
			JsonUtils.addTableManagedButton(applicationsRequest, table, verify);
		}
		*/
    session.getUiElements().resizePerunTable(sp, 100);
    firstTabPanel.add(sp);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ApplicationDetailTabItem(cz.metacentrum.perun.webgui.tabs.registrartabs.ApplicationDetailTabItem) GetApplicationsForVo(cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationsForVo) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) Application(cz.metacentrum.perun.webgui.model.Application) HandleApplication(cz.metacentrum.perun.webgui.json.registrarManager.HandleApplication)

Example 77 with TabMenu

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

the class VoGroupsTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": " + "groups");
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    // VO Groups request
    ArrayList<String> attrNames = new ArrayList<>();
    attrNames.add("urn:perun:group:attribute-def:def:synchronizationEnabled");
    attrNames.add("urn:perun:group:attribute-def:def:synchronizationInterval");
    attrNames.add("urn:perun:group:attribute-def:def:lastSynchronizationState");
    attrNames.add("urn:perun:group:attribute-def:def:lastSuccessSynchronizationTimestamp");
    attrNames.add("urn:perun:group:attribute-def:def:lastSynchronizationTimestamp");
    attrNames.add("urn:perun:group:attribute-def:def:authoritativeGroup");
    final GetAllRichGroups groups = new GetAllRichGroups(voId, attrNames);
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(groups);
    if (!session.isVoAdmin(voId))
        groups.setCheckable(false);
    // refresh
    menu.addWidget(UiElements.getRefreshButton(this));
    // add new group button
    CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createGroup(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new CreateGroupTabItem(vo));
        }
    });
    if (!session.isVoAdmin(voId))
        createButton.setEnabled(false);
    menu.addWidget(createButton);
    // delete selected groups button
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteGroup());
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<RichGroup> groupsToDelete = groups.getTableSelectedList();
            String text = "Following groups (including all sub-groups) will be deleted.";
            UiElements.showDeleteConfirm(groupsToDelete, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    DeleteGroups request = new DeleteGroups(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                    request.deleteGroups(groupsToDelete);
                }
            });
        }
    });
    menu.addWidget(removeButton);
    // filter box
    menu.addFilterWidget(new ExtendedSuggestBox(groups.getOracle()), new PerunSearchEvent() {

        public void searchFor(String text) {
            groups.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterGroup());
    // add a table with a onclick
    CellTable<RichGroup> table = groups.getTable(new FieldUpdater<RichGroup, String>() {

        public void update(int index, RichGroup group, String value) {
            session.getTabManager().addTab(new GroupDetailTabItem(group.getId()));
        }
    });
    // 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(menu);
    firstTabPanel.setCellHeight(menu, "30px");
    firstTabPanel.add(sp);
    removeButton.setEnabled(false);
    if (session.isVoAdmin(voId))
        JsonUtils.addTableManagedButton(groups, table, removeButton);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) RichGroup(cz.metacentrum.perun.webgui.model.RichGroup) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) CreateGroupTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.CreateGroupTabItem) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) GroupDetailTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem) GetAllRichGroups(cz.metacentrum.perun.webgui.json.groupsManager.GetAllRichGroups) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) DeleteGroups(cz.metacentrum.perun.webgui.json.groupsManager.DeleteGroups)

Example 78 with TabMenu

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

the class VoManagersTabItem method draw.

public Widget draw() {
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": managers");
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // HORIZONTAL MENU
    final TabMenu menu = new TabMenu();
    final ListBox box = new ListBox();
    box.addItem("Users");
    box.addItem("Groups");
    box.setSelectedIndex(selectedDropDownIndex);
    final ScrollPanel sp = new ScrollPanel();
    sp.addStyleName("perun-tableScrollPanel");
    // request
    final GetRichAdminsWithAttributes admins = new GetRichAdminsWithAttributes(PerunEntity.VIRTUAL_ORGANIZATION, voId, null);
    final GetAdminGroups adminGroups = new GetAdminGroups(PerunEntity.VIRTUAL_ORGANIZATION, voId);
    if (!session.isVoAdmin(voId))
        admins.setCheckable(false);
    if (!session.isVoAdmin(voId))
        adminGroups.setCheckable(false);
    box.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            if (box.getSelectedIndex() == 0) {
                selectedDropDownIndex = 0;
                sp.setWidget(fillContentUsers(admins, menu));
            } else {
                selectedDropDownIndex = 1;
                sp.setWidget(fillContentGroups(adminGroups, menu));
            }
        }
    });
    if (selectedDropDownIndex == 0) {
        sp.setWidget(fillContentUsers(admins, menu));
    } else {
        sp.setWidget(fillContentGroups(adminGroups, menu));
    }
    menu.addWidget(3, new HTML("<strong>Select mode: </strong>"));
    menu.addWidget(4, box);
    session.getUiElements().resizePerunTable(sp, 350, this);
    // add menu and the table to the main panel
    firstTabPanel.add(menu);
    firstTabPanel.setCellHeight(menu, "30px");
    firstTabPanel.add(sp);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : GetRichAdminsWithAttributes(cz.metacentrum.perun.webgui.json.authzResolver.GetRichAdminsWithAttributes) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) GetAdminGroups(cz.metacentrum.perun.webgui.json.authzResolver.GetAdminGroups) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu)

Example 79 with TabMenu

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

the class VoMembersTabItem method draw.

public Widget draw() {
    // SET TAB NAME
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": members");
    // MAIN PANEL
    final VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // MENU
    TabMenu tabMenu = new TabMenu();
    firstTabPanel.add(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    // DISABLED CHECKBOX
    final CheckBox disabled = new CheckBox(WidgetTranslation.INSTANCE.showDisabledMembers());
    disabled.setTitle(WidgetTranslation.INSTANCE.showDisabledMembersTitle());
    disabled.setValue(wasDisabled);
    disabled.setVisible(false);
    // CALLBACKS
    final GetCompleteRichMembers members = new GetCompleteRichMembers(PerunEntity.VIRTUAL_ORGANIZATION, voId, null);
    final FindCompleteRichMembers findMembers = new FindCompleteRichMembers(PerunEntity.VIRTUAL_ORGANIZATION, voId, "", null);
    members.excludeDisabled(!wasDisabled);
    final CustomButton searchButton = TabMenu.getPredefinedButton(ButtonType.SEARCH, ButtonTranslation.INSTANCE.searchMemberInVo());
    final CustomButton listAllButton = TabMenu.getPredefinedButton(ButtonType.LIST_ALL_MEMBERS, ButtonTranslation.INSTANCE.listAllMembersInVo());
    if (!session.isVoAdmin(voId))
        findMembers.setCheckable(false);
    final CellTable<RichMember> table = findMembers.getEmptyTable(new FieldUpdater<RichMember, RichMember>() {

        // when user click on a row -> open new tab
        public void update(int index, RichMember object, RichMember value) {
            session.getTabManager().addTab(new MemberDetailTabItem(object.getId(), 0));
        }
    });
    // refresh
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    // ADD
    CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addMemberToVo(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AddMemberToVoTabItem(voId), true);
        }
    });
    if (!session.isVoAdmin(voId))
        addButton.setEnabled(false);
    tabMenu.addWidget(addButton);
    // REMOVE
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeMemberFromVo());
    if (!session.isVoAdmin(voId))
        removeButton.setEnabled(false);
    tabMenu.addWidget(removeButton);
    /*
		final CustomButton addServiceButton = new CustomButton(ButtonTranslation.INSTANCE.createServiceMemberButton(), ButtonTranslation.INSTANCE.createServiceMember(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {
			public void onClick(ClickEvent clickEvent) {
				session.getTabManager().addTabToCurrentTab(new CreateServiceMemberInVoTabItem(vo));
			}
		});
		if (!session.isVoAdmin(voId)) addServiceButton.setEnabled(false);
		tabMenu.addWidget(addServiceButton);
		*/
    // refreshMembers
    final JsonCallbackEvents refreshEvent = new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            if (search) {
                findMembers.searchFor(searchString);
            } else {
                findMembers.clearTable();
                members.retrieveData();
            }
        }
    };
    // add click handler for remove button
    removeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            // state specific events
            final ArrayList<RichMember> membersForRemoving = findMembers.getTableSelectedList();
            String text = "Following members will be removed from VO and their settings will be lost.<p>You can consider changing their status to \"DISABLED\", which will prevent them from accessing VO resources.";
            UiElements.showDeleteConfirm(membersForRemoving, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < membersForRemoving.size(); i++) {
                        DeleteMember request;
                        if (i == membersForRemoving.size() - 1) {
                            request = new DeleteMember(JsonCallbackEvents.disableButtonEvents(removeButton, refreshEvent));
                        } else {
                            request = new DeleteMember(JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.deleteMember(membersForRemoving.get(i).getId());
                    }
                }
            });
        }
    });
    final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {

        public void searchFor(String text) {
            searchString = text;
            search = true;
            findMembers.searchFor(text);
        }
    }, searchButton);
    searchBox.getTextBox().setText(searchString);
    // checkbox click handler
    disabled.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            wasDisabled = disabled.getValue();
            if (search) {
                // case when update but not triggered by button
                searchString = searchBox.getTextBox().getText();
                members.excludeDisabled(!disabled.getValue());
            } else {
                members.excludeDisabled(!disabled.getValue());
                members.retrieveData();
            }
        }
    });
    findMembers.setEvents(JsonCallbackEvents.mergeEvents(JsonCallbackEvents.disableButtonEvents(searchButton, JsonCallbackEvents.disableCheckboxEvents(disabled)), new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            searchBox.getTextBox().setEnabled(true);
            listAllButton.setEnabled(true);
        }

        @Override
        public void onError(PerunError error) {
            searchBox.getTextBox().setEnabled(true);
            listAllButton.setEnabled(true);
        }

        @Override
        public void onLoadingStart() {
            searchBox.getTextBox().setEnabled(false);
            listAllButton.setEnabled(false);
            disabled.setVisible(false);
        }
    }));
    members.setEvents(JsonCallbackEvents.mergeEvents(JsonCallbackEvents.disableButtonEvents(listAllButton, JsonCallbackEvents.disableCheckboxEvents(disabled)), new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            // pass data to table handling callback
            findMembers.onFinished(jso);
            ((AjaxLoaderImage) table.getEmptyTableWidget()).setEmptyResultMessage("VO has no members.");
            searchBox.getTextBox().setEnabled(true);
            searchButton.setEnabled(true);
        }

        @Override
        public void onError(PerunError error) {
            // pass data to table handling callback
            findMembers.onError(error);
            searchBox.getTextBox().setEnabled(true);
            searchButton.setEnabled(true);
        }

        @Override
        public void onLoadingStart() {
            searchBox.getTextBox().setEnabled(false);
            searchButton.setEnabled(false);
            disabled.setVisible(true);
            // to show progress when reloading
            ((AjaxLoaderImage) table.getEmptyTableWidget()).loadingStart();
        }
    }));
    // LIST ALL BUTTON
    listAllButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            search = false;
            searchString = "";
            searchBox.getTextBox().setText("");
            findMembers.clearTable();
            members.retrieveData();
        }
    });
    tabMenu.addWidget(listAllButton);
    tabMenu.addWidget(disabled);
    /* WHEN TAB RELOADS, CHECK THE STATE */
    if (search) {
        findMembers.searchFor(searchString);
    } else {
        members.excludeDisabled(!disabled.getValue());
        members.retrieveData();
    }
    ScrollPanel tableWrapper = new ScrollPanel();
    table.addStyleName("perun-table");
    tableWrapper.setWidget(table);
    tableWrapper.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(tableWrapper, 350, this);
    // add menu and the table to the main panel
    firstTabPanel.add(tableWrapper);
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(findMembers, table, removeButton);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) MemberDetailTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.MemberDetailTabItem) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) AddMemberToVoTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.AddMemberToVoTabItem) ExtendedTextBox(cz.metacentrum.perun.webgui.widgets.ExtendedTextBox) RichMember(cz.metacentrum.perun.webgui.model.RichMember) DeleteMember(cz.metacentrum.perun.webgui.json.membersManager.DeleteMember) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) GetCompleteRichMembers(cz.metacentrum.perun.webgui.json.membersManager.GetCompleteRichMembers) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) PerunError(cz.metacentrum.perun.webgui.model.PerunError) FindCompleteRichMembers(cz.metacentrum.perun.webgui.json.membersManager.FindCompleteRichMembers)

Example 80 with TabMenu

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

the class AddVoManagerTabItem method draw.

public Widget draw() {
    titleWidget.setText("Add manager");
    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.addSelectedManagersToVo());
    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.addVoAdmin(vo, 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) 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)

Aggregations

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