Table of Contents
preface xv
acknowledgments xvi
about this book xviii
about the authors xxiii
about the title xxiv
about the cover illustration xxv
1 Overview of SWT and JFace 1
1.1 What is SWT/JFace? 2
- Building GUIs with SWT 3, Simplifying GUI development with JFace 3
1.2 Looking under the hood 4
- The old standby: Swing 4, The newcomer: SWT/JFace 6, The SWT/Swing debate 9
1.3 SWT/JFace: licensing and platform support 9
- The Common Public License 9, Platforms supported 9
1.4 The WidgetWindow 11
1.5 Summary 12
2 Getting started with SWT and JFace 13
2.1 Programming in SWT 14
- The HelloSWT program 14, The Display class 16, The Shell class 18
2.2 Programming in SWT/JFace 20
- Model-based adapters 20, The HelloSWT_JFace program 21, Coding in JFace and SWT/JFace 23, The ApplicationWindow class 23
2.3 Beginning the WidgetWindow application 24
2.4 Summary 26
3 Widgets: part 1 27
3.1 Introducing the Widget and Control classes 28
- Understanding the Widget class 28, Working with Control objects 30
3.2 Labels 32
- Styles and separators 33, Label methods 33
3.3 Involving the user with buttons 34
- Causing action with push buttons and SWT.PUSH 34, Moving on with arrow buttons and SWT.ARROW 35, Changing state with toggle buttons and SWT.TOGGLE 35, Choosing with check buttons and SWT.CHECK 36, Making a single choice with
radio buttons and SWT.RADIO 36
3.4 Containing components with Composites 38
- Understanding the Composite class 39, Groups 40, SashForms 43, TabFolders 44
3.5 Updating WidgetWindow 45
- Creating the Ch3_Composite class 45, Creating the WidgetWindow TabFolder 46
3.6 Summary 47
4 Working with events 48
4.1 Event processing in SWT 49
- Using typed listeners and events 50, Adapters 54, Keyboard events 55, Customizing event processing with untyped events 58, An SWT listener/event application 60
4.2 Event processing in JFace 62
- Understanding actions and contributions 63, Creating Action classes 65, Implementing contributions in an ApplicationWindow 66, Interfacing with contributions 69, Exploring the Action class 70
4.3 Updating the WidgetWindow 74
- Building the chapter 4 Composite 74 n Adding Ch4_Composite to the WidgetWindow 75
4.4 Summary 77
5 More widgets 78
5.1 Editing text with SWT 79
- The basic Text widget 79, The StyledText widget 82
5.2 JFace text support 88
- Obtaining the JFace text packages 88, TextViewer and Document 89, A JFace example 91
5.3 The Combo widget 100
5.4 ToolBarManager 101
- ControlContribution 102, Creating toolbars by hand 103
5.5 CoolBar 103
5.6 Slider 105
5.7 ProgressBar 106
5.8 ProgressIndicator 107
5.9 Summary 108
6 Layouts 109
6.1 The fill layout 110
6.2 The row layout 112
- Customizing individual layout cells 114
6.3 The grid layout 116
- GridData 117
6.4 The form layout 119
- Using FormData 120, Specifying relations using, FormAttachment 120, Laying out controls using a form layout 122
6.5 Custom layouts 124
- Calculating the layout?s size 125, Laying out the widgets 126, Updating WidgetWindow 128
6.6 Summary 132
7 Graphics 133
7.1 The graphic context 134
- Creating a GC object 134, Drawing shapes on a Canvas 136, Painting and PaintEvents 138, Clipping and Canvas styles 139
7.2 Programming with colors 140
- Color development with SWT 140, Additional color capability with JFace 144
7.3 Displaying text with fonts 145
- Using fonts with SWT 145, Coding with fonts 148, Improved font management with JFace 150
7.4 Incorporating images in graphics 152
- Allocating images 152, Coding graphics with images 154, Creating a bitmap with ImageData 155, Manipulating images with ImageData 159, Managing images with JFace 163
7.5 Updating the WidgetWindow 164
- Building the chapter 7 composite 164, Adding Ch7_Composite to the WidgetWindow 165
7.6 Summary 166
8 Working with trees and lists 167
8.1 Viewers and the Viewer framework 168
- Providers 170, Listeners 172, Filters and sorters 173
8.2 Trees 176
- SWT trees 176, JFace TreeViewers 177
8.3 Using the List widget 180
- SWT lists 180, JFace ListViewers 181
8.4 Updating WidgetWindow 182
8.5 Summary 189
9 Tables and menus 190
9.1 Tables 191
- Understanding SWT tables 191, JFace TableViewers 194
9.2 Creating menus 200
- Accelerator keys 201, Creating menus in SWT 201, Using JFace actions to add to menus 204
9.3 Updating WidgetWindow 205
9.4 Summary 211
10 Dialogs 212
10.1 SWT dialogs 213
- ColorDialog 213, DirectoryDialog 214, FileDialog 215, FontDialog 216, MessageBox 216
10.2 JFace dialogs 218
- Message dialogs 219, Error dialogs 220, Input dialogs 222, Progress monitor dialogs 224, Custom dialogs 228
10.3 Updating WidgetWindow 230
10.4 Summary 233
11 Wizards 234
11.1 Multipage dialogs 236
- IDialogPage 236, IWizardPage 237, WizardPage 237
11.2 The wizard 239
- IWizard 239, Wizard 240
11.3 Putting it all together 241
- Wizard containers 241, WizardDialog 242
11.4 Combining wizards 243
- WizardSelectionPage 243, IWizardNode 244
11.5 Persistent wizard data 244
- DialogSettings 245
11.6 Updating WidgetWindow 246
11.7 Summary 252
12 Advanced features 253
12.1 Transferring data 254
- The Transfer class 255, Drag-and-drop capability 256, Using the clipboard 261, The filesystem browser 262
12.2 Preferences 268
- Preference pages 268, Field editors 270, Preference page containers 273, Persistent preferences 274
12.3 Label decorators 276
- ILabelDecorator 276, DecoratingLabelProvider 277, An example 277
12.4 The Browser widget 280
12.5 Summary 283
13 Looking beyond SWT/JFace: the Rich Client Platform 284
13.1 Understanding RCP workbenches 285
- Entering data with editors 285, Displaying information with views 287, Combining editors and views with perspectives 288
13.2 RCP: Looking under the hood 288
- Creating and configuring an RCP project 288, Building the application class 290, Adding a WorkbenchAdvisor 291
13.3 Adding views and perspectives 294
- Building views 294, Arranging workbench windows with a perspective 295, Executing an RCP application 296, Reviewing the RCP process 297
13.4 Populating forms with Eclipse Forms widgets 299
- Using FormToolkit and the Eclipse Forms containers 299, Firing text-based events with Hyperlinks 302
13.5 Building a standalone RCP application 306
- Exporting RCPExample to an application directory 306, Adding plug-ins to the application directory 307, Executing the application 308
13.6 Summary 308
appendix A Creating projects with SWT/JFace 311
appendix B OLE and ActiveX in SWT/JFace 324
appendix C Changeable GUIs with Draw2D 362
appendix D The Graphical Editing Framework (GEF) 388
index 461