Eclipse RCP Application Development Making the IRSA client by pptfiles

VIEWS: 27 PAGES: 6

									Eclipse RCP Application Development: Making the IRSA client
Chris Kelley 8/21/2007 The data entry client used for the Indoor Residual Spraying application client is an Eclipse RCP (Rich client Platform) application. This paper documents the features of the application and how it was implemented. Eclipse RCP Application Development: Making the IRSA client ..................................... 1 Code version ................................................................................................................... 1 Security ........................................................................................................................... 1 Views .............................................................................................................................. 2 View screenshots ............................................................................................................ 2 Db View (Output database) ........................................................................................ 2 Location View ................................................................................................................. 3 ProcessFiles View ....................................................................................................... 3 StaffView .................................................................................................................... 3 Preferences ...................................................................................................................... 4 Data Entry ....................................................................................................................... 4 Persistence....................................................................................................................... 5 Menus .............................................................................................................................. 6 Application Window ....................................................................................................... 6 Logging ........................................................................................................................... 6

Code version
This app was developed using Eclipse 3.2. The current version of Eclipse, 3.3, may have some improvements in how data entry tables are rendered, among other improvements. The developer has not yet reviewed the improvements or done any refactoring to the application.

Security
A very simple login screen is displayed before the application starts.

This login is triggered in Application.java. Currently the login is very simple – if the username is admin, the app has a few extra Administration-related menus. There is already a pretty good pattern in-place if the user wants to implement passwords.

Views
Eclipse RCP uses the concept of views to render parts of the display. IRSA has the following classes that extend ViewPart:  HeaderView – renders the main data entry user interface(UI)  DbView – renders the db output panel  LocationView – renders the Location admin panel  ProcessFilesView – renders the Database sync page that processes database files sent from the field  ReportView – renders the reporting interface to BIRT  StaffView – renders the Staff admin panel

View screenshots
Db View (Output database)

Location View

ProcessFiles View

StaffView

Preferences
Some of the administration is done using the Eclipse RCP Preferences feature by extending FieldEditorPreferencePage. Discussion – When to use Preferences, and when to use normal views? My take: These admin panes are for administrative settings that change rarely. Classes:  MySQLPreferencePage – renders MySQL db settings for import of data to the master database.  SitePreferencePage – renders the Site prefs page

Data Entry
Much of the data entry is made using a user interface similar to what Access offers, which is familiar to many users. Unfortunately, it is pretty complex to build. It does however offer a lot of control over validation. The table interface fetches 15 records at a time; therefore, it does not put a heavy load on the application if there are many records in the database. Screenshot of table-based data entry:

Persistence
Object relational persistence handled by EJB3/Hibernate Hibernate.cfg.xml is in /src. Taking advantage of hibernate annotations to easily map classes to tables in the POJO. Sample code:
public static List getRecords() { List headers = null; EntityManagerFactory emf = null; try { emf = Persistence.createEntityManagerFactory("spraying"); EntityManager em = emf.createEntityManager(); EntityTransaction tx = em.getTransaction(); tx.begin(); headers = em.createQuery("from SprayingHeaders ORDER BY sprayingDate DESC").setMaxResults(15).getResultList(); tx.commit(); em.close(); } catch (RuntimeException e) { log.error("Error:", new Throwable()); e.printStackTrace(); } return headers; }

Connection string: <property name="hibernate.connection.url">jdbc:derby://localhost:1527/C:\\irsa\dbirsa</property>

Libs:     

Hibernate3.jar Hibernate-annotations.jar Ejb3-persistence.jar Jboss-ejb3.jar Jta.jar

Start Derby Network database in Application.java. The Derby Network db is very nice because we have the potential to use multiple clients to query the derby db. Use Derby plugin to manipulate derby schema in Eclipse.

Menus
Menus are enabled in ApplicationActionBarAdvisor. You enable the Preferences section by adding Window menu item to fillMenuBar method in ApplicationActionBarAdvisor.

Application Window
Configure main app window size in ApplicationWorkbenchWindowAdvisor. configurer.setInitialSize(new Point(1050, 780)); configurer.setShowCoolBar(false); configurer.setShowStatusLine(true); configurer.setShowProgressIndicator(true);

Logging
Enable logging of hibernate sql in persistence.xml For tons of debugging, change ERROR to DEBUG in log4j.propoerties.


								
To top