Search in sources :

Example 1 with GetEntityById

use of cz.metacentrum.perun.webgui.json.GetEntityById in project perun by CESNET.

the class FindUsersByIdsNotInRpc method retrieveData.

/**
 * Retrieves data from RPC
 */
public void retrieveData() {
    String[] ids = searchString.split(",");
    if (ids.length == 0) {
        return;
    }
    idsCount = ids.length;
    onLoadingStart();
    for (String id : ids) {
        // trims the whitespace
        id = id.trim();
        try {
            int idint = Integer.parseInt(id);
            GetEntityById req = new GetEntityById(PerunEntity.USER, idint, new JsonCallbackEvents() {

                public void onFinished(JavaScriptObject jso) {
                    idsFound++;
                    // add to result
                    int i = result.size();
                    result.set(i, new JSONObject(jso));
                    isFinished();
                }

                public void onError(PerunError err) {
                    idsFound++;
                    isFinished();
                }
            });
            req.retrieveData();
        } catch (Exception e) {
        }
    }
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetEntityById(cz.metacentrum.perun.webgui.json.GetEntityById) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 2 with GetEntityById

use of cz.metacentrum.perun.webgui.json.GetEntityById in project perun by CESNET.

the class PerunWebSession method setActiveVoId.

/**
 * Sets currently active VO (refresh links in menu)
 * when only ID is provided.
 *
 * @param voId ID of VO which user is editing now
 */
public void setActiveVoId(final int voId) {
    new GetEntityById(PerunEntity.VIRTUAL_ORGANIZATION, voId, new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            VirtualOrganization vo = jso.cast();
            setActiveVo(vo);
        }
    }).retrieveData();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetEntityById(cz.metacentrum.perun.webgui.json.GetEntityById)

Example 3 with GetEntityById

use of cz.metacentrum.perun.webgui.json.GetEntityById in project perun by CESNET.

the class PerunWebSession method setActiveGroupId.

/**
 * Sets currently active Group (refresh links in menu)
 * when only ID is provided.
 *
 * @param groupId ID of groupwhich user is editing now
 */
public void setActiveGroupId(int groupId) {
    new GetEntityById(PerunEntity.GROUP, groupId, new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            Group group = jso.cast();
            setActiveGroup(group);
        }
    }).retrieveData();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetEntityById(cz.metacentrum.perun.webgui.json.GetEntityById)

Example 4 with GetEntityById

use of cz.metacentrum.perun.webgui.json.GetEntityById in project perun by CESNET.

the class PerunWebSession method setActiveSecurityTeamId.

/**
 * Sets currently active SecurityTeam (refresh links in menu)
 * when only ID is provided.
 *
 * @param securityTeamId ID of SecTeam which user is editing now
 */
public void setActiveSecurityTeamId(int securityTeamId) {
    new GetEntityById(PerunEntity.SECURITY_TEAM, securityTeamId, new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            SecurityTeam f = jso.cast();
            setActiveSecurityTeam(f);
        }
    }).retrieveData();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetEntityById(cz.metacentrum.perun.webgui.json.GetEntityById)

Example 5 with GetEntityById

use of cz.metacentrum.perun.webgui.json.GetEntityById in project perun by CESNET.

the class ResourceDetailTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(resource.getName()));
    // main widget panel
    final VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    AbsolutePanel dp = new AbsolutePanel();
    // dp.setStyleName("decoration");
    final FlexTable menu = new FlexTable();
    menu.setCellSpacing(5);
    // MAIN INFO PANEL
    // resource info
    menu.setWidget(0, 0, new Image(LargeIcons.INSTANCE.serverGroupIcon()));
    Label resourceName = new Label();
    resourceName.setText(Utils.getStrippedStringWithEllipsis(resource.getName(), 40));
    resourceName.setStyleName("now-managing");
    resourceName.setTitle(resource.getName());
    menu.setWidget(0, 1, resourceName);
    menu.setHTML(0, 2, " ");
    menu.getFlexCellFormatter().setWidth(0, 2, "25px");
    int column = 3;
    final JsonCallbackEvents events = new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            new GetEntityById(PerunEntity.RICH_RESOURCE, resourceId, new JsonCallbackEvents() {

                public void onFinished(JavaScriptObject jso) {
                    resource = jso.cast();
                    open();
                    draw();
                }
            }).retrieveData();
        }
    };
    CustomButton change = new CustomButton("", ButtonTranslation.INSTANCE.editResourceDetails(), SmallIcons.INSTANCE.applicationFormEditIcon());
    if (!session.isVoAdmin(resource.getVoId()) && !session.isFacilityAdmin(resource.getFacilityId()))
        change.setEnabled(false);
    change.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            // prepare confirm content
            Resource r = resource.cast();
            session.getTabManager().addTabToCurrentTab(new EditResourceDetailsTabItem(r, events));
        }
    });
    menu.setWidget(0, column, change);
    column++;
    menu.setHTML(0, column, " ");
    menu.getFlexCellFormatter().setWidth(0, column, "25px");
    column++;
    if (JsonUtils.isExtendedInfoVisible()) {
        menu.setHTML(0, column, "<strong>ID:</strong><br/><span class=\"inputFormInlineComment\">" + resource.getId() + "</span>");
        column++;
        menu.setHTML(0, column, "&nbsp;");
        menu.getFlexCellFormatter().setWidth(0, column, "25px");
        column++;
    }
    if (facilityId > 0) {
        // facility admin view
        menu.setHTML(0, column, "<strong>VO:</strong><br/><span class=\"inputFormInlineComment\">" + resource.getVoId() + " / " + SafeHtmlUtils.fromString(resource.getVo().getShortName()).asString() + "</span>");
        column++;
        menu.setHTML(0, column, "&nbsp;");
        menu.getFlexCellFormatter().setWidth(0, column, "25px");
        column++;
    }
    menu.setHTML(0, column, "<strong>Description:</strong><br/><span class=\"inputFormInlineComment\">" + SafeHtmlUtils.fromString((resource.getDescription() != null) ? resource.getDescription() : "").asString() + "&nbsp;</span>");
    if (session.isFacilityAdmin(resource.getFacilityId())) {
        column++;
        menu.setHTML(0, column, "&nbsp;");
        menu.getFlexCellFormatter().setWidth(0, column, "25px");
        column++;
        Anchor a = new Anchor("View facility details >>");
        a.setStyleName("pointer");
        a.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                session.getTabManager().addTab(new FacilityDetailTabItem(resource.getFacility()));
            }
        });
        menu.setWidget(0, column, a);
    }
    dp.add(menu);
    vp.add(dp);
    vp.setCellHeight(dp, "30px");
    // TAB PANEL WITH INNER TABS
    tabPanel.clear();
    Resource r = resource.cast();
    tabPanel.add(new ResourceAssignedGroupsTabItem(r), "Assigned groups");
    tabPanel.add(new ResourceAssignedServicesTabItem(r), "Assigned services");
    tabPanel.add(new ResourceSettingsTabItem(r, null), "Service settings");
    tabPanel.add(new ResourceGroupSettingsTabItem(r), "Group settings");
    tabPanel.add(new ResourceMemberSettingsTabItem(resource), "Member settings");
    if (session.isVoAdmin(r.getVoId()) || session.isVoObserver(r.getVoId())) {
        tabPanel.add(new ResourceTagsTabItem(r), "Tags");
    }
    // Resize must be called after page fully displays
    Scheduler.get().scheduleDeferred(new Command() {

        @Override
        public void execute() {
            tabPanel.finishAdding();
        }
    });
    vp.add(tabPanel);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ImageResource(com.google.gwt.resources.client.ImageResource) Resource(cz.metacentrum.perun.webgui.model.Resource) RichResource(cz.metacentrum.perun.webgui.model.RichResource) FacilityDetailTabItem(cz.metacentrum.perun.webgui.tabs.facilitiestabs.FacilityDetailTabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) Command(com.google.gwt.user.client.Command) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) GetEntityById(cz.metacentrum.perun.webgui.json.GetEntityById)

Aggregations

JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)18 GetEntityById (cz.metacentrum.perun.webgui.json.GetEntityById)18 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)18 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)9 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)8 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)8 Command (com.google.gwt.user.client.Command)4 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)4 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)3 HashMap (java.util.HashMap)3 RegExp (com.google.gwt.regexp.shared.RegExp)2 CreatePassword (cz.metacentrum.perun.webgui.json.usersManager.CreatePassword)2 GenerateAccount (cz.metacentrum.perun.webgui.json.usersManager.GenerateAccount)2 SetLogin (cz.metacentrum.perun.webgui.json.usersManager.SetLogin)2 Attribute (cz.metacentrum.perun.webgui.model.Attribute)2 PerunError (cz.metacentrum.perun.webgui.model.PerunError)2 User (cz.metacentrum.perun.webgui.model.User)2 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)2 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2