Java SWT Design Patterns

What are some good design patterns for creating a form in java?

I have an application in which there are 6 tabs with a different form. How does a typical Java programmer make these elements available?

For example, as a wpf programmer, I can bind all of these controls to basic objects.

What do java programmers like to do?

+4
source share
2 answers

I don't know what programmers like to do, but you have to listen to what MVC patterns say.

And he tells you that each view should have its own controller. Your view clearly has approaches. Thus, the design in this case will obviously be as follows:

MainView Label1 Text1 Tab1Subview Label1 Text1 Tab2Subview Label1 Text1 MainViewController Tab1SubviewController Tab2SubviewController 

And the controllers define the binding for each particular view. You can also use one controller for all subzones and link it inside. Your main controller may have a link to the main object of the root model, for example. Forms. And a specific controller can bind subobjects. As I said, you can go with one big controller and tie it all in one place.

This is for creating MVC.

Instruments

If you are looking for a SWT graphic designer, then Window Builder Pro (Eclipse Plugin) is definitely the choice (not perfect, although the best of all available).

Things like EMF are pretty complicated. You can start with a combination of Window Builder Pro and coding, and, as mentioned above, the JFace Binding API will become an option, but this is not necessary, it depends on the model, which you can either use JFace Binding or do it yourself in the code.

To save a simple form, all you have to do is write something like a save method, for example:

 person.setName(view.getFullNameTextField().getText()); 

this is not much worse than using the advanced binding functions, especially if you will not depend on additional libraries such as JFace.

+1
source

If you use Eclipse, you can try EMF, a terrific infrastructure to help you design your model, generate Java code and provide a pretty cool model editor in minutes.

EMF provides data binding between the widgets of the user interface and the model, you can read the generated code to see how it works.

0
source

Source: https://habr.com/ru/post/1309057/


All Articles