Search in sources :

Example 1 with BelongToFrame

use of com.haulmont.cuba.gui.components.Component.BelongToFrame in project cuba by cuba-platform.

the class DesktopTableCellEditor method getCellComponent.

protected Component getCellComponent(int row) {
    Entity item = desktopAbstractTable.getTableModel().getItem(row);
    StopWatch sw = new Slf4JStopWatch("TableColumnGenerator." + desktopAbstractTable.getId());
    @SuppressWarnings("unchecked") com.haulmont.cuba.gui.components.Component component = columnGenerator.generateCell(item);
    sw.stop();
    Component comp;
    if (component == null) {
        comp = new JLabel("");
    } else if (component instanceof Table.PlainTextCell) {
        comp = new JLabel(((Table.PlainTextCell) component).getText());
    } else {
        if (component instanceof BelongToFrame) {
            BelongToFrame belongToFrame = (BelongToFrame) component;
            if (belongToFrame.getFrame() == null) {
                belongToFrame.setFrame(desktopAbstractTable.getFrame());
            }
        }
        component.setParent(desktopAbstractTable);
        JComponent jComposition = DesktopComponentsHelper.getComposition(component);
        jComposition.putClientProperty(CELL_EDITOR_TABLE, desktopAbstractTable.getComponent());
        jComposition.putClientProperty(CELL_COMPONENT, component);
        comp = jComposition;
    }
    cache.put(row, comp);
    return comp;
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) Table(com.haulmont.cuba.gui.components.Table) BelongToFrame(com.haulmont.cuba.gui.components.Component.BelongToFrame) Slf4JStopWatch(org.perf4j.slf4j.Slf4JStopWatch) StopWatch(org.perf4j.StopWatch)

Example 2 with BelongToFrame

use of com.haulmont.cuba.gui.components.Component.BelongToFrame in project cuba by cuba-platform.

the class WebWindowManager method initDebugIds.

@Override
public void initDebugIds(final Frame frame) {
    if (ui.isTestMode()) {
        ComponentsHelper.walkComponents(frame, (component, name) -> {
            if (component.getDebugId() == null) {
                Frame componentFrame = null;
                if (component instanceof BelongToFrame) {
                    componentFrame = ((BelongToFrame) component).getFrame();
                }
                if (componentFrame == null) {
                    log.warn("Frame for component {} is not assigned", component.getClass());
                } else {
                    if (component instanceof WebAbstractComponent) {
                        WebAbstractComponent webComponent = (WebAbstractComponent) component;
                        webComponent.assignAutoDebugId();
                    }
                }
            }
        });
    }
}
Also used : BelongToFrame(com.haulmont.cuba.gui.components.Component.BelongToFrame) BelongToFrame(com.haulmont.cuba.gui.components.Component.BelongToFrame) WebAbstractComponent(com.haulmont.cuba.web.gui.components.WebAbstractComponent)

Aggregations

BelongToFrame (com.haulmont.cuba.gui.components.Component.BelongToFrame)2 Entity (com.haulmont.cuba.core.entity.Entity)1 Table (com.haulmont.cuba.gui.components.Table)1 WebAbstractComponent (com.haulmont.cuba.web.gui.components.WebAbstractComponent)1 StopWatch (org.perf4j.StopWatch)1 Slf4JStopWatch (org.perf4j.slf4j.Slf4JStopWatch)1