Search in sources :

Example 46 with ExtendedSuggestBox

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

the class FacilityHostsTabItem method draw.

public Widget draw() {
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Hosts");
    // main panel
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    final GetHosts hosts = new GetHosts(facilityId);
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(hosts);
    // menu
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addHost(), new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().addTabToCurrentTab(new AddHostsTabItem(facility));
        }
    }));
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeHosts());
    removeButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<Host> hostsForRemoving = hosts.getTableSelectedList();
            String text = "<span class=\"serverResponseLabelError\"><strong>Removing host(s) won't stop services propagation. For this please remove proper 'Services destinations'.</strong></span><p>Following hosts will be removed from facility.";
            UiElements.showDeleteConfirm(hostsForRemoving, text, new ClickHandler() {

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

        @Override
        public void searchFor(String text) {
            hosts.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterHosts());
    // Hosts table
    CellTable<Host> table = hosts.getTable(new FieldUpdater<Host, String>() {

        @Override
        public void update(int index, Host object, String value) {
            session.getTabManager().addTab(new FacilityHostsSettingsTabItem(facility, object));
        }
    });
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(hosts, 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 menu and the table to the main panel
    firstTabPanel.add(menu);
    firstTabPanel.setCellHeight(menu, "30px");
    firstTabPanel.add(sp);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) RemoveHosts(cz.metacentrum.perun.webgui.json.facilitiesManager.RemoveHosts) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) Host(cz.metacentrum.perun.webgui.model.Host) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) GetHosts(cz.metacentrum.perun.webgui.json.facilitiesManager.GetHosts) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)

Example 47 with ExtendedSuggestBox

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

the class FacilityOwnersTabItem method draw.

public Widget draw() {
    // TITLE
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Owners");
    // CONTENT
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // MENU
    TabMenu menu = new TabMenu();
    // CALLBACK
    final GetFacilityOwners jsonCallback = new GetFacilityOwners(facility);
    // AUTHZ
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    menu.addWidget(UiElements.getRefreshButton(this));
    // add button
    CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addNewOwners());
    addButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new AddFacilityOwnerTabItem(facility), true);
        }
    });
    // remove button
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeSelectedOwners());
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<Owner> list = jsonCallback.getTableSelectedList();
            UiElements.showDeleteConfirm(list, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < list.size(); i++) {
                        if (i == list.size() - 1) {
                            RemoveOwner request = new RemoveOwner(JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(jsonCallback)));
                            request.removeFacilityOwner(facilityId, list.get(i).getId());
                        } else {
                            RemoveOwner request = new RemoveOwner(JsonCallbackEvents.disableButtonEvents(removeButton));
                            request.removeFacilityOwner(facilityId, list.get(i).getId());
                        }
                    }
                }
            });
        }
    });
    menu.addWidget(addButton);
    menu.addWidget(removeButton);
    menu.addFilterWidget(new ExtendedSuggestBox(jsonCallback.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            jsonCallback.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterOwners());
    // TABLE
    CellTable<Owner> table = jsonCallback.getTable();
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    vp.add(sp);
    removeButton.setEnabled(false);
    JsonUtils.addTableManagedButton(jsonCallback, table, removeButton);
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : Owner(cz.metacentrum.perun.webgui.model.Owner) RemoveOwner(cz.metacentrum.perun.webgui.json.facilitiesManager.RemoveOwner) RemoveOwner(cz.metacentrum.perun.webgui.json.facilitiesManager.RemoveOwner) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) GetFacilityOwners(cz.metacentrum.perun.webgui.json.facilitiesManager.GetFacilityOwners) 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)

Example 48 with ExtendedSuggestBox

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

Example 49 with ExtendedSuggestBox

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

the class AllAuthorsTabItem method draw.

public Widget draw() {
    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));
    final FindAllAuthors callback = new FindAllAuthors();
    menu.addFilterWidget(new ExtendedSuggestBox(callback.getOracle()), new PerunSearchEvent() {

        @Override
        public void searchFor(String text) {
            callback.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterAuthors());
    CellTable<Author> table = callback.getTable(new FieldUpdater<Author, String>() {

        public void update(int index, Author object, String value) {
            if (session.isPerunAdmin()) {
                session.getTabManager().addTab(new UsersPublicationsTabItem(object.getId()));
            }
        }
    });
    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 : FindAllAuthors(cz.metacentrum.perun.webgui.json.cabinetManager.FindAllAuthors) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) Author(cz.metacentrum.perun.webgui.model.Author)

Example 50 with ExtendedSuggestBox

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

the class AttributeDefinitionsTabItem method draw.

public Widget draw() {
    // create main panel for content
    VerticalPanel mainPage = new VerticalPanel();
    mainPage.setWidth("100%");
    // create new instance for jsonCall
    final GetAttributesDefinition attrDef = new GetAttributesDefinition();
    final ExtendedSuggestBox box = new ExtendedSuggestBox(attrDef.getOracle());
    // custom events for reloading when created or deleted
    final JsonCallbackEvents refreshTabEvents = JsonCallbackEvents.mergeEvents(JsonCallbackEvents.refreshTableEvents(attrDef), new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            if (box.getSuggestBox().getValue() != null)
                attrDef.filterTable(box.getSuggestBox().getValue());
        }
    });
    // TAB MENU
    TabMenu tabMenu = new TabMenu();
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    // create buttons
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, buttonTranslation.createAttributeDefinition(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new CreateAttributeDefinitionTabItem());
        }
    }));
    // remove button
    final CustomButton deleteButton = TabMenu.getPredefinedButton(ButtonType.DELETE, buttonTranslation.deleteAttributeDefinition());
    deleteButton.setEnabled(false);
    deleteButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<AttributeDefinition> attrDefToBeDeleted = attrDef.getTableSelectedList();
            String text = "Following attribute definitions will be deleted.</p><p style=\"color: red;\">All stored values of such attributes will be deleted too!";
            UiElements.showDeleteConfirm(attrDefToBeDeleted, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                    for (int i = 0; i < attrDefToBeDeleted.size(); i++) {
                        final int x = i;
                        DeleteAttribute request = new DeleteAttribute(JsonCallbackEvents.disableButtonEvents(deleteButton, new JsonCallbackEvents() {

                            @Override
                            public void onFinished(JavaScriptObject jso) {
                                // remove deleted attrs from table
                                attrDef.removeFromBackupTable(attrDefToBeDeleted.get(x));
                            }
                        }));
                        request.deleteAttributeDefinition(attrDefToBeDeleted.get(i).getId());
                    }
                }
            });
        }
    });
    tabMenu.addWidget(deleteButton);
    // filter box
    tabMenu.addFilterWidget(box, new PerunSearchEvent() {

        public void searchFor(String text) {
            attrDef.filterTable(text);
        }
    }, buttonTranslation.filterAttributeDefinition());
    final CustomButton saveButton = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveChangesInAttributes());
    saveButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            final ArrayList<AttributeDefinition> list = attrDef.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
                for (int i = 0; i < list.size(); i++) {
                    final int x = i;
                    UpdateAttribute request = new UpdateAttribute(JsonCallbackEvents.disableButtonEvents(saveButton, new JsonCallbackEvents() {

                        @Override
                        public void onFinished(JavaScriptObject jso) {
                            attrDef.getSelectionModel().setSelected(list.get(x), false);
                        }
                    }));
                    request.updateAttribute(list.get(i));
                }
            }
        }
    });
    tabMenu.addWidget(saveButton);
    // if checkbox is checked only entityless attributes will be shown
    CheckBox showEntitylessBox = new CheckBox("Show only Entityless Attributes");
    showEntitylessBox.setValue(false);
    showEntitylessBox.addValueChangeHandler(valueChangeEvent -> {
        if (showEntitylessBox.getValue()) {
            attrDef.setEntity("entityless");
        } else {
            attrDef.setEntities(new HashSet<>());
        }
        attrDef.retrieveData();
    });
    tabMenu.addWidget(showEntitylessBox);
    // add menu to page
    mainPage.add(tabMenu);
    mainPage.setCellHeight(tabMenu, "30px");
    CellTable<AttributeDefinition> attrDefTable = attrDef.getTable(new FieldUpdater<AttributeDefinition, String>() {

        @Override
        public void update(int index, AttributeDefinition object, String value) {
            if (object.getEntity().equals("entityless")) {
                session.getTabManager().addTabToCurrentTab(new EntitylessAttributesDetailTabItem(object), true);
            } else {
                session.getTabManager().addTabToCurrentTab(new AttributeDefinitionDetailTabItem(object), true);
            }
        }
    });
    attrDefTable.setStyleName("perun-table");
    ScrollPanel scrollTable = new ScrollPanel(attrDefTable);
    scrollTable.addStyleName("perun-tableScrollPanel");
    JsonUtils.addTableManagedButton(attrDef, attrDefTable, deleteButton);
    // put page into scroll panel
    mainPage.add(scrollTable);
    session.getUiElements().resizePerunTable(scrollTable, 350, this);
    this.contentWidget.setWidget(mainPage);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) UpdateAttribute(cz.metacentrum.perun.webgui.json.attributesManager.UpdateAttribute) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) AttributeDefinition(cz.metacentrum.perun.webgui.model.AttributeDefinition) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) EntitylessAttributesDetailTabItem(cz.metacentrum.perun.webgui.tabs.entitylessattributestabs.EntitylessAttributesDetailTabItem) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) DeleteAttribute(cz.metacentrum.perun.webgui.json.attributesManager.DeleteAttribute) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetAttributesDefinition(cz.metacentrum.perun.webgui.json.attributesManager.GetAttributesDefinition)

Aggregations

ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)50 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)50 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)41 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)41 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)41 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)41 ArrayList (java.util.ArrayList)41 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)26 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)15 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)15 Group (cz.metacentrum.perun.webgui.model.Group)8 JsArray (com.google.gwt.core.client.JsArray)5 VirtualOrganization (cz.metacentrum.perun.webgui.model.VirtualOrganization)5 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)4 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)4 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)4 ScrollPanel (com.google.gwt.user.client.ui.ScrollPanel)4 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)4 GetAllGroups (cz.metacentrum.perun.webgui.json.groupsManager.GetAllGroups)4 GetVos (cz.metacentrum.perun.webgui.json.vosManager.GetVos)4