Search in sources :

Example 11 with RichResource

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

the class GetRichResources 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 12 with RichResource

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

the class GetRichResources 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 facility by filter
            if (res.getName().toLowerCase().contains(filter.toLowerCase())) {
                list.add(res);
            }
            for (ResourceTag r : res.getResourceTags()) {
                // remove " (tag)" from 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 {
        loaderImage.setEmptyResultMessage("VO has no resources.");
    }
    dataProvider.flush();
    dataProvider.refresh();
    loaderImage.loadingFinished();
}
Also used : ResourceTag(cz.metacentrum.perun.webgui.model.ResourceTag) RichResource(cz.metacentrum.perun.webgui.model.RichResource)

Example 13 with RichResource

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

the class GetRichResources method removeFromTable.

/**
	 * Removes object as row from table
	 *
	 * @param object Resource to be removed as row
	 */
public void removeFromTable(RichResource object) {
    for (RichResource rr : list) {
        if (rr.getId() == object.getId())
            list.remove(rr);
    }
    selectionModel.getSelectedSet().remove(object);
    dataProvider.flush();
    dataProvider.refresh();
}
Also used : RichResource(cz.metacentrum.perun.webgui.model.RichResource)

Example 14 with RichResource

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

the class MemberResourcesTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(member.getUser().getFullNameWithTitles().trim()) + ": resources");
    // main widget panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    TabMenu menu = new TabMenu();
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    menu.addWidget(UiElements.getRefreshButton(this));
    CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, "Add member to new resource", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            AddMemberToResourceTabItem tab = new AddMemberToResourceTabItem(member.getVoId());
            tab.startAtStageTwo(member);
            session.getTabManager().addTabToCurrentTab(tab);
        }
    });
    if (!session.isVoAdmin(member.getVoId()))
        addButton.setEnabled(false);
    menu.addWidget(addButton);
    final GetAssignedRichResources resourcesCall = new GetAssignedRichResources(memberId, PerunEntity.MEMBER);
    resourcesCall.setCheckable(false);
    CellTable<RichResource> table = resourcesCall.getTable(new FieldUpdater<RichResource, String>() {

        @Override
        public void update(int i, RichResource resource, String s) {
            if (session.isVoAdmin(resource.getVoId()) || session.isFacilityAdmin(resource.getFacilityId())) {
                session.getTabManager().addTab(new ResourceDetailTabItem(resource, 0));
            } else {
                UiElements.generateInfo("Not privileged", "You are not allowed to manage this resource. You must be VO manager or Facility manager.");
            }
        }
    });
    menu.addFilterWidget(new ExtendedSuggestBox(resourcesCall.getOracle()), new PerunSearchEvent() {

        public void searchFor(String text) {
            resourcesCall.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterResources());
    // JsonUtils.addTableManagedButton(resourcesCall, table, removeButton);
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    session.getUiElements().resizePerunTable(sp, 350, this);
    vp.add(sp);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : RichResource(cz.metacentrum.perun.webgui.model.RichResource) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) GetAssignedRichResources(cz.metacentrum.perun.webgui.json.resourcesManager.GetAssignedRichResources) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) ResourceDetailTabItem(cz.metacentrum.perun.webgui.tabs.resourcestabs.ResourceDetailTabItem)

Example 15 with RichResource

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

the class ManageGroupsBeforeAssigning method draw.

public Widget draw() {
    final VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    TabMenu menu = new TabMenu();
    final ListBoxWithObjects<Group> groupsDropDown = new ListBoxWithObjects<Group>();
    for (Group grp : groupsToAssign) {
        groupsDropDown.addItem(grp);
    }
    final ListBoxWithObjects<Group> subgroupsDropDown = new ListBoxWithObjects<Group>();
    subgroupsDropDown.addNotSelectedOption();
    final CustomButton finishAssigningButton = TabMenu.getPredefinedButton(ButtonType.FINISH, ButtonTranslation.INSTANCE.finishGroupAssigning());
    final JsonCallbackEvents closeTabEvents = JsonCallbackEvents.closeTabDisableButtonEvents(finishAssigningButton, this);
    final JsonCallbackEvents disableButtonEvents = JsonCallbackEvents.disableButtonEvents(finishAssigningButton);
    finishAssigningButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            // assign all
            if (groupsDropDown.getSelectedIndex() == 0) {
                AssignGroupsToResource request = new AssignGroupsToResource(closeTabEvents);
                request.assignGroupsToResource(groupsToAssign, resource);
            } else {
                // assign selected
                if (groupsDropDown.getSelectedObject() == null) {
                    Window.alert("No group selected");
                    return;
                }
                JsonCallbackEvents localEvents = new JsonCallbackEvents() {

                    public void onFinished(JavaScriptObject jso) {
                        // call previus events
                        closeTabEvents.onFinished(null);
                        // removed finished group
                        groupsDropDown.removeSelectedItem();
                        if (groupsDropDown.isEmpty()) {
                            // if no group left - close windows
                            closeTabEvents.onFinished(null);
                        }
                    }
                };
                AssignGroupToResources request = new AssignGroupToResources(JsonCallbackEvents.disableButtonEvents(finishAssigningButton, localEvents));
                request.assignGroupToResources(groupsDropDown.getSelectedObject(), JsonUtils.<RichResource>toList(resource));
            }
        }
    });
    menu.addWidget(finishAssigningButton);
    menu.addWidget(new HTML("<strong>Selected group: </strong>"));
    menu.addWidget(groupsDropDown);
    // TODO - get subgroups correctly too
    //menu.addWidget(new HTML("<strong>Configure sub-groups: </strong>"));
    //menu.addWidget(subgroupsDropDown);
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    groupsDropDown.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            // removes previous table
            if (vp.getWidgetCount() == 2) {
                vp.remove(1);
            }
            if (groupsDropDown.getSelectedIndex() > 0) {
                /*
					// fill subgroups listbox with groups
					subgroupsDropDown.removeAllOption();
					subgroupsDropDown.removeNotSelectedOption();
					subgroupsDropDown.clear();
					subgroupsDropDown.addNotSelectedOption();
					for (Group grp : findSubgroups(groupsDropDown.getSelectedObject())){
					subgroupsDropDown.addItem(grp);
					}
					subgroupsDropDown.addAllOption();
					*/
                // some group selected
                TabItem ti = new GroupResourceRequiredAttributesTabItem(resourceId, groupsDropDown.getSelectedObject().getId());
                ti.draw();
                Widget w = ti.getWidget();
                vp.add(w);
                vp.setCellHeight(w, "100%");
            } else {
                /*
					//clear listbox
					subgroupsDropDown.removeAllOption();
					subgroupsDropDown.removeNotSelectedOption();
					subgroupsDropDown.clear();
					subgroupsDropDown.addNotSelectedOption();
					subgroupsDropDown.addItem("All");
					*/
                // all groups tab
                TabItem ti = new GroupsResourceRequiredAttributesTabItem(resourceId, groupsToAssign);
                ti.draw();
                Widget w = ti.getWidget();
                vp.add(w);
                vp.setCellHeight(w, "100%");
            }
        }
    });
    /*

			 subgroupsDropDown.addChangeHandler(new ChangeHandler(){
			 public void onChange(ChangeEvent event) {
			 if (vp.getWidgetCount() == 2) { vp.remove(1); } // removes previous table
			 if (subgroupsDropDown.getSelectedIndex() > 1){
// sub-group selected
TabItem ti = new GroupResourceRequiredAttributesTabItem(session, resourceId, subgroupsDropDown.getSelectedObject().getId());
ti.draw();
Widget w = ti.getWidget();
vp.add(w);
vp.setCellHeight(w, "100%");
} else if (subgroupsDropDown.getSelectedIndex() == 1){
// all selected
if (groupsDropDown.getSelectedIndex() > 0) {
// all subgroups of selected group
TabItem ti = new GroupsResourceRequiredAttributesTabItem(session, resourceId, subgroupsDropDown.getAllObjects());
ti.draw();
Widget w = ti.getWidget();
vp.add(w);
vp.setCellHeight(w, "100%");
} else {
		// all groups and subgroups
		TabItem ti = new GroupsResourceRequiredAttributesTabItem(session, resourceId, allGroups);
		ti.draw();
		Widget w = ti.getWidget();
		vp.add(w);
		vp.setCellHeight(w, "100%");
}
} else {
		// parent-group selected / subgroup not selected
		TabItem ti = new GroupResourceRequiredAttributesTabItem(session, resourceId, groupsDropDown.getSelectedObject().getId());
		ti.draw();
		Widget w = ti.getWidget();
		vp.add(w);
		vp.setCellHeight(w, "100%");
}
			 }
			 });

*/
    TabItem ti = new GroupResourceRequiredAttributesTabItem(resourceId, groupsDropDown.getSelectedObject().getId());
    ti.draw();
    Widget w = ti.getWidget();
    vp.add(w);
    vp.setCellHeight(w, "100%");
    groupsDropDown.addAllOption();
    /*
// if some group selected
if (groupsDropDown.getSelectedObject() != null){
// fill subgroups listbox with groups
subgroupsDropDown.addNotSelectedOption();
for (Group grp : findSubgroups(groupsDropDown.getSelectedObject())){
subgroupsDropDown.addItem(grp);
}
subgroupsDropDown.addAllOption();
}
*/
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) Group(cz.metacentrum.perun.webgui.model.Group) RichResource(cz.metacentrum.perun.webgui.model.RichResource) AssignGroupToResources(cz.metacentrum.perun.webgui.json.resourcesManager.AssignGroupToResources) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) AssignGroupsToResource(cz.metacentrum.perun.webgui.json.resourcesManager.AssignGroupsToResource) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) GroupsResourceRequiredAttributesTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.GroupsResourceRequiredAttributesTabItem) GroupResourceRequiredAttributesTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.GroupResourceRequiredAttributesTabItem) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ListBoxWithObjects(cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) GroupsResourceRequiredAttributesTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.GroupsResourceRequiredAttributesTabItem) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) GroupResourceRequiredAttributesTabItem(cz.metacentrum.perun.webgui.tabs.groupstabs.GroupResourceRequiredAttributesTabItem)

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