Search in sources :

Example 1 with ColorPicker

use of io.jmix.ui.component.ColorPicker in project jmix-sneferu by mariodavid.

the class PetTypeBrowse method colorPicker.

private Component colorPicker(String color) {
    ColorPicker component = uiComponents.create(ColorPicker.class);
    component.setValue(color);
    component.setEditable(false);
    return component;
}
Also used : ColorPicker(io.jmix.ui.component.ColorPicker)

Example 2 with ColorPicker

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

the class ColorComponentGenerationStrategy method createComponent.

@Nullable
@Override
public Component createComponent(ComponentGenerationContext context) {
    String property = context.getProperty();
    MetaPropertyPath mpp = context.getMetaClass().getPropertyPath(property);
    if (mpp != null) {
        Range mppRange = mpp.getRange();
        if (mppRange.isDatatype() && (Datatype) mppRange.asDatatype() instanceof ColorDatatype) {
            ColorPicker colorPicker = uiComponents.create(ColorPicker.class);
            colorPicker.setDefaultCaptionEnabled(true);
            ValueSource valueSource = context.getValueSource();
            if (valueSource != null) {
                colorPicker.setValueSource(valueSource);
            }
            return colorPicker;
        }
    }
    return null;
}
Also used : ColorPicker(io.jmix.ui.component.ColorPicker) ValueSource(io.jmix.ui.component.data.ValueSource) MetaPropertyPath(io.jmix.core.metamodel.model.MetaPropertyPath) Range(io.jmix.core.metamodel.model.Range) Datatype(io.jmix.core.metamodel.datatype.Datatype) Nullable(javax.annotation.Nullable)

Example 3 with ColorPicker

use of io.jmix.ui.component.ColorPicker in project jmix-docs by Haulmont.

the class ColorComponentGenerationStrategy method createComponent.

@Nullable
@Override
public Component createComponent(ComponentGenerationContext context) {
    String property = context.getProperty();
    MetaPropertyPath mpp = context.getMetaClass().getPropertyPath(property);
    if (mpp != null) {
        Range mppRange = mpp.getRange();
        if (mppRange.isDatatype() && (Datatype) mppRange.asDatatype() instanceof ColorDatatype) {
            ColorPicker colorPicker = uiComponents.create(ColorPicker.class);
            colorPicker.setDefaultCaptionEnabled(true);
            ValueSource valueSource = context.getValueSource();
            if (valueSource != null) {
                colorPicker.setValueSource(valueSource);
            }
            return colorPicker;
        }
    }
    return null;
}
Also used : ColorPicker(io.jmix.ui.component.ColorPicker) ValueSource(io.jmix.ui.component.data.ValueSource) MetaPropertyPath(io.jmix.core.metamodel.model.MetaPropertyPath) Range(io.jmix.core.metamodel.model.Range) ColorDatatype(ui.ex1.entity.ColorDatatype) Datatype(io.jmix.core.metamodel.datatype.Datatype) ColorDatatype(ui.ex1.entity.ColorDatatype) Nullable(javax.annotation.Nullable)

Aggregations

ColorPicker (io.jmix.ui.component.ColorPicker)3 Datatype (io.jmix.core.metamodel.datatype.Datatype)2 MetaPropertyPath (io.jmix.core.metamodel.model.MetaPropertyPath)2 Range (io.jmix.core.metamodel.model.Range)2 ValueSource (io.jmix.ui.component.data.ValueSource)2 Nullable (javax.annotation.Nullable)2 ColorDatatype (ui.ex1.entity.ColorDatatype)1