[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Newsgroup Home]
[news.eclipse.platform.swt] Re: trying to load gif from plugin into SWT browser

> Is it that I should interrogate eclipse to see where the plugin
 resides in the directory tree and make up the base path that way?

Yes. That's what I did for the plugin 
org.eclipse.swt.examples.browser.demos. This plugin is part of the Eclipse 
CVS and available in the Eclipse Example plug-ins on the download page. This 
plugin contains subfolders css1, css2 etc. that contain the stylesheet, gif 
and other required image files for each theme used by the plugin.
I get the plugin path through Eclipse API. Then add the particular subfolder 
(css1, css2 ...) that contains my cascading style sheet and images.

In my class that extends AbstractUIPlugin I get the PLUGIN_PATH as in below.

 public void start(BundleContext context) throws Exception {
  super.start(context);
  PLUGIN_PATH = 
Platform.resolve(plugin.getBundle().getEntry(".")).toString();
 }

I then build absolute paths like:
 static String CSS_FOLDER = "css2";
 static String URL_CSS = PLUGIN_PATH+CSS_FOLDER+"/style.css";
 static String URL_WELCOME =PLUGIN_PATH+CSS_FOLDER+"/welcome.html";

before using it to generate HTML:
html = "<html><header><link rel=\"stylesheet\" type=\"text/css\" 
href=\""+URL_CSS+"\"></header><body><div class=\"board\"><table><tbody>";
...
browser.setText(html);


Details on how to get this plugin:
Go to the regular Eclipse download page (e.g. from the Main Eclipse download 
site)
section: "Example Plug-ins"
SWT Browser examples are available in either Windows or "All Other 
Platforms" downloads - so it does not matter which one you take.

Follow instructions in that section.
Then you can see the Browser plugins from:
Windows > Show View > Others > SWT Examples > Browser Demo
or the other one:
Windows > Show View > Others > SWT Examples > Web Browser