Search in sources :

Example 1 with Comment

use of com.haulmont.cuba.web.testmodel.compositecomponent.Comment in project cuba by cuba-platform.

the class TestCommentaryPanel method addMessage.

private void addMessage(String text) {
    if (getCommentProvider() == null) {
        return;
    }
    Comment comment = getCommentProvider().apply(text);
    DataGridItems<Comment> items = commentsDataGrid.getItems();
    if (items instanceof ContainerDataUnit) {
        // noinspection unchecked
        CollectionContainer<Comment> container = ((ContainerDataUnit<Comment>) items).getContainer();
        container.getMutableItems().add(comment);
    } else {
        throw new IllegalStateException("Items must implement com.haulmont.cuba.gui.components.data.meta.ContainerDataUnit");
    }
}
Also used : Comment(com.haulmont.cuba.web.testmodel.compositecomponent.Comment) ContainerDataUnit(com.haulmont.cuba.gui.components.data.meta.ContainerDataUnit)

Example 2 with Comment

use of com.haulmont.cuba.web.testmodel.compositecomponent.Comment in project cuba by cuba-platform.

the class TestProgrammaticCommentaryPanel method createComponent.

private void createComponent() {
    VBoxLayout rootPanel = uiComponents.create(VBoxLayout.class);
    rootPanel.setId("rootPanel");
    rootPanel.setMargin(true);
    rootPanel.setSpacing(true);
    rootPanel.setStyleName("commentary-panel card");
    rootPanel.setWidthFull();
    DataGrid<Comment> commentsDataGrid = uiComponents.create(DataGrid.of(Comment.class));
    commentsDataGrid.setId("commentsDataGrid");
    commentsDataGrid.setBodyRowHeight(100);
    commentsDataGrid.setColumnReorderingAllowed(false);
    commentsDataGrid.setColumnsCollapsingAllowed(false);
    commentsDataGrid.setHeaderVisible(false);
    commentsDataGrid.setSelectionMode(DataGrid.SelectionMode.NONE);
    commentsDataGrid.setWidthFull();
    CssLayout sendMessageBox = uiComponents.create(CssLayout.class);
    sendMessageBox.setId("sendMessageBox");
    sendMessageBox.setStyleName("v-component-group message-box");
    sendMessageBox.setWidthFull();
    TextField<String> messageField = uiComponents.create(TextField.TYPE_STRING);
    messageField.setId("messageField");
    messageField.setInputPrompt("Enter your message");
    messageField.setWidthFull();
    Button sendBtn = uiComponents.create(Button.class);
    sendBtn.setId("sendBtn");
    sendBtn.setCaption(messages.getMessage(TestProgrammaticCommentaryPanel.class, "commentary-panel.send"));
    sendMessageBox.add(messageField, sendBtn);
    rootPanel.add(commentsDataGrid, sendMessageBox);
    rootPanel.expand(commentsDataGrid);
    setComposition(rootPanel);
}
Also used : VBoxLayout(com.haulmont.cuba.gui.components.VBoxLayout) Comment(com.haulmont.cuba.web.testmodel.compositecomponent.Comment) CssLayout(com.haulmont.cuba.gui.components.CssLayout) Button(com.haulmont.cuba.gui.components.Button)

Example 3 with Comment

use of com.haulmont.cuba.web.testmodel.compositecomponent.Comment in project cuba by cuba-platform.

the class TestProgrammaticCommentaryPanel method addMessage.

private void addMessage(String text) {
    if (getCommentProvider() == null) {
        return;
    }
    Comment comment = getCommentProvider().apply(text);
    DataGridItems<Comment> items = commentsDataGrid.getItems();
    if (items instanceof ContainerDataUnit) {
        // noinspection unchecked
        CollectionContainer<Comment> container = ((ContainerDataUnit<Comment>) items).getContainer();
        container.getMutableItems().add(comment);
    } else {
        throw new IllegalStateException("Items must implement com.haulmont.cuba.gui.components.data.meta.ContainerDataUnit");
    }
}
Also used : Comment(com.haulmont.cuba.web.testmodel.compositecomponent.Comment) ContainerDataUnit(com.haulmont.cuba.gui.components.data.meta.ContainerDataUnit)

Aggregations

Comment (com.haulmont.cuba.web.testmodel.compositecomponent.Comment)3 ContainerDataUnit (com.haulmont.cuba.gui.components.data.meta.ContainerDataUnit)2 Button (com.haulmont.cuba.gui.components.Button)1 CssLayout (com.haulmont.cuba.gui.components.CssLayout)1 VBoxLayout (com.haulmont.cuba.gui.components.VBoxLayout)1