Documentation

Trace:

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
jvx:reference [2020/06/10 11:23]
cduncan [UI]
jvx:reference [2020/06/10 12:30]
cduncan [The Basics]
Line 68: Line 68:
 ===== Why is the UI layer necessary? ===== ===== Why is the UI layer necessary? =====
  
-It isn’t, not at all. The Implementations ​could be used directly without any problems, but having yet another layer has two key benefits:+It isn’t, not at all. The implementations ​could be used directly without any problems, but having yet another layer has two key benefits:
  
   * It allows easier usage.   * It allows easier usage.
-  * It allows to add Technology ​independent features.+  * It allows to add technology-independent features.
  
-By wrapping it one more time we gain a lot of freedom which we would not have otherwisewhen it comes to features ​as when it comes to coding. The user does not need to call the factory directly and instead just needs to create a new object:+By wrapping it one more timewe gain a lot of freedom which we would not have otherwise when it comes to features ​and coding. The user does not need to call the factory directly andinsteadjust needs to create a new object:
  
 <code java> <code java>
 IButton button = new UIButton(); IButton button = new UIButton();
 </​code>​ </​code>​
-Internally, of course, the Factory ​is called and an implementation instance is created, but that is an implementation detail. If we would use the implementation layer directly, our code would either ​need to know about the implementations,​ which doesn’t follow the single-sourcing principle:+Internally, of course, the factory ​is called and an implementation instance is created, but that is an implementation detail. If we would use the implementation layer directly, our code would need to know about the implementations,​ which doesn’t follow the single-sourcing principle:
  
 <code java> <code java>
Line 88: Line 88:
 IButton button = UIFactoryManager.getFactory().createButton();​ IButton button = UIFactoryManager.getFactory().createButton();​
 </​code>​ </​code>​
-Both can be avoided by using another layer which does the factory calls for us:+Both can be avoided by using another layer that the factory calls for us:
  
 <code java> <code java>
Line 106: Line 106:
 } }
 </​code>​ </​code>​
-Additionally this layer allows us to implement features ​which can be technology independent, our naming scheme, which we created during stress testing of an Vaadin application,​ is a very good example of that. The names of the components are derived in the UI layer without any knowledge of the underlying ​Technology ​or Implementation.+Additionallythis layer allows us to implement features ​that can be technology-independent. Our naming scheme, which we created during stress testing of Vaadin application,​ is a very good example of that. The names of the components are derived in the UI layer without any knowledge of the underlying ​technology ​or implementation.
  
-Also it does provide ​us (and everyone else of course) with a layer which allows to rapidly and easily build [[#​compound_components|compound components]] out of already existing ones, like this:+Alsoit provides ​us (and everyone elseof course) with a layer which allows to rapidly and easily build [[#​compound_components|compound components]] out of already existing ones, like this:
  
 <code java> <code java>
Line 134: Line 134:
 } }
 </​code>​ </​code>​
-Of course that is not even close to sophisticated,​ or a good example for that matter. ​But it shows that one can build new components out of already existing ones without having to deal with the Technology ​or Implementation ​at all, creating truly cross-technology controls.+Of coursethat is not even close to sophisticated,​ or even a good example for that matter. ​However, ​it shows that one can build new components out of already existing ones without having to deal with the technology ​or implementation ​at all, creating truly cross-technology controls.
  
 ===== The Factory ===== ===== The Factory =====
  
-The heart piece of the UI layer is the Factory, which is creating the implemented classes. It’s a rather simple system, a singleton which is set to the Technology specific implementation and can be retrieved later:+The heart piece of the UI layer is the factory that is creating the implemented classes. It’s a rather simple system, a singleton which is set to the Technology specific implementation and can be retrieved later:
  
 <code java> <code java>
Line 166: Line 166:
 It “just returns new objects” from the implementation layer. That’s about it when it comes to the factory, it is as simple as that. It “just returns new objects” from the implementation layer. That’s about it when it comes to the factory, it is as simple as that.
  
-===== Piecing ​it together ​=====+===== Piecing ​It Together ​=====
  
-With all this in mind, we know now that [[https://​sourceforge.net/​projects/​jvx/​|JVx]] has swappable ​implementations underneath its UI layer for each technology it utilizes:+With all this in mind, we know now that [[https://​sourceforge.net/​projects/​jvx/​|JVx]] has swapable ​implementations underneath its UI layer for each technology it utilizes:
  
 {{:​jvx:​reference:​multi-layers.png?​nolink|Multiple Extensions/​Implementations/​Technologies can be used}} {{:​jvx:​reference:​multi-layers.png?​nolink|Multiple Extensions/​Implementations/​Technologies can be used}}
  
-Changing between them can be as easy as setting a different factory. I say “can”because that is only true for Swing, JavaFX and similar technologiesVaadin, obviously, requires some more setup work. I meantheoretically ​one could embed a complete application server and launch it when the factory for Vaadin is created, allowing the application to be basically stand-alone and be started as easily as a Swing application. That is possible.+Changing between them can be as easy as setting a different factory. I say “can” because that is only true for Swing, JavaFXand similar technologiesVaadin, obviously, requires some more setup work. Theoretically, one could embed a complete application server and launch it when the factory for Vaadin is created, allowing the application to be basically stand-alone and be started as easily as a Swing application. That is possible.
  
 ===== What else? ===== ===== What else? =====
  
-That is how [[https://​sourceforge.net/​projects/​jvx/​|JVx]] works in regards to the UI layer. It depends on “technology specific stacks” which can be swapped out and implemented for pretty much every GUI framework out there. We currently provide support for Swing, JavaFX and Vaadin, but we also had implementations for GWT and Qt. Additionally we do support a “headless” implementation which uses lightweight objects which can be serialized and send over the wire without much effort.+That is how [[https://​sourceforge.net/​projects/​jvx/​|JVx]] works in regards to the UI layer. It depends on “technology specific stacks” which can be swapped out and implemented for pretty much every GUI framework out there. We currently provide support for Swing, JavaFXand Vaadin, but we also had implementations for GWT and Qt. Additionallywe do support a “headless” implementation which uses lightweight objects which can be serialized and send over the wire without much effort.
  
-===== Adding a new Technology =====+===== Adding a New Technology =====
  
-Adding support for a new Technology ​is as straightforward as one can imaginesimply creating the Extensions/Implementations ​layers and implementing the factory for that Technology. Giving a complete manual would be out for scope for this document, but the most simple approach to adding a new stack to [[https://​sourceforge.net/​projects/​jvx/​|JVx]] is to start with stubbing out the ''​%%IFactory%%''​ and implementing ''​%%IWindow%%''​. Once that one window shows up, it’s just implementing one interface after another in a quite straightforward manner. ​And in the end, your application can switch to yet another GUI framework without the need to change your code.+Adding support for a new technology ​is as straightforward as one can imaginesimply creating the extensions/implementations ​layers and implementing the factory for that technology. Giving a complete manual would be out for scope for this document, but the most simple approach to adding a new stack to [[https://​sourceforge.net/​projects/​jvx/​|JVx]] is to start with stubbing out the ''​%%IFactory%%''​ and implementing ''​%%IWindow%%''​. Once that one window shows up, it’s just implementing one interface after another in a quite straightforward manner. ​In the end, your application can switch to yet another GUI framework without the need to change your code.
  
 ===== Conclusion ===== ===== Conclusion =====
  
-Even though the stack of [[https://​sourceforge.net/​projects/​jvx/​|JVx]] is more complicated compared with other GUI or application frameworks, this complexity is set off by the benefits it brings. One can change the used GUI Technology ​without much effort and, most important of all, without touching the application logic at all.+Even though the stack of [[https://​sourceforge.net/​projects/​jvx/​|JVx]] is more complicated compared with other GUI or application frameworks, this complexity is set off by the benefits it brings. One can change the used GUI technology ​without much effort and, most importantly, without touching the application logic at all.
  
 ====== Resource and UIResource ====== ====== Resource and UIResource ======
Line 192: Line 192:
 ===== The Basics ===== ===== The Basics =====
  
-We’ve [[#​encapsulated_by_a_wrapper_class|encapsulated by a wrapper class]]. ​An “UIResource” on the other hand is an encapsulated concrete implementation of one of the interfaces on the UI layer.+We’ve [[#​encapsulated_by_a_wrapper_class|encapsulated by a wrapper class]]. ​“UIResource”on the other handis an encapsulated concrete implementation of one of the interfaces on the UI layer.
  
-Let’s do a short brush-up ​on how the [[https://​sourceforge.net/​projects/​jvx/​|JVx]] architecture looks like in regards to the GUI stack:+Let’s do a short overview ​on how the [[https://​sourceforge.net/​projects/​jvx/​|JVx]] architecture looks like in regards to the GUI stack:
  
-{{:​jvx:​reference:​resource.png?​nolink|The JVx layers revisited. UI-Wrapper ​and Implementation ​implement the interface, ​Extension ​and Technology ​do not.}}+{{:​jvx:​reference:​resource.png?​nolink|The JVx layers revisited. UI wrapper ​and implementation ​implement the interface, ​extension ​and technology ​do not.}}
  
-The UI Wrappers ​are the main UI classes ​which are used to create the GUI (f.e. ''​%%UIButton%%''​). These are wrapping the Implementations ​(f.e. ''​%%SwingButton%%''​) which themselves are wrapping the Extension/Technology ​(f.e. a ''​%%JVxButton%%''/''​%%JButton%%''​). Only the UI and Implementation ​classes are implementing the interface are required for the component (f.e. ''​%%IButton%%''​). That also means that the Implementation ​is dependent on the Extension/Technology ​component, but the UI can use any object which implements the interface.+The UI wrappers ​are the main UI classes ​that are used to create the GUI (f.e. ''​%%UIButton%%''​). These are wrapping the implementations ​(f.e. ''​%%SwingButton%%''​)which themselves are wrapping the extension/technology ​(f.e. a ''​%%JVxButton%%''/''​%%JButton%%''​). Only the UI and implementation ​classes are implementing the interface are required for the component (f.e. ''​%%IButton%%''​). That also means that the implementation ​is dependent on the extension/technology ​component, but the UI can use any object which implements the interface.
  
-Now, with that knowledge we can start defining what is what:+Now, with that knowledgewe can start defining what is what:
  
-{{:​jvx:​reference:​resource2.png?​nolink|The UI-Wrapper ​is the uicomponent, the Implementation ​is the uiresource ​and the Extension ​and Technology ​are the resource.}}+{{:​jvx:​reference:​resource2.png?​nolink|The UI wrapper ​is the  UI component, the implementation ​is the UI resource, ​and the extension ​and technology ​are the resource.}}
  
-The resource itself, accessed by calling ''​%%<​uiwrapper>​.getResource()%%'',​ is the Extension/Technology ​component. The uiresource ​can be accessed by calling ''​%%<​uiwrapper>​.getUIResource()%%''​. The uicomponent ​can be accessed by calling ''​%%<​uiwrapper>​.getUIComponent()%%''​ and is usually the UI Wrapper ​class itself. If we use our previous Swing example, the resource would be a ''​%%JVxButton%%''/''​%%JButton%%'',​ the uiresource ​would be the ''​%%SwingButton%%''​ and the uicomponent ​would be the ''​%%UIButton%%''​.+The resource itself, accessed by calling ''​%%<​uiwrapper>​.getResource()%%'',​ is the extension/technology ​component. The  UI resource ​can be accessed by calling ''​%%<​uiwrapper>​.getUIResource()%%''​. The UI component ​can be accessed by calling ''​%%<​uiwrapper>​.getUIComponent()%%''​ and is usually the UI wrapper ​class itself. If we use our previous Swing example, the resource would be a ''​%%JVxButton%%''/''​%%JButton%%'',​ the  UI resource ​would be the ''​%%SwingButton%%''​ and the UI component ​would be the ''​%%UIButton%%''​.
  
-As one can see, access to all objects which are comprising the GUI is at all times possible. We, of course, have the UI component, we can access the Implementation ​component and we can access the Extension/Technology ​component. Theoretically we could also swap them at runtime, but in [[https://​sourceforge.net/​projects/​jvx/​|JVx]] this is limited to the construction of the object to greatly reduce the error potential and complexity of the framework code.+As one can see, access to all objects which comprise ​GUI possible ​at all times.. We, of course, have the UI component, we can access the implementation ​componentand we can access the extension/technology ​component. Theoreticallywe could also swap them at runtime, but in [[https://​sourceforge.net/​projects/​jvx/​|JVx]]this is limited to the construction of the object to greatly reduce the error potential and complexity of the framework code.
  
 ===== Creating custom components ===== ===== Creating custom components =====
This website uses cookies for visitor traffic analysis. By using the website, you agree with storing the cookies on your computer.More information