SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Eclipse Plug-ins
and RCP
Training Course
Standard Widgets Toolkit
JFace
1
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
1. SWT Overview
a) Understanding Layouts
b) Events and Listeners
∗ Life-Cycle
a) Containers and Widgets
∗ Simple Widgets
∗ Complex Widgets
a) Class Hierarchy
b) Fonts, Colors, Images
c) SWT Style Bits
Agenda
2
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
∗ SWT is an open source widget toolkit for Java, designed to
provide efficient, portable access to the user-interface facilities
of the operating systems on which it is implemented.
∗ It abstracts the OS rendering implementation.
SWT Overview
3
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
∗ Layouts gives your windows a specific look, controlling the position and size of
childrens and how childrens adapt to their parent
Understanding Layouts
4
∗ Standard Layouts
∗ FillLayout lays out equal-sized
widgets in a single row or column
∗ RowLayout lays out widgets in a row
or rows, with fill, wrap, and spacing
options
∗ GridLayout lays out widgets in a grid
∗ FormLayout lays out widgets by
creating attachments for each of
their sides
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
Events and Listeners (1/4)
5
TIP: much of the widget state is stored in the platform widget rather than in the widget itself (as for
SWING)
class SWTWidgets Model
User
Widget
xxxEv ent
xxxListener
+ eventHandler()
«interface»
xxxListener
Trigger the source
«flow»
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
Events and Listeners (2/4)
6
sd Business Process Model
:User
:Widget :xxxEvent :xxxListener
Register the listeners()
Trigger the source()
Construct an xxxEvent object()
eventHandler(xxxEvent)
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
ControlListener Classes which implement this interface provide methods that deal with the events that are generated by moving and resizing controls.
DisposeListener Classes which implement this interface provide a method that deals with the event that is generated when a widget is disposed.
DragDetectListener Classes which implement this interface provide methods that deal with the events that are generated when a drag gesture is detected.
ExpandListener Classes which implement this interface provide methods that deal with the expanding and collapsing of ExpandItems.
FocusListener Classes which implement this interface provide methods that deal with the events that are generated as controls gain and lose focus.
HelpListener
Classes which implement this interface provide a method that deals with the event that is generated when help is requested for a
control, typically when the user presses F1.
KeyListener
Classes which implement this interface provide methods that deal with the events that are generated as keys are pressed on the
system keyboard.
MenuDetectListener
Classes which implement this interface provide methods that deal with the events that are generated when the platform-specific
trigger for showing a context menu is detected.
MenuListener Classes which implement this interface provide methods that deal with the hiding and showing of menus.
ModifyListener Classes which implement this interface provide a method that deals with the events that are generated when text is modified.
MouseListener Classes which implement this interface provide methods that deal with the events that are generated as mouse buttons are pressed.
MouseMoveListener Classes which implement this interface provide a method that deals with the events that are generated as the mouse pointer moves.
MouseTrackListener
Classes which implement this interface provide methods that deal with the events that are generated as the mouse pointer passes (or
hovers) over controls.
MouseWheelListener Classes which implement this interface provide a method that deals with the event that is generated as the mouse wheel is scrolled.
PaintListener
Classes which implement this interface provide methods that deal with the events that are generated when the control needs to be
painted.
SelectionListener
Classes which implement this interface provide methods that deal with the events that are generated when selection occurs in a
control.
ShellListener Classes which implement this interface provide methods that deal with changes in state of Shells.
TouchListener
Classes which implement this interface provide methods that deal with the events that are generated as touches occur on a touch-
aware input surface.
TraverseListener
Classes which implement this interface provide a method that deals with the events that are generated when a traverse event occurs
in a control.
TreeListener Classes which implement this interface provide methods that deal with the expanding and collapsing of tree branches.
VerifyListener
Classes which implement this interface provide a method that deals with the events that are generated when text is about to be
modified.
Events and Listeners (3/4)
7
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
ControlAdapter This adapter class provides default implementations for the methods described by the ControlListener interface.
ControlEvent Instances of this class are sent as a result of controls being moved or resized.
DisposeEvent Instances of this class are sent as a result of widgets being disposed.
DragDetectEvent Instances of this class are sent as a result of a drag gesture.
ExpandAdapter This adapter class provides default implementations for the methods described by the ExpandListener interface.
ExpandEvent Instances of this class are sent as a result of ExpandItems being expanded or collapsed.
FocusAdapter This adapter class provides default implementations for the methods described by the FocusListener interface.
FocusEvent Instances of this class are sent as a result of widgets gaining and losing focus.
HelpEvent Instances of this class are sent as a result of help being requested for a widget.
KeyAdapter This adapter class provides default implementations for the methods described by the KeyListener interface.
KeyEvent Instances of this class are sent as a result of keys being pressed and released on the keyboard.
MenuAdapter This adapter class provides default implementations for the methods described by the MenuListener interface.
MenuDetectEvent Instances of this class are sent whenever the platform- specific trigger for showing a context menu is detected.
MenuEvent Instances of this class are sent as a result of menus being shown and hidden.
ModifyEvent Instances of this class are sent as a result of text being modified.
MouseEvent Instances of this class are sent whenever mouse related actions occur.
MouseTrackAdapter This adapter class provides default implementations for the methods described by the MouseTrackListener interface.
PaintEvent Instances of this class are sent as a result of visible areas of controls requiring re-painting.
SelectionAdapter This adapter class provides default implementations for the methods described by the SelectionListener interface.
SelectionEvent Instances of this class are sent as a result of widgets being selected.
ShellEvent Instances of this class are sent as a result of operations being performed on shells.
TouchEvent Instances of this class are sent in response to a touch-based input source being touched.
TraverseEvent Instances of this class are sent as a result of widget traversal actions.
TreeAdapter This adapter class provides default implementations for the methods described by the TreeListener interface.
TreeEvent Instances of this class are sent as a result of trees being expanded and collapsed.
TypedEvent This is the super class for all typed event classes provided by SWT.
VerifyEvent Instances of this class are sent as a result of widgets handling keyboard events
Events and Listeners (4/4)
8
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
∗ Display
∗ Instances of this class are responsible for managing the connection between SWT and the
underlying operating system.
∗ Their most important function is to implement the SWT event loop in terms of the platform
event model.
∗ They also provide various methods for accessing information about the operating system,
and have overall control over the operating system resources which SWT allocates.
∗ Shell
∗ Represent the "windows" which the desktop or is managing.
∗ Composite and Scrolled Composite
∗ Represent controls which are capable of containing other controls.
∗ A ScrolledComposite provides scrollbars and will scroll its
content when the user uses the scrollbars.
Containers (1/2)
9
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
∗ Group, Sash, Tab Folder
∗ Groups are subclass of composite that provide an etched border
with an optional title.
∗ A Sash represents a selectable user interface container that allows
the user to drag a rubber banded outline of the sash within the
parent control.
∗ Tab Folder allows the user to select a notebook page from set of
pages.
Containers (2/2)
10
TIP: Calls to SWT methods that create widgets or modify currently visible widgets must be made from
UI thread. Use Display.xxxExec!
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
∗ Label
∗ Button
∗ Text
∗ Combo
Simple Widgets
11
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
∗ Menu and Toolbar
∗ Table
∗ Tree
Complex Widgets
12
TIP: the Eclipse Nebula project contains other custom Widgets and UI
components.
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
class Widgets
widgets::Button
Drawable
widgets::Control
widgets::Label
widgets::Menu
Item
widgets::MenuItem
widgets::Widget
Decorations
widgets::Shell
widgets::Sash
~menu
~parent~menu
~cascade
~lastActive
~activeMenu
Widget Class Hierarchy (1/3)
13
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
class Composite
widgets::Combo
widgets::Composite
Widget
Drawable
widgets::Control
widgets::Group
Item
widgets::TreeItem
widgets::TabFolder
Item
widgets::TabItem
widgets::Table
Item
widgets::TableItem
widgets::Text
Item
widgets::ToolItem
widgets::Tree
widgets::ToolBar
widgets::Scrollable
~items~parent
~tabList
~items
~items~currentItem
~parent
~control
~tabItemList
~parent~parent
~items~currentItem
~parent
~control
Widget Class Hierarchy (2/3)
14
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
Main Methods
 void addListener(int eventType, Listener listener) 
          Adds the listener to the collection of listeners who will be notified when an event of the given type occurs.
 void dispose() 
          Disposes of the operating system resources associated with the receiver and all its descendants.
 Object getData(String key) 
          Returns the application defined property of the receiver with the specified name, or null if it has not been set.
 Display getDisplay() 
          Returns the Display that is associated with the receiver.
 Listener[] getListeners(int eventType) 
          Returns an array of listeners who will be notified when an event of the given type occurs.
 int getStyle() 
          Returns the receiver's style information.
 boolean isDisposed() 
          Returns true if the widget has been disposed, and false otherwise.
 boolean isListening(int eventType) 
          Returns true if there are any listeners for the specified event type associated with the receiver, and false otherwise.
 void notifyListeners(int eventType, Event event) 
          Notifies all of the receiver's listeners for events of the given type that one such event has occurred by invoking their 
handleEvent() method.
 void removeListener(int eventType, Listener listener) 
          Removes the listener from the collection of listeners who will be notified when an event of the given type occurs.
protected 
 void
removeListener(int eventType, org.eclipse.swt.internal.SWTEventListener listener) 
          Removes the listener from the collection of listeners who will be notified when an event of the given type occurs.
 void setData(Object data) 
          Sets the application defined widget data associated with the receiver to be the argument.
 void setData(String key, Object value) 
          Sets the application defined property of the receiver with the specified name to the given value.
Widget Class Hierarchy (3/3)
15
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
Widget Class Styles
org.eclipse.swt.widgets.Button
TOGGLE, ARROW, PUSH, RADIO, CHECK, FLAT,UP, DOWN, LEFT, RIGHT, CENT
ER
org.eclipse.swt.widgets.Combo DROP_DOWN, READ_ONLY, SIMPLE
org.eclipse.swt.widgets.Composite
NO_BACKGROUND, NO_FOCUS, NO_REDRAW_RESIZE,NO_MERGE_PAINTS, N
O_RADIO_GROUP, EMBEDDED,DOUBLE_BUFFERED, UP
org.eclipse.swt.widgets.Group
SHADOW_IN, SHADOW_OUT, SHADOW_ETCHED_IN,SHADOW_ETCHED_OUT, 
SHADOW_NONE
org.eclipse.swt.widgets.Label
SEPARATOR, WRAP, SHADOW_IN, SHADOW_OUT,SHADOW_NONE, LEFT, RIG
HT, CENTER,HORIZONTAL, VERTICAL
org.eclipse.swt.widgets.Menu
BAR, DROP_DOWN, POP_UP, NO_RADIO_GROUP,LEFT_TO_RIGHT, RIGHT_TO
_LEFT
org.eclipse.swt.widgets.MenuItem SEPARATOR, PUSH, RADIO, CHECK, CASCADE
org.eclipse.swt.widgets.Sash SMOOTH, HORIZONTAL, VERTICAL
org.eclipse.swt.widgets.Scrollable H_SCROLL, V_SCROLL
org.eclipse.swt.widgets.Shell
TOOL, NO_TRIM, RESIZE, TITLE, CLOSE, MIN, MAX,BORDER, ON_TOP, MODEL
ESS, PRIMARY_MODAL,APPLICATION_MODAL, SYSTEM_MODAL
org.eclipse.swt.widgets.TabFolder TOP, BOTTOM
org.eclipse.swt.widgets.Table CHECK, MULTI, SINGLE, HIDE_SELECTION,FULL_SELECTION, VIRTUAL
org.eclipse.swt.widgets.Text
MULTI, SINGLE, READ_ONLY, WRAP, SEARCH,PASSWORD, LEFT, RIGHT, CEN
TER
org.eclipse.swt.widgets.ToolBar WRAP, SHADOW_OUT, FLAT, RIGHT, HORIZONTAL,VERTICAL
org.eclipse.swt.widgets.ToolItem DROP_DOWN, SEPARATOR, PUSH, RADIO, CHECK
org.eclipse.swt.widgets.Tree CHECK, MULTI, SINGLE, FULL_SELECTION, VIRTUAL
SWT Style Bits
16
TIP: not all styles are supported on all platforms.
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
∗ Fonts:
∗ manage operating system resources that define how text looks when it is
displayed. Fonts may be constructed by providing a device and either name, size
and style information or a FontData object which encapsulates this data.
∗ Colors:
∗ manage the operating system resources that implement SWT's RGB color model.
To create a color you can either specify the individual color components as
integers in the range 0 to 255 or provide an instance of an RGB.
∗ Images:
∗ graphics which have been prepared for display on a specific device.
∗ If loaded from a file format that supports it, an Image may have transparency.
∗ Images can be also created using SWT Canvas and GC
∗ Supported formats: GIF, JPG, PNG, BMP (Windows) and ICO (Windows)
TIP: these resources should be managed by a resource manager that creates them once and
destroy them when the application exits.
Fonts, Colors, Images
17
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
Exercise
18
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
1. JFace Overview
2. Model-View-Controller Concepts
a) A simple model
3. Viewers Architecture
a) ContentProvider, LabelProvider, DecoratingLabelProvider
b) Viewer Sorter and Viewer Filter
c) Drag & Drop
d) Managing Selection
4. Putting all togheter
Agenda
19
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
∗ SWT provides a direct interface to the native platform
widgets, but it is limited to using simple data types:
∗ strings, numbers, images, …
∗ This represents a limitation when dealing with object-
oriented (OO) data that needs to be presented in lists,
tables, trees, and text widgets.
∗ This is where JFace viewers step in to provide OO
wrappers around their associated SWT widgets.
JFace Overview (1/2)
20
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
∗ JFace allows you to directly use your domain model objects:
∗ No need to manually decompose them into their basic string,
numerical, and image elements.
∗ The viewers provide adapter interface for handling domain model
object.
∗ Main JFace Viewers
∗ Table Viewer
∗ Tree Viewer
∗ List Viewer
∗ Text Viewer
JFace Overview (2/2)
21
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
∗ “Model–view–controller (MVC) is a software
architecture pattern which separates the
representation of information from the user's
interaction with it.” (cit. Wikipedia)
∗ A model is an object representing data or even
activity, e.g. a database table or even some
plant-floor production-machine process.
∗ A view is some form of visualization of the
state of the model.
∗ A controller offers facilities to change the state
of the model.
Model-View-Controller
Concepts
22
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
class Model
Universe
Galaxy Cluster
Dark Matter
Galaxy
Star ClusterNebulae
Solar Systems Planets
Stars
SatellitesAsteroid
0..* 0..*
0..1
1..*1..*
0..*
1..* 1..*
1..*
A simple model
23
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
∗ Input element
∗ An input element is the main object that the viewer is displaying (or editing).
∗ A viewer must be able to handle a change of input element.
∗ Content viewers
∗ A content viewer is a viewer that has a well defined protocol for obtaining information
from its input element.
∗ Content viewers use two specialized helper classes, the IContentProvider
and ILabelProvider, to populate their widget and display information about the input
element.
∗ IContentProvider provides basic lifecycle protocol for associating a content provider with an
input element and handling a change of input element. More specialized content providers are
implemented for different kinds of viewers.
∗ ILabelProvider given the content of a viewer, it can produce the specific UI elements, such as
names and icons, that are needed to display the content in the viewer.
∗ A label provider can show more than just text and an image:
Viewers Architecture (1/4)
24
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
∗ Filter and Sorter
∗ Filtering and sorting capability is handled by designating a viewer sorter (ViewerSorter)
and/or viewer filter (ViewerFilter) for the viewer.
∗ Drag & Drop
∗ Viewers can handle D&D adding user defined classes known as DragSupport and
DropSupport
∗ Adding drag support to a viewer means that it enables the user to select any item in
the viewer with the mouse, and drag it into another viewer or another application,
while the drop support verify if the viewer can accept a dragged element.
∗ A Transfer provides a mechanism for converting between a java representation of data
and a platform specific representation of data and vice versa
∗ Managing Selection
∗ Viewers implement ISelectionProvider interface in order to provide selection to other
entities
Viewers Architecture (2/4)
25
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
class JFaceViewers
viewers::
AbstractListViewer
viewers::
AbstractTableViewer
viewers::
AbstractTreeViewer
viewers::
CheckboxTableViewer
viewers::
CheckboxTreeViewer
viewers::ColumnViewer
viewers::ContentViewer«interface»
v iewers::
IBaseLabelProvider
«interface»
v iewers::
IContentProvider
«interface»
v iewers::
IPostSelectionProv ider
«interface»
v iewers::
ISelectionProv ider
v iewers::ListViewer
viewers::
StructuredViewer
v iewers::
TableTreeViewer
v iewers::TableViewer v iewers::TreeViewer
viewers::Viewer
viewers::
ViewerComparator
DropTargetAdapter
viewers::
ViewerDropAdapter
viewers::ViewerFilter
viewers::ViewerSorter
-contentProvider -sorter
-viewer
-labelProvider
Viewers Architecture (3/4)
26
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
class JFaceProv iders
viewers::
ArrayContentProvider
EventManager
v iewers::
BaseLabelProv ider
Viewer
viewers::
ContentViewer
viewers::
DecoratingLabelProv ider
«interface»
v iewers::
IBaseLabelProv ider
«interface»
viewers::
IContentProvider
«interface»
v iewers::
ILabelDecorator
«interface»
viewers::
ILabelProvider
«interface»
viewers::
IStructuredContentProv ider
«interface»
v iewers::
ITableLabelProv ider
«interface»
v iewers::
ITreeContentProvider
«interface»
viewers::
IViewerLabelProv ider
v iewers::
LabelProv ider
-decorator
-instance
-labelProvider
-contentProvider
Viewers Architecture (4/4)
27
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
Putting All Together
28
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
∗ http://www.eclipse.org/swt/widgets/
∗ http://www.java2s.com/Tutorial/Java/0280__SWT/Catalog0280_
_SWT.htm
∗ http://wiki.eclipse.org/JFace
References
29
October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions

Weitere ähnliche Inhalte

Was ist angesagt?

[수정본] 우아한 객체지향
[수정본] 우아한 객체지향[수정본] 우아한 객체지향
[수정본] 우아한 객체지향Young-Ho Cho
 
Observer design pattern
Observer design patternObserver design pattern
Observer design patternSara Torkey
 
Android Navigation Component
Android Navigation ComponentAndroid Navigation Component
Android Navigation ComponentŁukasz Ciupa
 
React workshop presentation
React workshop presentationReact workshop presentation
React workshop presentationBojan Golubović
 
Understanding LINQ in C#
Understanding LINQ in C# Understanding LINQ in C#
Understanding LINQ in C# MD. Shohag Mia
 
HTML 5 Complete Reference
HTML 5 Complete ReferenceHTML 5 Complete Reference
HTML 5 Complete ReferenceEPAM Systems
 
Win runner testing tool
Win runner testing toolWin runner testing tool
Win runner testing toolmansirajpara
 
Uml Presentation
Uml PresentationUml Presentation
Uml Presentationmewaseem
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript ProgrammingSehwan Noh
 
Activity diagram-UML diagram
Activity diagram-UML diagramActivity diagram-UML diagram
Activity diagram-UML diagramRamakant Soni
 
Multi Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And TypesMulti Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And TypesEthan Cha
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event LoopDesignveloper
 
JavaScript Engines and Event Loop
JavaScript Engines and Event Loop JavaScript Engines and Event Loop
JavaScript Engines and Event Loop Tapan B.K.
 
introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3 ArezooKmn
 

Was ist angesagt? (20)

[수정본] 우아한 객체지향
[수정본] 우아한 객체지향[수정본] 우아한 객체지향
[수정본] 우아한 객체지향
 
React js
React jsReact js
React js
 
Observer design pattern
Observer design patternObserver design pattern
Observer design pattern
 
SQLITE Android
SQLITE AndroidSQLITE Android
SQLITE Android
 
Object diagram
Object diagramObject diagram
Object diagram
 
Android Navigation Component
Android Navigation ComponentAndroid Navigation Component
Android Navigation Component
 
React workshop presentation
React workshop presentationReact workshop presentation
React workshop presentation
 
Understanding LINQ in C#
Understanding LINQ in C# Understanding LINQ in C#
Understanding LINQ in C#
 
HTML 5 Complete Reference
HTML 5 Complete ReferenceHTML 5 Complete Reference
HTML 5 Complete Reference
 
Angular overview
Angular overviewAngular overview
Angular overview
 
Java reflection
Java reflectionJava reflection
Java reflection
 
Win runner testing tool
Win runner testing toolWin runner testing tool
Win runner testing tool
 
Uml Presentation
Uml PresentationUml Presentation
Uml Presentation
 
JavaScript Programming
JavaScript ProgrammingJavaScript Programming
JavaScript Programming
 
Activity diagram-UML diagram
Activity diagram-UML diagramActivity diagram-UML diagram
Activity diagram-UML diagram
 
Multi Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And TypesMulti Touch And Gesture Event Interface And Types
Multi Touch And Gesture Event Interface And Types
 
JavaScript Event Loop
JavaScript Event LoopJavaScript Event Loop
JavaScript Event Loop
 
JavaScript Engines and Event Loop
JavaScript Engines and Event Loop JavaScript Engines and Event Loop
JavaScript Engines and Event Loop
 
Sq lite database
Sq lite databaseSq lite database
Sq lite database
 
introduction to Vue.js 3
introduction to Vue.js 3 introduction to Vue.js 3
introduction to Vue.js 3
 

Andere mochten auch

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
 
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
 
L0036 - Creating Views and Editors
L0036 - Creating Views and EditorsL0036 - Creating Views and Editors
L0036 - Creating Views and EditorsTonny Madsen
 
L0020 - The Basic RCP Application
L0020 - The Basic RCP ApplicationL0020 - The Basic RCP Application
L0020 - The Basic RCP ApplicationTonny Madsen
 
PDE Good Practices
PDE Good PracticesPDE Good Practices
PDE Good PracticesAnkur Sharma
 

Andere mochten auch (6)

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
 
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
 
L0036 - Creating Views and Editors
L0036 - Creating Views and EditorsL0036 - Creating Views and Editors
L0036 - Creating Views and Editors
 
TMF meets GMF
TMF meets GMFTMF meets GMF
TMF meets GMF
 
L0020 - The Basic RCP Application
L0020 - The Basic RCP ApplicationL0020 - The Basic RCP Application
L0020 - The Basic RCP Application
 
PDE Good Practices
PDE Good PracticesPDE Good Practices
PDE Good Practices
 

Ähnlich wie Eclipse Training - SWT & JFace

Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024nehakumari0xf
 
Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024kashyapneha2809
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptsharanyak0721
 
Design Pattern with Actionscript
Design Pattern with ActionscriptDesign Pattern with Actionscript
Design Pattern with ActionscriptDaniel Swid
 
Advance ui development and design
Advance ui  development and design Advance ui  development and design
Advance ui development and design Rakesh Jha
 
lecture10-patterns.ppt
lecture10-patterns.pptlecture10-patterns.ppt
lecture10-patterns.pptAnkitPangasa1
 
lecture10-patterns.ppt
lecture10-patterns.pptlecture10-patterns.ppt
lecture10-patterns.pptbryafaissal
 
ActionScript Design Patterns
ActionScript Design Patterns ActionScript Design Patterns
ActionScript Design Patterns Yoss Cohen
 
Java AWT and Java FX
Java AWT and Java FXJava AWT and Java FX
Java AWT and Java FXpratikkadam78
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01Ankit Dubey
 
Java for android developers
Java for android developersJava for android developers
Java for android developersAly Abdelkareem
 
Event handling
Event handlingEvent handling
Event handlingswapnac12
 
Ajp notes-chapter-03
Ajp notes-chapter-03Ajp notes-chapter-03
Ajp notes-chapter-03Ankit Dubey
 

Ähnlich wie Eclipse Training - SWT & JFace (20)

Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024
 
Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024Java Abstract Window Toolkit (AWT) Presentation. 2024
Java Abstract Window Toolkit (AWT) Presentation. 2024
 
Unit 6 Java
Unit 6 JavaUnit 6 Java
Unit 6 Java
 
Custom components
Custom componentsCustom components
Custom components
 
JAVA (UNIT 5)
JAVA (UNIT 5)JAVA (UNIT 5)
JAVA (UNIT 5)
 
engineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.pptengineeringdsgtnotesofunitfivesnists.ppt
engineeringdsgtnotesofunitfivesnists.ppt
 
What is Event
What is EventWhat is Event
What is Event
 
Design Pattern with Actionscript
Design Pattern with ActionscriptDesign Pattern with Actionscript
Design Pattern with Actionscript
 
Advance ui development and design
Advance ui  development and design Advance ui  development and design
Advance ui development and design
 
lecture10-patterns.ppt
lecture10-patterns.pptlecture10-patterns.ppt
lecture10-patterns.ppt
 
lecture10-patterns.ppt
lecture10-patterns.pptlecture10-patterns.ppt
lecture10-patterns.ppt
 
ActionScript Design Patterns
ActionScript Design Patterns ActionScript Design Patterns
ActionScript Design Patterns
 
Java AWT and Java FX
Java AWT and Java FXJava AWT and Java FX
Java AWT and Java FX
 
Gui
GuiGui
Gui
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
Java for android developers
Java for android developersJava for android developers
Java for android developers
 
Event handling
Event handlingEvent handling
Event handling
 
JAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
JAVA PROGRAMMING- GUI Programming with Swing - The Swing ButtonsJAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
JAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
 
Ajp notes-chapter-03
Ajp notes-chapter-03Ajp notes-chapter-03
Ajp notes-chapter-03
 
Design patterns
Design patternsDesign patterns
Design patterns
 

Kürzlich hochgeladen

Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...itnewsafrica
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Alkin Tezuysal
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsRavi Sanghani
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsNathaniel Shimoni
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxLoriGlavin3
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Strongerpanagenda
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...Wes McKinney
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024TopCSSGallery
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Mark Goldstein
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructureitnewsafrica
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPathCommunity
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch TuesdayIvanti
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkPixlogix Infotech
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observabilityitnewsafrica
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Hiroshi SHIBATA
 

Kürzlich hochgeladen (20)

Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...Abdul Kader Baba- Managing Cybersecurity Risks  and Compliance Requirements i...
Abdul Kader Baba- Managing Cybersecurity Risks and Compliance Requirements i...
 
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
Unleashing Real-time Insights with ClickHouse_ Navigating the Landscape in 20...
 
Potential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and InsightsPotential of AI (Generative AI) in Business: Learnings and Insights
Potential of AI (Generative AI) in Business: Learnings and Insights
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Time Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directionsTime Series Foundation Models - current state and future directions
Time Series Foundation Models - current state and future directions
 
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptxThe Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
The Role of FIDO in a Cyber Secure Netherlands: FIDO Paris Seminar.pptx
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better StrongerModern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
Modern Roaming for Notes and Nomad – Cheaper Faster Better Stronger
 
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
The Future Roadmap for the Composable Data Stack - Wes McKinney - Data Counci...
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024Top 10 Hubspot Development Companies in 2024
Top 10 Hubspot Development Companies in 2024
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
Arizona Broadband Policy Past, Present, and Future Presentation 3/25/24
 
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical InfrastructureVarsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
Varsha Sewlal- Cyber Attacks on Critical Critical Infrastructure
 
UiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to HeroUiPath Community: Communication Mining from Zero to Hero
UiPath Community: Communication Mining from Zero to Hero
 
2024 April Patch Tuesday
2024 April Patch Tuesday2024 April Patch Tuesday
2024 April Patch Tuesday
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
React Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App FrameworkReact Native vs Ionic - The Best Mobile App Framework
React Native vs Ionic - The Best Mobile App Framework
 
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security ObservabilityGlenn Lazarus- Why Your Observability Strategy Needs Security Observability
Glenn Lazarus- Why Your Observability Strategy Needs Security Observability
 
Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024Long journey of Ruby standard library at RubyConf AU 2024
Long journey of Ruby standard library at RubyConf AU 2024
 

Eclipse Training - SWT & JFace

  • 1. Eclipse Plug-ins and RCP Training Course Standard Widgets Toolkit JFace 1 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 2. 1. SWT Overview a) Understanding Layouts b) Events and Listeners ∗ Life-Cycle a) Containers and Widgets ∗ Simple Widgets ∗ Complex Widgets a) Class Hierarchy b) Fonts, Colors, Images c) SWT Style Bits Agenda 2 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 3. ∗ SWT is an open source widget toolkit for Java, designed to provide efficient, portable access to the user-interface facilities of the operating systems on which it is implemented. ∗ It abstracts the OS rendering implementation. SWT Overview 3 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 4. ∗ Layouts gives your windows a specific look, controlling the position and size of childrens and how childrens adapt to their parent Understanding Layouts 4 ∗ Standard Layouts ∗ FillLayout lays out equal-sized widgets in a single row or column ∗ RowLayout lays out widgets in a row or rows, with fill, wrap, and spacing options ∗ GridLayout lays out widgets in a grid ∗ FormLayout lays out widgets by creating attachments for each of their sides October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 5. Events and Listeners (1/4) 5 TIP: much of the widget state is stored in the platform widget rather than in the widget itself (as for SWING) class SWTWidgets Model User Widget xxxEv ent xxxListener + eventHandler() «interface» xxxListener Trigger the source «flow» October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 6. Events and Listeners (2/4) 6 sd Business Process Model :User :Widget :xxxEvent :xxxListener Register the listeners() Trigger the source() Construct an xxxEvent object() eventHandler(xxxEvent) October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 7. ControlListener Classes which implement this interface provide methods that deal with the events that are generated by moving and resizing controls. DisposeListener Classes which implement this interface provide a method that deals with the event that is generated when a widget is disposed. DragDetectListener Classes which implement this interface provide methods that deal with the events that are generated when a drag gesture is detected. ExpandListener Classes which implement this interface provide methods that deal with the expanding and collapsing of ExpandItems. FocusListener Classes which implement this interface provide methods that deal with the events that are generated as controls gain and lose focus. HelpListener Classes which implement this interface provide a method that deals with the event that is generated when help is requested for a control, typically when the user presses F1. KeyListener Classes which implement this interface provide methods that deal with the events that are generated as keys are pressed on the system keyboard. MenuDetectListener Classes which implement this interface provide methods that deal with the events that are generated when the platform-specific trigger for showing a context menu is detected. MenuListener Classes which implement this interface provide methods that deal with the hiding and showing of menus. ModifyListener Classes which implement this interface provide a method that deals with the events that are generated when text is modified. MouseListener Classes which implement this interface provide methods that deal with the events that are generated as mouse buttons are pressed. MouseMoveListener Classes which implement this interface provide a method that deals with the events that are generated as the mouse pointer moves. MouseTrackListener Classes which implement this interface provide methods that deal with the events that are generated as the mouse pointer passes (or hovers) over controls. MouseWheelListener Classes which implement this interface provide a method that deals with the event that is generated as the mouse wheel is scrolled. PaintListener Classes which implement this interface provide methods that deal with the events that are generated when the control needs to be painted. SelectionListener Classes which implement this interface provide methods that deal with the events that are generated when selection occurs in a control. ShellListener Classes which implement this interface provide methods that deal with changes in state of Shells. TouchListener Classes which implement this interface provide methods that deal with the events that are generated as touches occur on a touch- aware input surface. TraverseListener Classes which implement this interface provide a method that deals with the events that are generated when a traverse event occurs in a control. TreeListener Classes which implement this interface provide methods that deal with the expanding and collapsing of tree branches. VerifyListener Classes which implement this interface provide a method that deals with the events that are generated when text is about to be modified. Events and Listeners (3/4) 7 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 8. ControlAdapter This adapter class provides default implementations for the methods described by the ControlListener interface. ControlEvent Instances of this class are sent as a result of controls being moved or resized. DisposeEvent Instances of this class are sent as a result of widgets being disposed. DragDetectEvent Instances of this class are sent as a result of a drag gesture. ExpandAdapter This adapter class provides default implementations for the methods described by the ExpandListener interface. ExpandEvent Instances of this class are sent as a result of ExpandItems being expanded or collapsed. FocusAdapter This adapter class provides default implementations for the methods described by the FocusListener interface. FocusEvent Instances of this class are sent as a result of widgets gaining and losing focus. HelpEvent Instances of this class are sent as a result of help being requested for a widget. KeyAdapter This adapter class provides default implementations for the methods described by the KeyListener interface. KeyEvent Instances of this class are sent as a result of keys being pressed and released on the keyboard. MenuAdapter This adapter class provides default implementations for the methods described by the MenuListener interface. MenuDetectEvent Instances of this class are sent whenever the platform- specific trigger for showing a context menu is detected. MenuEvent Instances of this class are sent as a result of menus being shown and hidden. ModifyEvent Instances of this class are sent as a result of text being modified. MouseEvent Instances of this class are sent whenever mouse related actions occur. MouseTrackAdapter This adapter class provides default implementations for the methods described by the MouseTrackListener interface. PaintEvent Instances of this class are sent as a result of visible areas of controls requiring re-painting. SelectionAdapter This adapter class provides default implementations for the methods described by the SelectionListener interface. SelectionEvent Instances of this class are sent as a result of widgets being selected. ShellEvent Instances of this class are sent as a result of operations being performed on shells. TouchEvent Instances of this class are sent in response to a touch-based input source being touched. TraverseEvent Instances of this class are sent as a result of widget traversal actions. TreeAdapter This adapter class provides default implementations for the methods described by the TreeListener interface. TreeEvent Instances of this class are sent as a result of trees being expanded and collapsed. TypedEvent This is the super class for all typed event classes provided by SWT. VerifyEvent Instances of this class are sent as a result of widgets handling keyboard events Events and Listeners (4/4) 8 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 9. ∗ Display ∗ Instances of this class are responsible for managing the connection between SWT and the underlying operating system. ∗ Their most important function is to implement the SWT event loop in terms of the platform event model. ∗ They also provide various methods for accessing information about the operating system, and have overall control over the operating system resources which SWT allocates. ∗ Shell ∗ Represent the "windows" which the desktop or is managing. ∗ Composite and Scrolled Composite ∗ Represent controls which are capable of containing other controls. ∗ A ScrolledComposite provides scrollbars and will scroll its content when the user uses the scrollbars. Containers (1/2) 9 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 10. ∗ Group, Sash, Tab Folder ∗ Groups are subclass of composite that provide an etched border with an optional title. ∗ A Sash represents a selectable user interface container that allows the user to drag a rubber banded outline of the sash within the parent control. ∗ Tab Folder allows the user to select a notebook page from set of pages. Containers (2/2) 10 TIP: Calls to SWT methods that create widgets or modify currently visible widgets must be made from UI thread. Use Display.xxxExec! October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 11. ∗ Label ∗ Button ∗ Text ∗ Combo Simple Widgets 11 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 12. ∗ Menu and Toolbar ∗ Table ∗ Tree Complex Widgets 12 TIP: the Eclipse Nebula project contains other custom Widgets and UI components. October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 15. Main Methods  void addListener(int eventType, Listener listener)            Adds the listener to the collection of listeners who will be notified when an event of the given type occurs.  void dispose()            Disposes of the operating system resources associated with the receiver and all its descendants.  Object getData(String key)            Returns the application defined property of the receiver with the specified name, or null if it has not been set.  Display getDisplay()            Returns the Display that is associated with the receiver.  Listener[] getListeners(int eventType)            Returns an array of listeners who will be notified when an event of the given type occurs.  int getStyle()            Returns the receiver's style information.  boolean isDisposed()            Returns true if the widget has been disposed, and false otherwise.  boolean isListening(int eventType)            Returns true if there are any listeners for the specified event type associated with the receiver, and false otherwise.  void notifyListeners(int eventType, Event event)            Notifies all of the receiver's listeners for events of the given type that one such event has occurred by invoking their  handleEvent() method.  void removeListener(int eventType, Listener listener)            Removes the listener from the collection of listeners who will be notified when an event of the given type occurs. protected   void removeListener(int eventType, org.eclipse.swt.internal.SWTEventListener listener)            Removes the listener from the collection of listeners who will be notified when an event of the given type occurs.  void setData(Object data)            Sets the application defined widget data associated with the receiver to be the argument.  void setData(String key, Object value)            Sets the application defined property of the receiver with the specified name to the given value. Widget Class Hierarchy (3/3) 15 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 16. Widget Class Styles org.eclipse.swt.widgets.Button TOGGLE, ARROW, PUSH, RADIO, CHECK, FLAT,UP, DOWN, LEFT, RIGHT, CENT ER org.eclipse.swt.widgets.Combo DROP_DOWN, READ_ONLY, SIMPLE org.eclipse.swt.widgets.Composite NO_BACKGROUND, NO_FOCUS, NO_REDRAW_RESIZE,NO_MERGE_PAINTS, N O_RADIO_GROUP, EMBEDDED,DOUBLE_BUFFERED, UP org.eclipse.swt.widgets.Group SHADOW_IN, SHADOW_OUT, SHADOW_ETCHED_IN,SHADOW_ETCHED_OUT,  SHADOW_NONE org.eclipse.swt.widgets.Label SEPARATOR, WRAP, SHADOW_IN, SHADOW_OUT,SHADOW_NONE, LEFT, RIG HT, CENTER,HORIZONTAL, VERTICAL org.eclipse.swt.widgets.Menu BAR, DROP_DOWN, POP_UP, NO_RADIO_GROUP,LEFT_TO_RIGHT, RIGHT_TO _LEFT org.eclipse.swt.widgets.MenuItem SEPARATOR, PUSH, RADIO, CHECK, CASCADE org.eclipse.swt.widgets.Sash SMOOTH, HORIZONTAL, VERTICAL org.eclipse.swt.widgets.Scrollable H_SCROLL, V_SCROLL org.eclipse.swt.widgets.Shell TOOL, NO_TRIM, RESIZE, TITLE, CLOSE, MIN, MAX,BORDER, ON_TOP, MODEL ESS, PRIMARY_MODAL,APPLICATION_MODAL, SYSTEM_MODAL org.eclipse.swt.widgets.TabFolder TOP, BOTTOM org.eclipse.swt.widgets.Table CHECK, MULTI, SINGLE, HIDE_SELECTION,FULL_SELECTION, VIRTUAL org.eclipse.swt.widgets.Text MULTI, SINGLE, READ_ONLY, WRAP, SEARCH,PASSWORD, LEFT, RIGHT, CEN TER org.eclipse.swt.widgets.ToolBar WRAP, SHADOW_OUT, FLAT, RIGHT, HORIZONTAL,VERTICAL org.eclipse.swt.widgets.ToolItem DROP_DOWN, SEPARATOR, PUSH, RADIO, CHECK org.eclipse.swt.widgets.Tree CHECK, MULTI, SINGLE, FULL_SELECTION, VIRTUAL SWT Style Bits 16 TIP: not all styles are supported on all platforms. October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 17. ∗ Fonts: ∗ manage operating system resources that define how text looks when it is displayed. Fonts may be constructed by providing a device and either name, size and style information or a FontData object which encapsulates this data. ∗ Colors: ∗ manage the operating system resources that implement SWT's RGB color model. To create a color you can either specify the individual color components as integers in the range 0 to 255 or provide an instance of an RGB. ∗ Images: ∗ graphics which have been prepared for display on a specific device. ∗ If loaded from a file format that supports it, an Image may have transparency. ∗ Images can be also created using SWT Canvas and GC ∗ Supported formats: GIF, JPG, PNG, BMP (Windows) and ICO (Windows) TIP: these resources should be managed by a resource manager that creates them once and destroy them when the application exits. Fonts, Colors, Images 17 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 18. Exercise 18 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 19. 1. JFace Overview 2. Model-View-Controller Concepts a) A simple model 3. Viewers Architecture a) ContentProvider, LabelProvider, DecoratingLabelProvider b) Viewer Sorter and Viewer Filter c) Drag & Drop d) Managing Selection 4. Putting all togheter Agenda 19 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 20. ∗ SWT provides a direct interface to the native platform widgets, but it is limited to using simple data types: ∗ strings, numbers, images, … ∗ This represents a limitation when dealing with object- oriented (OO) data that needs to be presented in lists, tables, trees, and text widgets. ∗ This is where JFace viewers step in to provide OO wrappers around their associated SWT widgets. JFace Overview (1/2) 20 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 21. ∗ JFace allows you to directly use your domain model objects: ∗ No need to manually decompose them into their basic string, numerical, and image elements. ∗ The viewers provide adapter interface for handling domain model object. ∗ Main JFace Viewers ∗ Table Viewer ∗ Tree Viewer ∗ List Viewer ∗ Text Viewer JFace Overview (2/2) 21 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 22. ∗ “Model–view–controller (MVC) is a software architecture pattern which separates the representation of information from the user's interaction with it.” (cit. Wikipedia) ∗ A model is an object representing data or even activity, e.g. a database table or even some plant-floor production-machine process. ∗ A view is some form of visualization of the state of the model. ∗ A controller offers facilities to change the state of the model. Model-View-Controller Concepts 22 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 23. class Model Universe Galaxy Cluster Dark Matter Galaxy Star ClusterNebulae Solar Systems Planets Stars SatellitesAsteroid 0..* 0..* 0..1 1..*1..* 0..* 1..* 1..* 1..* A simple model 23 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 24. ∗ Input element ∗ An input element is the main object that the viewer is displaying (or editing). ∗ A viewer must be able to handle a change of input element. ∗ Content viewers ∗ A content viewer is a viewer that has a well defined protocol for obtaining information from its input element. ∗ Content viewers use two specialized helper classes, the IContentProvider and ILabelProvider, to populate their widget and display information about the input element. ∗ IContentProvider provides basic lifecycle protocol for associating a content provider with an input element and handling a change of input element. More specialized content providers are implemented for different kinds of viewers. ∗ ILabelProvider given the content of a viewer, it can produce the specific UI elements, such as names and icons, that are needed to display the content in the viewer. ∗ A label provider can show more than just text and an image: Viewers Architecture (1/4) 24 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 25. ∗ Filter and Sorter ∗ Filtering and sorting capability is handled by designating a viewer sorter (ViewerSorter) and/or viewer filter (ViewerFilter) for the viewer. ∗ Drag & Drop ∗ Viewers can handle D&D adding user defined classes known as DragSupport and DropSupport ∗ Adding drag support to a viewer means that it enables the user to select any item in the viewer with the mouse, and drag it into another viewer or another application, while the drop support verify if the viewer can accept a dragged element. ∗ A Transfer provides a mechanism for converting between a java representation of data and a platform specific representation of data and vice versa ∗ Managing Selection ∗ Viewers implement ISelectionProvider interface in order to provide selection to other entities Viewers Architecture (2/4) 25 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 26. class JFaceViewers viewers:: AbstractListViewer viewers:: AbstractTableViewer viewers:: AbstractTreeViewer viewers:: CheckboxTableViewer viewers:: CheckboxTreeViewer viewers::ColumnViewer viewers::ContentViewer«interface» v iewers:: IBaseLabelProvider «interface» v iewers:: IContentProvider «interface» v iewers:: IPostSelectionProv ider «interface» v iewers:: ISelectionProv ider v iewers::ListViewer viewers:: StructuredViewer v iewers:: TableTreeViewer v iewers::TableViewer v iewers::TreeViewer viewers::Viewer viewers:: ViewerComparator DropTargetAdapter viewers:: ViewerDropAdapter viewers::ViewerFilter viewers::ViewerSorter -contentProvider -sorter -viewer -labelProvider Viewers Architecture (3/4) 26 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 27. class JFaceProv iders viewers:: ArrayContentProvider EventManager v iewers:: BaseLabelProv ider Viewer viewers:: ContentViewer viewers:: DecoratingLabelProv ider «interface» v iewers:: IBaseLabelProv ider «interface» viewers:: IContentProvider «interface» v iewers:: ILabelDecorator «interface» viewers:: ILabelProvider «interface» viewers:: IStructuredContentProv ider «interface» v iewers:: ITableLabelProv ider «interface» v iewers:: ITreeContentProvider «interface» viewers:: IViewerLabelProv ider v iewers:: LabelProv ider -decorator -instance -labelProvider -contentProvider Viewers Architecture (4/4) 27 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 28. Putting All Together 28 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions
  • 29. ∗ http://www.eclipse.org/swt/widgets/ ∗ http://www.java2s.com/Tutorial/Java/0280__SWT/Catalog0280_ _SWT.htm ∗ http://wiki.eclipse.org/JFace References 29 October 2013Copyright © 2013 Luca D’Onofrio – RCP Solutions