SlideShare una empresa de Scribd logo
1 de 25
JFace




The graphical sub-system of the Eclipse platform is made up of two
components: SWT, the Standard Widget Toolkit ;and JFace, an
architecture-independent modeling layer. This module describes how
JFace extends SWT with viewers, commands, wizards, dialogs, and field
assist.




Redistribution and other use of this material requires written permission from The RCP Company.

L0001 - 2010-11-27
Eclipse User Interface Layers


4 Layers:                             Eclipse RCP




                                                                       Preferences




                                                                                                   Commands

                                                                                                              Registry
                                                     Workbench
   The Eclipse Workbench




                                                                                     Jobs

                                                                                            ICU
                                                     JFace
     
         Overall look-n-feel
                                                    SWT
   JFace                                              OSGi/Run-time
     
         Architecture-independent models
   SWT
     
         Platform independent API yet rather close to the metal
   Native widgets
     
         Platform dependent: Windows, Linux, Mac, Unix

The “Eclipse User Interface Guidelines” governs the look-n-feel of the
workbench and JFace
   Consequently (nearly) all Eclipse RCP based applications look the same!

Use the SWT Bible “The Definitive Guide to SWT and JFace” by Robert Harris
and Rob Warner



                                                                                                  L0001 - 2010-11-27
JFace


A set of classes for handling many common UI programming tasks
   Viewers handle the drudgery of populating, sorting, filtering, and
    updating widgets
   Actions and contributions introduce semantics for defining user
    actions and specifying where to make them available
   Image and font registries provide common patterns for handling UI
    resources
   Dialogs and wizards define a framework for building complex
    interactions with the user
   Field assist provides classes that help guide the user in choosing
    appropriate content for fields in dialogs, wizards, or forms

Does not hide SWT; rather, it extends SWT




                                                                         L0001 - 2010-11-27
The JFace Viewers


Provides a glue layer between the application model and SWT

Viewers exists for most structured widgets – e.g.
   Combo boxes
   Lists
   Trees
   Tables

Uses common interfaces to control:
   The content of the viewer: IContentProvider and child interfaces
   The text and image of the cells: ILabelProvider and child interfaces
   Decoration of images: ILabelDecorator
   Filtering: ViewerFilter
   Sorting: ViewerComparator




                                                                           L0001 - 2010-11-27
Using JFace Viewers


Common design pattern
   Create viewer in parent Composite
     
         Assign layout to the Control of the viewer
   Add columns
     
         new TableViewerColumn(viewer, ...)
     
         Set text and width of columns
   Set content provider – normally ArrayContentProvider
     
         The interface depends on the type of the viewer
   Install commands and action
   Set input
     
         Must be last

Call viewer.refresh(…) when changes are made to the data




                                                           L0001 - 2010-11-27
Using JFace Viewers


Also possible to specify background, foreground, font, tooltip…

public void createPartControl(Composite parent) {
    TableViewer viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL |
SWT.V_SCROLL);
    viewer.setContentProvider(new ArrayContentProvider());
    Table table = viewer.getTable();
    TableViewerColumn c;

    table.setHeaderVisible(true);
    c = new TableViewerColumn(viewer, SWT.LEFT);
    c.setLabelProvider(new NameLabelProvider());
    c.getColumn().setText("Name");
    c.getColumn().setWidth(100);

    c = new TableViewerColumn(viewer, SWT.LEFT);
    c.setLabelProvider(new RestLabelProvider());
    c.getColumn().setText("Rest");
    c.getColumn().setWidth(300);

    viewer.setInput(getSite().getShell().getDisplay().getFontList(null, true));
}




              private class NameLabelProvider extends ColumnLabelProvider {
                  @Override
                  public String getText(Object element) {
                      return ((FontData) element).getName();
                  }
              }


                                                                                  L0001 - 2010-11-27
IContentProvider


Provides the glue between the content of the application model and the
appropriate viewer
   IStructuredContentProvider – used for combo boxes, lists and tables
   ITreeContentProvider – used for trees
   ILazyContentProvider – used for SWT.VIRTUAL tables
   ILazyTreeContentProvider – used for SWT.VIRTUAL trees

For arrays and List use ArrayContentProvider




   public interface IStructuredContentProvider {
       public void dispose();
       public void inputChanged(Viewer viewer, Object oldInput, Object newInput);
       public Object[] getElements(Object inputElement);
   }




                                                                                    L0001 - 2010-11-27
ILabelProvider


ILabelProvider provides the basic label and image for a row object in a
viewer
   Given the row object, the text, image. colors, font, ... for the cell is
    returned

Several interesting implementations
   ColumnLabelProvider - base class for label providers for
    TableViewerColumn
   OwnerDrawLabelProvider - base class for label providers that wish to
    paint their cells


   CellLabelProvider - don’t use this; use ColumnLabelProvider instead




                                                                               L0001 - 2010-11-27
ILabelDecorator




ILabelDecorator provides a standard means to
decorate an existing label and image
   Used extensively in Eclipse IDE: team and
    class information

Label decorators can be registered as
extensions
   Activated automatically based on the class
    of the current row object of the viewer




                                                 L0001 - 2010-11-27
Label Providers for Table and Tree (3.3 and later edition)


For Table and Tree, a label provider can be registered per column
   Use superclass ColumnLabelProvider and not CellLabelProvider

This allows reuse of label providers across projects




                                                                    L0001 - 2010-11-27
Sample Decorator


This decorator will add a bullet to the top-right corner of the image for an
IRes object, if the IActionFilter of the object returns true for the children
property

The extension point currently uses the “old” style expression form


             <extension
                 point="org.eclipse.ui.decorators">
                 <decorator
                     adaptable="true"
                     icon="icons/sample_decorator.gif"
                     id="com.rcpcompany.demo.providers.ui.decorators.decorator"
                     label="Resource Decorator"
                     lightweight="true"
                     location="TOP_RIGHT"
                     state="true">
                     <enablement>
                          <and>
                              <objectClass
                                  name="com.rcpcompany.demo.providers.model.IRes"/>
                              <objectState
                                  name="children"
                                  value="true"/>
                          </and>
                     </enablement>
                 </decorator>
             </extension>




                                                                                      L0001 - 2010-11-27
Filters and Sorters


Viewers support filtering
   viewer.addFilter(ViewerFilter) – adds a filter to a viewer
      
          Implement filter.select(viewer, parentElement, element)
          •element is the object of the current row
      
          Consider using the label providers for the different columns along
          with SearchPattern
      
          Multiple filters are logically and’ed
   For trees use FilteredTree



    final TableViewer viewer = new TableViewer(top, SWT.SINGLE);
    ...
    viewer.addFilter(new ViewerFilter() {
        public boolean select(Viewer viewer, Object parentElement, Object element) {
            Contact c = (Contact)element;
            return ...;
        }
    });




                                                                                       L0001 - 2010-11-27
Using SearchPattern


Create a new Pattern
   SeachPattern sp = new SearchPattern();
   sp.setPattern(“”)=;

Set the current pattern
   sp.setPattern(“*M”);

Test the pattern
   sp.matches(“Madsen”);




                                             L0001 - 2010-11-27
Filters and Sorters


Viewers support sorting
   viewer.setComparator(ViewerComparator) – sets the comparator/sorter
    of a viewer

For Table the header can be changed to show the current sort
   setSortColumn(TableColumn) and setSortDirection(int)




                                                                     L0001 - 2010-11-27
Lab Exercise


Create a view with a JFace table
   Add columns for first name and family name

Create both content and label providers (3.3 edition style)

Add a filter for the full name of a contact
   Check out SearchPattern (3.3 and later edition)




                                                              L0001 - 2010-11-27
Lab Exercise


Extra: When the “arrow down” key is pressed in the filter box, move the
focus to the table

Extra: And back again

Extra: Add column for all cities of a contact and filter on this as well as the
full name

Extra: Add a dialog to select the shown columns




                                                                              L0001 - 2010-11-27
When You Want to…


Paint specific columns of a TableViewer yourself
   Use OwnerDrawLabelProvider

Decorate images
   Use new DecoratingLabelProvider(yourLabelProvider,
    PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator())

Control navigation in a Table or Tree
   Subclass and use TableViewerFocusCellManager and
    TreeViewerFocusCellManager

Edit the values in a column
   See the EditingSupport class and subclasses
     
         Remember to use SWT.FULL_SELECTION




                                                                      L0001 - 2010-11-27
When You Want to…


Get the item of a TableViewer at a specific event position
   Use table.getItem(new Point(e.x,e.y))

Hide the selection when nothing can be selected




          v.getTable().addMouseListener(new MouseAdapter() {
              public void mouseDown(MouseEvent e) {
                  if( v.getTable().getItem(new Point(e.x,e.y)) == null ) {
                      v.setSelection(new StructuredSelection());
                  }
              }
          });




                                                                             L0001 - 2010-11-27
Management of Image Resources


Two types of image resources in Eclipse
   Image
     
         1-to-1 with the underlying image resource
     
         Must be disposed when not used any more
   ImageDescription
     
         Lightweight descriptor of image

The Plugin class contains an image manager!
   AbstractUIPlugin.imageDescriptorFromPlugin()
   Different method must be used if using multiple monitors (and thus
    possibly multiple Displays)

The platform also contains a large set of shared images that can cover
many usages:
   PlatformUI.getWorkbench().getSharedImages().getImage(…)




                                                                         L0001 - 2010-11-27
Managing Resources - JFaceResources


JFace contains a resource manager that handles fonts, images, and colors

You store RGB, FontData and ImageDescriptor objects and you retrieve
Color, Font and Image objects

As you don’t create these resources, you don’t have to dispose them!!!

JFaceResources contains a lot of standard resources:
   All colors and fonts as specified in the current theme




                                                                           L0001 - 2010-11-27
Managing Resources - JFaceResources


To add a color – really RGB value:

        RGB rgb = new RGB(100, 100, 100);
        JFaceResources.getColorRegistry().put(“BGColor”, rgb);




To retrieve the color:

        Color color = JFaceResources.getColorRegistry().get(“BGColor”);

To monitor changes to the resources:

        JFaceResources.getColorRegistry().addListener(new IPropertyChangeListener() {
            public void propertyChange(PropertyChangeEvent event) {
                ...
            }
        });


   Remember to remove the listener as well!

Likewise for fonts and images




                                                                                        L0001 - 2010-11-27
Managing Resources - JFaceResources


You can add images from your plug-in in your Activator.start(...) using the
following code
   OK, as the existence of nor checked




   ImageDescriptor id = imageDescriptorFromPlugin("com.rcpcompany.cexx", "icons/exit16.gif");
   JFaceResources.getImageRegistry().put("exit", id);




                                                                                                L0001 - 2010-11-27
More Information


“Eclipse User Interface Guidelines: Version 2.1”
   http://www.eclipse.org/resources/resource.php?id=162
    
        The Look-n-Feel guidelines for Eclipse – heavily influenced by the
        corresponding Microsoft Windows Look-n-Feel guidelines

“The Definitive Guide to SWT and JFace” by Robert Harris and Rob Warner
(ISBN: 978-1590593257)
   As it says – “The Definitive Guide…” – and needed due to the poor
    Javadoc of SWT

“JFaceSnippets” Repository
   http://wiki.eclipse.org/index.php/JFaceSnippets
    
        Likewise for JFace




                                                                             L0001 - 2010-11-27
More Information


“Eclipse Forms: Rich UI for the Rich Client”
   http://www.eclipse.org/resources/resource.php?id=140

“Rich clients with the SWT and JFace”
   http://www.javaworld.com/javaworld/jw-04-2004/jw-0426-
    swtjface.html?page=2

“Understanding Decorators in Eclipse”
   http://www.eclipse.org/resources/resource.php?id=216

“Decorating resources in WebSphere”
   http://www.ibm.com/developerworks/ibm/library/i-wsdeco/
    
        In-dept article on the decorators




                                                              L0001 - 2010-11-27
More Information


“Building and delivering a table editor with SWT/JFace”
   http://www.eclipse.org/resources/resource.php?id=209
    
        Older – yet correct – article with all the needed information for editors
        in tables

“JFace Plug-in Developers Guide”
   http://help.eclipse.org/ganymede/topic/org.eclipse.platform.doc.isv/
    guide/jface.htm

“UI Forms”
   http://help.eclipse.org/ganymede/topic/org.eclipse.platform.doc.isv/
    guide/forms.htm

“Eclipse Forms: Rich UI for the Rich Client”
   http://www.eclipse.org/articles/Article-Forms/article.html
    
        The Forms UI explained with some good examples




                                                                               L0001 - 2010-11-27

Más contenido relacionado

La actualidad más candente (20)

Java Beans
Java BeansJava Beans
Java Beans
 
Java beans
Java beansJava beans
Java beans
 
Producing Readable Output with iSQL*Plus - Oracle Data Base
Producing Readable Output with iSQL*Plus - Oracle Data BaseProducing Readable Output with iSQL*Plus - Oracle Data Base
Producing Readable Output with iSQL*Plus - Oracle Data Base
 
Java beans
Java beansJava beans
Java beans
 
S313937 cdi dochez
S313937 cdi dochezS313937 cdi dochez
S313937 cdi dochez
 
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
EclipseCon 2005: Everything You Always Wanted to do with EMF (But were Afraid...
 
Javabean1
Javabean1Javabean1
Javabean1
 
Unit iv
Unit ivUnit iv
Unit iv
 
Swing
SwingSwing
Swing
 
Creating other schema objects
Creating other schema objectsCreating other schema objects
Creating other schema objects
 
Les08
Les08Les08
Les08
 
Ajp notes-chapter-02
Ajp notes-chapter-02Ajp notes-chapter-02
Ajp notes-chapter-02
 
SQL WORKSHOP::Lecture 13
SQL WORKSHOP::Lecture 13SQL WORKSHOP::Lecture 13
SQL WORKSHOP::Lecture 13
 
javabeans
javabeansjavabeans
javabeans
 
Javabeans .pdf
Javabeans .pdfJavabeans .pdf
Javabeans .pdf
 
SQL Views
SQL ViewsSQL Views
SQL Views
 
View & index in SQL
View & index in SQLView & index in SQL
View & index in SQL
 
Les10
Les10Les10
Les10
 
Introduction to java beans
Introduction to java beansIntroduction to java beans
Introduction to java beans
 
Java beans
Java beansJava beans
Java beans
 

Similar a L0033 - JFace

L0020 - The Basic RCP Application
L0020 - The Basic RCP ApplicationL0020 - The Basic RCP Application
L0020 - The Basic RCP ApplicationTonny Madsen
 
React table tutorial use filter (part 2)
React table tutorial use filter (part 2)React table tutorial use filter (part 2)
React table tutorial use filter (part 2)Katy Slemon
 
EJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLinkEJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLinkBill Lyons
 
Design Patterns in Cocoa Touch
Design Patterns in Cocoa TouchDesign Patterns in Cocoa Touch
Design Patterns in Cocoa TouchEliah Nikans
 
Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1Michał Orman
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryjanet736113
 
DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)Hendrik Ebbers
 
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedJetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedToru Wonyoung Choi
 
Advanced #6 clean architecture
Advanced #6  clean architectureAdvanced #6  clean architecture
Advanced #6 clean architectureVitali Pekelis
 
Eclipse 2011 Hot Topics
Eclipse 2011 Hot TopicsEclipse 2011 Hot Topics
Eclipse 2011 Hot TopicsLars Vogel
 
A brief overview of java frameworks
A brief overview of java frameworksA brief overview of java frameworks
A brief overview of java frameworksMD Sayem Ahmed
 
A Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X TransformationA Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X TransformationCoen De Roover
 

Similar a L0033 - JFace (20)

DataFX - JavaOne 2013
DataFX - JavaOne 2013DataFX - JavaOne 2013
DataFX - JavaOne 2013
 
L0020 - The Basic RCP Application
L0020 - The Basic RCP ApplicationL0020 - The Basic RCP Application
L0020 - The Basic RCP Application
 
React table tutorial use filter (part 2)
React table tutorial use filter (part 2)React table tutorial use filter (part 2)
React table tutorial use filter (part 2)
 
react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptx
 
EJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLinkEJB 3.0 Java Persistence with Oracle TopLink
EJB 3.0 Java Persistence with Oracle TopLink
 
Olap
OlapOlap
Olap
 
Design Patterns in Cocoa Touch
Design Patterns in Cocoa TouchDesign Patterns in Cocoa Touch
Design Patterns in Cocoa Touch
 
Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1Integration of Backbone.js with Spring 3.1
Integration of Backbone.js with Spring 3.1
 
react-slides.pdf
react-slides.pdfreact-slides.pdf
react-slides.pdf
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react library
 
myslide1
myslide1myslide1
myslide1
 
myslide6
myslide6myslide6
myslide6
 
NewSeriesSlideShare
NewSeriesSlideShareNewSeriesSlideShare
NewSeriesSlideShare
 
DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)DataFX 8 (JavaOne 2014)
DataFX 8 (JavaOne 2014)
 
Jetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO ExtendedJetpack, with new features in 2021 GDG Georgetown IO Extended
Jetpack, with new features in 2021 GDG Georgetown IO Extended
 
Advanced #6 clean architecture
Advanced #6  clean architectureAdvanced #6  clean architecture
Advanced #6 clean architecture
 
Advance RCP
Advance RCPAdvance RCP
Advance RCP
 
Eclipse 2011 Hot Topics
Eclipse 2011 Hot TopicsEclipse 2011 Hot Topics
Eclipse 2011 Hot Topics
 
A brief overview of java frameworks
A brief overview of java frameworksA brief overview of java frameworks
A brief overview of java frameworks
 
A Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X TransformationA Recommender System for Refining Ekeko/X Transformation
A Recommender System for Refining Ekeko/X Transformation
 

Más de Tonny Madsen

L0037 - Basic Eclipse Configuration
L0037 - Basic Eclipse ConfigurationL0037 - Basic Eclipse Configuration
L0037 - Basic Eclipse ConfigurationTonny Madsen
 
L0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-inL0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-inTonny Madsen
 
L0001 - The Terminology of the Eclipse Platform
L0001 - The Terminology of the Eclipse PlatformL0001 - The Terminology of the Eclipse Platform
L0001 - The Terminology of the Eclipse PlatformTonny Madsen
 
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...Tonny Madsen
 
PROSA - Eclipse Is Just What?
PROSA - Eclipse Is Just What?PROSA - Eclipse Is Just What?
PROSA - Eclipse Is Just What?Tonny Madsen
 
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the FutureEclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the FutureTonny Madsen
 
Eclipse Demo Camp 2010 - UI Bindings - An Introduction
Eclipse Demo Camp 2010 - UI Bindings - An IntroductionEclipse Demo Camp 2010 - UI Bindings - An Introduction
Eclipse Demo Camp 2010 - UI Bindings - An IntroductionTonny Madsen
 
ITU - MDD – Model-to-Model Transformations
ITU - MDD – Model-to-Model TransformationsITU - MDD – Model-to-Model Transformations
ITU - MDD – Model-to-Model TransformationsTonny Madsen
 
IDA - Eclipse Workshop II (In Danish)
IDA - Eclipse Workshop II (In Danish)IDA - Eclipse Workshop II (In Danish)
IDA - Eclipse Workshop II (In Danish)Tonny Madsen
 
IDA - Eclipse Workshop I (In Danish)
IDA - Eclipse Workshop I (In Danish)IDA - Eclipse Workshop I (In Danish)
IDA - Eclipse Workshop I (In Danish)Tonny Madsen
 
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...Tonny Madsen
 
ITU - MDD - Eclipse Plug-ins
ITU - MDD - Eclipse Plug-insITU - MDD - Eclipse Plug-ins
ITU - MDD - Eclipse Plug-insTonny Madsen
 
eclipse.dk - Eclipse RCP Under the Hood
eclipse.dk - Eclipse RCP Under the Hoodeclipse.dk - Eclipse RCP Under the Hood
eclipse.dk - Eclipse RCP Under the HoodTonny Madsen
 
EclipseCon '08 - BoF - Building a local Eclipse user group
EclipseCon '08 - BoF - Building a local Eclipse user groupEclipseCon '08 - BoF - Building a local Eclipse user group
EclipseCon '08 - BoF - Building a local Eclipse user groupTonny Madsen
 
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...Tonny Madsen
 
EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...
EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...
EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...Tonny Madsen
 
javagruppen.dk - e4, the next generation Eclipse platform
javagruppen.dk - e4, the next generation Eclipse platformjavagruppen.dk - e4, the next generation Eclipse platform
javagruppen.dk - e4, the next generation Eclipse platformTonny Madsen
 
ITU - MDD – Modeling Techniques
ITU - MDD – Modeling TechniquesITU - MDD – Modeling Techniques
ITU - MDD – Modeling TechniquesTonny Madsen
 

Más de Tonny Madsen (20)

L0037 - Basic Eclipse Configuration
L0037 - Basic Eclipse ConfigurationL0037 - Basic Eclipse Configuration
L0037 - Basic Eclipse Configuration
 
L0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-inL0016 - The Structure of an Eclipse Plug-in
L0016 - The Structure of an Eclipse Plug-in
 
L0001 - The Terminology of the Eclipse Platform
L0001 - The Terminology of the Eclipse PlatformL0001 - The Terminology of the Eclipse Platform
L0001 - The Terminology of the Eclipse Platform
 
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
EclipseCon '11 - Using Adapters to Handle Menus and Handlers in Large Scale A...
 
PROSA - Eclipse Is Just What?
PROSA - Eclipse Is Just What?PROSA - Eclipse Is Just What?
PROSA - Eclipse Is Just What?
 
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the FutureEclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
Eclipse Demo Camp 2010 - Eclipse e4 – The Status and the Future
 
Eclipse Demo Camp 2010 - UI Bindings - An Introduction
Eclipse Demo Camp 2010 - UI Bindings - An IntroductionEclipse Demo Camp 2010 - UI Bindings - An Introduction
Eclipse Demo Camp 2010 - UI Bindings - An Introduction
 
ITU - MDD – Model-to-Model Transformations
ITU - MDD – Model-to-Model TransformationsITU - MDD – Model-to-Model Transformations
ITU - MDD – Model-to-Model Transformations
 
IDA - Eclipse Workshop II (In Danish)
IDA - Eclipse Workshop II (In Danish)IDA - Eclipse Workshop II (In Danish)
IDA - Eclipse Workshop II (In Danish)
 
IDA - Eclipse Workshop I (In Danish)
IDA - Eclipse Workshop I (In Danish)IDA - Eclipse Workshop I (In Danish)
IDA - Eclipse Workshop I (In Danish)
 
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
IDA - Fra forretningside til bundlinie: Eclipse følger dig hele vejen (In Dan...
 
ITU - MDD - EMF
ITU - MDD - EMFITU - MDD - EMF
ITU - MDD - EMF
 
ITU - MDD - Eclipse Plug-ins
ITU - MDD - Eclipse Plug-insITU - MDD - Eclipse Plug-ins
ITU - MDD - Eclipse Plug-ins
 
ITU - MDD - XText
ITU - MDD - XTextITU - MDD - XText
ITU - MDD - XText
 
eclipse.dk - Eclipse RCP Under the Hood
eclipse.dk - Eclipse RCP Under the Hoodeclipse.dk - Eclipse RCP Under the Hood
eclipse.dk - Eclipse RCP Under the Hood
 
EclipseCon '08 - BoF - Building a local Eclipse user group
EclipseCon '08 - BoF - Building a local Eclipse user groupEclipseCon '08 - BoF - Building a local Eclipse user group
EclipseCon '08 - BoF - Building a local Eclipse user group
 
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...
Eclipse Summit Europe '08 - Implementing Screen Flows in Eclipse RCP Applicat...
 
EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...
EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...
EclipseCon '09 - The Happy Marriage of EMF, Data binding, UI Forms and Field ...
 
javagruppen.dk - e4, the next generation Eclipse platform
javagruppen.dk - e4, the next generation Eclipse platformjavagruppen.dk - e4, the next generation Eclipse platform
javagruppen.dk - e4, the next generation Eclipse platform
 
ITU - MDD – Modeling Techniques
ITU - MDD – Modeling TechniquesITU - MDD – Modeling Techniques
ITU - MDD – Modeling Techniques
 

Último

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 

Último (20)

BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 

L0033 - JFace

  • 1. JFace The graphical sub-system of the Eclipse platform is made up of two components: SWT, the Standard Widget Toolkit ;and JFace, an architecture-independent modeling layer. This module describes how JFace extends SWT with viewers, commands, wizards, dialogs, and field assist. Redistribution and other use of this material requires written permission from The RCP Company. L0001 - 2010-11-27
  • 2. Eclipse User Interface Layers 4 Layers: Eclipse RCP Preferences Commands Registry Workbench  The Eclipse Workbench Jobs ICU JFace  Overall look-n-feel SWT  JFace OSGi/Run-time  Architecture-independent models  SWT  Platform independent API yet rather close to the metal  Native widgets  Platform dependent: Windows, Linux, Mac, Unix The “Eclipse User Interface Guidelines” governs the look-n-feel of the workbench and JFace  Consequently (nearly) all Eclipse RCP based applications look the same! Use the SWT Bible “The Definitive Guide to SWT and JFace” by Robert Harris and Rob Warner L0001 - 2010-11-27
  • 3. JFace A set of classes for handling many common UI programming tasks  Viewers handle the drudgery of populating, sorting, filtering, and updating widgets  Actions and contributions introduce semantics for defining user actions and specifying where to make them available  Image and font registries provide common patterns for handling UI resources  Dialogs and wizards define a framework for building complex interactions with the user  Field assist provides classes that help guide the user in choosing appropriate content for fields in dialogs, wizards, or forms Does not hide SWT; rather, it extends SWT L0001 - 2010-11-27
  • 4. The JFace Viewers Provides a glue layer between the application model and SWT Viewers exists for most structured widgets – e.g.  Combo boxes  Lists  Trees  Tables Uses common interfaces to control:  The content of the viewer: IContentProvider and child interfaces  The text and image of the cells: ILabelProvider and child interfaces  Decoration of images: ILabelDecorator  Filtering: ViewerFilter  Sorting: ViewerComparator L0001 - 2010-11-27
  • 5. Using JFace Viewers Common design pattern  Create viewer in parent Composite  Assign layout to the Control of the viewer  Add columns  new TableViewerColumn(viewer, ...)  Set text and width of columns  Set content provider – normally ArrayContentProvider  The interface depends on the type of the viewer  Install commands and action  Set input  Must be last Call viewer.refresh(…) when changes are made to the data L0001 - 2010-11-27
  • 6. Using JFace Viewers Also possible to specify background, foreground, font, tooltip… public void createPartControl(Composite parent) { TableViewer viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); viewer.setContentProvider(new ArrayContentProvider()); Table table = viewer.getTable(); TableViewerColumn c; table.setHeaderVisible(true); c = new TableViewerColumn(viewer, SWT.LEFT); c.setLabelProvider(new NameLabelProvider()); c.getColumn().setText("Name"); c.getColumn().setWidth(100); c = new TableViewerColumn(viewer, SWT.LEFT); c.setLabelProvider(new RestLabelProvider()); c.getColumn().setText("Rest"); c.getColumn().setWidth(300); viewer.setInput(getSite().getShell().getDisplay().getFontList(null, true)); } private class NameLabelProvider extends ColumnLabelProvider { @Override public String getText(Object element) { return ((FontData) element).getName(); } } L0001 - 2010-11-27
  • 7. IContentProvider Provides the glue between the content of the application model and the appropriate viewer  IStructuredContentProvider – used for combo boxes, lists and tables  ITreeContentProvider – used for trees  ILazyContentProvider – used for SWT.VIRTUAL tables  ILazyTreeContentProvider – used for SWT.VIRTUAL trees For arrays and List use ArrayContentProvider public interface IStructuredContentProvider { public void dispose(); public void inputChanged(Viewer viewer, Object oldInput, Object newInput); public Object[] getElements(Object inputElement); } L0001 - 2010-11-27
  • 8. ILabelProvider ILabelProvider provides the basic label and image for a row object in a viewer  Given the row object, the text, image. colors, font, ... for the cell is returned Several interesting implementations  ColumnLabelProvider - base class for label providers for TableViewerColumn  OwnerDrawLabelProvider - base class for label providers that wish to paint their cells  CellLabelProvider - don’t use this; use ColumnLabelProvider instead L0001 - 2010-11-27
  • 9. ILabelDecorator ILabelDecorator provides a standard means to decorate an existing label and image  Used extensively in Eclipse IDE: team and class information Label decorators can be registered as extensions  Activated automatically based on the class of the current row object of the viewer L0001 - 2010-11-27
  • 10. Label Providers for Table and Tree (3.3 and later edition) For Table and Tree, a label provider can be registered per column  Use superclass ColumnLabelProvider and not CellLabelProvider This allows reuse of label providers across projects L0001 - 2010-11-27
  • 11. Sample Decorator This decorator will add a bullet to the top-right corner of the image for an IRes object, if the IActionFilter of the object returns true for the children property The extension point currently uses the “old” style expression form <extension point="org.eclipse.ui.decorators"> <decorator adaptable="true" icon="icons/sample_decorator.gif" id="com.rcpcompany.demo.providers.ui.decorators.decorator" label="Resource Decorator" lightweight="true" location="TOP_RIGHT" state="true"> <enablement> <and> <objectClass name="com.rcpcompany.demo.providers.model.IRes"/> <objectState name="children" value="true"/> </and> </enablement> </decorator> </extension> L0001 - 2010-11-27
  • 12. Filters and Sorters Viewers support filtering  viewer.addFilter(ViewerFilter) – adds a filter to a viewer  Implement filter.select(viewer, parentElement, element) •element is the object of the current row  Consider using the label providers for the different columns along with SearchPattern  Multiple filters are logically and’ed  For trees use FilteredTree final TableViewer viewer = new TableViewer(top, SWT.SINGLE); ... viewer.addFilter(new ViewerFilter() { public boolean select(Viewer viewer, Object parentElement, Object element) { Contact c = (Contact)element; return ...; } }); L0001 - 2010-11-27
  • 13. Using SearchPattern Create a new Pattern  SeachPattern sp = new SearchPattern();  sp.setPattern(“”)=; Set the current pattern  sp.setPattern(“*M”); Test the pattern  sp.matches(“Madsen”); L0001 - 2010-11-27
  • 14. Filters and Sorters Viewers support sorting  viewer.setComparator(ViewerComparator) – sets the comparator/sorter of a viewer For Table the header can be changed to show the current sort  setSortColumn(TableColumn) and setSortDirection(int) L0001 - 2010-11-27
  • 15. Lab Exercise Create a view with a JFace table  Add columns for first name and family name Create both content and label providers (3.3 edition style) Add a filter for the full name of a contact  Check out SearchPattern (3.3 and later edition) L0001 - 2010-11-27
  • 16. Lab Exercise Extra: When the “arrow down” key is pressed in the filter box, move the focus to the table Extra: And back again Extra: Add column for all cities of a contact and filter on this as well as the full name Extra: Add a dialog to select the shown columns L0001 - 2010-11-27
  • 17. When You Want to… Paint specific columns of a TableViewer yourself  Use OwnerDrawLabelProvider Decorate images  Use new DecoratingLabelProvider(yourLabelProvider, PlatformUI.getWorkbench().getDecoratorManager().getLabelDecorator()) Control navigation in a Table or Tree  Subclass and use TableViewerFocusCellManager and TreeViewerFocusCellManager Edit the values in a column  See the EditingSupport class and subclasses  Remember to use SWT.FULL_SELECTION L0001 - 2010-11-27
  • 18. When You Want to… Get the item of a TableViewer at a specific event position  Use table.getItem(new Point(e.x,e.y)) Hide the selection when nothing can be selected v.getTable().addMouseListener(new MouseAdapter() { public void mouseDown(MouseEvent e) { if( v.getTable().getItem(new Point(e.x,e.y)) == null ) { v.setSelection(new StructuredSelection()); } } }); L0001 - 2010-11-27
  • 19. Management of Image Resources Two types of image resources in Eclipse  Image  1-to-1 with the underlying image resource  Must be disposed when not used any more  ImageDescription  Lightweight descriptor of image The Plugin class contains an image manager!  AbstractUIPlugin.imageDescriptorFromPlugin()  Different method must be used if using multiple monitors (and thus possibly multiple Displays) The platform also contains a large set of shared images that can cover many usages:  PlatformUI.getWorkbench().getSharedImages().getImage(…) L0001 - 2010-11-27
  • 20. Managing Resources - JFaceResources JFace contains a resource manager that handles fonts, images, and colors You store RGB, FontData and ImageDescriptor objects and you retrieve Color, Font and Image objects As you don’t create these resources, you don’t have to dispose them!!! JFaceResources contains a lot of standard resources:  All colors and fonts as specified in the current theme L0001 - 2010-11-27
  • 21. Managing Resources - JFaceResources To add a color – really RGB value: RGB rgb = new RGB(100, 100, 100); JFaceResources.getColorRegistry().put(“BGColor”, rgb); To retrieve the color: Color color = JFaceResources.getColorRegistry().get(“BGColor”); To monitor changes to the resources: JFaceResources.getColorRegistry().addListener(new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) { ... } });  Remember to remove the listener as well! Likewise for fonts and images L0001 - 2010-11-27
  • 22. Managing Resources - JFaceResources You can add images from your plug-in in your Activator.start(...) using the following code  OK, as the existence of nor checked ImageDescriptor id = imageDescriptorFromPlugin("com.rcpcompany.cexx", "icons/exit16.gif"); JFaceResources.getImageRegistry().put("exit", id); L0001 - 2010-11-27
  • 23. More Information “Eclipse User Interface Guidelines: Version 2.1”  http://www.eclipse.org/resources/resource.php?id=162  The Look-n-Feel guidelines for Eclipse – heavily influenced by the corresponding Microsoft Windows Look-n-Feel guidelines “The Definitive Guide to SWT and JFace” by Robert Harris and Rob Warner (ISBN: 978-1590593257)  As it says – “The Definitive Guide…” – and needed due to the poor Javadoc of SWT “JFaceSnippets” Repository  http://wiki.eclipse.org/index.php/JFaceSnippets  Likewise for JFace L0001 - 2010-11-27
  • 24. More Information “Eclipse Forms: Rich UI for the Rich Client”  http://www.eclipse.org/resources/resource.php?id=140 “Rich clients with the SWT and JFace”  http://www.javaworld.com/javaworld/jw-04-2004/jw-0426- swtjface.html?page=2 “Understanding Decorators in Eclipse”  http://www.eclipse.org/resources/resource.php?id=216 “Decorating resources in WebSphere”  http://www.ibm.com/developerworks/ibm/library/i-wsdeco/  In-dept article on the decorators L0001 - 2010-11-27
  • 25. More Information “Building and delivering a table editor with SWT/JFace”  http://www.eclipse.org/resources/resource.php?id=209  Older – yet correct – article with all the needed information for editors in tables “JFace Plug-in Developers Guide”  http://help.eclipse.org/ganymede/topic/org.eclipse.platform.doc.isv/ guide/jface.htm “UI Forms”  http://help.eclipse.org/ganymede/topic/org.eclipse.platform.doc.isv/ guide/forms.htm “Eclipse Forms: Rich UI for the Rich Client”  http://www.eclipse.org/articles/Article-Forms/article.html  The Forms UI explained with some good examples L0001 - 2010-11-27

Notas del editor

  1. \n
  2. The look-n-feel of the native widgets and SWT is governed by the native look-n-feel guide. Eclipse adds some further rules on top of these in the form of &amp;#x201C;Eclipse User Interface Guidelines&amp;#x201D;.\nThe look-n-feel of an RCP application can be changed; this is described in the module &amp;#x201C;L0019 - Changing the Look-n-Feel&amp;#x201D;.\n
  3. Where does JFace end and the workbench begin? Sometimes the lines aren&apos;t so obvious. In general, the JFace APIs (from the packages org.eclipse.jface.*) are independent of the workbench extension points and APIs. Conceivably, a JFace program could be written without using any workbench code at all.\nThe workbench makes use of JFace but attempts to reduce dependencies where possible. For example, the workbench part model (IWorkbenchPart) is designed to be independent of JFace. Views and editors can be implemented using SWT widgets directly without using any JFace classes. The workbench attempts to remain &quot;JFace neutral&quot; wherever possible, allowing programmers to use the parts of JFace they find useful. In practice, the workbench uses JFace for much of its implementation and there are references to JFace types in API definitions. (For example, the JFace interfaces for IMenuManager, IToolBarManager, and IStatusLineManager show up as types in the workbench IActionBar methods.)\nWhen using JFace API, it&apos;s a good idea to keep in mind the rules of engagement for using background threads.\nThe lines between SWT and JFace are much cleaner. SWT does not depend on any JFace or platform code at all. Many of the SWT examples show how you can build a standalone application. \nJFace is designed to provide common application UI function on top of the SWT library. JFace does not try to &quot;hide&quot; SWT or replace its function. It provides classes and interfaces that handle many of the common tasks associated with programming a dynamic UI using SWT.\nThe relationship between JFace and SWT is most clearly demonstrated by looking at viewers and their relationship to SWT widgets.\nDialogs and wizards are described in the module &amp;#x201C;L0007 - More Interaction with the Workbench&amp;#x201D;.\n
  4. JFace viewers exist in most cases where data must be mapped to a structured widget.\nSee &amp;#x201C;JFace Plug-in Developers Guide&amp;#x201D; for more information.\nThe use of two types of providers is a major difference from the corresponding models in Swing.\n
  5. If any changes are made to the structure of a viewer, then refresh(..) must be called.\nIf setInput(&amp;#x2026;) is not the last method called, all sorts of peculiar things can happen &amp;#x2013; most often some columns will only be present in the header and not in the table data. \n
  6. Use ColumnLabelProvider, not CellLabelProvider.\n
  7. The methods of the IStructuredContentProvider are:\ndispose() &amp;#x2013; called when the viewer is disposed\ninputChanged(Viewer viewer, Object oldInput, Object newInput) - notifies this content provider that the given viewer&apos;s input has been switched to a different element\ngetElements(Object inputElement) - returns the elements to display in the viewer when its input is set to the given element\n
  8. There are two means for providing labels and images in the Eclipse platform. The base label and image are provided via an ILabelProvider. These can then be augmented or decorated via ILabelDecorators.\nIn Eclipse IDE, the current set of decorators can be found on the &amp;#x201C;Label Decoration&amp;#x201D; page of the preferences.\nDecorators are registered via the extension point org.eclipse.ui.decorators &amp;#x2013; see later slide for example.\n
  9. There are two means for providing labels and images in the Eclipse platform. The base label and image are provided via an ILabelProvider. These can then be augmented or decorated via ILabelDecorators.\nIn Eclipse IDE, the current set of decorators can be found on the &amp;#x201C;Label Decoration&amp;#x201D; page of the preferences.\nDecorators are registered via the extension point org.eclipse.ui.decorators &amp;#x2013; see later slide for example.\n
  10. The primary advantage of the column label providers is the ability to use the same label providers across a complete project. The means the same look will be used for the same field throughout the application &amp;#x2013; something most users appreciate &amp;#xF04A;\nThe feel of viewers is to a large degree handled via the commands that are installed in the viewer and the content menu.\n
  11. \n
  12. \n
  13. \n
  14. \n
  15. Now it&amp;#x2019;s time for the lab.\nThe data for the table will be provided by the trainer. It consists of a plug-in with a ContactManager that provides a number of contacts each with name, address, zip, city and country attributes.\n
  16. Now it&amp;#x2019;s time for the lab.\nThe data for the table will be provided by the trainer. It consists of a plug-in with a ContactManager that provides a number of contacts each with name, address, zip, city and country attributes.\n
  17. \n
  18. \n
  19. A main cause of resource problems in many Eclipse RCP applications is faulty management of images! Either they are never released (or disposed) properly or they are shared between parts of the application and released too early.\nThe important issue is to handle images (and fonts) consistently. Eclipse includes multiple resource managers:\norg.eclipse.ui.plugin.AbstractUIPlugin.imageDescriptorFromPlugin()\norg.eclipse.jface.resource.ResourceManager\nOne special issue is that images and fonts are associated with a specific Display. So, if multiple monitors are used in the application, the images must be handled on a per Display basis.\n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n