Search in sources :

Example 1 with ChangeStatusTabItem

use of cz.metacentrum.perun.webgui.tabs.memberstabs.ChangeStatusTabItem in project perun by CESNET.

the class PerunStatusWidget method getChangeStatusButton.

/**
	 * Changing status button
	 * @return the widget
	 */
private Widget getChangeStatusButton() {
    Anchor button = new Anchor("change");
    button.setTitle("Change status for " + objectName + ".");
    button.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            RichMember member = object.cast();
            JsonCallbackEvents newEvent = JsonCallbackEvents.mergeEvents(events, new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    Member m = jso.cast();
                    object.setStatus(m.getStatus());
                    build();
                }
            });
            PerunWebSession.getInstance().getTabManager().addTabToCurrentTab(new ChangeStatusTabItem(member, newEvent));
        }
    });
    return button;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ChangeStatusTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.ChangeStatusTabItem) RichMember(cz.metacentrum.perun.webgui.model.RichMember) Member(cz.metacentrum.perun.webgui.model.Member) RichMember(cz.metacentrum.perun.webgui.model.RichMember)

Example 2 with ChangeStatusTabItem

use of cz.metacentrum.perun.webgui.tabs.memberstabs.ChangeStatusTabItem in project perun by CESNET.

the class MemberColumnProvider method addStatusColumn.

public void addStatusColumn(IsClickableCell authz, int width) {
    // Status column
    final Column<RichMember, String> statusColumn = new Column<RichMember, String>(new PerunStatusCell()) {

        @Override
        public String getValue(RichMember object) {
            return object.getStatus();
        }
    };
    // own onClick tab for changing member's status
    statusColumn.setFieldUpdater(new FieldUpdater<RichMember, String>() {

        @Override
        public void update(final int index, final RichMember object, final String value) {
            PerunWebSession.getInstance().getTabManager().addTabToCurrentTab(new ChangeStatusTabItem(object, new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    Member m = jso.cast();
                    // set status to object in cell to change rendered value
                    object.setStatus(m.getStatus());
                    // because they are not updated during .update() on cell
                    for (RichMember rm : dataProvider.getList()) {
                        if (rm.getId() == m.getId()) {
                            rm.setStatus(m.getStatus());
                        }
                    }
                    if (backupList != null) {
                        for (RichMember rm : backupList) {
                            if (rm.getId() == m.getId()) {
                                rm.setStatus(m.getStatus());
                            }
                        }
                    }
                    dataProvider.refresh();
                    dataProvider.flush();
                }
            }));
        }
    });
    // add column
    table.addColumn(statusColumn, "Status");
    if (width != 0) {
        table.setColumnWidth(statusColumn, width, Style.Unit.PX);
    }
    // status column sortable
    statusColumn.setSortable(true);
    table.getColumnSortHandler().setComparator(statusColumn, new GeneralComparator<RichMember>(GeneralComparator.Column.STATUS));
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) RichMember(cz.metacentrum.perun.webgui.model.RichMember) Column(com.google.gwt.user.cellview.client.Column) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) PerunStatusCell(cz.metacentrum.perun.webgui.widgets.cells.PerunStatusCell) ChangeStatusTabItem(cz.metacentrum.perun.webgui.tabs.memberstabs.ChangeStatusTabItem) Member(cz.metacentrum.perun.webgui.model.Member) RichMember(cz.metacentrum.perun.webgui.model.RichMember)

Aggregations

JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)2 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)2 Member (cz.metacentrum.perun.webgui.model.Member)2 RichMember (cz.metacentrum.perun.webgui.model.RichMember)2 ChangeStatusTabItem (cz.metacentrum.perun.webgui.tabs.memberstabs.ChangeStatusTabItem)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 Column (com.google.gwt.user.cellview.client.Column)1 PerunStatusCell (cz.metacentrum.perun.webgui.widgets.cells.PerunStatusCell)1