You create the Decorator
class in this
lesson, which will later be responsible for placing the graphics as
decorators on CARMA members.
About this task
To create the Java™ Decorator
class:
Procedure
- Start by setting the appropriate dependencies for the Eclipse
plug-in project. Right click the
com.ibm.carma.plugin.decorators
Eclipse
plug-in project, and select PDE Tools > Open
Manifest. This opens the Plug-in Editor in
the main editor window.
- From the bottom menu of tabs in the Plug-in
Editor, select Dependencies. This
opens the plug-in dependency editor.
- Ensure the following plug-ins are listed in the first panel:
org.eclipse.ui
org.eclipse.core.runtime
com.ibm.carma.core(9.0.0)
- If any of the plug-ins are missing, click the Add button.
In the Plug-in Selection dialog box that opens,
enter the name of the missing plug-in in the filter text field. When
it appears in the panel, select it, and click OK.
- Now, you create a new package to contain the
Decorator
class.
Placing relevant Java classes
together in packages helps to keep your code organized. Right click
the com.ibm.carma.plugin.decorators
plug-in project,
and select New Package.
- In the New Java Package dialog box
that opens, enter decorator in the Name text
field, and click Finish. You should see the
package you just created appear in the
src
directory.
- Right click the
decorator
package you
created, and select New > Class.
- In the Name text field, enter Decorator.
- Next, to the Superclass text field,
click Browse to browse for the class that your
Descriptor
class
extends.
- In the Superclass Selection dialog
box that opens, enter LabelProvider in the
text field. Select the class that is part of the
org.eclipse.jface.viewers
package,
and click OK.
- Next, to the Interfaces panel, click Add.
In the Implemented Interfaces Selection dialog
box that opens, enter ILightweightLabelDecorator,
and select the matching item that appears. Click OK.
- Click Finish to close out of the New
Java Class dialog box.
Results
You should see the Decorator
class appear
under the decorator
package and the source code for
the Decorator
class open in the editor.