Chapter 3 – Creating JFace Viewers

Understanding JFace

1. getImage() is called to determine what image to show for an entry, while getText() is used to determine the text value of an entry.

2. The hasChildren() method is used to determine whether or not an element is shown with an expandable element, and getChildren() is used to calculate a list of children.

3. An ImageRegistry is used to share images between plug-ins or different views in plug-ins, with a means of clearing up the resources when the view is disposed.

4. Entries can be styled with an IStyledLabelProvider.

Understanding sorting and filters

1. Specifying a ViewerComparator can allow elements to be sorted in a different order other than the default one.

2. The select() method is used to filter elements, which is originally derived from the Smalltalk terminology.

3. Multiple filters can be combined by setting an array of filters, or by writing a filter to combine two or more filters together.

Understanding interaction

1. Add a DoubleClickListener to the view.

2. Dialog subclasses are used to create a Dialog with custom content.

Understanding tables

1. To show the headers, get the Table from the viewer, and use it to call the setHeaderVisible(true).

2. TableViewerColumn instances are used to set properties on individual columns and to bind the label provider for the columns.

3. An ArrayContentProvider can be used to store items as an array.

4. The TableViewerColumn is a class in the JFace package which defines where the data comes from; the TableColumn is the underlying SWT widget that the width of the column.

Understanding selection

1. Viewers have the getSelection and setSelection methods to get and set the selection, using the ISelection interface (or more commonly the IStructuredSelection interface).

2. The ISelectionChangedListener interface is used to receive notifications for selection changes from a viewer.

3. E4 uses the ESelectionService to maintain the selected object in the workspace, which can be injected into a part.

4. Although the currently selected object can be injected as a field into a part, it is more common to use an optional method with a @Named argument of IServiceConstants.ACTIVE_SELECTION.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.74.239