Search in sources :

Example 1 with Label

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

the class DynamicAttributesOperationEditor method createComponent.

@Override
protected Component createComponent() {
    ComponentsFactory componentsFactory = AppBeans.get(ComponentsFactory.class);
    Label label = componentsFactory.createComponent(Label.class);
    label.setValue(condition.getOperationCaption());
    return label;
}
Also used : ComponentsFactory(com.haulmont.cuba.gui.xml.layout.ComponentsFactory) Label(io.jmix.ui.component.Label)

Example 2 with Label

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

the class CanvasUiComponentsFactory method createCanvasWidgetLayout.

@Override
public CanvasWidgetLayout createCanvasWidgetLayout(CanvasFragment canvasFragment, WidgetLayout widgetLayout) {
    Widget widget = widgetLayout.getWidget();
    Optional<WidgetTypeInfo> widgetTypeOpt = widgetRepository.getWidgetTypesInfo().stream().filter(widgetType -> StringUtils.equals(widget.getFragmentId(), widgetType.getFragmentId())).findFirst();
    if (!widgetTypeOpt.isPresent()) {
        CanvasWidgetLayout layout = components.create(CanvasWidgetLayout.class).init(widgetLayout);
        Label<String> label = components.create(Label.class);
        String message = messages.formatMessage(CanvasUiComponentsFactory.class, "widgetNotFound", widget.getCaption(), widget.getName());
        label.setValue(message);
        layout.addComponent(label);
        log.error(message);
        return layout;
    }
    widget.setDashboard(canvasFragment.getDashboardModel());
    String fragmentId = widgetTypeOpt.get().getFragmentId();
    Map<String, Object> params = new HashMap<>(ParamsMap.of(WIDGET, widget, DASHBOARD_MODEL, canvasFragment.getDashboardModel(), DASHBOARD, canvasFragment.getDashboard()));
    params.putAll(widgetRepository.getWidgetParams(widget));
    ScreenFragment screenFragment = AppUI.getCurrent().getFragments().create(canvasFragment, fragmentId, new MapScreenOptions(params)).init();
    Fragment fragment = screenFragment.getFragment();
    fragment.setSizeFull();
    Component widgetComponent = fragment;
    if (BooleanUtils.isTrue(widget.getShowWidgetCaption())) {
        VBoxLayout vBoxLayout = components.create(VBoxLayout.class);
        vBoxLayout.setSpacing(true);
        vBoxLayout.setMargin(true);
        vBoxLayout.setSizeFull();
        Label<String> label = components.create(Label.class);
        label.setValue(widget.getCaption());
        label.setStyleName("h2");
        vBoxLayout.add(label);
        vBoxLayout.add(fragment);
        vBoxLayout.expand(fragment);
        widgetComponent = vBoxLayout;
    } else {
        fragment.setMargin(true);
    }
    CanvasWidgetLayout layout = components.create(CanvasWidgetLayout.class).init(widgetLayout);
    layout.setUuid(UUID.randomUUID());
    layout.addComponent(widgetComponent);
    layout.setWidgetComponent(screenFragment);
    layout.setInnerLayout(widgetComponent);
    layout.setWidget(widget);
    layout.getDelegate().expand(widgetComponent);
    layout.setSizeFull();
    return layout;
}
Also used : ScreenFragment(io.jmix.ui.screen.ScreenFragment) Dashboard(io.jmix.dashboardsui.component.Dashboard) Fragment(io.jmix.ui.component.Fragment) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ParamsMap(io.jmix.core.common.util.ParamsMap) BooleanUtils(org.apache.commons.lang3.BooleanUtils) HashMap(java.util.HashMap) Widget(io.jmix.dashboards.model.Widget) StringUtils(org.apache.commons.lang3.StringUtils) Messages(io.jmix.core.Messages) WidgetRepository(io.jmix.dashboardsui.repository.WidgetRepository) Component(io.jmix.ui.component.Component) CanvasComponentsFactory(io.jmix.dashboardsui.dashboard.tools.factory.CanvasComponentsFactory) UiComponents(io.jmix.ui.UiComponents) VBoxLayout(io.jmix.ui.component.VBoxLayout) Map(java.util.Map) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions) Logger(org.slf4j.Logger) UUID(java.util.UUID) io.jmix.dashboards.model.visualmodel(io.jmix.dashboards.model.visualmodel) CanvasLayout(io.jmix.dashboardsui.component.CanvasLayout) Label(io.jmix.ui.component.Label) AppUI(io.jmix.ui.AppUI) Optional(java.util.Optional) io.jmix.dashboardsui.component.impl(io.jmix.dashboardsui.component.impl) CanvasFragment(io.jmix.dashboardsui.screen.dashboard.editor.canvas.CanvasFragment) WidgetTypeInfo(io.jmix.dashboardsui.repository.WidgetTypeInfo) VBoxLayout(io.jmix.ui.component.VBoxLayout) HashMap(java.util.HashMap) Widget(io.jmix.dashboards.model.Widget) WidgetTypeInfo(io.jmix.dashboardsui.repository.WidgetTypeInfo) ScreenFragment(io.jmix.ui.screen.ScreenFragment) Fragment(io.jmix.ui.component.Fragment) CanvasFragment(io.jmix.dashboardsui.screen.dashboard.editor.canvas.CanvasFragment) ScreenFragment(io.jmix.ui.screen.ScreenFragment) MapScreenOptions(io.jmix.ui.screen.MapScreenOptions) Component(io.jmix.ui.component.Component)

Aggregations

Label (io.jmix.ui.component.Label)2 ComponentsFactory (com.haulmont.cuba.gui.xml.layout.ComponentsFactory)1 Messages (io.jmix.core.Messages)1 ParamsMap (io.jmix.core.common.util.ParamsMap)1 Widget (io.jmix.dashboards.model.Widget)1 io.jmix.dashboards.model.visualmodel (io.jmix.dashboards.model.visualmodel)1 CanvasLayout (io.jmix.dashboardsui.component.CanvasLayout)1 Dashboard (io.jmix.dashboardsui.component.Dashboard)1 io.jmix.dashboardsui.component.impl (io.jmix.dashboardsui.component.impl)1 CanvasComponentsFactory (io.jmix.dashboardsui.dashboard.tools.factory.CanvasComponentsFactory)1 WidgetRepository (io.jmix.dashboardsui.repository.WidgetRepository)1 WidgetTypeInfo (io.jmix.dashboardsui.repository.WidgetTypeInfo)1 CanvasFragment (io.jmix.dashboardsui.screen.dashboard.editor.canvas.CanvasFragment)1 AppUI (io.jmix.ui.AppUI)1 UiComponents (io.jmix.ui.UiComponents)1 Component (io.jmix.ui.component.Component)1 Fragment (io.jmix.ui.component.Fragment)1 VBoxLayout (io.jmix.ui.component.VBoxLayout)1 MapScreenOptions (io.jmix.ui.screen.MapScreenOptions)1 ScreenFragment (io.jmix.ui.screen.ScreenFragment)1