16
Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Embed Size (px)

Citation preview

Page 1: Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Copyright © IBM Corp., 2008. All rights reserved.

Plastic Surgery For Eclipse: Custom SWT Widgets, RCP

Customization, and more

Benjamin Pasero

Page 2: Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, And More | Copyright © IBM Corp., 2008. All rights reserved.

Goal for Today: Pimping the Mail Template

First Part

Custom SWT Widgets

Custom Owner Drawn using latest 3.4 API

Rich Tooltips with JFace

Second Part

Custom Presentation

Product Transformation

Custom Splash Handler

Page 3: Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, And More | Copyright © IBM Corp., 2008. All rights reserved.

Setup Eclipse 3.4 and the Mail Template

Make sure to use Eclipse 3.4 M5

Create a new Plug-in Project

From the Templates choose RCP Mail Template

Open the plugin.xml

Execute Launch an Eclipse application

The UI is nice, but we can do better!

Page 4: Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, And More | Copyright © IBM Corp., 2008. All rights reserved.

Using the PShelf Widget from Nebula

The Nebula Project: http://www.eclipse.org/nebula/

Official source for custom SWT Widgets

Examples

Grid

Gallery

GanttChart

PShelf

CDateTime

Page 5: Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, And More | Copyright © IBM Corp., 2008. All rights reserved.

Writing our own Custom Widget

SWT:Two strategies

Custom Widget by extending Canvas

Custom Compound Widget by extending Composite

Goal: Simple Link Widget that supports Image and Text

Features

Looks and behaves like a real link

Listener for handling selection

Keyboard Accessibility

Page 6: Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, And More | Copyright © IBM Corp., 2008. All rights reserved.

Custom Owner Drawn Inbox

New JFace-API in Eclipse 3.4: SimpleStyledCellLabelProvider

Use it to have mixed styles per Table- or Treeitem

Hides complexity of custom owner drawn

Mixed fonts not yet supported

We want to draw the number of unread Mails

Using a different Color

We want to highlight Folders

Using an Underline

Page 7: Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, And More | Copyright © IBM Corp., 2008. All rights reserved.

Rich Tooltips using JFace

JFace makes it easy to add rich tooltips to Viewers

CellLabelProvider provides API to define the custom Tooltip

Text and Image

Foreground and Background color

We want to preview a Mail by using a rich tooltip:

Page 8: Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, And More | Copyright © IBM Corp., 2008. All rights reserved.

Custom Mail Presentation: Large and In Charge

Presentations allow to make our RCP app not look like Eclipse

Eclipse offers extension points to add our own Presentation

org.eclipse.ui.presentationFactories

org.eclipse.ui.themes

Goal for our Presentation

Large Round Tabs

Close Button will be a red Arc

Foundation for our Product Transformation with large Icons

Page 9: Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, And More | Copyright © IBM Corp., 2008. All rights reserved.

Page 10: Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, And More | Copyright © IBM Corp., 2008. All rights reserved.

Product Transforms

Presentations allow for extreme customization

but some things are beyond their reach

Themes can allow for an additional axis of customization

but they don't cover images

Time to break out the chainsaw and apply some product transforms

Remove/modify extensions from plugins outside of your control

Swap in new icon sets

Help available: http://wiki.eclipse.org/Equinox_Transforms

Page 11: Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, And More | Copyright © IBM Corp., 2008. All rights reserved.

Our Mail Transformation in a Nutshell

We register a framework extension that OSGI loads on startup

org.eclipse.equinox.transforms.hook

We register a Service for the transformation with some properties

Use the ReplaceTransformer

Use transform.csv for the replacement

We ensure early startup using a custom config.ini for

org.mailtemplate.transform

org.eclipse.equinox.transforms.replace

Page 12: Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, And More | Copyright © IBM Corp., 2008. All rights reserved.

Custom Splash Screen

Using the org.eclipse.ui.splashHandlers Extension Point

Getting full control of the Shell that is used for the Splash on startup

Let’s have a look at the available templates

Adding product images

Simulated session log-in

Embedded Browser (?)

Page 13: Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, And More | Copyright © IBM Corp., 2008. All rights reserved.

Pointers & References

Eclipse Corner Articles: http://www.eclipse.org/articles/

Eclipse Wiki: http://wiki.eclipse.org

Eclipse SWT

Snippets: http://www.eclipse.org/swt/snippets/

Examples: http://www.eclipse.org/swt/examples.php

Community: http://www.eclipse.org/swt/community.php

The Nebula Project

http://www.eclipse.org/nebula/

Page 14: Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, And More | Copyright © IBM Corp., 2008. All rights reserved.

Thanks for listening and attending!

E-Mail: [email protected]

Page 15: Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, And More | Copyright © IBM Corp., 2008. All rights reserved.

Legal Notices (1/2)

Copyright © IBM Corp., 2008. All rights reserved.  This presentation is licensed under Creative Commons Att. Nc Nd 2.5 license.

IBM and the IBM logo are trademarks or registered trademarks of IBM

Corporation, in the United States, other countries or both.

Java and all Java-based marks, among others, are trademarks or registered

trademarks of Sun Microsystems in the United States, other countries or both.

OSGi is a trademark or registered trademark of the OSGi Alliance in the United

States and other countries.

Eclipse and the Eclipse logo are trademarks of Eclipse Foundation, Inc.

Other company, product and service names may be trademarks or service

marks of others.

Page 16: Copyright © IBM Corp., 2008. All rights reserved. Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, and more Benjamin Pasero

Plastic Surgery For Eclipse: Custom SWT Widgets, RCP Customization, And More | Copyright © IBM Corp., 2008. All rights reserved.

Legal Notices (2/2)

THE INFORMATION DISCUSSED IN THIS PRESENTATION IS PROVIDED FOR INFORMATIONAL PURPOSES ONLY.  WHILE EFFORTS WERE MADE TO VERIFY THE COMPLETENESS AND ACCURACY OF THE INFORMATION, IT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, AND IBM SHALL NOT BE RESPONSIBLE FOR ANY DAMAGES ARISING OUT OF THE USE OF, OR OTHERWISE RELATED TO, SUCH INFORMATION.  ANY INFORMATION CONCERNING IBM'S PRODUCT PLANS OR STRATEGY IS SUBJECT TO CHANGE BY IBM WITHOUT NOTICE.