Search in sources :

Example 81 with Component

use of com.vaadin.ui.Component in project cuba by cuba-platform.

the class WebWindowManager method showWindowThisTab.

protected Component showWindowThisTab(final Window window, final String caption, final String description) {
    getDialogParams().reset();
    WebAppWorkArea workArea = getConfiguredWorkArea(createWorkAreaContext(window));
    Layout layout;
    if (workArea.getMode() == Mode.TABBED) {
        TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
        layout = (Layout) tabSheet.getSelectedTab();
    } else {
        layout = (Layout) workArea.getSingleWindowContainer().getComponent(0);
    }
    final WindowBreadCrumbs breadCrumbs = tabs.get(layout);
    if (breadCrumbs == null) {
        throw new IllegalStateException("BreadCrumbs not found");
    }
    final Window currentWindow = breadCrumbs.getCurrentWindow();
    Set<Map.Entry<Window, Integer>> set = windows.entrySet();
    boolean pushed = false;
    for (Map.Entry<Window, Integer> entry : set) {
        if (entry.getKey().equals(currentWindow)) {
            windows.remove(currentWindow);
            getStack(breadCrumbs).push(new Pair<>(entry.getKey(), entry.getValue()));
            pushed = true;
            break;
        }
    }
    if (!pushed) {
        getStack(breadCrumbs).push(new Pair<>(currentWindow, null));
    }
    removeFromWindowMap(currentWindow);
    layout.removeComponent(WebComponentsHelper.getComposition(currentWindow));
    final Component component = WebComponentsHelper.getComposition(window);
    component.setSizeFull();
    layout.addComponent(component);
    breadCrumbs.addWindow(window);
    if (workArea.getMode() == Mode.TABBED) {
        TabSheetBehaviour tabSheet = workArea.getTabbedWindowContainer().getTabSheetBehaviour();
        String tabId = tabSheet.getTab(layout);
        String formattedCaption = formatTabCaption(caption, description);
        tabSheet.setTabCaption(tabId, formattedCaption);
        String formattedDescription = formatTabDescription(caption, description);
        if (!Objects.equals(formattedCaption, formattedDescription)) {
            tabSheet.setTabDescription(tabId, formattedDescription);
        } else {
            tabSheet.setTabDescription(tabId, null);
        }
        tabSheet.setTabIcon(tabId, iconResolver.getIconResource(window.getIcon()));
        ContentSwitchMode contentSwitchMode = ContentSwitchMode.valueOf(window.getContentSwitchMode().name());
        tabSheet.setContentSwitchMode(tabId, contentSwitchMode);
    } else {
        layout.markAsDirtyRecursive();
    }
    return layout;
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WebWindow(com.haulmont.cuba.web.gui.WebWindow) WebAppWorkArea(com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea) CssLayout(com.vaadin.ui.CssLayout) WindowBreadCrumbs(com.haulmont.cuba.web.sys.WindowBreadCrumbs) WebAbstractComponent(com.haulmont.cuba.web.gui.components.WebAbstractComponent) Component(com.vaadin.ui.Component) ParamsMap(com.haulmont.bali.util.ParamsMap) Collections.singletonMap(java.util.Collections.singletonMap)

Example 82 with Component

use of com.vaadin.ui.Component in project cuba by cuba-platform.

the class WebDataGrid method setRowsCount.

@Override
public void setRowsCount(RowsCount rowsCount) {
    if (this.rowsCount != null && topPanel != null) {
        topPanel.removeComponent(WebComponentsHelper.unwrap(this.rowsCount));
        this.rowsCount.setParent(null);
    }
    this.rowsCount = rowsCount;
    if (rowsCount != null) {
        if (rowsCount.getParent() != null && rowsCount.getParent() != this) {
            throw new IllegalStateException("Component already has parent");
        }
        if (topPanel == null) {
            topPanel = createTopPanel();
            topPanel.setWidth("100%");
            componentComposition.addComponentAsFirst(topPanel);
        }
        com.vaadin.ui.Component rc = WebComponentsHelper.unwrap(rowsCount);
        topPanel.addComponent(rc);
        topPanel.setExpandRatio(rc, 1);
        topPanel.setComponentAlignment(rc, com.vaadin.ui.Alignment.BOTTOM_RIGHT);
        if (rowsCount instanceof VisibilityChangeNotifier) {
            ((VisibilityChangeNotifier) rowsCount).addVisibilityChangeListener(event -> updateCompositionStylesTopPanelVisible());
        }
    }
    updateCompositionStylesTopPanelVisible();
}
Also used : com.haulmont.cuba.web.toolkit.ui(com.haulmont.cuba.web.toolkit.ui) com.vaadin.ui(com.vaadin.ui) Component(com.vaadin.ui.Component)

Example 83 with Component

use of com.vaadin.ui.Component in project cuba by cuba-platform.

the class WebFileUploadField method setPasteZone.

@Override
public void setPasteZone(Container pasteZone) {
    super.setPasteZone(pasteZone);
    if (uploadButton instanceof CubaFileUpload) {
        if (pasteZone == null) {
            ((CubaFileUpload) uploadButton).setPasteZone(null);
        } else {
            Component vComponent = pasteZone.unwrapComposition(Component.class);
            ((CubaFileUpload) uploadButton).setPasteZone(vComponent);
        }
    }
}
Also used : CubaFileUpload(com.haulmont.cuba.web.toolkit.ui.CubaFileUpload) UploadComponent(com.haulmont.cuba.web.toolkit.ui.UploadComponent) Component(com.vaadin.ui.Component)

Example 84 with Component

use of com.vaadin.ui.Component in project cuba by cuba-platform.

the class WebAbstractTable method addGeneratedColumn.

@Override
public void addGeneratedColumn(String columnId, ColumnGenerator<? super E> generator) {
    checkNotNullArgument(columnId, "columnId is null");
    checkNotNullArgument(generator, "generator is null for column id '%s'", columnId);
    MetaPropertyPath targetCol = getDatasource().getMetaClass().getPropertyPath(columnId);
    Object generatedColumnId = targetCol != null ? targetCol : columnId;
    Column column = getColumn(columnId);
    Column associatedRuntimeColumn = null;
    if (column == null) {
        Column newColumn = new Column(generatedColumnId);
        columns.put(newColumn.getId(), newColumn);
        columnsOrder.add(newColumn);
        associatedRuntimeColumn = newColumn;
        newColumn.setOwner(this);
    }
    // save column order
    Object[] visibleColumns = component.getVisibleColumns();
    boolean removeOldGeneratedColumn = component.getColumnGenerator(generatedColumnId) != null;
    // replace generator for column if exist
    if (removeOldGeneratedColumn) {
        component.removeGeneratedColumn(generatedColumnId);
    }
    component.addGeneratedColumn(generatedColumnId, new CustomColumnGenerator(generator, associatedRuntimeColumn) {

        @SuppressWarnings("unchecked")
        @Override
        public Object generateCell(com.vaadin.ui.Table source, Object itemId, Object columnId) {
            Entity entity = getDatasource().getItem(itemId);
            com.haulmont.cuba.gui.components.Component component = getColumnGenerator().generateCell(entity);
            if (component == null) {
                return null;
            }
            if (component instanceof PlainTextCell) {
                return ((PlainTextCell) component).getText();
            }
            if (component instanceof BelongToFrame) {
                BelongToFrame belongToFrame = (BelongToFrame) component;
                if (belongToFrame.getFrame() == null) {
                    belongToFrame.setFrame(getFrame());
                }
            }
            component.setParent(WebAbstractTable.this);
            com.vaadin.ui.Component vComponent = component.unwrapComposition(Component.class);
            // wrap field for show required asterisk
            if ((vComponent instanceof com.vaadin.ui.Field) && (((com.vaadin.ui.Field) vComponent).isRequired())) {
                VerticalLayout layout = new VerticalLayout();
                layout.addComponent(vComponent);
                if (vComponent.getWidth() < 0) {
                    layout.setWidthUndefined();
                }
                layout.addComponent(vComponent);
                vComponent = layout;
            }
            return vComponent;
        }
    });
    if (removeOldGeneratedColumn) {
        // restore column order
        component.setVisibleColumns(visibleColumns);
    }
}
Also used : Entity(com.haulmont.cuba.core.entity.Entity) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath) com.vaadin.ui(com.vaadin.ui) Component(com.vaadin.ui.Component)

Example 85 with Component

use of com.vaadin.ui.Component in project cuba by cuba-platform.

the class WebComponentsHelper method findChildComponent.

@Nullable
protected static com.haulmont.cuba.gui.components.Component findChildComponent(Container container, Component target) {
    Component vaadinSource = getVaadinSource(container);
    Collection<com.haulmont.cuba.gui.components.Component> components = container.getOwnComponents();
    return findChildComponent(components, vaadinSource, target);
}
Also used : Component(com.vaadin.ui.Component) Nullable(javax.annotation.Nullable)

Aggregations

Component (com.vaadin.ui.Component)146 LayoutBoundTransferable (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.events.LayoutBoundTransferable)23 VerticalDropLocation (com.vaadin.shared.ui.dd.VerticalDropLocation)13 ComponentContainer (com.vaadin.ui.ComponentContainer)12 SingleComponentContainer (com.vaadin.ui.SingleComponentContainer)12 WebAbstractComponent (com.haulmont.cuba.web.gui.components.WebAbstractComponent)11 HorizontalLayout (com.vaadin.ui.HorizontalLayout)11 VerticalLayout (com.vaadin.ui.VerticalLayout)11 Button (com.vaadin.ui.Button)9 Window (com.haulmont.cuba.gui.components.Window)8 Label (com.vaadin.ui.Label)8 Test (org.junit.Test)8 WebWindow (com.haulmont.cuba.web.gui.WebWindow)7 AbstractOrderedLayout (com.vaadin.ui.AbstractOrderedLayout)6 CssLayout (com.vaadin.ui.CssLayout)6 List (java.util.List)6 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)5 CubaUI (com.haulmont.cuba.web.widgets.CubaUI)5 DDAbsoluteLayout (com.haulmont.cuba.web.widgets.addons.dragdroplayouts.DDAbsoluteLayout)5 Item (com.vaadin.data.Item)5