Search in sources :

Example 26 with PerunSearchEvent

use of cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent in project perun by CESNET.

the class VosTabItem method draw.

public Widget draw() {
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // Get vos request
    final GetVos getVos = new GetVos();
    // Events for reloading when finished
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(getVos);
    // create new VO button
    TabMenu tabMenu = new TabMenu();
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    // add menu to the main panel
    firstTabPanel.add(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, buttonTranslation.createVo(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new CreateVoTabItem());
        }
    }));
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, buttonTranslation.deleteVo());
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<VirtualOrganization> itemsToRemove = getVos.getTableSelectedList();
            UiElements.showDeleteConfirm(itemsToRemove, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < itemsToRemove.size(); i++) {
                        DeleteVo request;
                        if (i == itemsToRemove.size() - 1) {
                            request = new DeleteVo(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        } else {
                            request = new DeleteVo(JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.deleteVo(itemsToRemove.get(i).getId(), false);
                    }
                }
            });
        }
    });
    tabMenu.addWidget(removeButton);
    // filter
    tabMenu.addFilterWidget(new ExtendedSuggestBox(getVos.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            getVos.filterTable(text);
        }
    }, buttonTranslation.filterVo());
    // get the table with custom onclick
    CellTable<VirtualOrganization> table = getVos.getTable(new FieldUpdater<VirtualOrganization, VirtualOrganization>() {

        @Override
        public void update(int index, VirtualOrganization object, VirtualOrganization value) {
            session.getTabManager().addTab(new VoDetailTabItem(object));
        }
    });
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(getVos, table, removeButton);
    // 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 the table to the main panel
    firstTabPanel.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, 0, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) GetVos(cz.metacentrum.perun.webgui.json.vosManager.GetVos) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) DeleteVo(cz.metacentrum.perun.webgui.json.vosManager.DeleteVo) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CreateVoTabItem(cz.metacentrum.perun.webgui.tabs.vostabs.CreateVoTabItem) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) VoDetailTabItem(cz.metacentrum.perun.webgui.tabs.vostabs.VoDetailTabItem)

Example 27 with PerunSearchEvent

use of cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent in project perun by CESNET.

the class GroupsTabItem method draw.

public Widget draw() {
    // main panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // Horizontal menu
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    //call
    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);
    groups.setCheckable(false);
    // listbox
    final ListBoxWithObjects<VirtualOrganization> vos = new ListBoxWithObjects<VirtualOrganization>();
    menu.addWidget(new HTML("<strong>Selected VO: </strong>"));
    menu.addWidget(vos);
    menu.addFilterWidget(new ExtendedSuggestBox(groups.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            groups.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterGroup());
    menu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
    menu.addWidget(new HTML("<strong>Select VO to see groups that you can manage.</strong>"));
    final TabItem tab = this;
    // groups table
    CellTable<RichGroup> table = groups.getEmptyTable(new FieldUpdater<RichGroup, String>() {

        public void update(int index, RichGroup group, String value) {
            session.getTabManager().addTab(new GroupDetailTabItem(group));
            // close group selection tab when group is selected
            session.getTabManager().closeTab(tab, false);
        }
    });
    // listbox change => load vo's groups
    vos.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent changeEvent) {
            groups.setVoId(vos.getSelectedObject().getId());
            groups.clearTable();
            groups.retrieveData();
        }
    });
    // initial fill listbox and trigger groups loading
    GetVos vosCall = new GetVos(new JsonCallbackEvents() {

        public void onLoadingStart() {
            vos.clear();
            vos.addItem("Loading...");
        }

        public void onFinished(JavaScriptObject jso) {
            vos.clear();
            ArrayList<VirtualOrganization> returnedVos = JsonUtils.jsoAsList(jso);
            returnedVos = new TableSorter<VirtualOrganization>().sortByName(returnedVos);
            if (returnedVos == null || returnedVos.isEmpty()) {
                vos.addItem("No VO available");
                return;
            }
            // put and set selected
            for (int i = 0; i < returnedVos.size(); i++) {
                vos.addItem(returnedVos.get(i));
                if (voId == returnedVos.get(i).getId()) {
                    vos.setSelected(returnedVos.get(i), true);
                }
            }
            // trigger loading of groups for selected VO
            groups.setVoId(vos.getSelectedObject().getId());
            groups.clearTable();
            groups.retrieveData();
        }

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

        ;
    });
    vosCall.retrieveData();
    // set width to 100%
    table.setWidth("100%");
    // add menu and table to the main panel
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) RichGroup(cz.metacentrum.perun.webgui.model.RichGroup) ArrayList(java.util.ArrayList) VirtualOrganization(cz.metacentrum.perun.webgui.model.VirtualOrganization) ListBoxWithObjects(cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) GetVos(cz.metacentrum.perun.webgui.json.vosManager.GetVos) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetAllRichGroups(cz.metacentrum.perun.webgui.json.groupsManager.GetAllRichGroups) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 28 with PerunSearchEvent

use of cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent in project perun by CESNET.

the class OwnersTabItem method draw.

public Widget draw() {
    // tab content
    final VerticalPanel mainTab = new VerticalPanel();
    mainTab.setSize("100%", "100%");
    // horizontal menu
    TabMenu tabMenu = new TabMenu();
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    final GetOwners owners = new GetOwners();
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(owners);
    // create button
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createOwner(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new CreateOwnerTabItem());
        }
    }));
    // remove button
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteOwner());
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<Owner> itemsToRemove = owners.getTableSelectedList();
            String text = "Following owners will be removed.";
            UiElements.showDeleteConfirm(itemsToRemove, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < itemsToRemove.size(); i++) {
                        DeleteOwner request;
                        if (i == itemsToRemove.size() - 1) {
                            request = new DeleteOwner(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        } else {
                            request = new DeleteOwner(JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.deleteOwner(itemsToRemove.get(i).getId());
                    }
                }
            });
        }
    });
    tabMenu.addWidget(removeButton);
    tabMenu.addFilterWidget(new ExtendedSuggestBox(owners.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            owners.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterOwners());
    // adding menu to the page
    mainTab.add(tabMenu);
    mainTab.setCellHeight(tabMenu, "30px");
    CellTable<Owner> table = owners.getTable();
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel();
    sp.add(table);
    sp.addStyleName("perun-tableScrollPanel");
    mainTab.add(sp);
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(owners, table, removeButton);
    // resize perun table to correct size on screen
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(mainTab);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Owner(cz.metacentrum.perun.webgui.model.Owner) DeleteOwner(cz.metacentrum.perun.webgui.json.ownersManager.DeleteOwner) DeleteOwner(cz.metacentrum.perun.webgui.json.ownersManager.DeleteOwner) GetOwners(cz.metacentrum.perun.webgui.json.ownersManager.GetOwners) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) 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) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

Aggregations

PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)28 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)27 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)24 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)23 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)23 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)21 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)21 ArrayList (java.util.ArrayList)21 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)12 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)10 GetVos (cz.metacentrum.perun.webgui.json.vosManager.GetVos)4 Group (cz.metacentrum.perun.webgui.model.Group)4 VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)4 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)2 JsArray (com.google.gwt.core.client.JsArray)2 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)2 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)2 HTML (com.google.gwt.user.client.ui.HTML)2 ScrollPanel (com.google.gwt.user.client.ui.ScrollPanel)2 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)2