Search code examples
csseclipseeclipse-rcprcpe4

Add Image in background using default.css in eclipse e4


I am creating a Eclipse e4 RCP Application. I want to add a image at the background. I have tried adding property in plugin.xml:

<property
        name="applicationCSSResources"
        value="platform:/plugin/rcptutorial/image/image.jpg">

Also, I created a new folder "Images" and added "image.jpg in it. I also added the line in default.css:

Shell {  background-image: url('./image.jpg');} 

But nothing happens when I run it. I can apply background-color but unable to add image.

Please help.

My Plugin.xml is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>

<plugin>  

<extension
     id="product"
     point="org.eclipse.core.runtime.products">
  <product
        name="org.rcptutorial.rcp"
        application="org.eclipse.e4.ui.workbench.swt.E4Application">
     <property
           name="lifeCycleURI"
           value="bundleclass://rcptutorial/org.rcptutorial.rcp.E4LifeCycle">
     </property>
     <property
           name="applicationCSS"
           value="platform:/plugin/rcptutorial/css/default.css">
     </property>
     <property
        name="applicationCSSResources"
        value="platform:/plugin/rcptutorial/images/">
    </property>



  </product>


</extension>

</plugin>

My default.css is as follows:

Shell {  background-image: url('./images/image.jpg');}

I have an "images" folder that contains the image "image.jpg". The folder is located inside my project


Solution

  • applicationCSSResources must specify a folder which contains the images:

    <property
          name="applicationCSSResources"
          value="platform:/plugin/rcptutorial/image/">
    </property>
    

    (the ending '/' must be present).

    The URL in the CSS should just be:

    url('./image.jpg')