Learn about JFace data binding in Eclipse, part 2nd: The Basics of binding

Source: Internet
Author: User

Before you start

About this series

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 1th part of the "Understanding JFace data Binding in Eclipse" series illustrates the purpose of the data binding framework, introduces several popular Java GUI data binding frameworks, and gives advantages and disadvantages of using data binding. As part 2nd of the series, this tutorial introduces the basic API components. Part 3rd will move to the introduction of advanced topics such as tables, transformations, and validation.

About this tutorial

This tutorial explains why you use the data binding API, and then shows you how to use the core components of the JFace data binding API, and introduces how the description of how the underlying work is done in part 3rd.

Prerequisite

This tutorial is intended for developers who have a certain Java™ programming language and Eclipse experience, and must have a basic understanding of SWT and JFace.

System Requirements

To run the sample, you must have an Eclipse software development Kit (SDK) and a computer that can run the software Development Kit.

Synchronizing data between domain objects and controls

Sync requirements

Desktop applications tend to have long term objects, most of which contain user-visible data. For example, changes in the name field of a person's object typically need to be reflected in the form where the user edits the object. This means that you want to update the text field widget that is used to display the data. If the change was initiated in a text field widget, you need to update the person object. If a person object has changed for business reasons, the widget that displays the changes also needs to be changed.

Many widgets, such as tables and lists, have models that can simplify this process. Changing this model will automatically notify the widget. Most application data is not in the form of an SWT-specific model. For example, when using tables, the data used to populate the table is often the java.util.List form of the values that are queried from the server or database. Further to consider the more complex situation, the fact that some widgets (such as text fields) do not have a model at all, they only contain simple properties that are intrinsic to the widget that displays the data.

Sample Sync

The two main Java widget toolkit Swing and SWT widgets do not recognize data. This means that it will be up to you to decide how to manage the synchronization process. Let's take a look at the following example to help you understand what it means. Follow these steps to perform the action:

Open Eclipse V3.2 and create a new workspace.

Select File > Import from the menu. The Eclipse Project Import Wizard opens (see Figure 1).

Figure 1. Eclipse Project Import Wizard

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.