Search code examples
javaeclipse-plugineclipse-rcprcp

Images for Perspective and Views not loading in RCP Product


I have created a new perspective in an already existing RCP product, The perspective contains two views. I have different images for the perspective and the views. When I run the product in eclipse it takes the images for the perspective and all the views but when I export it as a product the images for the perspective and views are missing. Each view also contains a tree view and the expandable icons at nodes are also missing. I have no clue what can be the cause for this problem. As it works in eclipse but not in the exported product. In the exported product all the functionality also works.

My label provider class for the tree is

 private static class ComponentsTreeLabelProvider extends LabelProvider implements IColorProvider{

    private static ImageRegistry imageRegistry = new ImageRegistry();


    @Override
    public Image getImage(Object element) {
        SoftwareArchitectureModel softModel = activeArchitectureModelReader.getArchitectureModel();
        ImageDescriptor imageDescriptor = null;

        if(element instanceof Component){
            if(softModel.isEnabled(element))
                imageDescriptor = Activator.getDefault().getImageRegistry().getDescriptor(Activator.COMPONENT_ID);
            else
                imageDescriptor = Activator.getDefault().getImageRegistry().getDescriptor(Activator.COMPONENT_DISABLED_ID);
        }

        if (imageDescriptor == null)
            return null;

        Image image = imageRegistry.get(imageDescriptor.toString());
        if (image == null) {
            image = imageDescriptor.createImage();
            imageRegistry.put(imageDescriptor.toString(), image);
        }           
        return image;
    }

    @Override
    public String getText(Object element) {

        if(element instanceof Component)
            return ((Component) element).getName();

        return null;
    }

    @Override
    public Color getForeground(Object element) {
        SoftwareArchitectureModel softModel = activeArchitectureModelReader.getArchitectureModel();
        if(element instanceof Component){
            if(softModel.isEnabled(element))
                return Display.getCurrent().getSystemColor(SWT.COLOR_BLACK);
            else
                return Display.getCurrent().getSystemColor(SWT.COLOR_RED);
        }
        return null;
    }

    @Override
    public Color getBackground(Object element) {
        return null;
    }
}

Plugin name is : myproject.memorymodeling.ui under this plugin I have icons folder in which all the images are available. In the manifest file Under Extensions I added

 org.eclipse.ui.views 

which contains both the views and under the icon fields I provided icons/imagename.png

Anyone has any idea why my images are missing when I export the product?

Thanks


Solution

  • Everything you want to include in your plugin must be listed in the 'build.properties' file (either individually or the whole folder).

    When you are testing by running the code from Eclipse the build.properties is not used so it is easy to miss including things.