Welcome!
Part 1 - Part 2 - Part 3 - Part 4 - Part 5
To introduce you to working with Eclipse, we have created a small demo application called DVDStorage, which will allow you to keep record of your DVD collection using prevalent technology.
DVDStorage will contain basic functions for adding, changing and deleting DVDs. Some pointers on how to create more challenging applications will be given at the end of this tutorial.
The final application created in this tutorial will look like this:
Let's get into the groove!
First, fire up your brand-new Eclipse 3.0 Final. I assume you already installed Preclipse using the update site.
We will create DVDStorage not using a Swing, but an SWT/JFace Layout, because we believe SWT leads to cooler-looking apps. As we won't go into detail about SWT here, the GUI classes will be provided as a ZIP file. Please note that the GUI files are designed to fit into the rest of the code presented here. If you use the same names for the packages and classes we create during the tutorial, integration of the GUI will be straighforward.
Let's start by first creating a new prevalent project:
Then, choose to create a new Prevayler-based project:
We create a new project and call it "PrevailingDVDStorage":
I like to keep my class files separate from the source files, which also makes the package and folder structure look much nicer in Eclipse, therefore, I create a separate source folder:
Now, finally, we'll get to the interesting point: Clicking "Next>" brings us to the configuration of our new Prevayler-based project:
Of course, we want to take advantage of the code generation capabilites of Preclipse, therefore, we choose to let Preclipse create a skeleton implementation for us. Our new prevalent system is going to store DVDs; therefore, we call our prevalent system class "DVDStorage". It resides in the "bo" folder, "bo" standing for "business object". We will later add a separate package for transactions as we consider it good style to keep them apart.
We also want to create a main class for starting the application; Preclipse will configure Prevayler here.
Preclipse can also create a separate thread for taking snapshots of the system in regular intervals. In DVDStorage, we will provide the user with a button for creating snapshots, therefore, we don't need this thread.
For the rest of the fields we will just use the default values. "data" is the directory where the snapshot and transaction files will go to; the "lib" folder will contain the Prevayler.jar we need.
We hit "Finish" and watch Preclipse create the following structure:
Note that the Prevayler.jar is automatically copied into the project and added as a library.
We are now ready to add our first Business Object.