Search in sources :

Example 46 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.

the class FacilitiesTabItem method draw.

public Widget draw() {
    // MAIN PANEL
    VerticalPanel firstTabPanel = new VerticalPanel();
    firstTabPanel.setSize("100%", "100%");
    // TAB MENU
    TabMenu tabMenu = new TabMenu();
    tabMenu.addWidget(UiElements.getRefreshButton(this));
    // get RICH facilities request
    final GetFacilities facilities = new GetFacilities(true);
    // retrieve data (table)
    final CellTable<Facility> table = facilities.getTable(new FieldUpdater<Facility, String>() {

        public void update(int index, Facility object, String value) {
            session.getTabManager().addTab(new FacilityDetailTabItem(object));
        }
    });
    // add new facility button
    tabMenu.addWidget(TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createFacility(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTab(new CreateFacilityTabItem());
        }
    }));
    final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(facilities);
    // add delete facilities button
    final CustomButton deleteButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteFacilities());
    tabMenu.addWidget(deleteButton);
    deleteButton.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            final ArrayList<Facility> list = facilities.getTableSelectedList();
            String text = "Following facilities will be deleted.";
            UiElements.showDeleteConfirm(list, text, 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) {
                            DeleteFacility request = new DeleteFacility(JsonCallbackEvents.disableButtonEvents(deleteButton, events));
                            request.deleteFacility(list.get(i).getId());
                        } else {
                            DeleteFacility request = new DeleteFacility(JsonCallbackEvents.disableButtonEvents(deleteButton));
                            request.deleteFacility(list.get(i).getId());
                        }
                    }
                }
            });
        }
    });
    // filter box
    tabMenu.addFilterWidget(new ExtendedSuggestBox(facilities.getOracle()), new PerunSearchEvent() {

        public void searchFor(String text) {
            facilities.filterTable(text);
        }
    }, ButtonTranslation.INSTANCE.filterFacilities());
    deleteButton.setEnabled(false);
    JsonUtils.addTableManagedButton(facilities, table, deleteButton);
    // 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(tabMenu);
    firstTabPanel.setCellHeight(tabMenu, "30px");
    firstTabPanel.add(sp);
    firstTabPanel.setCellHeight(sp, "100%");
    session.getUiElements().resizePerunTable(sp, 350, this);
    this.contentWidget.setWidget(firstTabPanel);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) PerunSearchEvent(cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) DeleteFacility(cz.metacentrum.perun.webgui.json.facilitiesManager.DeleteFacility) GetFacilities(cz.metacentrum.perun.webgui.json.facilitiesManager.GetFacilities) FacilityDetailTabItem(cz.metacentrum.perun.webgui.tabs.facilitiestabs.FacilityDetailTabItem) 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) CreateFacilityTabItem(cz.metacentrum.perun.webgui.tabs.facilitiestabs.CreateFacilityTabItem) DeleteFacility(cz.metacentrum.perun.webgui.json.facilitiesManager.DeleteFacility) Facility(cz.metacentrum.perun.webgui.model.Facility)

Example 47 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.

the class GroupResourceRequiredAttributesTabItem method draw.

public Widget draw() {
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": settings for " + Utils.getStrippedStringWithEllipsis(resource.getName()));
    if (JsonUtils.isExtendedInfoVisible()) {
        columnId = 3;
    } else {
        columnId = 2;
    }
    final VerticalPanel mainTab = new VerticalPanel();
    mainTab.setSize("100%", "100%");
    TabMenu menu = new TabMenu();
    final Label facilityId = new Label();
    JsonCallbackEvents events = new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            Facility fac = (Facility) jso;
            facilityId.setText(String.valueOf(fac.getId()));
        }
    };
    GetFacility facility = new GetFacility(resourceId, events);
    facility.retrieveData();
    mainTab.add(new HTML("<hr size=\"2px\" />"));
    // set attributes type to group_resource
    final Map<String, Integer> ids = new HashMap<String, Integer>();
    ids.put("resourceToGetServicesFrom", resourceId);
    ids.put("group", groupId);
    // gets all required group attributes for specified group and resource
    final GetResourceRequiredAttributesV2 reqAttrs = new GetResourceRequiredAttributesV2(ids);
    final CellTable<Attribute> reqAttrsTable = reqAttrs.getTable();
    reqAttrsTable.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    // get all required group_resource attributes too
    ids.put("resource", resourceId);
    reqAttrs.setIds(ids);
    reqAttrs.retrieveData();
    final ListBoxWithObjects<RichMember> listBox = new ListBoxWithObjects<RichMember>();
    listBox.setTitle(WidgetTranslation.INSTANCE.selectingMember());
    // local event fills the listBox
    JsonCallbackEvents localEvents = new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            ArrayList<RichMember> mems = JsonUtils.jsoAsList(jso);
            mems = new TableSorter<RichMember>().sortByName(mems);
            listBox.addNotSelectedOption();
            for (int i = 0; i < mems.size(); i++) {
                listBox.addItem(mems.get(i));
            }
            listBox.addAllOption();
        }
    };
    final GetGroupRichMembers getGroupRichMembers = new GetGroupRichMembers(groupId, localEvents);
    getGroupRichMembers.retrieveData();
    reqAttrsTable.addStyleName("perun-table");
    final ScrollPanel sp = new ScrollPanel(reqAttrsTable);
    sp.addStyleName("perun-tableScrollPanel");
    // store for column with values
    final Column<Attribute, ?> columnStore = reqAttrsTable.getColumn(columnId);
    listBox.addChangeHandler(new ChangeHandler() {

        public void onChange(ChangeEvent event) {
            int selectedIndex = listBox.getSelectedIndex();
            // no member selected
            if (selectedIndex == 0) {
                // offer just group and group resource attributes
                reqAttrs.clearTable();
                ids.clear();
                ids.put("resourceToGetServicesFrom", resourceId);
                // get groups attributes
                ids.put("group", groupId);
                reqAttrs.setIds(ids);
                reqAttrs.retrieveData();
                // get group_resource attributes
                ids.put("resource", resourceId);
                reqAttrs.setIds(ids);
                reqAttrs.retrieveData();
                reqAttrs.sortTable();
            // some member is selected
            } else {
                reqAttrs.clearTable();
                ids.clear();
                ids.put("resourceToGetServicesFrom", resourceId);
                // get member, member-resource, user, user-facility  attributes
                ids.put("member", listBox.getSelectedObject().getId());
                ids.put("resource", resourceId);
                // to get user, user-facility attrs
                ids.put("workWithUserAttributes", 1);
                reqAttrs.setIds(ids);
                reqAttrs.retrieveData();
                // all members are selected
                if (selectedIndex == 1) {
                    // remove value column
                    reqAttrsTable.removeColumn(columnId);
                    // create own value column
                    // Value column
                    Column<Attribute, Attribute> valueColumn = JsonUtils.addColumn(new PerunAttributeValueCell(), "Value", new JsonUtils.GetValue<Attribute, Attribute>() {

                        public Attribute getValue(Attribute attribute) {
                            attribute.setValueAsJso(null);
                            return attribute;
                        }
                    }, new FieldUpdater<Attribute, Attribute>() {

                        public void update(int index, Attribute object, Attribute value) {
                            object = value;
                            reqAttrsTable.getSelectionModel().setSelected(object, object.isAttributeValid());
                        }
                    });
                    // add to table
                    reqAttrsTable.insertColumn(columnId, valueColumn, "Value");
                } else {
                    // member selected
                    // return original column
                    reqAttrsTable.removeColumn(columnId);
                    reqAttrsTable.insertColumn(columnId, columnStore, "Value");
                }
            }
        }
    });
    CustomButton saveChangesButton = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveChangesInAttributes(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            ArrayList<Attribute> list = reqAttrs.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                // send lists
                ArrayList<Attribute> groupList = new ArrayList<Attribute>();
                ArrayList<Attribute> groupResourceList = new ArrayList<Attribute>();
                ArrayList<Attribute> memberList = new ArrayList<Attribute>();
                ArrayList<Attribute> memberResourceList = new ArrayList<Attribute>();
                ArrayList<Attribute> userList = new ArrayList<Attribute>();
                ArrayList<Attribute> userFacilityList = new ArrayList<Attribute>();
                SetAttributes request = new SetAttributes();
                int selectedIndex = listBox.getSelectedIndex();
                // if all selected
                if (selectedIndex == 1) {
                    // TODO - USE NEW CONFIRM DESIGN
                    if (!Window.confirm("Same values for selected attributes will be set to all members in group." + "\n\nDo you want to continue ?")) {
                        return;
                    }
                }
                // get different attributes
                for (Attribute attr : list) {
                    if (attr.getNamespace().contains("urn:perun:group:")) {
                        groupList.add(attr);
                    } else if (attr.getNamespace().contains("urn:perun:group_resource:")) {
                        groupResourceList.add(attr);
                    } else if (attr.getNamespace().contains("urn:perun:member:")) {
                        memberList.add(attr);
                    } else if (attr.getNamespace().contains("urn:perun:member_resource:")) {
                        memberResourceList.add(attr);
                    } else if (attr.getNamespace().contains("urn:perun:user:")) {
                        userList.add(attr);
                    } else if (attr.getNamespace().contains("urn:perun:user_facility:")) {
                        userFacilityList.add(attr);
                    }
                }
                // if not empty, send request
                if (!(groupList.isEmpty())) {
                    ids.clear();
                    ids.put("group", groupId);
                    request.setAttributes(ids, groupList);
                }
                if (!(groupResourceList.isEmpty())) {
                    ids.clear();
                    ids.put("group", groupId);
                    ids.put("resource", resourceId);
                    request.setAttributes(ids, groupResourceList);
                }
                if (!(memberList.isEmpty())) {
                    if (selectedIndex == 1) {
                        // for all members
                        for (int i = 0; i < listBox.getItemCount(); i++) {
                            ids.clear();
                            ids.put("member", (listBox.getObjectAt(i)).getId());
                            request.setAttributes(ids, memberList);
                        }
                    } else {
                        // for one member
                        ids.clear();
                        ids.put("member", listBox.getSelectedObject().getId());
                        request.setAttributes(ids, memberList);
                    }
                }
                if (!(memberResourceList.isEmpty())) {
                    if (selectedIndex == 1) {
                        // for all members
                        for (int i = 0; i < listBox.getItemCount(); i++) {
                            ids.clear();
                            ids.put("resource", resourceId);
                            ids.put("member", (listBox.getObjectAt(i)).getId());
                            request.setAttributes(ids, memberResourceList);
                        }
                    } else {
                        // for one member
                        ids.clear();
                        ids.put("resource", resourceId);
                        ids.put("member", listBox.getSelectedObject().getId());
                        request.setAttributes(ids, memberResourceList);
                    }
                }
                if (!(userList.isEmpty())) {
                    if (selectedIndex == 1) {
                        // for all members
                        for (int i = 0; i < listBox.getItemCount(); i++) {
                            ids.clear();
                            ids.put("user", (listBox.getObjectAt(i)).getUser().getId());
                            request.setAttributes(ids, userList);
                        }
                    } else {
                        // for one member
                        ids.clear();
                        ids.put("user", listBox.getSelectedObject().getUser().getId());
                        request.setAttributes(ids, userList);
                    }
                }
                if (!(userFacilityList.isEmpty())) {
                    if (selectedIndex == 1) {
                        // for all members
                        for (int i = 0; i < listBox.getItemCount(); i++) {
                            ids.clear();
                            ids.put("user", listBox.getObjectAt(i).getUser().getId());
                            ids.put("facility", Integer.parseInt(facilityId.getText()));
                            request.setAttributes(ids, userFacilityList);
                        }
                    } else {
                        // for one member
                        ids.clear();
                        ids.put("user", listBox.getSelectedObject().getUser().getId());
                        ids.put("facility", Integer.parseInt(facilityId.getText()));
                        request.setAttributes(ids, userFacilityList);
                    }
                }
                reqAttrs.clearTableSelectedSet();
            }
        }
    });
    menu.addWidget(UiElements.getRefreshButton(this));
    menu.addWidget(saveChangesButton);
    if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
        saveChangesButton.setEnabled(false);
    menu.addWidget(new HTML("<strong>Group members:</strong>"));
    menu.addWidget(listBox);
    // table content
    session.getUiElements().resizePerunTable(sp, 350, this);
    mainTab.add(menu);
    mainTab.add(sp);
    mainTab.setCellHeight(sp, "100%");
    mainTab.setCellHeight(menu, "30px");
    this.contentWidget.setWidget(mainTab);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) HashMap(java.util.HashMap) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) SetAttributes(cz.metacentrum.perun.webgui.json.attributesManager.SetAttributes) ListBoxWithObjects(cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects) ChangeHandler(com.google.gwt.event.dom.client.ChangeHandler) Column(com.google.gwt.user.cellview.client.Column) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) GetFacility(cz.metacentrum.perun.webgui.json.resourcesManager.GetFacility) PerunAttributeValueCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeValueCell) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) GetResourceRequiredAttributesV2(cz.metacentrum.perun.webgui.json.attributesManager.GetResourceRequiredAttributesV2) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) ChangeEvent(com.google.gwt.event.dom.client.ChangeEvent) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetFacility(cz.metacentrum.perun.webgui.json.resourcesManager.GetFacility) GetGroupRichMembers(cz.metacentrum.perun.webgui.json.groupsManager.GetGroupRichMembers)

Example 48 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent 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 49 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.

the class GroupsResourceRequiredAttributesTabItem method draw.

public Widget draw() {
    if (groups == null || groups.get(0) == null) {
        Window.alert("No groups in list.");
    }
    if (JsonUtils.isExtendedInfoVisible()) {
        columnId = 3;
    } else {
        columnId = 2;
    }
    final VerticalPanel mainTab = new VerticalPanel();
    mainTab.setSize("100%", "100%");
    TabMenu menu = new TabMenu();
    mainTab.add(new HTML("<hr size=\"2px\" />"));
    // set attributes type to group_resource
    final Map<String, Integer> ids = new HashMap<String, Integer>();
    ids.put("resourceToGetServicesFrom", resourceId);
    ids.put("group", groups.get(0).getId());
    // gets all required group attributes for specified group and resource
    final GetResourceRequiredAttributesV2 reqAttrs = new GetResourceRequiredAttributesV2(ids);
    final CellTable<Attribute> reqAttrsTable = reqAttrs.getTable();
    // remove value column
    reqAttrsTable.removeColumn(columnId);
    // create own value column
    Column<Attribute, Attribute> valueColumn = JsonUtils.addColumn(new PerunAttributeValueCell(), "Value", new JsonUtils.GetValue<Attribute, Attribute>() {

        public Attribute getValue(Attribute attribute) {
            // set empty value
            attribute.setValueAsJso(null);
            return attribute;
        }
    }, new FieldUpdater<Attribute, Attribute>() {

        public void update(int index, Attribute object, Attribute value) {
            object = value;
            reqAttrsTable.getSelectionModel().setSelected(object, object.isAttributeValid());
        }
    });
    // add to table
    reqAttrsTable.insertColumn(columnId, valueColumn, "Value");
    // get all required group_resource attributes too
    ids.put("resource", resourceId);
    reqAttrs.setIds(ids);
    reqAttrs.retrieveData();
    reqAttrsTable.addStyleName("perun-table");
    final ScrollPanel sp = new ScrollPanel(reqAttrsTable);
    sp.addStyleName("perun-tableScrollPanel");
    CustomButton saveChangesButton = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveChangesInAttributes(), new ClickHandler() {

        public void onClick(ClickEvent event) {
            ArrayList<Attribute> list = reqAttrs.getTableSelectedList();
            if (UiElements.cantSaveEmptyListDialogBox(list)) {
                ArrayList<Attribute> groupList = new ArrayList<Attribute>();
                ArrayList<Attribute> groupResourceList = new ArrayList<Attribute>();
                SetAttributes request = new SetAttributes();
                // TODO - use new confirm dialog
                if (!Window.confirm("Same values for selected attributes will be set to all groups you are about to assign." + "\n\nDo you want to continue ?")) {
                    return;
                }
                // get different attributes
                for (Attribute attr : list) {
                    if (attr.getNamespace().contains("urn:perun:group:")) {
                        groupList.add(attr);
                    } else if (attr.getNamespace().contains("urn:perun:group_resource:")) {
                        groupResourceList.add(attr);
                    }
                }
                if (!(groupList.isEmpty())) {
                    ids.clear();
                    for (int i = 0; i < groups.size(); i++) {
                        ids.put("group", groups.get(i).getId());
                        request.setAttributes(ids, groupList);
                    }
                }
                if (!(groupResourceList.isEmpty())) {
                    ids.clear();
                    ids.put("resource", resourceId);
                    for (int i = 0; i < groups.size(); i++) {
                        ids.put("group", groups.get(i).getId());
                        request.setAttributes(ids, groupResourceList);
                    }
                }
                reqAttrs.clearTableSelectedSet();
            }
        }
    });
    menu.addWidget(UiElements.getRefreshButton(this));
    menu.addWidget(saveChangesButton);
    if (!session.isGroupAdmin() && !session.isVoAdmin())
        saveChangesButton.setEnabled(false);
    // table content
    session.getUiElements().resizePerunTable(sp, 350, this);
    mainTab.add(menu);
    mainTab.add(sp);
    mainTab.setCellHeight(sp, "100%");
    mainTab.setCellHeight(menu, "30px");
    this.contentWidget.setWidget(mainTab);
    return getWidget();
}
Also used : PerunAttributeValueCell(cz.metacentrum.perun.webgui.widgets.cells.PerunAttributeValueCell) HashMap(java.util.HashMap) Attribute(cz.metacentrum.perun.webgui.model.Attribute) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) SetAttributes(cz.metacentrum.perun.webgui.json.attributesManager.SetAttributes) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) GetResourceRequiredAttributesV2(cz.metacentrum.perun.webgui.json.attributesManager.GetResourceRequiredAttributesV2) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JsonUtils(cz.metacentrum.perun.webgui.json.JsonUtils) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Example 50 with ClickEvent

use of com.google.gwt.event.dom.client.ClickEvent in project perun by CESNET.

the class GroupDetailTabItem method draw.

public Widget draw() {
    titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()));
    // main panel
    VerticalPanel vp = new VerticalPanel();
    vp.setSize("100%", "100%");
    // The table
    AbsolutePanel dp = new AbsolutePanel();
    //dp.setStyleName("decoration");
    final FlexTable menu = new FlexTable();
    menu.setCellSpacing(5);
    // Add group information
    menu.setWidget(0, 0, new Image(LargeIcons.INSTANCE.groupIcon()));
    Label groupName = new Label();
    groupName.setText(Utils.getStrippedStringWithEllipsis(group.getName(), 40));
    groupName.setStyleName("now-managing");
    groupName.setTitle(group.getName());
    menu.setWidget(0, 1, groupName);
    final JsonCallbackEvents events = new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            new GetEntityById(PerunEntity.RICH_GROUP, groupId, new JsonCallbackEvents() {

                public void onFinished(JavaScriptObject jso) {
                    group = jso.cast();
                    open();
                    draw();
                }
            }).retrieveData();
        }
    };
    menu.setHTML(0, 2, "&nbsp;");
    menu.getFlexCellFormatter().setWidth(0, 2, "25px");
    int column = 3;
    CustomButton change;
    if (group.isCoreGroup()) {
        change = new CustomButton("", "Core group's name and description can't be changed", SmallIcons.INSTANCE.applicationFormEditIcon());
        change.setEnabled(false);
    } else {
        change = new CustomButton("", ButtonTranslation.INSTANCE.editGroupDetails(), SmallIcons.INSTANCE.applicationFormEditIcon());
    }
    if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
        change.setEnabled(false);
    change.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new EditGroupDetailsTabItem(group, events));
        }
    });
    menu.setWidget(0, column, change);
    column++;
    menu.setHTML(0, column, "&nbsp;");
    menu.getFlexCellFormatter().setWidth(0, column, "25px");
    column++;
    if (JsonUtils.isExtendedInfoVisible()) {
        menu.setHTML(0, column, "<strong>ID:</strong><br/><span class=\"inputFormInlineComment\">" + group.getId() + "</span>");
        column++;
        menu.setHTML(0, column, "&nbsp;");
        menu.getFlexCellFormatter().setWidth(0, column, "25px");
        column++;
    }
    /*
		String text = (((RichGroup)group).isSyncEnabled()) ? "Enabled" : "Disabled";

		text += (((RichGroup)group).getAuthoritativeGroup().equals("1")) ? " / Authoritative" : "";

		menu.setHTML(0, column, "<strong>Sync:</strong><br/><span class=\"inputFormInlineComment\">"+text+"</span>");

		column++;
		*/
    menu.setHTML(0, column, "<strong>Description:</strong><br/><span class=\"inputFormInlineComment\">" + group.getDescription() + "&nbsp;</span>");
    dp.add(menu);
    vp.add(dp);
    vp.setCellHeight(dp, "30px");
    tabPanel.clear();
    tabPanel.add(new GroupMembersTabItem(group), "Members");
    if (!group.isCoreGroup()) {
        tabPanel.add(new SubgroupsTabItem(group), "Subgroups");
        tabPanel.add(new GroupRelationsTabItem(group), "Relations");
    }
    tabPanel.add(new GroupResourcesTabItem(group), "Resources");
    if (!group.isCoreGroup()) {
        tabPanel.add(new GroupApplicationsTabItem(group), "Applications");
        tabPanel.add(new GroupApplicationFormSettingsTabItem(group), "Application form");
    }
    tabPanel.add(new GroupSettingsTabItem(group), "Settings");
    if (!group.isCoreGroup()) {
        // core groups can't have managers
        tabPanel.add(new GroupManagersTabItem(group), "Managers");
    }
    if (!group.isCoreGroup()) {
        // core groups can't have ext sources
        tabPanel.add(new GroupExtSourcesTabItem(group), "External sources");
    }
    // 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) 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

ClickEvent (com.google.gwt.event.dom.client.ClickEvent)385 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)382 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)161 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)135 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)124 ArrayList (java.util.ArrayList)117 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)105 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)76 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)42 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)41 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)40 PerunError (cz.metacentrum.perun.webgui.model.PerunError)36 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)32 HashMap (java.util.HashMap)32 Button (com.google.gwt.user.client.ui.Button)30 Image (com.google.gwt.user.client.ui.Image)28 HTML (com.google.gwt.user.client.ui.HTML)26 Button (org.gwtbootstrap3.client.ui.Button)26 FlexCellFormatter (com.google.gwt.user.client.ui.FlexTable.FlexCellFormatter)25 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)23