Trace:
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
jvx:reference [2020/06/10 13:05] cduncan [Following the chain] |
jvx:reference [2020/06/10 13:20] cduncan [DataRow] |
||
---|---|---|---|
Line 438: | Line 438: | ||
So we need two classes, the ''%%ILauncher%%'' implementation that knows how to start the technology and the ''%%IApplication%%'' implementation. That we already knew, so let’s try to put this into code. For simplicity reasons (and because I don’t want to write a complete factory from scratch for this example), we will reuse the Swing implementation and write a new launcher and application for it. | So we need two classes, the ''%%ILauncher%%'' implementation that knows how to start the technology and the ''%%IApplication%%'' implementation. That we already knew, so let’s try to put this into code. For simplicity reasons (and because I don’t want to write a complete factory from scratch for this example), we will reuse the Swing implementation and write a new launcher and application for it. | ||
- | ===== Entry point ===== | + | ===== Entry Point ===== |
- | The ''%%Main%%'' class that we will use as example is very straightforward: | + | The ''%%main%%'' class that we will use as example is very straightforward: |
<code java> | <code java> | ||
Line 457: | Line 457: | ||
} | } | ||
</code> | </code> | ||
- | All we have to do there is start the launcher itself. As the comment suggests, there might be work required for a “real” application startup. For this example, it is all we need to do. Of course we could also directly embed this little function into the launcher implementation itself, to save us one class. | + | All we have to do there is start the launcher itself. As the comment suggests, there might be work required for a “real” application startup. For this example, it is all we need to do. Of course, we could also directly embed this little function into the launcher implementation itself to save us one class. |
- | ===== The launcher ===== | + | ===== The Launcher ===== |
- | The ''%%ILauncher%%'' implementation on the other hand contains quite some logic, but nothing not manageable: | + | The ''%%ILauncher%%'' implementation, on the other hand, contains quite some logic but nothing not manageable: |
<code java> | <code java> | ||
Line 540: | Line 540: | ||
} | } | ||
</code> | </code> | ||
- | In short, the launcher is kicking off the Swing thread by invoking the startup method on the main Swing thread. This startup method will instantiate the factory and then create the application. From there we only need to set it visible and then our application has started. | + | In short, the launcher is kicking off the Swing thread by invoking the startup method on the main Swing thread. This startup method will instantiate the factory and then create the application. From there, we only need to set it to visible and then our application has started. |
- | The launcher extends from ''%%SwingFrame%%'', that is required because there hasn’t been a factory created yet which could be used by UI components to create themselves. If we’d try to use an UI component before creating/setting a factory, we would obviously see the constructor of the component fail with a ''%%NullPointerException%%''. | + | The launcher extends from ''%%SwingFrame%%''. That is required because there hasn’t been a factory created yet that could be used by UI components to create themselves. If we’d try to use an UI component before creating/setting a factory, we would see the constructor of the component fail with a ''%%NullPointerException%%''. |
- | The method ''%%startup()%%'' is invoked on the main Swing thread, which also happens to be the main UI thread for [[https://sourceforge.net/projects/jvx/|JVx]] in this application. Once we are on the main UI thread we can create the application, add it and then set everything to visible. | + | The method ''%%startup()%%'' is invoked on the main Swing thread, which also happens to be the main UI thread for [[https://sourceforge.net/projects/jvx/|JVx]] in this application. Once we are on the main UI thread, we can create the application, add it, and then set everything to visible. |
- | ===== The application ===== | + | ===== The Application ===== |
- | The ''%%IApplication%%'' implementation is quite short, because we extend ''%%com.sibvisions.rad.application.Application%%'', an ''%%IApplication%%'' implementation created with UI components. | + | The ''%%IApplication%%'' implementation is quite short because we extend ''%%com.sibvisions.rad.application.Application%%'', an ''%%IApplication%%'' implementation created with UI components. |
<code java> | <code java> | ||
Line 572: | Line 572: | ||
} | } | ||
</code> | </code> | ||
- | Because the launcher has previously started the technology and created the factory we can from here on now use UI components, which means we are already independent of the underlying technology. So the ''%%IApplication%%'' implementation can already be used with different technologies and is completely independent. | + | Because the launcher has previously started the technology and created the factory, we can now use UI components, which means we are already independent of the underlying technology. So, the ''%%IApplication%%'' implementation can already be used with different technologies and is completely independent. |
- | ===== Notes on the launcher ===== | + | ===== Notes on the Launcher ===== |
- | As you might have noticed, in our example the launcher is a (window) frame, that makes sense for nearly every desktop GUI toolkit as they all depend upon a window as main method to display their applications. But the launcher could also be simpler, for example just a call to start the GUI thread. Or it could be something completely different, for example an incoming HTTP request. | + | As you might have noticed, in our example the launcher is a (window) frame. That makes sense for nearly every desktop GUI toolkit as they all depend upon a window as main method to display their applications. But the launcher could also be simpler: for example, just a call to start the GUI thread. Or it could be something completely different: for example, an incoming HTTP request. |
- | Also don’t forget that the launcher is providing additional functionality to the application, like saving file handles, reading and writing the configuration and similar platform and toolkit dependent operations, see the [[https://sourceforge.net/p/jvx/code/HEAD/tree/trunk/java/swing/src/com/sibvisions/rad/ui/swing/impl/SwingApplication.java|launcher for Swing for further details]]. | + | Also, don’t forget that the launcher is providing additional functionality to the application, like saving file handles, reading and writing the configuration, and similar platform and toolkit-dependent operations. See the [[https://sourceforge.net/p/jvx/code/HEAD/tree/trunk/java/swing/src/com/sibvisions/rad/ui/swing/impl/SwingApplication.java|launcher for Swing for further details]]. |
===== Conclusion ===== | ===== Conclusion ===== | ||
Line 590: | Line 590: | ||
===== What is it? ===== | ===== What is it? ===== | ||
- | DataBooks are an active model, which allow you to directly query and manipulate the data. Contrary to many other systems [[https://sourceforge.net/projects/jvx/|JVx]] does not map the data into objects, but instead allows you to directly access it in a table like fashion, exposing columns, rows and values. | + | DataBooks are an active model, which allow you to directly query and manipulate the data. Contrary to many other systems, [[https://sourceforge.net/projects/jvx/|JVx]] does not map the data into objects, but allows you to directly access it in a table-like fashion exposing columns, rows, and values. |
- | One could say that it is like a three dimensional array, with these dimensions: | + | One could say that it is like a three dimensional array with these dimensions: |
* DataPages | * DataPages | ||
Line 598: | Line 598: | ||
* Columns/Values | * Columns/Values | ||
- | With DataPages containing DataRows, which itself contain the values and everything is referencing the RowDefinition, which outlines how a row looks like. | + | with DataPages containing DataRows, which in turn contain the values and everything referencing the RowDefinition, which further outlines how a row looks like. |
{{:jvx:reference:databook.png?nolink|DataBook Architecture, the DataBook contains DataPages, which contain DataRows.}} | {{:jvx:reference:databook.png?nolink|DataBook Architecture, the DataBook contains DataPages, which contain DataRows.}} | ||
Line 616: | Line 616: | ||
dataBook.setRowDefinition(rowDefinition); | dataBook.setRowDefinition(rowDefinition); | ||
</code> | </code> | ||
- | ==== ColumnDefinition ==== | + | ==== Column Definition ==== |
- | The ColumnDefinition defines and provides all necessary information about the column, like its DataType, its size and if it is nullable or not. You can think of it as one column in a table. | + | The column definition defines and provides all necessary information about the column, like its datatype, its size, and whether it is nullable or not. You can think of it as one column in a table. |
<code java> | <code java> | ||
Line 624: | Line 624: | ||
columnDefinition.setNullable(false); | columnDefinition.setNullable(false); | ||
</code> | </code> | ||
- | ==== MetaData ==== | + | ==== Metadata ==== |
- | Most of the ColumnDefinition is additional information about the column, like if it is nullable, the label of the column, default values, allowed values and similar information. | + | Most of the column definition is additional information about the column, like if it is nullable, the label of the column, default values, allowed values, and similar information. |
- | ==== DataType ==== | + | ==== Datatype ==== |
- | Of course we must define what type the value in the column has, this is done by setting a DataType on the ColumnDefinition. The DataType defines what kind of values the column holds, like if it is a String, or a Number or something else. We do provide the most often used DataTypes out of the box: | + | Of course, we must define what type the value in the column has. This is done by setting a datatype on the column definition. The datatype defines what kind of values the column holds, like if it is a String, a Number, or something else. We provide the most often used datatypes out of the box: |
* BigDecimal | * BigDecimal | ||
Line 640: | Line 640: | ||
* Timestamp | * Timestamp | ||
- | It is possible to add new DataTypes by simply implementing ''%%IDataType%%''. | + | It is possible to add new datatypes by simply implementing ''%%IDataType%%''. |
- | ===== DataRow ===== | + | ===== Data Row ===== |
- | The DataRow repesents a single row of data, it holds/references its own RowDefinition and of course provides access to the values of the row. Accessing the DataRow can be done either by column index or column name, and the methods do either return or accept Objects. Let’s look at a simple usage example: | + | The data row represents a single row of data; it holds/references its own row definition and, of course, provides access to the values of the row. Accessing the data row can be done either by column index or column name, and the methods either return or accept objects. Let’s look at a simple usage example: |
<code java> | <code java> |