Download Making the most of Eclipse

Document related concepts
no text concepts found
Transcript
Presented by IBM developerWorks
ibm.com/developerWorks
Making the
most of
Doug Tidwell, Eric Long & Akmal Chaudhri
IBM Developer Relations
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Agenda
•
•
•
•
•
•
•
•
T18.2
An introduction to Eclipse
Installing and running Eclipse
The Eclipse Java Development Tools
The Eclipse debugger
Extending Eclipse with plug-ins
The Web Tools Platform
Creating Eclipse plug-ins
Eclipse resources
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
An overview of Eclipse
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
What we'll cover
•
•
•
•
T18.4
Eclipse and The Eclipse Foundation
Eclipse architecture
Major Eclipse projects
Eclipse in the marketplace
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Eclipse and
The Eclipse Foundation
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
What is Eclipse?
• A technology platform – originally an IDE, now can be
anything (see the Eclipse Rich Client Platform)
• An open source project –
The Eclipse Public License
is OSI certified.
T18.6
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
What is Eclipse?
• A community – The most vital part of the platform.
– Hundreds of companies and thousands of programmers are
working to improve and extend it all the time.
• See eclipse.org/community.
T18.7
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Eclipse Foundation
• Launched by IBM in November 2001
• Originally led by Borland, IBM, Merant, QNX,
Rational and others
• Today dozens of vendors participate,
including Intel, BEA, Oracle, HP, SAP, Hitachi,
Telelogic and Ericsson.
• The Eclipse Foundation is non-profit and not
controlled by IBM.
– The current head of the foundation is from Oracle,
for example.
T18.8
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Eclipse Foundation
• There are four levels of membership in
The Eclipse Foundation:
– Strategic members – Contribute developers and
financial resources
– Add-in provider members – Participate in Eclipse
development
– Associate members – Non-profit orgs,
universities, standards bodies and so forth; want to
participate in Eclipse development
– Committer members – Individuals who are core
developers and can commit changes to the source
code
T18.9
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Strategic members (developers)
T18.10
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Strategic members (consumers)
T18.11
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
[Some of the] other members…
T18.12
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Eclipse architecture
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Eclipse architecture
Rich Client
Platform
applications
RCP app
Development
tools
Eclipse plug-in
development
CDT
…
ATF
TPTP
BIRT
WTP
EMF
GEF
JDT
PDE
Platform
T18.14
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Eclipse architecture
Platform
Release
engineering
Platform
text
T18.15
Platform
UI
CVS
SWT
Compare
Platform
resources
Team
Search
Ant
Platform
runtime
Help
Update
Platform
debug
Making the most of
Platform
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Eclipse architecture
C++
plug-in
Workbench
Help
System
Workspace
Team
Components
Modeling
plug-in
GUI builder
plug-in
T18.16
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Eclipse projects
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Eclipse projects
• Eclipse project (the core platform)
– Provide the base Eclipse platform, not just an IDE
anymore
• Eclipse Tools project
– Coordinates groups building world-class tools for
Eclipse, also provides input for Eclipse future
directions
• Eclipse Technology project
– Research, incubation and education
• Java Development Tools (JDT) project
– The original focus of the IDE
T18.18
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Eclipse projects
• Web Tools Platform (WTP) project
– "Generic, extensible and standards-based" tools
for the Web + Java EE
• Data Tools Platform (DTP) project
– “Generic, extensible and standards-based” tools
for databases
• Ajax Tools Framework (ATF) project
– An open, extensible framework
• Test and Performance Tools Platform project
(TPTP)
– World-class testing and performance tools
T18.19
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Eclipse projects
• The Eclipse Modeling Project
– Integrates several model-based frameworks and
technologies:
•
•
•
•
•
The Eclipse Modeling Framework (EMF)
The Graphical Editing Framework (GEF)
UML2
Object Constraint Language (OCL)
XML Schema Infoset Modeling
• The C Development Tools (CDT) project
– Provide C/C++ tools that are as complete as the
Java tools
T18.20
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Eclipse projects
• Business Intelligence and Reporting Tools
project (BIRT)
– Lots of applications need reporting functions. The
BIRT project intends to provide a complete suite of
reporting tools and frameworks.
• ECESIS
– Open-source courseware, including slides, lab
exercises and solutions.
T18.21
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Eclipse in the marketplace
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Eclipse is valuable…
• …to users, because:
– All Eclipse-based tools work the same way
– Hundreds of plug-ins are available to extend
Eclipse
• …to ISVs, because:
– They don't have to write an enormous amount of
code (editors, debuggers, and so forth)
– Their work fits in to an established, rapidly growing
platform
– They can combine their work with other Eclipse
plug-ins to create custom solutions
T18.23
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Case study: NASA
• "Among the reasons for using open source
software is the philosophical idea that
spending taxpayer money to do things that
have already been done is just not
justifiable. Many development groups within
NASA … are being paid by the taxpayers to
do space exploration and that’s where the
money should be spent."
• From the case study NASA Uses Eclipse for
Interplanetary Operations, available at
eclipse.org/community/casestudies.
T18.24
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Eclipse by the numbers
• Tens of millions of downloads
• More than 1 million users in more than 125
countries
• More than 1,000 plug-ins at
eclipseplugincentral.com
• More than 950 Eclipse-related projects at
SourceForge
• Hundreds of articles on Eclipse at
developerWorks, eclipse.org and elsewhere
T18.25
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Eclipse books
T18.26
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The dominant development platform
• "Can anybody ignore Eclipse? No … maybe
Microsoft."
– Carl Zetie, Forrester analyst
• "The game is not over, but when we think of
developer ecosystems other than Visual
Studio we think Eclipse. We don't think
NetBeans."
– A Microsoft spokesperson at EclipseCon 2005
• From
T18.27
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Industry awards
• developer.com –
Development Tool of the Year 2006
• Java Developer's Journal Readers' Choice
Awards 2005
–
–
–
–
–
Best Java Application
Best Team Development Tool
Most Innovative Java Product
Best Java Class Library (Eclipse SWT)
Best Java Debugging Tool
• Software Development magazine
–Best Open Source Tool
T18.28
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Industry awards
• SD Times – Best in Category,
Tools and Environments 2005
• Jolt Awards 2005 – Product
Excellence Award for Languages
and Development Environments
• eclipse.org/community/awards.php
lists many other awards…
T18.29
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Summary
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Summary
• Eclipse has evolved from a base for building
developer tools into a general-purpose
framework.
• IBM created the Eclipse Foundation, but
doesn't have any more rights than any other
Strategic member.
• IBM and dozens of other vendors provide
hundreds of Eclipse-based products.
• Eclipse has more industry support
(downloads, products, users, books, etc.) than
any other tools platform.
T18.31
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The bottom line:
Eclipse is a great platform by itself,
but the Eclipse community is why
you should use it.
T18.32
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Installing and running Eclipse
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
What we'll cover
• Installing Eclipse
• Running Eclipse
• Eclipse terms and concepts: Perspectives,
views, editors and other useful things
• Other IDE functions
T18.34
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Installing Eclipse
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Installing Eclipse
• Installing Eclipse is very simple. To get started, go to
eclipse.org and click the Downloads link.
T18.36
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Installing Eclipse
• Download the Eclipse SDK.
– Currently the file name is
eclipse-SDK-3.2-win32.zip (for Windows)
– This file contains everything from Eclipse,
including the Eclipse platform and the SDK.
– Download the file (use a mirror if you can) and
unzip it.
– You're done!
• There are instructions on the Eclipse download page if
you need them.
T18.37
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Java Runtime Environment
• Because Eclipse is written in Java, you have
to have a Java Runtime Environment (JRE)
on your machine.
– A JRE isn't included with Eclipse itself.
• eclipse.org lists sites with JREs available
if you need one.
– The Eclipse Foundation wisely doesn't recommend
any particular JRE.
• JRE 1.5.0_02 works well, although you can
have multiple JREs/JDKs installed on your
machine and switch between them in Eclipse.
T18.38
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Running Eclipse
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Running Eclipse
• Now that you've installed Eclipse, use the
eclipse command to run it:
T18.40
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Performance tip
• If Eclipse runs slowly, try adding this switch to
the command line or shortcut:
eclipse –vmargs –Xms256M
• This starts the Java virtual machine with
256MB of RAM.
• Eclipse loads plug-ins only when you need
them, but it can start to slow down if you use
lots of tools.
– This tip is particularly helpful on Windows
platforms.
T18.41
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Eclipse terms and concepts
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Eclipse terms and concepts
•
•
•
•
•
•
T18.43
Workspace
Workbench
Perspectives
Views
Editors
Preferences
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Workspace
• The workspace is a physical location on your
machine.
– It contains projects, folders, and files.
– A project is a collection of folders and files for a
particular task.
– A folder is a subdirectory; it can contain folders
and other files.
– A file is just a file.
• In other words, a workspace is just a
directory.
T18.44
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Choosing a workspace
• The first time you run Eclipse, you'll be asked to
choose a workspace.
• You can also create different workspaces…
– To open Eclipse in a particular workspace, type
eclipse –data c:\workspace.
T18.45
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Using different workspaces
• You can create shortcuts for different workspaces and
launch those workspaces easily.
T18.46
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Switching workspaces
• You can use the Switch Workspace… item on the
File menu to change workspaces.
• You can change to another workspace without
restarting Eclipse.
T18.47
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Workbench
• The workbench is the Eclipse environment.
– When you open Eclipse, you see a workbench that
displays the resources in a particular workspace.
– A workbench contains perspectives, views, and
editors.
T18.48
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The workbench
T18.49
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Perspectives
• A perspective is a set of views organized for a
particular task.
– If you're writing Java code, certain views are useful.
– If you're debugging Java code, other views are useful.
– A perspective lets you arrange the views you need.
• Eclipse comes with several perspectives installed.
T18.50
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Perspectives
• As you install plug-ins for various tasks, other
perspectives may appear.
– The dialog on the left lists the perspectives shipped with the
basic Eclipse SDK.
– The dialog on the right is from IBM's WebSphere Business
Integration Modeler, an Eclipse-based product with many
advanced features.
T18.51
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Customizing perspectives
• You can customize a
perspective in many ways:
– You can change the views
that are part of a perspective
– You can change how those
views are arranged on the
screen
• If you use the Customize
Perspective… menu item,
you can define which menu
items and toolbar buttons are
available for a given
perspective.
T18.52
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Customizing perspectives
T18.53
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Saving perspectives
• When you have the
views and toolbars and
everything else
arranged the way you
want, you can save that
as your own
perspective.
• You can overwrite
existing perspectives if
you want.
T18.54
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Views
• A view is a window on some resources in your
workspace.
– One view might list all the files in your workspace
– Another view might list all the Java classes in a
JAR file.
• You can open and close and arrange views
any way you like.
• Two views might display the same thing in
different ways.
T18.55
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Two views of the same file
T18.56
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Opening views
• The Window Show
View menu lets you
open a view at any time.
• Click the Other… item
to see a complete list of
views.
T18.57
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Moving and stacking views
• To move a view, click and drag its tab. If more than
one view is in the same space, they'll be stacked.
• The Problems, Javadoc, Declaration and Console
views are stacked here.
T18.58
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Fast views
• A fast view has an icon; you can click on that icon to
go directly to the view.
• To create one, choose Fast View from the view's
menu.
T18.59
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Preferences
• Eclipse has a number of preferences you can
set.
• Whenever you install a plug-in, that plug-in
can have preferences also.
– As a result, your Eclipse installation can have
literally hundreds of settings.
• Choose WindowPreferences to get to the
Preferences dialog.
• You can change just about everything.
T18.60
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Preferences
T18.61
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Preferences
• If you have more than one Java Runtime Environment
installed on your machine, you can tell Eclipse which
one to use.
• You can add new environments or change the default
any time you want.
T18.62
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Editors
• An editor allows you to modify a resource. There are
different kinds of editors for different kinds of
resources, as you'd expect.
• Like all views, editors can be stacked. The asterisk
next to the file name above means that
HelloWorld.java has been changed.
T18.63
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Java editor
T18.64
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Other IDE functions
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Other IDE functions
• In addition to the editors themselves, Eclipse has
several useful features for working with files.
T18.66
–
–
–
–
–
Searching
Bookmarking
Tasks
Local history
File comparison (think "visual diff")
–
–
–
–
–
Import/export
Team functions (CVS)
File manipulation (navigation, cut/copy/paste)
Properties
Help
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Searching
• Eclipse has a very sophisticated search
facility.
• You can search through:
–
–
–
–
Files
The help system
Java source
Plug-ins
• There are special search options for each
kind of search.
T18.67
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Searching
T18.68
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Searching
• The results of the search show up in the Search view.
You can double-click on a match and go directly to
that file.
• There are toolbar buttons in the Search view; these
let you move through the search results.
– There will be different buttons depending on the kind of
search.
T18.69
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Bookmarking
• You can create a bookmark in a file and go directly to
that spot whenever you want.
• To create a bookmark, right-click in the gray area on
the left-hand side of the editor. You'll be asked to give
the bookmark a name; that's how you reference it
later.
T18.70
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Bookmarking
• All your bookmarks are listed in the Bookmarks view.
• Notice that the bookmarks here are in different
projects, and that not all of them are in Java files.
• You can set a bookmark wherever you want.
T18.71
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Tasks
• You can create tasks throughout your project.
– It's a way of building a to-do list.
• You can associate a task with a line in a file ("add
better error checking here") or create a more general
task ("set up an Ant script to automatically regenerate
the Javadoc").
T18.72
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Tasks
• The first task here is a generic task that applies to the
workspace.
• The second is a specific task that applies to a
particular line in a particular file.
• As with bookmarks, you can create a task for any line
in any file.
T18.73
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Local history
• Each time you save a
file, Eclipse creates a
new version.
• You can compare
versions later; you can
even restore deleted
files later.
• Think of local history as
a mini version control
system…
T18.74
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Comparing files
• Highlight any two files and
select Compare With 
Each Other from the
context menu
• Differences are shown
visually
• Move information from one
file to another:
– Entire file
– Current change
• Select next or previous
change
T18.75
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Import/export
• Eclipse supports many different ways to
import and export resources.
– You can import an existing project from another
workspace
– You can import or export a zip file, a JAR archive,
an EAR file, etc.
• You can also drag and drop files from the
operating system into the Eclipse
environment.
– Dragging and dropping files from Eclipse into
operating system containers (Windows Explorer,
for example) also works.
T18.76
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Navigating resources
• The Navigate menu has
many ways to find and view
your resources.
– Go Into
• Also available from
context menu
• Go backwards and
forwards using the arrow
icons
• At lower levels the view
includes the name of a
folder or file
– GoTo
• Start typing the name of
the resource to limit the
choice
• All other resources are
hidden
T18.77
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Copying, moving, renaming
• Copying and moving resources:
– Use the command from the context menu, or
– Drag and drop the resource
• Copy by holding the Ctrl key as you drag
– The Ctrl+X, Ctrl+C and Ctrl+V combinations work
most of the time as well (depends on the view)
• Renaming is part of Eclipse's refactoring
support.
T18.78
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Properties
• All resources have
properties
– The Properties view gives
basic information on the
resource
– The Properties dialog
(right-click the resource
and select Properties)
gives much more detailed
info
– Some resources have
more properties than
others.
T18.79
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Team functions
• Eclipse has built-in support for versioning,
configuration management and interacting
with code repositories such as CVS.
– There is an open source plug-in for Subversion as
well.
• Eclipse also supports FTP and WebDAV.
• As with everything in the world of Eclipse,
many groups (including IBM) have taken
these basic functions and extended them.
T18.80
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Help is on the way
• Eclipse's help system is very sophisticated.
Choose HelpHelp Contents to see it.
• You can view help topics from a list, or you
can search for what you need.
• When you install a plug-in, its help information
is integrated with everything else in the
platform.
– You can create a plug-in that does nothing more
than add information to the help system.
T18.81
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Help
T18.82
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Summary
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Summary
• We've looked at the basics of installing and
running Eclipse.
– We also discussed the basic terminology of
Eclipse, such as perspectives, views, editors and
so forth.
• Eclipse is extremely customizable, so you can
make the tool work however you think best.
• Eclipse also gives you very powerful editing
tools to help you manage your code and
documents.
T18.84
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Eclipse Java
Development Tools (JDT)
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
What we'll cover here
•
•
•
•
T18.86
The JDT environment
Creating and running a program
Scrapbook pages
Using JUnit, Ant and javadoc
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
The JDT environment
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The JDT environment
• A set of tools for writing, compiling, testing, and debugging Java
code.
– Note: Compiling happens automatically whenever you save
your code. It's not a separate step.
• The Eclipse SDK includes the Java tools. See
eclipse.org/jdt if you want to learn more about the project.
T18.88
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
JDT perspectives
• The most useful
perspectives for Java
development are Java
and Debug.
– There are also the Java
Browsing and Java Type
Hierarchy perspectives.
• We'll look at the Java
perspective now; we'll
cover the Eclipse
Debugger later.
T18.89
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Java perspective
Class hierarchy
T18.90
Making the most of
Syntax-aware
Java editor
Class outline
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Java editor
• As you'd expect from a world-class IDE,
Eclipse has a color-coded Java editor.
• As you type, it automatically highlights the
Java syntax and indents your code.
• If there are errors, they're indicated when you
save the file (if not before).
T18.91
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Java editor
T18.92
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Code assist
• If you type Ctrl+Space, Eclipse shows you the relevant method
signatures and the javadoc for each.
• This works for code you write as well as the standard Java
libraries.
• You don't have to run javadoc against your code for this to
work. The documentation above comes from the comment in
the source code.
T18.93
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Quick fix
• For many common problems,
Eclipse can offer fixes for
you.
– If a package statement
doesn't match a .java
file's location, Eclipse will
move the file or update the
package statement.
– If you're missing an
import statement, Eclipse
can automatically add it.
• If a Quick Fix is available, the
red X will have a light bulb
icon behind it.
T18.94
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Organize imports
• If you use a Java class
without a corresponding
import statement, Eclipse will
add them for you
automatically.
• By default Eclipse imports
java.io.OutputStream
instead of java.io.*.
• If you remove all instances of
a class and invoke Organize
Imports again, Eclipse
removes the import
statements you don't need.
T18.95
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Code refactoring
• Eclipse has very powerful code refactoring features.
– You can move a class up or down in the class hierarchy.
– You can rename a field and its associated get and set
methods
– You can move a class to another package…
T18.96
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Globalization
• Eclipse has an
"Externalize Strings"
function that helps you
manage translation or
localization of your
projects.
T18.97
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Creating and running Java
programs
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Creating and running Java programs
• It's a short process:
1.Create a Java project
2.Create a Java package
3.Create a Java class in that package
4.Run your code
– [You may need to set up a run configuration first…]
T18.99
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Creating a Java project
• Start with FileNew
Project…
• Choose Java Project,
give it a name and click
Finish.
T18.100
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Creating a Java package
• To create a Java package, right-click on your new
project in the Package Explorer, then choose
NewPackage.
T18.101
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Creating a Java package
• Enter a name for your
package.
• If you break Java style
rules (maybe your
package begins with an
uppercase letter),
Eclipse reminds you.
T18.102
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Creating a Java package
• Your new package appears in the Package Explorer
view beneath your project.
T18.103
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Creating a Java class
• To create a Java class, right-click on your new
package in the Package Explorer, then choose
NewClass.
T18.104
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Creating a Java class
• Enter a name for your
class.
• Eclipse reminds you of
style rules here as well.
• You can set the details
of your class, including
its superclasses,
visibility and interfaces.
T18.105
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Creating a Java class
• Your new class appears in the Package Explorer
beneath your package.
• Eclipse also opens the source file for your class in the
Java editor.
T18.106
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
A shortcut
• You can create a new
package and a new
class at the same time.
• Simply create a new
class and enter a new
package name while
you're in the wizard.
T18.107
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Running your code
• To run your code, rightclick on the Java file,
then choose Run
AsJava Application.
T18.108
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Running your code
• Because this is a console application (it uses
System.out.println), you'll see the output in the Console
view.
– By default, System.out is displayed in black, System.err is
displayed in red and System.in shows up in green.
• If the Console doesn't appear, you can open it through
WindowShow View…
T18.109
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Re-running your code
• Once you've run your
code, you can click Run
Last Launched
(Ctrl+F11) to run it
again.
• Your program's name
also appears in the Run
History menu.
T18.110
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Creating a run configuration
• If you need to set
command-line
arguments, JVM
parameters, etc., you
need to create a Run
configuration.
• Select your class in the
Package Explorer, then
choose RunRun…
– Click "Java Application"
in the list on the left to get
started.
T18.111
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Creating a run configuration
• This run configuration
sets the language and
country code for the
JVM.
• You can also set the
classpath, command
line arguments and
other details.
T18.112
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Scrapbook pages
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Scrapbook pages
• You can create a
scrapbook page with
the Java tools. A
scrapbook page lets you
enter and execute lines
of Java code without
building a class to hold
them.
• The wizard to create a
new scrapbook page is
under New
JavaJava
Run/Debug.
T18.114
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Scrapbook pages
• You can highlight some code, right-click on it, then
choose Inspect, Display or Execute.
• The code we're entering is System.out.println
("Here's the value of PI: " + Math.PI);
– Content assist appears when we type "Math."
T18.115
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Scrapbook pages
• If you highlight the code, right-click it and choose
Execute, you'll see these results in the Console view.
T18.116
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Scrapbook pages
• If you choose Inspect,
the scrapbook page
shows you the value of
whatever you've
highlighted.
– In this example, we've
only highlighted
Math.PI, not the whole
line of code.
• Display inserts the value
of whatever you've
highlighted.
T18.117
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Using JUnit, Ant and javadoc
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Using JUnit
• JUnit was created by programming legends
Kent Beck and Erich Gamma.
• It makes it easy to implement Test-Driven
Development (TDD), (sometimes called Test
First Development).
• Eclipse has JUnit support built in.
– JUnit 3.8.1 has been in Eclipse for quite a while;
JUnit 4 support was added in Version 3.2.
T18.119
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Creating a test case
• Right-click on a Java file
and choose
NewJUnit Test Case.
T18.120
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Creating a test case
• When you create a
JUnit test case, you
name the test case (the
test case is a Java
class).
• You also specify the
class you'll be testing.
• The JUnit JAR file is not
on the project's
classpath; click the link
at the bottom of the
panel to add it.
T18.121
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Creating a test case
• As you create your test
case, Eclipse's JUnit
support shows you a list
of all the methods you
can test.
– This includes methods of
the class you're testing
and all the methods of its
superclasses.
T18.122
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Creating a test case
• In this example, we ask Eclipse to generate a
JUnit TestCase for the getGreeting()
method.
• The complete testGetGreeting() method
is:
public void testGetGreeting() {
HelloWorld hw = new HelloWorld();
assertEquals("Hello, World!",
hw.getGreeting());
}
• We're saying that getGreeting() should
always return the string "Hello, World!"
T18.123
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Running a test case
• Our test case is the Java class TestHelloWorld.
• To run the class, select the test class in the Package
Explorer, then choose Run AsJUnit Test.
T18.124
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Running a test case
• The results of running
your test case appear in
the JUnit view.
– Green is good…
• You can also create and
run JUnit TestSuites.
A TestSuite is an
ordered collection of
TestCases.
• Run your test cases
early and often…
T18.125
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Using Ant
• Ant (ant.apache.org) is an XML- and
Java-based build tool.
– Designed to have the same functionality as make
without its [many, many, many] quirks.
– You can extend Ant to do other tasks if you want.
• An Ant build file (named build.xml by
default) can define a number of targets.
• You can define which target gets built from the
command line (or the Eclipse equivalent), or
let Ant figure out which one should be
created.
T18.126
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Using Ant
• Once you've created
your build.xml file (or
whatever you choose to
call it), you can rightclick on it and choose
Run Ant…
T18.127
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Using javadoc
• You can export your
project to javadoc.
• When you do this,
Eclipse runs javadoc
against your code and
exports the generated
files to the directory you
choose.
T18.128
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Using javadoc
• When you generate the
javadocs, you specify
which packages and
classes should be
processed.
• You can also decide
which class members
are processed (public,
protected, private)
T18.129
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Using javadoc
• You can customize the
files that are generated,
such as index pages or
navigation bars.
• If you want, you can
create links to the
standard Java libraries.
T18.130
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Using javadoc
• The generated
documentation is put in
the doc folder of your
project by default.
T18.131
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Summary
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Summary
• We've covered (although very quickly) the
Java development functions in Eclipse,
including:
–
–
–
–
–
T18.133
Various automatic coding features
How to create and run Java code
Using scrapbook pages
Automating testing with JUnit
Using ant and javadoc inside Eclipse
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
The Eclipse debugger
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
What we'll cover here
• Using the debugger:
–
–
–
–
Starting the debugger
Setting breakpoints
Stepping through the code
Inspecting variables and expressions
• Hot code replace
– Note: We'll talk about these features briefly in
the first section, then demonstrate them in the
second.
T18.135
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Using the debugger
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Eclipse debugger
• The Eclipse Java tools
include a world-class
debugger.
• To debug your code, you
run it in debug mode.
– You don't have to change
your code or recompile it
in any way.
• Right-click on the Java file,
then select Debug
AsJava Application
(instead of Run AsJava
Application).
T18.137
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The debug perspective
Variables,
breakpoints,
expressions
Execution
Stack
Source
Console
T18.138
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Stop in main()
• Depending on the
structure of your code,
you may want to stop
the debugger in the
main() method.
• To do this, you have to
create a debug
configuration, just like
you would a run
configuration.
T18.139
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Breakpoints
•
The simplest kind of
breakpoint is a line
breakpoint.
– To create one, double-click
in the margin next to a line
of code.
– Double-click the icon to
remove it.
•
A method breakpoint stops
when the debugger enters or
exits a particular method.
•
You can set an exception
breakpoint on a particular
Java exception (caught or
uncaught).
T18.140
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Breakpoints
• An expression breakpoint
stops when a condition
either becomes true or it
changes.
– An expression can be
more than a simple
variable name…
– You can use code assist
as you type an
expression.
• You can set a hit count on
a breakpoint, telling Eclipse
to stop after a breakpoint
has been reached a certain
number of times.
T18.141
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Stepping through code
1.
Resume – Continues execution until breakpoint or thread ends
2.
Suspend – Interrupts a running thread
3.
Terminate – Ends the execution of the selected thread
4.
Disconnect – Disconnect from a remote debugging session
5.
Remove terminated launches – Closes all terminated debug sessions
6.
Step Into – Steps into a method and executes its first line of code
7.
Step Over – Executes the next line of code in the current method
8.
Step Return – Continues execution until the end of the current method
(until a return)
9.
Drop to Frame – Returns to a previous stack frame
10. Step with Filters – Continues execution until the next line of code
which is not filtered out
1 2 3 4
T18.142
Making the most of
5
6 7 8
9
10
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Step filtering
• You can set filters in your
debugging session.
• This tells the debugger not
to stop on certain lines of
code.
• If you combine filters with
the Step with Filters button,
each step with the
debugger (step into, step
over or step return) will skip
the filtered lines of code.
T18.143
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Inspecting variables & expressions
• The debugger has a
variables view that
shows all the variables
currently in scope.
– You can change the
values of those variables
if you want.
• There's also an
expressions view that
lets you evaluate
expressions.
– These typically involve
some variable in scope,
but can be any Java
language expression.
T18.144
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Stack frames
• Whenever a thread invokes a method, that invocation is added
to the stack.
– main() called getUserInput(), which called itsAMatch().
• The Drop to Frame button lets you go backwards to the point at
which a thread invoked a particular method.
– Variable values are not reset to their previous state.
T18.145
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Re-running the debugger
• Once you've run your
code, you can click
Debug Last Launched
(F11) to run it again.
• Your program's name
also appears in the
Debug History menu.
T18.146
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Advanced debugger features
• Although the debugger that ships with the Eclipse
SDK is a Java debugger, the debugger component
itself can be extended.
– The C Development Tools extend the Eclipse debugger to
provide similar tools for C and C++ code, for example.
• Eclipse also has a remote debugging feature that's
very powerful.
– The debugger is on one machine, the code being debugged
is on another.
– See eclipse.org/eclipse/faq/eclipse-faq.html
#users_18 for more details on how to set up remote
debugging.
T18.147
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Hot code replace
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Hot code replace
• One of the coolest features of the Java
debugger is the ability to replace code
currently running in the debugger.
– You don't have to restart the debugger or recreate
the state of your program when you changed the
code.
T18.149
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Hot code replace
• How it works:
– The JVM you're using must support hot code
replace (most JVMs 1.4.x and later do)
– You can't do anything that changes the "signature"
of a class (add or remove methods or instance
variables, move it up and down in the class
hierarchy, and so forth)
– You can't change the main() method
– You go back up the stack to whatever called the
code you changed, but that's probably what you
wanted to do anyway.
T18.150
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Hot code replace
• Here's the console:
Starting the example:
Enter any string. To quit, type Quit.
Quit
You typed "Quit"
Enter any string. To quit, type Quit.
Quit
You typed "Quit"
Enter any string. To quit, type Quit.
• Our code never exits, regardless of what we type.
We'll run this through the debugger again…
T18.151
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Hot code replace
• We're stepping through the code when we
realize the problem. This line:
s.equals(exiting)
should be:
s.toString().equals
(exiting.toString())
• With hot code replace, we can fix the code
without restarting the debugger.
• As the debugging session continues, we can
verify that our code change fixed the problem.
T18.152
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Summary
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Summary
• We looked at the debugger in detail,
including:
– How to start the debugger
– The different kinds of breakpoints and how to set
them
– Stepping through the code
– Inspecting variables and expressions
– How to use Eclipse's hot code replace feature
T18.154
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Extending Eclipse
with plug-ins
Making the most of
V1.3
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
What we'll cover
• A brief discussion of the Eclipse plug-in
architecture
• Finding, installing and updating plug-ins
• Some popular plug-ins
• Demo: Building graphical applications with the
Eclipse Visual Editor (VE)
• The Callisto Project
T18.156
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
The Eclipse plug-in
architecture
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Eclipse plug-in architecture
• The Eclipse platform provides some basic
functions; everything else Eclipse does is
through plug-ins.
– The Java development tools are technically a set
of plug-ins, even though they come as part of the
basic Eclipse SDK.
T18.158
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Eclipse plug-in architecture
YOUR plug-in
C++
plug-in
Workbench
Help
System
GUI builder
plug-in
Workspace
Team
Components
Modeling
plug-in
T18.159
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Finding, installing and
updating plug-ins
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
eclipseplugincentral.com
• The Eclipse community
now has a single portal
for finding plug-ins.
• There are more than
1000 plug-ins listed at
the site. There's also a
search feature to help
you find what you're
looking for.
• There are also more
than 950 Eclipse-related
projects at Source
Forge...
T18.161
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Finding plug-ins
• The best way to install a plug-in is from an
update site.
– If you use an update site, Eclipse can check for
newer versions of the plug-in and install the
updates for you.
• If you want, you can download a zip file and
unpack it into the eclipse directory.
– This works, but it's error prone and Eclipse won't
be able to update the plug-in.
T18.162
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Installing plug-ins
• To start installing plugins, choose Software
UpdatesFind and
Install…
• You can look for new
features to install, or
look for updates for
what you've got
installed already.
T18.163
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Installing local plug-ins
• If you've downloaded
and unzipped a plug-in
into a directory, you can
define that directory as
a local site for plug-ins.
• You can tell Eclipse to
look for new or updated
plug-ins there.
– Eclipse can't update the
plug-in automatically,
though.
T18.164
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Installing remote plug-ins
• The best way to get a plug-in is to install it
directly from the site that hosts the plug-in.
• Given a URL, the workbench looks for a file
named site.xml.
– Eclipse uses the site.xml file to determine what
plug-ins are on that site, what the current versions
of those plug-ins are and what other plug-ins they
require, if any.
T18.165
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Installing remote plug-ins
• You can add a new site
bookmark that points to the
plug-in's URL.
• Eclipse uses the site to look
for new plug-ins.
• When you check for updates,
Eclipse looks at the site for
any new versions of the plugin.
• Some plug-ins automatically
define site bookmarks when
you install them.
T18.166
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Installing remote plug-ins
• In this case, Eclipse has contacted the Functional
Programming Tools update site and has found several
features.
– You decide which ones to install; Eclipse doesn't install
anything without your permission.
T18.167
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Dependencies
• Some plug-ins require other plug-ins.
– For example, the Graphical Editing Framework
and the Eclipse Modeling Framework are used by
lots of plug-ins.
• When you try to install a plug-in, Eclipse
checks to see if the required plug-ins are
already installed.
– If not, Eclipse will tell you (and possibly check the
Internet for them).
T18.168
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Installing remote plug-ins
• You have to accept the plug-in's license agreement
before you can install it.
– Be sure to read the agreement carefully…
• Eclipse won't install a plug-in that doesn't have a
license agreement.
T18.169
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Installing remote plug-ins
• Most open source plugins aren't signed.
• Eclipse warns you about
this, but you're free to
ignore it and install the
plug-in anyway.
T18.170
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Installing remote plug-ins
• After you've answered all of the questions, Eclipse
starts to download and install the plug-in.
• All you have to do now is wait…
T18.171
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Installing remote plug-ins
• When the plug-in has been downloaded and installed,
you might see a message like this.
• Restart the workbench if it's at all possible.
T18.172
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Installing remote-plug-ins
• When the workbench restarts, the plug-ins you just
installed are available.
– In this example, there is a new wizard to create an SQL file.
T18.173
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Updating remote plug-ins
• After you've defined
your update sites, you
can tell Eclipse which
ones to visit.
• In this case, we're
looking for updates to
the Perl tools.
T18.174
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Managing your configuration
• The Manage Configuration… menu item lets you
look at everything you have installed.
– You can search for updates for particular features you've
installed
– You can also disable or enable a particular feature.
T18.175
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Extension locations
• If you install new Eclipse
builds frequently, you can
create an extension
location.
• An extension location
contains plug-ins and
features that are in a
directory as if they were
installed in Eclipse.
• When you create an
extension location, Eclipse
will use the plug-ins installed
there automatically; you don't
have to copy them to each
Eclipse installation.
T18.176
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Extension locations
• An extension location is the directory eclipse with the
empty file .eclipseextension and the directories
features and plugins.
– Type echo 2>.eclipseextension to create an empty file.
• Put the features you want under features, and the plugins you want under plugins.
T18.177
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Some popular plug-ins
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Some popular plug-ins
• We'll look at several popular plug-ins that add
features to Eclipse.
– Hopefully you can find plug-ins that add the
functions you're looking for.
– If not, many plug-ins are open source, so you can
often take the source of someone else's plug-in
and customize it to your needs.
T18.179
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Web Tools Project (WTP)
• The Eclipse Web Tools Project (WTP) adds
many powerful features to the Eclipse
platform:
– Web site design and development
– JSP and JSF support
– Web services creation, testing and monitoring
• It consists of three subprojects: Web Standard
Tools (WST), Java EE Standard Tools (JST)
and Java Server Faces Tools (JSF).
• eclipse.org/webtools
T18.180
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Data Tools Project (DTP)
• The Data Tools Project (DTP) is now separate
from the Web Tools Project.
– There are some basic database tools in the WTP,
but the advanced work on database tools is in the
DTP.
– The latest beta of the tools contains support for
XQuery, for example.
• eclipse.org/datatools
T18.181
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Ajax Tools Framework (ATF)
• IBM, BEA, Oracle, Laszlo and others are
working on the Ajax Tools Framework (ATF).
– The goal of the project is to build tools that work
with the most popular Ajax frameworks (Dojo and
Rico, for example)
– You can define profiles for your favorite Ajax toolkit
as well.
– The latest version of these tools is available at
eclipse.org/atf.
T18.182
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Language tools
• PHP
– You have multiple choices here. The most popular plug-in is
PHP Eclipse, phpeclipse.sourceforge.net.
– There is now an official Eclipse project for PHP; see
eclipse.org/php for more information.
• Perl
– There are several tools for Perl; the most popular is EPIC,
the Eclipse Perl Integration project.
e-p-i-c.sf.net/updates is the Eclipse update site.
• C Development Tools (CDT) project
– The goal of the project is to provide Eclipse support for C and
C++ that's comparable for Eclipse support for Java.
eclipse.org/cdt
T18.183
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Language tools
• Ruby
– The Ruby Development Tools feature a custom editor, a
custom Ruby search dialog and a Ruby debugger. It reuses
regular expression support from the EPIC project.
www.rubypeople.org
• Python
– The Pydev toolkit is one of the most popular, although there
are others. sourceforge.net/projects/pydev
• Functional programming
– The EclipseFP project provides support for the functional
programming languages Haskell and OCaml.
– eclipsefp.sourceforge.net
T18.184
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Other notable plug-ins
• UML2 - An EMF-based implementation of UML 2.0.
– eclipse.org/uml2
– There are a number of commercial UML tools for Eclipse,
including IBM's Rational Software Architect and Rational
Software Modeler.
• BIRT – Business Intelligence and Reporting Tools
– A sophisticated report generation facility.
eclipse.org/birt
• TPTP - Test and Performance Tools Project
– Tools for profiling applications, identifying bottlenecks, etc.
eclipse.org/test-and-performance
T18.185
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Other notable plug-ins
• Aspect-oriented programming
– AspectJ is an aspect-oriented extension to Java
eclipse.org/aspectj
– AJDT is a set of aspect-oriented development tools
for AspectJ eclipse.org/ajdt
• WSVT – Web Services Validation Tools
– See eclipse.org/wsvt for downloadable files
and information about the project.
• FTP and WebDAV support
– Look for eclipse-FTP-WebDAV-3.0.1.zip on
your favorite Eclipse mirror.
T18.186
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Eclipse Visual Editor project
• You can get an open source graphical editor
through the Eclipse Visual Editor project,
eclipse.org/vep.
– The Visual Editor is built on the Graphical Editing
Framework (GEF) and the Eclipse Modeling
Framework (EMF).
• Other vendors have commercial visual
editors…
T18.187
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Two common frameworks
• The Eclipse Modeling Framework (EMF) and
the Graphical Editing Framework (GEF) are
behind many of the Eclipse projects we've
mentioned already.
– EMF – eclipse.org/emf
– GEF – eclipse.org/gef
T18.188
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Demo:
The Eclipse Visual Editor
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Demo: The Eclipse Visual Editor
• We'll take a brief look at the Eclipse Visual
Editor. This is an open source, professionalquality GUI build tool.
• As we mentioned before, the Visual Editor is
built on both GEF and EMF.
T18.190
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
The Callisto project
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Ten simultaneous releases
• The Callisto project
(eclipse.org/
projects/
callisto.php) released
Eclipse V3.2 and nine major
Eclipse projects
simultaneously.
– Users have ten major
pieces of software that
have been tested together.
• This shipped at the end of
June 2006.
Eclipse 3.2 base platform
BIRT
CDT
Data Tools Platform
EMF
GEF
Graphical Modeling Framework
Test and Performance Tools
Project
Web Tools Project
Visual Editor
T18.192
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Updating Callisto
• Point the Update Manager at
download.eclipse.org/
callisto/releases/ to
download, install and update
the various components.
• You select the components
that you're interested in, and
Eclipse does the rest.
• You must have Eclipse 3.2
installed to use this site.
T18.193
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Summary
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Summary
• We've taken a brief look at the Eclipse plug-in
architecture.
• We looked at ways to find, install and update plug-ins,
including update sites and extension locations.
• We also looked at some popular plug-ins.
• We used the Eclipse Visual Editor to build an
application. The Visual Editor is built on Eclipse and
two plug-in frameworks that extend the Eclipse
platform.
• Finally, we looked at the Eclipse Callisto release.
T18.195
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
The Eclipse
Web Tools Platform
(and related tools)
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
What we'll cover
• The Web Tools Platform (WTP)
• The Data Tools Platform (DTP)
• The Ajax Tools Framework (ATF)
T18.197
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
The Web Tools Platform
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Web Tools Platform
• End user tools and APIs for Web and Java EE
application development
• WTP is two subprojects and one incubation project:
– Web Standard Tools (WST)
– Java EE Standard Tools (JST)
– Java Server Faces (JSF) tools
• Supports open standards from OASIS, the W3C, JCP,
WS-I.org and others
• Includes tools for open source and commercial
products (Apache Tomcat, BEA WebLogic, IBM
WebSphere)
• eclipse.org/webtools
T18.199
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Project goals
•
•
•
•
API declaration where appropriate
Simple to use – wizards, editing support
Large-scale development
User experience – dynamic help, graphical
WSDL editor
• Responsive UI
• Seamless editing of resources
– JDT-like features applied to other languages
(HTML, JSP, XML…)
• Flexible project layout
• Vendor ecosystem support
T18.200
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Web Standard Tools (WST)
• Basic server tools
– Support for server types and server connectivity
(Web, DB)
– Configure, publish, start/stop, debug
• Structured Source Editor framework
• Web Language Tools
– HTML source editor
– CSS source editor
– JavaScript source editor
T18.201
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Web Standard Tools
• XML language tools
– XML source editor
– XSD source editor
– DTD source editor
• Web services tools
–
–
–
–
–
T18.202
WSDL editor
Web service explorer
Web service wizard
TCP/IP monitor
WS-I test tools
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Server tools
• Preferences pages to configure various server
runtimes
• Supported runtimes:
–
–
–
–
–
–
IBM WebSphere
Apache Tomcat
JBoss
JOnAS
BEA WebLogic
Apache Geronimo (with a plug-in)
• Highly extensible server frameworks
• Supports generic server adapters and custom server
adapters
T18.203
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Server tools
T18.204
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Server tools
• When you've configured a server, you can start and
stop it, republish applications and examine its
configuration.
– Here we see a Tomcat server with two applications deployed
to it.
T18.205
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Structured source editors
• Editors for:
–
–
–
–
–
–
T18.206
XML
DTDs
HTML
CSS
JavaScript
JSPs
Making the most of
These include the usual
Eclipse editor features:
Syntax highlighting
Quick fix
Delimiter matching
Content assist
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
XML tools
• Custom editors for XML
files, XML schemas,
DTDs and WSDL files
• XML Catalog support –
A repository for DTDs,
XSDs, or any XML
resource (WSDL, XSL,
etc.)
– Based on the OASIS
XML catalog standard
T18.207
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Web services tools
• This is the WSDL editor, a graphical application that
shows the structure of a Web service interface.
• The structure of the XML types passed by a Web
service is displayed as well.
T18.208
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Web services tools
• Wizards to create Web
services
– Top-down – Start with a
WSDL interface, go to
code
– Bottom-up – Start with
code, generate the
WSDL interface
• Supports Apache Axis
1.2 and many other
Web service runtimes.
T18.209
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Java EE standard tools (JST)
• Java EE core tools
– Natures and builders
– Java EE views and navigators
– Java EE models
• Java EE projects and modules
– Flexible directory layout
– Support for WAR files, EJBs, JARs, EAR files, etc.
– Models and source editors for deployment
descriptors
– Java EE navigator view
– Ability to target different servers
T18.210
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Java EE standard tools
• Servlet tools
• JSP tools
– JSP editor, HTML code assist, editors for Java, JavaScript,
taglibs
– JSR-45 compliant debugging
• Java EE server tools – extend WST
– Supports deploy, debug, project restart on Java EE runtimes
– Generic server adapter
– Custom (Java) server adapter for total control
• Javadoc annotation support
– Extensible facility to define tagsets
– Code assist in Java editors and builders for code generation
T18.211
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Java EE standard tools
• Wizards make it easy to create EJB projects and
deploy them to a server.
• If you change the project, Eclipse automatically
republishes and redeploys it for you.
T18.212
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
XDoclet support
T18.213
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Standards support
• WST:
–
–
–
–
–
–
–
–
–
–
–
T18.214
HTML 4.0.1
XHTML 1.0 / 1.1
XML Catalogs 1.0
CSS 2.0
ECMAScript 262
SQL99/SQL2003
XML 1.0
XML Schema 1.0
WSDL 1.1
SOAP 1.1
WS-I basic profile 1.1, attachment profile 1.0
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Standards support
• JST – JCP standards
–
–
–
–
–
–
–
–
–
T18.215
Java EE 1.2, 1.3, 1.4
Servlets
JSP
EJB
JAX-RPC
JSR 109
JSR 045
JSR 921
JDBC 2.1
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
The Data Tools Project
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Data Tools Project
• Designed to provide world-class support for
relational databases
• Ships with support for DB2, SQL Server,
Informix, Sybase, Oracle, MySQL,
Cloudscape/Derby, etc.
– You can add your own JDBC drivers if you
want.
T18.217
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Relational database tools
• Wizard to create live
connections to database
servers over JDBC
• Supported servers:
– Apache Derby /
Cloudscape
– DB2
– Informix
– MySQL
– SQL Server
– Oracle
– Sybase
– You can add your own…
T18.218
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Relational database tools
• Database Explorer –
View database
schemas, tables, views,
stored procedures and
user-defined functions
• Supports working in
disconnected mode
T18.219
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Connections
• To work with databases, you create
connection objects.
– Each object stores details about JDBC
drivers, URL formats, table names, user
IDs and passwords, etc.
• Once you've created a connection, you can
reuse it in different projects.
T18.220
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
The Ajax Tools Framework
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Ajax Tools Framework
• Ajax is an emerging technology that will be
very important in the forseeable future.
• The ATF supports Dojo and Rico out of the
box, but can be extended to support any Ajax
toolkit you want.
– There are more than 150 Ajax toolkits...
• We'll look at a quick example that uses visual
controls from the Rico toolkit, a database
connection from the DTP, and uses a servlet
built on the WTP.
T18.222
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Demos
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Demos
• We'll take a quick look at:
– A Web service built with the Web Tools
– A simple Ajax application
T18.224
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Summary
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Summary
• The Web Tools Project is part of the continuing
evolution of open source tools.
– Much of the code in the WTP was originally closed source
code in products from IBM, BEA, etc.
• In addition to being open source, the project also
helps advance open standards.
• The Data Tools Project provides the same vendorneutral, standards-based support for databases.
• The Ajax Tools Framework is still in its infancy, but is
shaping up as an extremely powerful and flexible tool.
T18.226
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Creating Eclipse plug-ins
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
What we'll cover
• The Eclipse plug-in architecture
• The Plug-in Development Environment
– We'll build a small plug-in and deploy it in the
Eclipse workbench.
• Suggested enhancements
T18.228
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The challenge of writing plug-ins
• There are two things you need to learn when
writing plug-ins:
– How to write the code of the plug-in itself
– [Most importantly] How to find the parts of Eclipse
(or EMF, GEF, etc.) that do 90% of what you want
to do.
• Learning to reuse as much code as possible
is the most important skill.
– Reusing code means you get your work done
faster, and it means that users of your plug-in will
see many of the same components they see in
other plug-ins.
T18.229
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
The Eclipse plug-in
architecture
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Eclipse plug-in architecture
C++
plug-in
Workbench
Help
System
Workspace
Team
Components
Modeling
plug-in
GUI builder
plug-in
T18.231
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Eclipse plug-in architecture
• In Eclipse, everything is a plug-in except the
Platform Runtime (the kernel).
• Everything else, including most of the things
you probably use, is a plug-in:
–
–
–
–
–
T18.232
The Java Development Tools
The Eclipse Modeling Framework
The Visual Editor
The Web Standards Tools
Etc.
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Extension points
• An extension point is similar to a Java
interface.
• When a plug-in uses an extension point, it
tells Eclipse that it can perform certain
functions.
– Or, to look at it another way, that it implements
certain interfaces.
T18.233
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Extension points
• In a few minutes we'll create a plug-in that
uses the extension points for the help system
and an action set.
– Using an extension point from the help system tells
Eclipse to ask our plug-in for information whenever
the help system is loaded.
– Using an action set tells Eclipse to look at our
plug-in when the UI is created. Our action set
creates a menu item and a toolbar button that
must be drawn when the workbench appears.
T18.234
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Extension points
• We also use the extension points for a
preferences page and the Welcome screen.
– The preferences page extension point means we'll
see an OOPSLA preference page under
WindowPreferences.
– The Welcome screen extension point lets us put
introductory information linked to the Welcome
screen seen the first time users open a particular
workspace.
T18.235
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Extension points
• In addition to the Eclipse platform's extension
points, plug-ins can provide their own.
– The Eclipse Modeling Framework and the
Graphical Editing Framework both provide their
own extension points.
– The EMF and GEF use Eclipse extension points to
provide certain functions.
– We can write plug-ins that use the extension points
defined in the EMF and GEF, which in turn use the
extension points defined by Eclipse.
T18.236
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Plug-in development tools
• In Eclipse Version 3.1, the plug-in development tools
were greatly enhanced. This is the visual editor for
plugin.xml.
• We'll look at the Plug-in Development Environment in
just a few minutes.
T18.237
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Plug-in development tools
• The plug-in development tools make it easy to
edit the XML file that describes the plug-in.
• The description file defines:
–
–
–
–
T18.238
What extension points the plug-in uses
What extension points it contributes
Its dependencies (JAR files, other plug-ins)
The properties of the extension points the plug-in
uses
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Features and plug-ins
• An Eclipse feature is a
collection of plug-ins. It
is the smallest thing you
can download and
install separately.
• For example, the Ruby
Development Tools are
a feature; they include
many different plug-ins.
• What we download and
install is the feature.
T18.239
Making the most of
feature
plug-in1
plug-in2
plug-in3
plug-in4
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Features and plug-ins
• What we'll develop here would normally be
part of a feature, although we won't go that far
in our example.
• To publish our plug-in, we would normally:
– Create a feature project to include our plug-ins
– Create an update site that uses a site.xml file to
describe our features
– Publish the site.xml file, the feature description
and the plug-ins to a Web site.
T18.240
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
The Plug-in Development
Environment (PDE)
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Plug-in Development Environment
• We'll use the PDE tools to create a new plugin.
• We'll start with the wizards that are part of the
development tools.
• After we've built a small plug-in, we'll test it in
the Eclipse workbench.
T18.242
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Getting started
• We'll go through these steps:
– Create a plug-in project and a new plug-in
– Launch the plug-in in a new workbench
• We'll finish with some improvements we could
make to the plug-in.
– These are left as an exercise for the reader…
T18.243
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Create a new plug-in project
• Our first step is to
create a new project for
our plug-in.
• Select FileNew
Other, then select Plugin Project.
• Click Next to continue.
T18.244
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Create a new plug-in project
• Give your project a
name, and take the
defaults for the rest of
the choices.
– You can target Eclipse
V3.0, 3.1 or 3.2.
– You can also create a
plug-in that runs with an
OSGi framework.
• Click Next to continue.
T18.245
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Create a new plug-in project
• Fill in the details of your
plug-in. The ID uniquely
identifies the plug-in.
• The version number is
used by the update
manager.
• Our plug-in will
contribute to the UI, but
we're not creating an
RCP application here.
• Click Next to continue.
T18.246
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Create a new plug-in project
• Select the Custom plugin wizard.
• We'll choose which
extension points we
want to use on the next
panel.
• Click Next to continue.
T18.247
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Create a new plug-in project
• Select these templates:
–
–
–
–
"Hello World" Action Set
Help Table of Contents
Preference Page
Universal Welcome
Contribution
• Click Next to continue.
T18.248
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Create a new plug-in project
• Enter a message in the
Message Box Text field.
– This text appears when
the user clicks on our
menu or toolbar button.
• Click Next to continue.
T18.249
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Create a new plug-in project
• Enter a title for the table
of contents.
• Select the Primary
check box; this creates
a new major heading in
the Help window.
• Click Next to continue.
T18.250
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Create a new plug-in project
• Enter a name for your
preferences page.
(OOPSLA Preferences
is what we entered
here.)
• Click Next to continue.
T18.251
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Create a new plug-in project
• Enter the OOPSLA
2006 URL as the link for
the Overview page.
(http://www.oopsla
.org/2006/)
• Click Finish to create
your plug-in.
• Eclipse generates the
plugin.xml file, the
Java classes and other
things you need to run
your plug-in.
T18.252
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Create a new plug-in project
• Eclipse will most likely ask you if you want to switch to
the Plug-in Development perspective.
– Click the "Remember my decision" check box, then click Yes
to continue.
T18.253
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Create a new plug-in project
• Eclipse creates several
files, including:
– Java source code
– XML files that describe
the plug-in
– HTML files that add
information to the help
system.
T18.254
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The plug-in editor
• When the PDE finishes creating the files for
your plug-in, you'll see the Plug-In
Development perspective.
• We'll look at the editor for the plug-in
descriptor files next.
T18.255
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The plug-in editor
T18.256
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The plug-in editor
• There are several tabs at the bottom of the plug-in
editor. We'll focus on the Overview tab.
• When you're ready to enhance the generated plug-in
code, the other tabs (especially the Extensions tab)
help you do that.
T18.257
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Launch the plug-in
• In the right-hand column
of the Overview page,
click "Launch an Eclipse
application" in the
Testing section.
• This launches a new
Eclipse workbench with
our plug-in installed.
T18.258
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The welcome screen
• The new workbench
appears with the
welcome screen loaded.
• Click on the Overview
button.
T18.259
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The overview page
• On the overview page there will be a link labeled
"Lorem ipsum."
• Clicking this link takes you to the OOPSLA 2006 Web
site.
– We defined the target of this link in the plug-in wizard.
T18.260
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The menu item and toolbar button
• Closing the welcome screen, we can see our plug-in
has added two items to the user interface:
– A menu named Sample Menu that contains a single item
named Sample Action
– A toolbar button with the hover text "Hello, Eclipse world"
T18.261
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The message dialog
• Clicking the toolbar button or selecting the menu item
causes this exciting message to appear.
• The text of the message is whatever we typed in the
plug-in wizard.
T18.262
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The preferences page
• Select
WindowPreferences
and click "OOPSLA
Preferences" on the lefthand side.
• There are custom
editors for each of these
preferences, and an
Eclipse API that
manages the user's
preferences
automatically.
T18.263
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The preferences page
• To test how the preferences page works,
change some of the values and click OK.
• When you restart the workbench, the values
you changed have automatically been saved
and restored in the preferences dialog.
• Eclipse provides an API for you to access the
preferences store for your plug-in.
– You probably want your code to behave differently
depending on how the user has set their
preferences.
T18.264
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The help system
• The last contribution our
plug-in has made to the
UI is in the help system.
• The PDE generates a
bunch of HTML files that
are deployed to the help
system; our job is to
write the information our
users need and publish
it.
T18.265
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The help system
• Now that our plug-in has added information to
the help system, all of that information is
available through the search facility.
• A later version of the plug-in can contribute
more information to the help facility.
• We can also write another plug-in that adds
more information to the section created by
this plug-in.
T18.266
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Suggested Enhancements
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Suggested enhancements
• Modify the "Lorem ipsum" text that appears
on the overview page.
• Find the file that contains this text and modify
it. The format of that file is straightforward.
T18.268
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Suggested enhancements
• When we implemented the Action Set
extension point, we changed the message
text to "Hello, OOPSLA!" The hover text of
the toolbar button wasn't changed.
• Find the hover text and change it so it's
consistent with the message text.
T18.269
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Suggested enhancements
• The preferences page contains four different
property editors: A directory path editor, a
simple text editor (an entry field), a choice
editor (radio buttons) and a boolean editor (a
check box).
• Add more properties and controls to the
preferences page. Look for editors for colors,
dates and other kinds of values.
T18.270
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Suggested enhancements
• Add a name property to the preferences page.
When the user clicks our toolbar button or the
menu item, display the message "Hello,
Akmal!" if the name property is Akmal.
– Define a default name if you want.
– Define a default message if the name property isn't
set or if it's blank.
T18.271
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Summary
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Summary
• We've taken a very brief look at the plug-in
development environment.
• The PDE tools are very good at helping you
get started. You get running code with very
little effort, then you can start adding features
to your plug-in one by one.
T18.273
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Eclipse resources
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Eclipse Web sites
• In addition to the content at developerWorks
(more on that in a minute), here are a couple
of sites you should visit:
• The Eclipse Corner at eclipse.org is a
great site for articles by Eclipse insiders.
– eclipse.org/articles/
• O'Reilly's Java developer site has quite a few
articles on Eclipse as well.
– Go to onjava.com, search for "eclipse."
T18.275
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Eclipse communities
• Eclipse is a great tool by itself, but the
community behind it is what makes Eclipse so
exciting.
• In addition to the forums and FAQs at the
Eclipse sites mentioned earlier, there are
communities for specific interest, languages,
and so forth.
• Visit eclipse.org/community to find links
to Eclipse groups all over the world.
– There are communities in French, German,
Korean and Japanese.
– The Italian community is particularly active…
T18.276
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Eclipse books
• Fortunately for us, many of the chief
developers of Eclipse have written very
helpful books.
• We'll mention a couple of books we've found
useful.
– More Eclipse books are being published all the
time, so keep your eyes open for new titles.
– We've found Eclipse books in English, French,
German, Spanish, Japanese and Chinese…
T18.277
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Java Developer's Guide
• Probably the most
popular book on
Eclipse.
• Make sure you get the
second edition; it covers
Eclipse V3.x.
• ISBN 0321305027
T18.278
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Contributing to Eclipse
• If you want to write plugins, you must get this
book.
• Written by gurus Erich
Gamma and Kent Beck,
it shows you how to
extend Eclipse.
– Any book written by
Erich Gamma or Kent
Beck is probably really
good…
• ISBN 0321205758
T18.279
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The Official Eclipse 3.0 FAQs
• This book is a great
resource for developers.
• You can install the full
text of the book as a
plug-in for the Eclipse
help system.
• ISBN 0321268385
T18.280
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
ibm.com/developerworks/opensource
• The developerWorks open
source zone has
articles, tutorials and
sample code built on
open source products.
• A recent sample
featured articles on:
– Apache Geronimo
– Eclipse
– iText (a Java PDF
library)
– Apache Derby
– PHP
T18.281
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
../top-projects/eclipse.html
• If you're in the developerWorks open source zone,
click the Eclipse link in the right-hand navigation for a
page just for Eclipse.
• ibm.com/developerworks/opensource/
top-projects/eclipse.html
T18.282
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Trial downloads of IBM products
• Visit ibm.com/developerworks/downloads for trial versions
of hundreds of IBM products.
– IBM's Eclipse-based development tools from Rational and
WebSphere are available here.
• When you download the trial versions, you also get links to
installation help, tutorials, demos, forums, newsgroups and other
types of support.
T18.283
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The developerWorks Software Eval Kit
• Visit …/developerworks/offers/sek to order the
free Software Evaluation Kit.
– From the downloads page, click the "developerWorks
Software Evaluation Kit" link in the right-hand navigation.
• 14 GB of IBM products for Windows and Linux
T18.284
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Software Development Platform webcasts
• Visit ibm.com/developerworks/offers/lp/wc/ to sign up
for free Webcasts on Eclipse and Eclipse-based development
tools.
• If you attend the Webcast live, you can submit questions and
interact with the experts. (If you miss it, you can listen to the
Webcast later…)
T18.285
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
The dW Software Architect Kit
• Themes:
– Patterns-based
development
– How to apply Model-Driven
Architecture
– Structural review & control
– SOAs
• Includes Webcasts, demos,
whitepapers, free downloads
and exclusive Grady Booch
podcasts.
• ibm.com/
developerworks/
architecture/kits
T18.286
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
developerWorks tutorials and training
• developerWorks has 500+ tutorials on a variety of topics,
including:
– Build a Web service using the Eclipse Web Tools Platform
– Building Eclipse plug-ins using templates
– Building cheat sheets in Eclipse
• ibm.com/developerworks/training
T18.287
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks – ibm.com/developerworks
Also see…
• …Wayne Beaton's "Eclipse hints, tips and
random musings" blog
– ibm.com/developerworks/blogs/beaton
• …Eclipse-related Redbooks
– Visit ibm.com/redbooks, search for "Eclipse"
– One of the best is Eclipse Development using the
Graphical Editing Framework and the Eclipse
Modeling Framework (ISBN 0738453161)
T18.288
Making the most of
© 2011 IBM Corporation.
Presented by IBM developerWorks
ibm.com/developerWorks
Thanks!
Doug Tidwell, Eric Long & Akmal Chaudhri
IBM Developer Relations
Making the most of
© 2011 IBM Corporation.