vaadin / designer

Public repository for Vaadin Designer
https://vaadin.com/designer
15 stars 3 forks source link

Add support for read-only preview #1446

Closed mvysny closed 7 years ago

mvysny commented 7 years ago

Feature request: Often when joining existing Java project it is possible to find that Vaadin Designer was not used to create UIs; thus there are no html files but there are Java-based components (objects extending Vaadin Component). In such case the Designer may offer a read-only preview of that particular component.

This will be very helpful in case when Kotlin DSL will be used to create the Vaadin UI. This is exactly what the Anko Android library does: https://blog.jetbrains.com/kotlin/2015/04/announcing-anko-for-android/ It does not attempt to edit the Kotlin code - that is not possible after all, since the DSL commands may be interleaved with for loops, parametrized, or otherwise disturbed. What Anko does is that it provides a read-only view which is both immensely helpful and a fast way to create UIs. Thanks! ;)

ripla commented 7 years ago

Thank you for the feature request. I think we should do all we can to help existing projects start using the Designer. Unfortunately I think this feature would not be the best way to do it.

First, I feel that fixing the root cause would be more beneficial than fixing this particular issue. By making the migration of existing projects as easy as possible we would gain more users and leverage the power of the Designer that we already have built. Whether it is with migration tools, improved documentation or tutorials, there are many low hanging fruits can do without adding a specific feature.

Secondly, rendering a small piece of a big application structure is not as easy as it might sound. We would need to be able to instantiate the component outside the project in our plugin class loader. It would need to work with external libraries, classes and stylesheets. Rendering custom components is something we have been planning for a while, but unfortunately there is no concrete roadmap for it yet.

Feel free to add comments to the issue and continue the discussion, but for now, I'm closing this as won't fix.

mvysny commented 7 years ago

@ripla please allow me kindly disagree here. With Kotlin DSLs, the developers in fact won't use the design html files at all - the devs will create UIs using Kotlin DSLs only. Therefore the migration tool won't be applicable to Kotlin. Intellij figured this out with Android: layout.xml will be replaced by Anko DSLs, and thus the Anko Plug-in just compiles the whole project and then executes the code creating the component. It is slow as hell, and is definitely not easy to implement, but probably it's the only way. Of course, at some point the renderer must give up and render nothing (if it requires some stuff from production and fails with an exception).

ripla commented 7 years ago

If a developer likes writing UI's in Kotlin DSL that's awesome! That kind of DSL gives some unique advantages over Java and the declarative. It also means that they are not the prime target for Designer right now. Given the specificity and perceived cost of the feature, I don't think we can consider it at this point.

mvysny commented 7 years ago

I understand and I completely agree that it is quite hard to render an arbitrary code. However, when the Custom Component functionality is eventually implemented in the Designer, would it be possible to treat Kotlin classes as Custom Components as well, and allow their read-only preview? Of course, that would only apply to Kotlin classes that extend/implement Vaadin Component.

ripla commented 7 years ago

If we decide to implement support for custom components in the future, we'll take another look at non-Java JVM languages. It would be awesome to be able to support Kotlin, Groovy, Scala etc...

mvysny commented 5 years ago

I believe this feature would be very helpful to developers that can't use Designer for some reason, for example because they inherited an existing project with forms done in Java, or for consultants temporarily working with customer's code.