Search in sources :

Example 51 with Window

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

the class WebEntityLinkField method openEntityEditor.

protected void openEntityEditor() {
    Object value = getValue();
    Entity entity;
    if (value instanceof Entity) {
        entity = (Entity) value;
    } else {
        entity = datasource.getItem();
    }
    if (entity == null) {
        return;
    }
    WindowManager wm;
    Window window = ComponentsHelper.getWindow(this);
    if (window == null) {
        throw new IllegalStateException("Please specify Frame for EntityLinkField");
    } else {
        wm = window.getWindowManager();
    }
    if (screenOpenType.getOpenMode() == OpenMode.DIALOG && screenDialogParams != null) {
        wm.getDialogParams().copyFrom(screenDialogParams);
    }
    if (entity instanceof SoftDelete && ((SoftDelete) entity).isDeleted()) {
        Messages messages = AppBeans.get(Messages.NAME);
        wm.showNotification(messages.getMainMessage("OpenAction.objectIsDeleted"), Frame.NotificationType.HUMANIZED);
        return;
    }
    DataSupplier dataSupplier = window.getDsContext().getDataSupplier();
    entity = dataSupplier.reload(entity, View.MINIMAL);
    String windowAlias = screen;
    WindowConfig windowConfig = AppBeans.get(WindowConfig.NAME);
    if (windowAlias == null) {
        windowAlias = windowConfig.getEditorScreenId(entity.getMetaClass());
    }
    final Window.Editor editor = wm.openEditor(windowConfig.getWindowInfo(windowAlias), entity, screenOpenType, screenParams != null ? screenParams : Collections.<String, Object>emptyMap());
    editor.addCloseListener(actionId -> {
        // move focus to component
        component.focus();
        if (Window.COMMIT_ACTION_ID.equals(actionId)) {
            Entity item = editor.getItem();
            afterCommitOpenedEntity(item);
        }
        if (screenCloseListener != null) {
            screenCloseListener.windowClosed(editor, actionId);
        }
    });
}
Also used : Window(com.haulmont.cuba.gui.components.Window) WindowConfig(com.haulmont.cuba.gui.config.WindowConfig) Entity(com.haulmont.cuba.core.entity.Entity) Messages(com.haulmont.cuba.core.global.Messages) SoftDelete(com.haulmont.cuba.core.entity.SoftDelete) DataSupplier(com.haulmont.cuba.gui.data.DataSupplier) WindowManager(com.haulmont.cuba.gui.WindowManager)

Example 52 with Window

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

the class DataGridLoader method loadButtonsPanel.

protected void loadButtonsPanel(DataGrid component) {
    if (buttonsPanelLoader != null) {
        // noinspection unchecked
        buttonsPanelLoader.loadComponent();
        ButtonsPanel panel = (ButtonsPanel) buttonsPanelLoader.getResultComponent();
        Window window = ComponentsHelper.getWindowImplementation(component);
        String alwaysVisible = panelElement.attributeValue("alwaysVisible");
        panel.setVisible(!(window instanceof Window.Lookup) || "true".equals(alwaysVisible));
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) HasButtonsPanel(com.haulmont.cuba.gui.components.Component.HasButtonsPanel) ButtonsPanel(com.haulmont.cuba.gui.components.ButtonsPanel)

Example 53 with Window

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

the class WebAbstractTable method setEditable.

@Override
public void setEditable(boolean editable) {
    if (this.editable != editable) {
        this.editable = editable;
        component.disableContentBufferRefreshing();
        if (datasource != null) {
            com.vaadin.data.Container ds = component.getContainerDataSource();
            @SuppressWarnings("unchecked") final Collection<MetaPropertyPath> propertyIds = (Collection<MetaPropertyPath>) ds.getContainerPropertyIds();
            if (editable) {
                MetaClass metaClass = datasource.getMetaClass();
                final List<MetaPropertyPath> editableColumns = new ArrayList<>(propertyIds.size());
                for (final MetaPropertyPath propertyId : propertyIds) {
                    if (!security.isEntityAttrUpdatePermitted(metaClass, propertyId.toString())) {
                        continue;
                    }
                    final Table.Column column = getColumn(propertyId.toString());
                    if (BooleanUtils.isTrue(column.isEditable())) {
                        com.vaadin.ui.Table.ColumnGenerator generator = component.getColumnGenerator(column.getId());
                        if (generator != null) {
                            if (generator instanceof SystemTableColumnGenerator) {
                                // remove default generator
                                component.removeGeneratedColumn(propertyId);
                            } else {
                                // do not edit generated columns
                                continue;
                            }
                        }
                        editableColumns.add(propertyId);
                    }
                }
                setEditableColumns(editableColumns);
            } else {
                setEditableColumns(Collections.emptyList());
                Window window = ComponentsHelper.getWindowImplementation(this);
                boolean isLookup = window instanceof Window.Lookup;
                // restore generators for some type of attributes
                for (MetaPropertyPath propertyId : propertyIds) {
                    final Table.Column column = columns.get(propertyId);
                    if (column != null) {
                        final String isLink = column.getXmlDescriptor() == null ? null : column.getXmlDescriptor().attributeValue("link");
                        if (component.getColumnGenerator(column.getId()) == null) {
                            if (propertyId.getRange().isClass()) {
                                if (!isLookup && StringUtils.isNotEmpty(isLink)) {
                                    setClickListener(propertyId.toString(), new LinkCellClickListener());
                                }
                            } else if (propertyId.getRange().isDatatype()) {
                                if (!isLookup && !StringUtils.isEmpty(isLink)) {
                                    setClickListener(propertyId.toString(), new LinkCellClickListener());
                                } else {
                                    if (column.getMaxTextLength() != null) {
                                        addGeneratedColumn(propertyId, new AbbreviatedColumnGenerator(column));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        component.setEditable(editable);
        component.enableContentBufferRefreshing(true);
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) Table(com.haulmont.cuba.gui.components.Table) CubaEnhancedTable(com.haulmont.cuba.web.toolkit.ui.CubaEnhancedTable) com.haulmont.cuba.gui.data(com.haulmont.cuba.gui.data) MetaPropertyPath(com.haulmont.chile.core.model.MetaPropertyPath) MetaClass(com.haulmont.chile.core.model.MetaClass)

Example 54 with Window

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

the class WebAccordion method initComponentTabChangeListener.

private void initComponentTabChangeListener() {
    // after all lazy tabs listeners
    if (!componentTabChangeListenerInitialized) {
        component.addSelectedTabChangeListener(event -> {
            if (context != null) {
                context.executeInjectTasks();
                context.executePostWrapTasks();
                context.executeInitTasks();
            }
            // Fire GUI listener
            fireTabChanged();
            // We suppose that context.executePostInitTasks() executes a task once and then remove it from task list.
            if (context != null) {
                context.executePostInitTasks();
            }
            Window window = ComponentsHelper.getWindow(WebAccordion.this);
            if (window != null) {
                ((DsContextImplementation) window.getDsContext()).resumeSuspended();
            } else {
                LoggerFactory.getLogger(WebAccordion.class).warn("Please specify Frame for Accordion");
            }
        });
        componentTabChangeListenerInitialized = true;
    }
}
Also used : Window(com.haulmont.cuba.gui.components.Window) DsContextImplementation(com.haulmont.cuba.gui.data.impl.DsContextImplementation)

Aggregations

Window (com.haulmont.cuba.gui.components.Window)54 DesktopWindow (com.haulmont.cuba.desktop.gui.components.DesktopWindow)15 WebWindow (com.haulmont.cuba.web.gui.WebWindow)13 com.haulmont.cuba.gui.components (com.haulmont.cuba.gui.components)10 WebAppWorkArea (com.haulmont.cuba.web.gui.components.mainwindow.WebAppWorkArea)6 WindowBreadCrumbs (com.haulmont.cuba.web.sys.WindowBreadCrumbs)6 ParamsMap (com.haulmont.bali.util.ParamsMap)5 Component (com.haulmont.cuba.gui.components.Component)5 WebAbstractComponent (com.haulmont.cuba.web.gui.components.WebAbstractComponent)5 Component (com.vaadin.ui.Component)5 Entity (com.haulmont.cuba.core.entity.Entity)4 TopLevelFrame (com.haulmont.cuba.desktop.TopLevelFrame)4 WindowConfig (com.haulmont.cuba.gui.config.WindowConfig)4 CssLayout (com.vaadin.ui.CssLayout)4 Pair (com.haulmont.bali.datastruct.Pair)3 WindowManager (com.haulmont.cuba.gui.WindowManager)3 Action (com.haulmont.cuba.gui.components.Action)3 ButtonsPanel (com.haulmont.cuba.gui.components.ButtonsPanel)3 Frame (com.haulmont.cuba.gui.components.Frame)3 WindowInfo (com.haulmont.cuba.gui.config.WindowInfo)3