Learn about JFace data binding in Eclipse, part 3rd: using advanced Features

Source: Internet
Author: User
Tags error code

Before you start

About this series

This section of the "Understanding JFace data Binding in Eclipse" tutorial series describes the advanced features of the new JFace data-binding application Programming Interface (API) that are included with the Eclipse V3.2.

Use the data binding API to free you from the pain of having to write sample synchronization code. The JFace data binding API provides this functionality for the user interface (UI), which is written with Standard Widget Toolkit (SWT) and JFace. The first part of a series of tutorials describes the basic components in the API. This section describes advanced topics such as testing, tables, converters, and validation.

About this tutorial

This tutorial explains how to use advanced features of JFace data binding, such as conversion programs, validation, and tables. It also describes how to construct the UI in a more testable way. You'll learn how to use the JFace data-binding API to write well structured and testable java™ui applications.

Prerequisite

This tutorial is intended for developers who have a certain Java programming language and experience with Eclipse. You must have some basic knowledge of SWT and JFace and read the 1th part.

System Requirements

To run the examples in this tutorial, you must have an Eclipse V3.2 software Development Kit (SDK) and a computer that can run the software Development Kit. The examples in this tutorial will use the Java V5 automatic boxing. Therefore, it is preferred to use the Java V1.5 Java Runtime Environment (JRE).

Writing testable Code

What can synchronization do for a UI test? It is a powerful tool used by Java UI developers to write Testable UIs.

Most desktop application developers do not test their UI. Although server-side code is often rigorously tested, most desktop business logic has never been tested by JUnit. Some tools are available to perform test tasks, such as Mercury Interactive Corp. 's product Abbot, and Redstone Software Inc. 's eggplant. However, many organizations do not use these tools.

Why not test the UI? There are usually three reasons:

Code is disorganized-server-side applications have good tiering, such as persistence and business logic, but desktop applications often need to take into account a variety of complex factors.

The functionality of the UI change--ui often changes its purpose because of changes in user requirements. Even the best UI test tools can be difficult to keep up with the change in this kind of static UI.

The common UI test solution on the market does not conform to the level of UI logic to be tested.

Do you want to test the entire WEB application at the HTTP level? It can be difficult to test all application logic with it as the only public access point. Similarly, using the UI to test business logic is also very the client/server.

The corrupted code is an error code

As a software developer, it has long been accepted that it is good to use separation of concerns. Tight coupling leads to code that is not reusable, difficult to test, and difficult to maintain. Interestingly, when developing the UI, all of these lessons are often caution. The following example is the best proof of this sentence.

Download the item from the Downloads section. Select File > Import from the menu to import it into your workspace. In the dialog box, select Existing Projects into Workspace. Select the archive option in the next screen and browse to select the compressed file that you just downloaded. When you click Finish to import the compressed file, you should now have a Databinding-tutorial2 project in the workspace.

Right-click on the Mangledconcernsexample and choose Run as > SWT application from the pop-up menu. You will see a window similar to the one shown in Figure 1. It provides a simple enabling rule to try to enable the Name, spouse, and Years married fields at the same time. If you fill in a value in the Name field and the Spouse field, the Years married field becomes enabled. Deleting the value in either field of Name or spouse causes the system to empty the Years married field and make it disabled. The code that enables this feature is shown in Listing 1.

Figure 1. UI Example

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.