Search in sources :

Example 21 with Frame

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

the class ShowPivotAction method showPivotTable.

@SuppressWarnings("unchecked")
protected void showPivotTable(ShowPivotMode mode) {
    Frame frame = target.getFrame();
    if (frame == null) {
        throw new IllegalStateException(String.format("ShowPivotAction cannot be used by component '%s' which is not added to frame", target.getId()));
    }
    Collection items;
    if (ShowPivotMode.ALL_ROWS.equals(mode)) {
        if (target.getItems() instanceof ContainerDataUnit) {
            CollectionContainer container = ((ContainerDataUnit) target.getItems()).getContainer();
            items = container.getItems();
        } else {
            items = Collections.emptyList();
        }
    } else {
        items = target.getSelected();
    }
    PivotScreenBuilder showPivotManager = applicationContext.getBean(PivotScreenBuilder.class, target);
    showPivotManager.withItems(items).withIncludedProperties(parseProperties(includedProperties)).withExcludedProperties(parseProperties(excludedProperties)).build().show();
}
Also used : Frame(io.jmix.ui.component.Frame) Collection(java.util.Collection) CollectionContainer(io.jmix.ui.model.CollectionContainer) ContainerDataUnit(io.jmix.ui.component.data.meta.ContainerDataUnit)

Example 22 with Frame

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

the class UiDataFilterSupport method isDefaultForMeFieldVisible.

protected boolean isDefaultForMeFieldVisible(Filter.Configuration currentConfiguration, FilterConfiguration configurationModel) {
    Frame filterFrame = currentConfiguration.getOwner().getFrame();
    if (currentConfiguration.getOwner().getId() != null && filterFrame != null) {
        ScreenSettingsFacet settingsFacet = UiControllerUtils.getFacet(filterFrame, ScreenSettingsFacet.class);
        if (settingsFacet != null) {
            ScreenSettings settings = settingsFacet.getSettings();
            if (settings != null) {
                settings.getSettings(currentConfiguration.getOwner().getId(), FilterSettings.class).ifPresent(filterSettings -> {
                    String defaultConfigurationId = filterSettings.getDefaultConfigurationId();
                    if (defaultConfigurationId != null) {
                        boolean defaultForMe = defaultConfigurationId.equals(configurationModel.getConfigurationId());
                        configurationModel.setDefaultForMe(defaultForMe);
                    }
                });
            }
            return true;
        }
    }
    return false;
}
Also used : Frame(io.jmix.ui.component.Frame) ScreenSettingsFacet(io.jmix.ui.settings.facet.ScreenSettingsFacet) ScreenSettings(io.jmix.ui.settings.ScreenSettings) FilterSettings(io.jmix.ui.settings.component.FilterSettings)

Example 23 with Frame

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

the class RelatedAction method execute.

@Override
public void execute() {
    if (target == null) {
        throw new IllegalStateException("RelatedAction target is not set");
    }
    if (!(target.getItems() instanceof EntityDataUnit)) {
        throw new IllegalStateException("RelatedAction target items is null or does not implement EntityDataUnit");
    }
    MetaClass metaClass = ((EntityDataUnit) target.getItems()).getEntityMetaClass();
    if (metaClass == null) {
        throw new IllegalStateException("Target is not bound to entity");
    }
    if (metaProperty == null && property == null) {
        throw new IllegalStateException("Either 'metaProperty' or 'property' must be defined");
    }
    Frame frame = target.getFrame();
    if (frame == null) {
        throw new IllegalStateException("Target is not bound to a frame");
    }
    RelatedEntitiesBuilder builder = relatedEntitiesSupport.builder(frame.getFrameOwner()).withMetaClass(metaClass).withProperty(property).withMetaProperty(metaProperty).withSelectedEntities(target.getSelected()).withConfigurationName(configurationName);
    builder = screenInitializer.initBuilder(builder);
    Screen screen = builder.build();
    screenInitializer.initScreen(screen);
    screen.show();
}
Also used : Frame(io.jmix.ui.component.Frame) RelatedEntitiesBuilder(io.jmix.ui.relatedentities.RelatedEntitiesBuilder) MetaClass(io.jmix.core.metamodel.model.MetaClass) Screen(io.jmix.ui.screen.Screen) EntityDataUnit(io.jmix.ui.component.data.meta.EntityDataUnit)

Example 24 with Frame

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

the class FilterUtils method generateFilterPath.

public static String generateFilterPath(Filter filter) {
    StringBuilder sb = new StringBuilder();
    Frame frame = filter.getFrame();
    while (frame != null) {
        String s = frame.getId() != null ? frame.getId() : "frameWithoutId";
        s = "[" + s + "]";
        sb.insert(0, s);
        if (frame instanceof Window) {
            break;
        }
        frame = frame.getFrame();
    }
    sb.append(".").append(filter.getId() != null ? filter.getId() : "filterWithoutId");
    return sb.toString();
}
Also used : Window(io.jmix.ui.component.Window) Frame(io.jmix.ui.component.Frame)

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