Jump to: navigation, search

Difference between revisions of "JFace Data Binding/Snippets"

(Running the Snippets)
(ComputedValue)
 
(9 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{JFace Data Binding}}
 
{{JFace Data Binding}}
Snippets show how common use cases can be implemented using the JFace Data Binding framework. They are typically a single self-contained Java class with a main method. See the bottom of this page for instructions on how to get and run the snippets.
+
Snippets show how common use cases can be implemented using the JFace Data Binding framework. They are typically a single self-contained Java class with a main method. See the bottom of this page for additional instructions on how to get and run the snippets.
 +
 
 +
==Running the Snippets==
 +
* [http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.rse.doc.isv%2Fguide%2Ftutorial%2FpdeProject.html Create an Eclipse plug-in project] and in the Manifest editor go to the '''Dependencies tab'''
 +
* Add dependencies to the following bundles: org.eclipse.core.databinding, org.eclipse.core.databinding.beans, and org.eclipse.jface.databinding
 +
* Click on any snippet in this list
 +
* Copy (CTRL+C) the source to your clipboard
 +
* Go to the src folder of your project and paste (CTRL+V). This will automatically create the correct package and source file.
 +
* Right click on the new source file and select "Run as / Java Application"
  
 
=== Basic ===
 
=== Basic ===
* [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet000HelloWorld.java?view=markup Hello World] - the most basic of bindings
+
* [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet000HelloWorld.java Hello World] - the most basic of bindings
  
 
=== WizardPage ===
 
=== WizardPage ===
* [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet014WizardDialog.java?view=markup Wizard Dialog] - Shows how to use data binding in a wizard dialog so that validation results are displayed in the dialog's title area
+
* [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet014WizardDialog.java Wizard Dialog] - Shows how to use data binding in a wizard dialog so that validation results are displayed in the dialog's title area
  
 
=== ComputedValue ===
 
=== ComputedValue ===
* [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet006Spreadsheet.java?view=markup Spreadsheet] - fills a Table updating cells upon change
+
* [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet006Spreadsheet.java Spreadsheet] - fills a Table updating cells upon change
* [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet008ComputedValue.java?view=markup Name Formatter] - observable value that updates when the first or last name changes
+
* [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet008ComputedValue.java Name Formatter] - observable value that updates when the first or last name changes
  
 
=== Bindings ===
 
=== Bindings ===
* [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet004DataBindingContextErrorLabel.java?view=markup Bind validation status to a Label]
+
* [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet004DataBindingContextErrorLabel.java Bind validation status to a Label]
* [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet011ValidateMultipleBindingsSnippet.java?view=markup Validate observables across Bindings]
+
* [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet011ValidateMultipleBindingsSnippet.java?view=markup Validate observables across Bindings]
  
 
=== Master Detail ===
 
=== Master Detail ===
* [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet010MasterDetail.java?view=markup Master detail] - display the detail of the selection of a ListViewer in a Text widget
+
* [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet010MasterDetail.java Master detail] - display the detail of the selection of a ListViewer in a Text widget
* [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet001NestedSelectionWithCombo.java?view=markup Nested Selection With ComboViewer]
+
* [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet001NestedSelectionWithCombo.java Nested Selection With ComboViewer]
  
 
=== SWT ===
 
=== SWT ===
* [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet005MenuUpdater.java?view=markup MenuUpdater]
+
* [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet005MenuUpdater.java MenuUpdater]
* [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet012CompositeUpdater.java?view=markup CompositeUpdater]
+
* [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet012CompositeUpdater.java CompositeUpdater]
  
 
=== Viewers ===
 
=== Viewers ===
* [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet009TableViewer.java?view=markup Model to TableViewer binding] - basic binding to a TableViewer
+
* [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet009TableViewer.java Model to TableViewer binding] - basic binding to a TableViewer
* [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet007ColorLabelProvider.java?view=markup TableViewer binding with colors] - label provider that provides Colors and auto updates the viewer
+
* [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet007ColorLabelProvider.java TableViewer binding with colors] - label provider that provides Colors and auto updates the viewer
* [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet013TableViewerEditing.java?view=markup TableViewer inline editing] - TableViewer editing with the Eclipse 3.3 JFace viewer APIs. ''(requires Eclipse 3.3)''
+
* [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet013TableViewerEditing.java TableViewer inline editing] - TableViewer editing with the Eclipse 3.3 JFace viewer APIs. ''(requires Eclipse 3.3)''
 
[[Category:Data Binding]][[Category:Snippets]]
 
[[Category:Data Binding]][[Category:Snippets]]
* [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet022ComputedListCombo.java?view=markup ComputedList and Combo] - Filter the elements in one viewer based on the selection in another
+
* [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet022ComputedListCombo.java ComputedList and Combo] - Filter the elements in one viewer based on the selection in another
* [http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet034ComboViewerAndEnum.java?view=markup ComboViewer and Java enum] - Demonstrates binding the list of a ComboViewer to the values of an enum and the selected value to a simple model property.
+
* [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/plain/examples/org.eclipse.jface.examples.databinding/src/org/eclipse/jface/examples/databinding/snippets/Snippet034ComboViewerAndEnum.java ComboViewer and Java enum] - Demonstrates binding the list of a ComboViewer to the values of an enum and the selected value to a simple model property.
  
=== Running the Snippets  ===
+
=== Additional Run Options ===
  
 
A great way to learn is to look at concrete examples that you can run and experiment with.
 
A great way to learn is to look at concrete examples that you can run and experiment with.
 
 
  
 
You can clone the [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/ eclipse.platform.ui git repository] which contains the "org.eclipse.jface.examples.databinding" project with the JFace Databinding examples. For cloning a git repository you can use the [http://eclipse.org/egit/ EGit] tooling of Eclipse.  
 
You can clone the [http://git.eclipse.org/c/platform/eclipse.platform.ui.git/ eclipse.platform.ui git repository] which contains the "org.eclipse.jface.examples.databinding" project with the JFace Databinding examples. For cloning a git repository you can use the [http://eclipse.org/egit/ EGit] tooling of Eclipse.  
 
 
  
 
Use the following URL to clone the repository via File -> Import -> Git repository  
 
Use the following URL to clone the repository via File -> Import -> Git repository  
 
 
  
 
*http://anonymous@git.eclipse.org/gitroot/platform/eclipse.platform.ui.git
 
*http://anonymous@git.eclipse.org/gitroot/platform/eclipse.platform.ui.git
  
 
+
After you cloned the project the clone wizard will allow you to import the included projects. For the databinding examples you only have to import the "org.eclipse.jface.examples.databinding" project. For an introduction into EGit please see [http://www.vogella.de/articles/EGit/article.html EGit ]  
 
+
After you cloned the project the clone wizard will allow you to import the included projects. For the databinding examples you only have to import the "org.eclipse.jface.examples.databinding" project. <p> For an introduction into EGit please see [http://www.vogella.de/articles/EGit/article.html EGit ]  
+
 
+
 
+
  
 
Most of the examples provide a main method, you can run it as a Java Application to see what happens.<br>  
 
Most of the examples provide a main method, you can run it as a Java Application to see what happens.<br>  
  
 
You can also copy any of the snippets (see below) into a scratch project within Eclipse. If you are copying single snippets into a scratch project, make sure that it is set up with the correct dependencies. You will need org.eclipse.core.databinding, org.eclipse.core.databinding.beans, and org.eclipse.jface.databinding.
 
You can also copy any of the snippets (see below) into a scratch project within Eclipse. If you are copying single snippets into a scratch project, make sure that it is set up with the correct dependencies. You will need org.eclipse.core.databinding, org.eclipse.core.databinding.beans, and org.eclipse.jface.databinding.

Latest revision as of 06:10, 22 December 2012

JFace Data Binding
Home
How to Contribute
FAQ
Snippets
Concepts
Binding
Converter
Observable
Realm

Snippets show how common use cases can be implemented using the JFace Data Binding framework. They are typically a single self-contained Java class with a main method. See the bottom of this page for additional instructions on how to get and run the snippets.

Running the Snippets

  • Create an Eclipse plug-in project and in the Manifest editor go to the Dependencies tab
  • Add dependencies to the following bundles: org.eclipse.core.databinding, org.eclipse.core.databinding.beans, and org.eclipse.jface.databinding
  • Click on any snippet in this list
  • Copy (CTRL+C) the source to your clipboard
  • Go to the src folder of your project and paste (CTRL+V). This will automatically create the correct package and source file.
  • Right click on the new source file and select "Run as / Java Application"

Basic

WizardPage

  • Wizard Dialog - Shows how to use data binding in a wizard dialog so that validation results are displayed in the dialog's title area

ComputedValue

  • Spreadsheet - fills a Table updating cells upon change
  • Name Formatter - observable value that updates when the first or last name changes

Bindings

Master Detail

SWT

Viewers

Additional Run Options

A great way to learn is to look at concrete examples that you can run and experiment with.

You can clone the eclipse.platform.ui git repository which contains the "org.eclipse.jface.examples.databinding" project with the JFace Databinding examples. For cloning a git repository you can use the EGit tooling of Eclipse.

Use the following URL to clone the repository via File -> Import -> Git repository

After you cloned the project the clone wizard will allow you to import the included projects. For the databinding examples you only have to import the "org.eclipse.jface.examples.databinding" project. For an introduction into EGit please see EGit

Most of the examples provide a main method, you can run it as a Java Application to see what happens.

You can also copy any of the snippets (see below) into a scratch project within Eclipse. If you are copying single snippets into a scratch project, make sure that it is set up with the correct dependencies. You will need org.eclipse.core.databinding, org.eclipse.core.databinding.beans, and org.eclipse.jface.databinding.