Search in sources :

Example 1 with RichResource

use of cz.metacentrum.perun.webgui.model.RichResource in project perun by CESNET.

the class GetAssignedRichResources method filterTable.

public void filterTable(String text) {
    // store list only for first time
    if (backupList.isEmpty() || backupList == null) {
        backupList.addAll(list);
    }
    // always clear selected items
    selectionModel.clear();
    list.clear();
    if (text.equalsIgnoreCase("")) {
        list.addAll(backupList);
    } else {
        for (RichResource r : backupList) {
            if ((r.getName().toLowerCase().contains(text.toLowerCase())) || (r.getVo().getName().toLowerCase().contains(text.toLowerCase())) || (r.getVo().getShortName().toLowerCase().contains(text.toLowerCase()))) {
                list.add(r);
            }
        }
    }
    if (list.isEmpty() && !text.isEmpty()) {
        loaderImage.setEmptyResultMessage("No resource matching '" + text + "' found.");
    } else {
        loaderImage.setEmptyResultMessage("Facility has no resources.");
    }
    dataProvider.flush();
    dataProvider.refresh();
    loaderImage.loadingFinished();
}
Also used : RichResource(cz.metacentrum.perun.webgui.model.RichResource)

Example 2 with RichResource

use of cz.metacentrum.perun.webgui.model.RichResource in project perun by CESNET.

the class GetAssignedRichResources method filterTable.

public void filterTable(String filter) {
    // store list only for first time
    if (fullBackup.isEmpty() || fullBackup == null) {
        fullBackup.addAll(list);
    }
    // always clear selected items
    selectionModel.clear();
    list.clear();
    if (filter.equalsIgnoreCase("")) {
        list.addAll(fullBackup);
    } else {
        for (RichResource res : fullBackup) {
            // store resource by filter
            if (res.getName().toLowerCase().contains(filter.toLowerCase())) {
                list.add(res);
            }
            for (ResourceTag r : res.getResourceTags()) {
                // remove " (tag)" after tag name
                if (r.getName().contains(filter.substring(0, (filter.length() > 6) ? filter.length() - 6 : filter.length()).trim())) {
                    list.add(res);
                    break;
                }
            }
        }
    }
    dataProvider.flush();
    dataProvider.refresh();
    loaderImage.loadingFinished();
}
Also used : ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag) RichResource(cz.metacentrum.perun.webgui.model.RichResource)

Example 3 with RichResource

use of cz.metacentrum.perun.webgui.model.RichResource in project perun by CESNET.

the class GetAssignedRichResources method setList.

public void setList(ArrayList<RichResource> list) {
    clearTable();
    this.list.addAll(list);
    for (RichResource r : list) {
        oracle.add(r.getName());
        for (ResourceTag rt : r.getResourceTags()) {
            oracle.add(rt.getName() + " (tag)");
        }
    }
    dataProvider.flush();
    dataProvider.refresh();
}
Also used : ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag) RichResource(cz.metacentrum.perun.webgui.model.RichResource)

Example 4 with RichResource

use of cz.metacentrum.perun.webgui.model.RichResource in project perun by CESNET.

the class GroupResourcesTabItem method draw.

public Widget draw() {
    // set title
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.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(groupId, PerunEntity.GROUP);
    if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
        resources.setCheckable(false);
    // custom events for viewResource
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(resources);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeGroupFromSelectedResources());
    // add / remove resource from group can be done by vo / perun admin only.
    if (session.isVoAdmin(group.getVoId())) {
        menu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.assignGroupToResources(), new ClickHandler() {

            public void onClick(ClickEvent event) {
                session.getTabManager().addTabToCurrentTab(new AssignGroupTabItem(group, resources.getList()), true);
            }
        }));
        removeButton.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                final ArrayList<RichResource> toRemove = resources.getTableSelectedList();
                String text = "Following resources will be removed from group and it's members won't have access to them anymore.";
                UiElements.showDeleteConfirm(toRemove, text, new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent clickEvent) {
                        RemoveGroupFromResources request = new RemoveGroupFromResources(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        request.removeGroupFromResources(group, toRemove);
                    }
                });
            }
        });
        menu.addWidget(removeButton);
    }
    // filter box
    menu.addFilterWidget(new ExtendedSuggestBox(resources.getOracle()), new PerunSearchEvent() {

        public void searchFor(String text) {
            resources.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterResources());
    // add menu to the main panel
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    CellTable<RichResource> table;
    // perun / vo admin can set attributes
    if (session.isVoAdmin(group.getVoId()) || session.isVoObserver(group.getVoId())) {
        table = resources.getTable(new FieldUpdater<RichResource, String>() {

            public void update(int index, RichResource object, String value) {
                session.getTabManager().addTab(new ResourceDetailTabItem(object, 0));
            }
        });
    } else {
        table = resources.getTable();
    }
    removeButton.setEnabled(false);
    if (session.isGroupAdmin(groupId) || session.isVoAdmin(group.getVoId()))
        JsonUtils.addTableManagedButton(resources, table, removeButton);
    table.addStyleName("perun-table");
    table.setWidth("100%");
    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) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) RichResource(cz.metacentrum.perun.webgui.model.RichResource) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) RemoveGroupFromResources(cz.metacentrum.perun.webgui.json.resourcesManager.RemoveGroupFromResources) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) GetAssignedRichResources(cz.metacentrum.perun.webgui.json.resourcesManager.GetAssignedRichResources) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) ResourceDetailTabItem(cz.metacentrum.perun.webgui.tabs.resourcestabs.ResourceDetailTabItem)

Example 5 with RichResource

use of cz.metacentrum.perun.webgui.model.RichResource in project perun by CESNET.

the class AssignGroupTabItem method draw.

public Widget draw() {
    // set tab name
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": assign to resource");
    // main content
    VerticalPanel mainTab = new VerticalPanel();
    mainTab.setSize("100%", "100%");
    // menu
    TabMenu menu = new TabMenu();
    menu.addWidget(UiElements.getRefreshButton(this));
    // callback
    final GetRichResources callback = new GetRichResources(group.getVoId());
    callback.setEvents(new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            for (RichResource rr : resources) {
                callback.removeFromTable(rr);
            }
            ArrayList<RichResource> temp = new ArrayList<RichResource>();
            temp.addAll(callback.getList());
            callback.setList(temp);
        }
    });
    CellTable<RichResource> table = callback.getTable();
    // close tab event
    final TabItem tab = this;
    // filter box
    menu.addFilterWidget(new ExtendedSuggestBox(callback.getOracle()), new PerunSearchEvent() {

        public void searchFor(String text) {
            callback.filterTable(text);
            // if single group, select
            if (callback.getList().size() == 1) {
                callback.getSelectionModel().setSelected(callback.getList().get(0), true);
            }
        }
    }, ButtonTranslation.INSTANCE.filterResources());
    // button
    final CustomButton assignButton = TabMenu.getPredefinedButton(ButtonType.ADD, ButtonTranslation.INSTANCE.assignGroupToSelectedResources());
    assignButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<RichResource> toAssign = callback.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(toAssign)) {
                AssignGroupToResources request = new AssignGroupToResources(JsonCallbackEvents.disableButtonEvents(assignButton, new JsonCallbackEvents() {

                    @Override
                    public void onFinished(JavaScriptObject jso) {
                        alreadyAddedList.addAll(toAssign);
                        for (RichResource r : toAssign) {
                            callback.getSelectionModel().setSelected(r, false);
                        }
                        rebuildAlreadyAddedWidget();
                    }
                }));
                request.assignGroupToResources(group, toAssign);
            }
        }
    });
    menu.addWidget(assignButton);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CLOSE, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    assignButton.setEnabled(false);
    JsonUtils.addTableManagedButton(callback, table, assignButton);
    // add menu and the table to the main panel
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    // do not use resizePerunTable() in overlay mode - calculated width is wrong
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    mainTab.add(menu);
    mainTab.setCellHeight(menu, "30px");
    rebuildAlreadyAddedWidget();
    mainTab.add(alreadyAdded);
    mainTab.add(sp);
    this.contentWidget.setWidget(mainTab);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) RichResource(cz.metacentrum.perun.webgui.model.RichResource) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) AssignGroupToResources(cz.metacentrum.perun.webgui.json.resourcesManager.AssignGroupToResources) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) GetRichResources(cz.metacentrum.perun.webgui.json.resourcesManager.GetRichResources) 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) ExtendedSuggestBox(cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Aggregations

RichResource (cz.metacentrum.perun.webgui.model.RichResource)15 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)6 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)6 ResourceTag (cz.metacentrum.perun.webgui.model.ResourceTag)6 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)6 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)5 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)5 ResourceDetailTabItem (cz.metacentrum.perun.webgui.tabs.resourcestabs.ResourceDetailTabItem)4 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)4 ArrayList (java.util.ArrayList)4 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 AssignGroupToResources (cz.metacentrum.perun.webgui.json.resourcesManager.AssignGroupToResources)2 DeleteResource (cz.metacentrum.perun.webgui.json.resourcesManager.DeleteResource)2 GetAssignedRichResources (cz.metacentrum.perun.webgui.json.resourcesManager.GetAssignedRichResources)2 GetRichResources (cz.metacentrum.perun.webgui.json.resourcesManager.GetRichResources)2 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)2 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)1 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)1 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)1