The Activator
class is created automatically
with the creation of the Eclipse plug-in project. This lesson guides
you through the steps to modify the Activator
class
to display the appropriate graphics as decorators.
About this task
To update the Java™ Activator
class:
Procedure
- In the Package Explorer view, navigate
to the
Activator
class by expanding com.ibm.carma.plugin.decorators
> src
> com.ibm.carma.plugin.decorators
,
and double-click on the Activator.java
file to open
it in the editor.
- Scroll down, and below the
getDefault
method,
add the following method to the Java Activator
class: public static ImageDescriptor getImageDescriptor(String path)
{
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
This method provides a way for the
Activator
class
to find the graphics you plan to use as decorators.
- Ensure that the following classes and packages are included
in the import commands. An easy way of doing this is by right-clicking
within the editor, and selecting Source > Organize
Imports and verifying all the listed import statements
were included. You can also manually enter the import commands at
the top of the class with any other import commands.
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
- Save the
Activator.java
file.