Search in sources :

Example 1 with CommentObject

use of test_support.entity.model_objects.CommentObject in project jmix by jmix-framework.

the class TestProgrammaticCommentaryPanel method addMessage.

protected void addMessage(String text) {
    if (getCommentProvider() == null) {
        return;
    }
    CommentObject comment = getCommentProvider().apply(text);
    DataGridItems<CommentObject> items = commentsDataGrid.getItems();
    if (items instanceof ContainerDataUnit) {
        // noinspection unchecked
        CollectionContainer<CommentObject> container = ((ContainerDataUnit<CommentObject>) items).getContainer();
        container.getMutableItems().add(comment);
    } else {
        throw new IllegalStateException("Items must implement ContainerDataUnit");
    }
}
Also used : ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit) CommentObject(test_support.entity.model_objects.CommentObject)

Example 2 with CommentObject

use of test_support.entity.model_objects.CommentObject in project jmix by jmix-framework.

the class TestProgrammaticCommentaryPanel method initComponent.

protected void initComponent(ComponentContainer composition) {
    commentsDataGrid.addGeneratedColumn("comment", event -> {
        CommentObject item = event.getItem();
        return "<p class=\"message-text\">" + item.getText() + "</p>";
    });
    commentsDataGrid.setRowDescriptionProvider(CommentObject::getText);
    sendBtn.addClickListener(clickEvent -> sendMessage());
    messageField.addEnterPressListener(enterPressEvent -> sendMessage());
}
Also used : CommentObject(test_support.entity.model_objects.CommentObject)

Example 3 with CommentObject

use of test_support.entity.model_objects.CommentObject in project jmix by jmix-framework.

the class TestProgrammaticCommentaryPanel method createComponent.

protected 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<CommentObject> commentsDataGrid = uiComponents.create(DataGrid.of(CommentObject.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("Send");
    sendMessageBox.add(messageField, sendBtn);
    rootPanel.add(commentsDataGrid, sendMessageBox);
    rootPanel.expand(commentsDataGrid);
    setComposition(rootPanel);
}
Also used : VBoxLayout(io.jmix.ui.component.VBoxLayout) CssLayout(io.jmix.ui.component.CssLayout) Button(io.jmix.ui.component.Button) CommentObject(test_support.entity.model_objects.CommentObject)

Example 4 with CommentObject

use of test_support.entity.model_objects.CommentObject in project jmix by jmix-framework.

the class TestCommentaryPanel method addMessage.

protected void addMessage(String text) {
    if (getCommentProvider() == null) {
        return;
    }
    CommentObject comment = getCommentProvider().apply(text);
    DataGridItems<CommentObject> items = commentsDataGrid.getItems();
    if (items instanceof ContainerDataUnit) {
        // noinspection unchecked
        CollectionContainer<CommentObject> container = ((ContainerDataUnit<CommentObject>) items).getContainer();
        container.getMutableItems().add(comment);
    } else {
        throw new IllegalStateException("Items must implement ContainerDataUnit");
    }
}
Also used : ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit) CommentObject(test_support.entity.model_objects.CommentObject)

Example 5 with CommentObject

use of test_support.entity.model_objects.CommentObject in project jmix by jmix-framework.

the class TestCommentaryPanel method initComponent.

protected void initComponent() {
    commentsDataGrid.addGeneratedColumn("comment", event -> {
        CommentObject item = event.getItem();
        return "<p class=\"message-text\">" + item.getText() + "</p>";
    });
    commentsDataGrid.setRowDescriptionProvider(CommentObject::getText);
    sendBtn.addClickListener(clickEvent -> sendMessage());
    messageField.addEnterPressListener(enterPressEvent -> sendMessage());
}
Also used : CommentObject(test_support.entity.model_objects.CommentObject)

Aggregations

CommentObject (test_support.entity.model_objects.CommentObject)5 ContainerDataUnit (io.jmix.ui.component.data.meta.ContainerDataUnit)2 Button (io.jmix.ui.component.Button)1 CssLayout (io.jmix.ui.component.CssLayout)1 VBoxLayout (io.jmix.ui.component.VBoxLayout)1