Search in sources :

Example 61 with TabMenu

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

the class PublicationDetailTabItem method loadAuthorsSubTab.

/**
	 * Returns widget with authors management for publication
	 *
	 * @return widget
	 */
private Widget loadAuthorsSubTab() {
    DisclosurePanel dp = new DisclosurePanel();
    dp.setWidth("100%");
    dp.setOpen(true);
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    dp.setContent(vp);
    FlexTable header = new FlexTable();
    header.setWidget(0, 0, new Image(LargeIcons.INSTANCE.userGreenIcon()));
    header.setHTML(0, 1, "<h3>Authors / Reported by</h3>");
    dp.setHeader(header);
    // menu
    TabMenu menu = new TabMenu();
    // callback
    final FindAuthorsByPublicationId call = new FindAuthorsByPublicationId(publication.getId());
    call.setCheckable(false);
    if (!publication.getLocked()) {
        // editable if not locked
        vp.add(menu);
        vp.setCellHeight(menu, "30px");
        call.setCheckable(true);
    }
    final CustomButton addButton = new CustomButton("Add myself", "Add you as author of publication", SmallIcons.INSTANCE.addIcon());
    addButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(call);
            CreateAuthorship request = new CreateAuthorship(JsonCallbackEvents.disableButtonEvents(addButton, events));
            request.createAuthorship(publicationId, session.getActiveUser().getId());
        }
    });
    menu.addWidget(addButton);
    CustomButton addOthersButton = new CustomButton("Add others", "Add more authors", SmallIcons.INSTANCE.addIcon());
    addOthersButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AddAuthorTabItem(publication, JsonCallbackEvents.refreshTableEvents(call)), true);
        }
    });
    menu.addWidget(addOthersButton);
    // fill table
    CellTable<Author> table = call.getEmptyTable();
    call.retrieveData();
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, "Remove select author(s) from publication");
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(call, table, removeButton);
    menu.addWidget(removeButton);
    removeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<Author> list = call.getTableSelectedList();
            String text = "Following users will be removed from publication's authors. They will lose any benefit granted by publication's rank.";
            UiElements.showDeleteConfirm(list, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                    for (int i = 0; i < list.size(); i++) {
                        // calls the request
                        if (i == list.size() - 1) {
                            DeleteAuthorship request = new DeleteAuthorship(JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(call)));
                            request.deleteAuthorship(publicationId, list.get(i).getId());
                        } else {
                            DeleteAuthorship request = new DeleteAuthorship();
                            request.deleteAuthorship(publicationId, list.get(i).getId());
                        }
                    }
                }
            });
        }
    });
    ScrollPanel sp = new ScrollPanel();
    sp.add(table);
    table.addStyleName("perun-table");
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    return dp;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) Author(cz.metacentrum.perun.webgui.model.Author)

Example 62 with TabMenu

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

the class PublicationSystemsTabItem method draw.

public Widget draw() {
    // main panel
    VerticalPanel vp = new VerticalPanel();
    vp.getElement().setAttribute("style", "padding-top: 5px;");
    vp.setSize("100%", "100%");
    // MENU
    TabMenu menu = new TabMenu();
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    menu.addWidget(UiElements.getRefreshButton(this));
    GetPublicationSystems call = new GetPublicationSystems();
    call.setCheckable(false);
    CellTable<PublicationSystem> table = call.getTable();
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel();
    sp.add(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    // resize perun table to correct size on screen
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : PublicationSystem(cz.metacentrum.perun.webgui.model.PublicationSystem) GetPublicationSystems(cz.metacentrum.perun.webgui.json.cabinetManager.GetPublicationSystems) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu)

Example 63 with TabMenu

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

the class FacilityManagersTabItem method draw.

public Widget draw() {
    // set title
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Managers");
    // content
    VerticalPanel vp = new VerticalPanel();
    vp.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.FACILITY, facilityId, null);
    final GetAdminGroups adminGroups = new GetAdminGroups(PerunEntity.FACILITY, facilityId);
    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);
    menu.addWidget(5, new Image(SmallIcons.INSTANCE.helpIcon()));
    menu.addWidget(6, new HTML("<strong>People with privilege to manage this facility in Perun. They aren't automatically \"roots\" on machine.</strong>"));
    session.getUiElements().resizePerunTable(sp, 350, this);
    // add menu and the table to the main panel
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    vp.add(sp);
    this.contentWidget.setWidget(vp);
    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 64 with TabMenu

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

the class FacilityResourcesTabItem method draw.

public Widget draw() {
    // set title
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Resources");
    // main panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    // get VO resources
    final GetAssignedRichResources resources = new GetAssignedRichResources(facility.getId());
    // custom events for viewResource
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(resources);
    // create resource button
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createResource(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new CreateFacilityResourceTabItem(facility), false);
        }
    }));
    final CustomButton deleteButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteResource());
    menu.addWidget(deleteButton);
    deleteButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            final ArrayList<RichResource> toDelete = resources.getTableSelectedList();
            String text = "Following resources will be deleted.";
            UiElements.showDeleteConfirm(toDelete, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < toDelete.size(); i++) {
                        if (i == toDelete.size() - 1) {
                            DeleteResource request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(deleteButton, events));
                            request.deleteResource(toDelete.get(i).getId());
                        } else {
                            DeleteResource request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(deleteButton));
                            request.deleteResource(toDelete.get(i).getId());
                        }
                    }
                }
            });
        }
    });
    menu.addFilterWidget(new ExtendedSuggestBox(resources.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            resources.filterTable(text);
        }
    }, "Filter resources by name or VO name");
    CellTable<RichResource> table = resources.getTable(new FieldUpdater<RichResource, String>() {

        public void update(int index, RichResource object, String value) {
            session.getTabManager().addTab(new ResourceDetailTabItem(object, facilityId));
        }
    });
    deleteButton.setEnabled(false);
    JsonUtils.addTableManagedButton(resources, table, deleteButton);
    table.addStyleName("perun-table");
    table.setWidth("100%");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(sp, 350, this);
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    vp.add(sp);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) RichResource(cz.metacentrum.perun.webgui.model.RichResource) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) DeleteResource(cz.metacentrum.perun.webgui.json.resourcesManager.DeleteResource) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) GetAssignedRichResources(cz.metacentrum.perun.webgui.json.facilitiesManager.GetAssignedRichResources) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) CreateFacilityResourceTabItem(cz.metacentrum.perun.webgui.tabs.resourcestabs.CreateFacilityResourceTabItem) ResourceDetailTabItem(cz.metacentrum.perun.webgui.tabs.resourcestabs.ResourceDetailTabItem)

Example 65 with TabMenu

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

the class SelfApplicationsTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(user.getFullNameWithTitles().trim()) + ": Applications");
    VerticalPanel bodyContents = new VerticalPanel();
    bodyContents.setWidth("100%");
    // callback
    final GetApplicationsForUser req = new GetApplicationsForUser(user.getId());
    req.setCheckable(false);
    // tab menu for filtering
    TabMenu tabMenu = new TabMenu();
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    tabMenu.addFilterWidget(new ExtendedSuggestBox(req.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            req.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterByVoOrGroup());
    bodyContents.add(tabMenu);
    CellTable<Application> appsTable = req.getTable(new FieldUpdater<Application, String>() {

        @Override
        public void update(int index, Application object, String value) {
            session.getTabManager().addTab(new SelfApplicationDetailTabItem(object));
        }
    });
    appsTable.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(appsTable);
    sp.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(sp, 350, this);
    bodyContents.add(sp);
    this.contentWidget.setWidget(bodyContents);
    return getWidget();
}
Also used : GetApplicationsForUser(cz.metacentrum.perun.webgui.json.registrarManager.GetApplicationsForUser) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) Application(cz.metacentrum.perun.webgui.model.Application)

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