vaadin / flow

Vaadin Flow is a Java framework binding Vaadin web components to Java. This is part of Vaadin 10+.
Apache License 2.0
617 stars 167 forks source link

Add a general abstraction for most of the UI components #16603

Closed mgarciavaadin closed 1 year ago

mgarciavaadin commented 1 year ago

It would be great to have a basic abstraction class or interface gathering most of the features of a component as it was available in Vaadin 8 with the Component Interface.

This new abstraction would have an impact on the modernization of Vaadin 8 to Flow 24 applications where the Component Interface was frequently used. Also for new developments it would provide a common access point to the most frequently used methods related to components and a way to iterate over a same class/interface instance been able to change the style, the label, the size... etc without extra castings.

First approach would be to create an interface with the methods from:

Then this abstraction would be applied to all classes that implement HasLabel, which covers the smallest subset of Flow components implementing these 5 interfaces listed above.

The list so far is:

The intention is that this new feature won't have impact on existing apps as components affected should keep implementing the same interfaces just having a higher level common interface available.

For new implementations the developer would be able to call methods from the collected interfaces without additional castings. i.e.:

        // listComponents is a list with different types of components such as ComboBox, Checkbox, CheckboxGroup, etc...
        for (CommonComponentInterface cm : listComponents){
                  //HasLabel
                  cm.setLabel("");
                  //HasSize
                  cm.setHeight("");
                  //HasEnabled
                  cm.setEnabled(false);
                  //HasStyle
                  cm.addClassName("");
                  //HasTooltip
                  cm.setTooltipText("");
        }
Legioth commented 1 year ago

Please describe what impact this change would have on application code.

mgarciavaadin commented 1 year ago

Closed as it has been moved to flow-components