Search in sources :

Example 1 with GetAuditMessagesByCount

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

the class AuditLogTabItem method draw.

public Widget draw() {
    // page main tab
    final VerticalPanel mainTab = new VerticalPanel();
    mainTab.setSize("100%", "100%");
    // number of messages
    final TextBox tb = new TextBox();
    tb.setText(String.valueOf(count));
    tb.setWidth("100px");
    // menu panel
    TabMenu menu = new TabMenu();
    mainTab.add(menu);
    mainTab.setCellHeight(menu, "30px");
    CustomButton refreshButton = TabMenu.getPredefinedButton(ButtonType.REFRESH, ButtonTranslation.INSTANCE.refreshAuditMessages());
    // retrieve messages
    final GetAuditMessagesByCount call = new GetAuditMessagesByCount(JsonCallbackEvents.disableButtonEvents(refreshButton));
    call.setCount(count);
    CellTable<AuditMessage> table = call.getTable();
    table.addStyleName("perun-table");
    ScrollPanel sp = new ScrollPanel(table);
    sp.addStyleName("perun-tableScrollPanel");
    mainTab.add(sp);
    // resize perun table to correct size on screen
    session.getUiElements().resizePerunTable(sp, 350, this);
    // refresh button action
    refreshButton.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            if (JsonUtils.checkParseInt(tb.getText())) {
                call.clearTable();
                count = Integer.parseInt(tb.getText());
                call.setCount(count);
                call.retrieveData();
            } else {
                JsonUtils.cantParseIntConfirm("Number of messages", tb.getText());
            }
        }
    });
    menu.addWidget(refreshButton);
    // enter key = refresh on count text box
    tb.addKeyPressHandler(new KeyPressHandler() {

        public void onKeyPress(KeyPressEvent event) {
            if (event.getNativeEvent().getKeyCode() == KeyCodes.KEY_ENTER) {
                if (JsonUtils.checkParseInt(tb.getText())) {
                    call.clearTable();
                    count = Integer.parseInt(tb.getText());
                    call.setCount(count);
                    call.retrieveData();
                } else {
                    JsonUtils.cantParseIntConfirm("Number of messages", tb.getText());
                }
            }
        }
    });
    // add textbox into menu
    menu.addWidget(new HTML("<strong>Number of messages: </strong>"));
    menu.addWidget(tb);
    this.contentWidget.setWidget(mainTab);
    return getWidget();
}
Also used : AuditMessage(cz.metacentrum.perun.webgui.model.AuditMessage) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) GetAuditMessagesByCount(cz.metacentrum.perun.webgui.json.auditMessagesManager.GetAuditMessagesByCount) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton)

Aggregations

GetAuditMessagesByCount (cz.metacentrum.perun.webgui.json.auditMessagesManager.GetAuditMessagesByCount)1 AuditMessage (cz.metacentrum.perun.webgui.model.AuditMessage)1 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)1 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)1