Search in sources :

Example 6 with RichResource

use of cz.metacentrum.perun.webgui.model.RichResource 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 7 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 rr : list) {
        oracle.add(rr.getVo().getName());
        oracle.add(rr.getVo().getShortName());
        oracle.add(rr.getName());
    }
    dataProvider.flush();
    dataProvider.refresh();
}
Also used : RichResource(cz.metacentrum.perun.webgui.model.RichResource)

Example 8 with RichResource

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

the class VoResourcesTabItem method draw.

public Widget draw() {
    // set title
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": resources");
    // main panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // HORIZONTAL MENU
    TabMenu menu = new TabMenu();
    // refresh
    menu.addWidget(UiElements.getRefreshButton(this));
    // get VO resources
    final GetRichResources resources = new GetRichResources(voId);
    if (!session.isVoAdmin(voId))
        resources.setCheckable(false);
    // custom events for viewResource
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(resources);
    final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteResource());
    menu.addWidget(removeButton);
    removeButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            final ArrayList<RichResource> resourcesForDeleting = resources.getTableSelectedList();
            String text = "Following resources will be deleted and VO members won't be able to access them anymore.";
            UiElements.showDeleteConfirm(resourcesForDeleting, text, new ClickHandler() {

                @Override
                public void onClick(ClickEvent clickEvent) {
                    // TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
                    for (int i = 0; i < resourcesForDeleting.size(); i++) {
                        DeleteResource request;
                        if (i == resourcesForDeleting.size() - 1) {
                            request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(removeButton, events));
                        } else {
                            request = new DeleteResource(JsonCallbackEvents.disableButtonEvents(removeButton));
                        }
                        request.deleteResource(resourcesForDeleting.get(i).getId());
                    }
                }
            });
        }
    });
    // add menu to the main panel
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    // filter box
    menu.addFilterWidget(new ExtendedSuggestBox(resources.getOracle()), new PerunSearchEvent() {

        public void searchFor(String text) {
            resources.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterResources());
    CellTable<RichResource> table = resources.getTable(new FieldUpdater<RichResource, String>() {

        public void update(int index, RichResource object, String value) {
            session.getTabManager().addTab(new ResourceDetailTabItem(object, 0));
        }
    });
    removeButton.setEnabled(false);
    if (session.isVoAdmin(voId))
        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) RichResource(cz.metacentrum.perun.webgui.model.RichResource) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) GetRichResources(cz.metacentrum.perun.webgui.json.resourcesManager.GetRichResources) DeleteResource(cz.metacentrum.perun.webgui.json.resourcesManager.DeleteResource) 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) ResourceDetailTabItem(cz.metacentrum.perun.webgui.tabs.resourcestabs.ResourceDetailTabItem)

Example 9 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 10 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;
                }
            }
        }
    }
    if (list.isEmpty() && !filter.isEmpty()) {
        loaderImage.setEmptyResultMessage("No resource matching '" + filter + "' found.");
    } else {
        if (PerunEntity.GROUP.equals(entity)) {
            loaderImage.setEmptyResultMessage("Group is not assigned to any resource.");
        } else if (PerunEntity.MEMBER.equals(entity)) {
            loaderImage.setEmptyResultMessage("Member has no access to VO resources.");
        }
    }
    dataProvider.flush();
    dataProvider.refresh();
    loaderImage.loadingFinished();
}
Also used : ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag) RichResource(cz.metacentrum.perun.webgui.model.RichResource)

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