Search in sources :

Example 6 with Frame

use of io.jmix.ui.component.Frame in project jmix by jmix-framework.

the class EditorScreenFacetImpl method create.

@Override
public S create() {
    Frame owner = getOwner();
    if (owner == null) {
        throw new IllegalStateException("Screen facet is not attached to Frame");
    }
    EditorBuilder<E> editorBuilder = createEditorBuilder(owner, getEntityToEdit());
    screen = createScreen(editorBuilder);
    initScreenListeners(screen);
    injectScreenProperties(screen, properties);
    applyScreenConfigurer(screen);
    return screen;
}
Also used : Frame(io.jmix.ui.component.Frame)

Example 7 with Frame

use of io.jmix.ui.component.Frame in project jmix by jmix-framework.

the class LookupScreenFacetImpl method create.

@Override
public S create() {
    Frame owner = getOwner();
    if (owner == null) {
        throw new IllegalStateException("Screen facet is not attached to Frame");
    }
    LookupBuilder<E> lookupBuilder = createLookupBuilder(owner);
    screen = createScreen(lookupBuilder);
    initScreenListeners(screen);
    injectScreenProperties(screen, properties);
    applyScreenConfigurer(screen);
    return screen;
}
Also used : Frame(io.jmix.ui.component.Frame)

Example 8 with Frame

use of io.jmix.ui.component.Frame in project jmix by jmix-framework.

the class CubaFilterLoader method loadComponent.

@Override
public void loadComponent() {
    assignXmlDescriptor(resultComponent, element);
    assignFrame(resultComponent);
    loadAlign(resultComponent, element);
    loadVisible(resultComponent, element);
    loadEnable(resultComponent, element);
    loadStyleName(resultComponent, element);
    loadCss(resultComponent, element);
    loadMargin(resultComponent, element);
    loadIcon(resultComponent, element);
    loadHtmlSanitizerEnabled(resultComponent, element);
    loadCaption(resultComponent, element);
    loadDescription(resultComponent, element);
    loadContextHelp(resultComponent, element);
    loadWidth(resultComponent, element, "100%");
    loadCollapsible(resultComponent, element, true);
    loadSettingsEnabled(resultComponent, element);
    loadBorderVisible(resultComponent, element);
    loadWindowCaptionUpdateEnabled(resultComponent, element);
    String useMaxResults = element.attributeValue("useMaxResults");
    resultComponent.setUseMaxResults(useMaxResults == null || Boolean.parseBoolean(useMaxResults));
    String textMaxResults = element.attributeValue("textMaxResults");
    resultComponent.setTextMaxResults(Boolean.parseBoolean(textMaxResults));
    final String manualApplyRequired = element.attributeValue("manualApplyRequired");
    resultComponent.setManualApplyRequired(BooleanUtils.toBooleanObject(manualApplyRequired));
    String editable = element.attributeValue("editable");
    resultComponent.setEditable(editable == null || Boolean.parseBoolean(editable));
    String columnsCount = element.attributeValue("columnsCount");
    if (!Strings.isNullOrEmpty(columnsCount)) {
        resultComponent.setColumnsCount(Integer.parseInt(columnsCount));
    }
    String folderActionsEnabled = element.attributeValue("folderActionsEnabled");
    if (folderActionsEnabled != null) {
        resultComponent.setFolderActionsEnabled(Boolean.parseBoolean(folderActionsEnabled));
    }
    String dataLoaderId = element.attributeValue("dataLoader");
    if (StringUtils.isNotBlank(dataLoaderId)) {
        FrameOwner frameOwner = getComponentContext().getFrame().getFrameOwner();
        ScreenData screenData = UiControllerUtils.getScreenData(frameOwner);
        DataLoader dataLoader = screenData.getLoader(dataLoaderId);
        if (!(dataLoader instanceof CollectionLoader) && !(dataLoader instanceof KeyValueCollectionLoader)) {
            throw new IllegalStateException(String.format("Filter cannot work with %s because it is not a CollectionLoader or a KeyValueCollectionLoader", dataLoaderId));
        }
        resultComponent.setDataLoader((BaseCollectionLoader) dataLoader);
    } else {
        String datasource = element.attributeValue("datasource");
        if (StringUtils.isNotBlank(datasource)) {
            if (getComponentContext().getDsContext() == null) {
                throw new IllegalStateException("'datasource' attribute can be used only in screens with 'dsContext' element. " + "In a screen with 'data' element use 'dataContainer' attribute.");
            }
            CollectionDatasource ds = (CollectionDatasource) getComponentContext().getDsContext().get(datasource);
            if (ds == null) {
                throw new GuiDevelopmentException("Can't find datasource by name: " + datasource, context);
            }
            resultComponent.setDatasource(ds);
        }
    }
    Frame frame = getComponentContext().getFrame();
    String applyTo = element.attributeValue("applyTo");
    if (!StringUtils.isEmpty(applyTo)) {
        getComponentContext().addPostInitTask((c, w) -> {
            Component applyToComponent = frame.getComponent(applyTo);
            if (c == null) {
                throw new GuiDevelopmentException("Can't apply component to component with ID: " + applyTo, context);
            }
            resultComponent.setApplyTo(applyToComponent);
        });
    }
    String modeSwitchVisible = element.attributeValue("modeSwitchVisible");
    if (StringUtils.isNotEmpty(modeSwitchVisible)) {
        resultComponent.setModeSwitchVisible(Boolean.parseBoolean(modeSwitchVisible));
    }
    String immediatelySearch = element.attributeValue("applyImmediately");
    if (!Strings.isNullOrEmpty(immediatelySearch)) {
        resultComponent.setApplyImmediately(Boolean.parseBoolean(immediatelySearch));
    }
    getComponentContext().addPostInitTask((context1, window) -> {
        String controlsLayoutTemplate = element.attributeValue("controlsLayoutTemplate");
        if (!Strings.isNullOrEmpty(controlsLayoutTemplate)) {
            resultComponent.setControlsLayoutTemplate(controlsLayoutTemplate);
            resultComponent.createLayout();
        }
        ((FilterImplementation) resultComponent).loadFiltersAndApplyDefault();
        String defaultMode = element.attributeValue("defaultMode");
        if (FTS_MODE_VALUE.equals(defaultMode)) {
            resultComponent.switchFilterMode(FilterDelegate.FilterMode.FTS_MODE);
        }
    });
}
Also used : Frame(io.jmix.ui.component.Frame) FrameOwner(io.jmix.ui.screen.FrameOwner) CollectionDatasource(com.haulmont.cuba.gui.data.CollectionDatasource) GuiDevelopmentException(io.jmix.ui.GuiDevelopmentException) Component(io.jmix.ui.component.Component) FilterImplementation(io.jmix.ui.component.FilterImplementation)

Example 9 with Frame

use of io.jmix.ui.component.Frame in project jmix by jmix-framework.

the class DynAttrFacetImpl method subscribe.

private void subscribe() {
    Frame frame = getOwner();
    if (frame == null) {
        throw new IllegalStateException("DynAttrFacet is not attached to Frame");
    }
    Screen screen = UiControllerUtils.getScreen(frame.getFrameOwner());
    if (screen instanceof StandardEditor) {
        EventHub screenEvents = UiControllerUtils.getEventHub(screen);
        screenEvents.subscribe(StandardEditor.InitEntityEvent.class, this::initEntityInStandardEditor);
    } else if (screen instanceof MasterDetailScreen) {
        EventHub screenEvents = UiControllerUtils.getEventHub(screen);
        screenEvents.subscribe(MasterDetailScreen.InitEntityEvent.class, this::initEntityInMasterDetailScreen);
    }
}
Also used : Frame(io.jmix.ui.component.Frame) MasterDetailScreen(io.jmix.ui.screen.MasterDetailScreen) Screen(io.jmix.ui.screen.Screen) EventHub(io.jmix.core.common.event.EventHub) StandardEditor(io.jmix.ui.screen.StandardEditor) MasterDetailScreen(io.jmix.ui.screen.MasterDetailScreen)

Example 10 with Frame

use of io.jmix.ui.component.Frame in project jmix by jmix-framework.

the class ViewAction method isReadOnlyCompositionEditor.

/**
 * In case of composition relation, editor for nested entities should be in read-only mode with hidden
 * "enableEditing" action if master editor is in read-only mode too.
 *
 * @param editor editor to check
 * @return {@code true} if the relation between entities is a composition
 */
protected boolean isReadOnlyCompositionEditor(Screen editor) {
    Frame frame = target.getFrame();
    if (frame == null) {
        throw new IllegalStateException("Component is not attached to the Frame");
    }
    FrameOwner origin = target.getFrame().getFrameOwner();
    if (!(origin instanceof ReadOnlyAwareScreen) || !((ReadOnlyAwareScreen) origin).isReadOnly() || !(editor instanceof StandardEditor)) {
        return false;
    }
    DataUnit items = target.getItems();
    if (!(items instanceof ContainerDataUnit)) {
        return false;
    }
    CollectionContainer container = ((ContainerDataUnit) target.getItems()).getContainer();
    if (!(container instanceof CollectionPropertyContainer)) {
        return false;
    }
    InstanceContainer masterContainer = ((CollectionPropertyContainer) container).getMaster();
    String property = ((CollectionPropertyContainer) container).getProperty();
    MetaClass metaClass = masterContainer.getEntityMetaClass();
    MetaProperty metaProperty = metaClass.getProperty(property);
    return metaProperty.getType() == MetaProperty.Type.COMPOSITION;
}
Also used : Frame(io.jmix.ui.component.Frame) CollectionContainer(io.jmix.ui.model.CollectionContainer) InstanceContainer(io.jmix.ui.model.InstanceContainer) ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit) DataUnit(io.jmix.ui.component.data.DataUnit) EntityDataUnit(io.jmix.ui.component.data.meta.EntityDataUnit) MetaClass(io.jmix.core.metamodel.model.MetaClass) ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit) MetaProperty(io.jmix.core.metamodel.model.MetaProperty) CollectionPropertyContainer(io.jmix.ui.model.CollectionPropertyContainer)

Aggregations

Frame (io.jmix.ui.component.Frame)24 LegacyFrame (com.haulmont.cuba.gui.screen.compatibility.LegacyFrame)6 Component (io.jmix.ui.component.Component)5 FrameOwner (io.jmix.ui.screen.FrameOwner)4 Screen (io.jmix.ui.screen.Screen)4 MetaClass (io.jmix.core.metamodel.model.MetaClass)3 GuiDevelopmentException (io.jmix.ui.GuiDevelopmentException)3 Window (io.jmix.ui.component.Window)3 CollectionDatasource (com.haulmont.cuba.gui.data.CollectionDatasource)2 MetaProperty (io.jmix.core.metamodel.model.MetaProperty)2 ContainerDataUnit (io.jmix.ui.component.data.meta.ContainerDataUnit)2 EntityDataUnit (io.jmix.ui.component.data.meta.EntityDataUnit)2 CollectionContainer (io.jmix.ui.model.CollectionContainer)2 ScreenSettingsFacet (io.jmix.ui.settings.facet.ScreenSettingsFacet)2 Nullable (javax.annotation.Nullable)2 Strings (com.google.common.base.Strings)1 Iterables (com.google.common.collect.Iterables)1 Security (com.haulmont.cuba.core.global.Security)1 UiComponents (com.haulmont.cuba.gui.UiComponents)1 AbstractWindow (com.haulmont.cuba.gui.components.AbstractWindow)1