Images from component? [message #717077] |
Fri, 19 August 2011 08:29 |
andiqo Messages: 32 Registered: July 2009 |
Member |
|
|
I'd like to be able to see images when I drag and drop components with embedded image from the palette. Unfortunatly, I couldn't manage. I think this is the ResourceManager.PluginResourceProvider "fault", but do someone have a solution?
For exemple, let's say in plugin1, I develop a simple component like this:
public class MyComp1 extends Composite {
public MyComp1(Composite parent, int style) {
super(parent, style);
Button btnMyButton = new Button(this, SWT.NONE);
btnMyButton.setImage(ResourceManager.getPluginImage("plugin1", "resource/image.png"));
btnMyButton.setBounds(0, 10, 97, 28);
btnMyButton.setText("My Button");
}
}
I then release plugin1 and use my target platform which contains plugin1 (but plugin1 is removed from my workspace!).
When I develop plugin2 and try to use MyComp1, I can't see my image in WindowBuilder...
Thanks a lot for your help.
--andiqo
|
|
|
Re: Images from component? [message #717289 is a reply to message #717077] |
Fri, 19 August 2011 20:29 |
Konstantin Scheglov Messages: 555 Registered: July 2009 |
Senior Member |
|
|
This works for me.
I've created RCP project "RCP" and can reference both images from this "workspace" plugin and also from "binary" plugin.
public Composite_1(Composite parent, int style) {
super(parent, style);
setLayout(new RowLayout(SWT.HORIZONTAL));
{
Button button = new Button(this, SWT.NONE);
button.setImage(ResourceManager.getPluginImage("RCP", "icons/drafts.gif"));
button.setText("New Button");
}
{
Button button = new Button(this, SWT.NONE);
button.setImage(ResourceManager.getPluginImage("org.eclipse.ui", "/icons/full/etool16/copy_edit.gif"));
button.setText("New Button");
}
}
We need test case to reproduce this, or at least more details.
Konstantin Scheglov,
Google, Inc.
[Updated on: Fri, 19 August 2011 20:30] Report message to a moderator
|
|
|
Re: Images from component? [message #717760 is a reply to message #717289] |
Mon, 22 August 2011 09:12 |
andiqo Messages: 32 Registered: July 2009 |
Member |
|
|
Thanks a lot for your answer.
Actually, this also works for me if I use "org.eclipse.ui", but this does not work anymore if I reference one of my bundle.
Here is my test case :
* change your target platform to reference the attached bundle com.sneda.wb.test1_1.0.0.201108221041.jar
* create a new Plug-in Project
* create a Composite class with the following source code:
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.wb.swt.ResourceManager;
import com.sneda.wb.test1.api.MyComponent;
public class MyComp extends Composite {
public MyComp(Composite parent, int style) {
super(parent, style);
setLayout(new GridLayout(1, false));
// There should be test.png visible as it is embedded in MyComponent?!
MyComponent myComponent = new MyComponent(this, SWT.NONE);
// Let's try to reference test.png in a Button
Button btnNewButton = new Button(this, SWT.NONE);
btnNewButton.setText("New Button2");
btnNewButton.setImage(ResourceManager.getPluginImage("com.sneda.wb.test1", "/icons/test.png"));
//btnNewButton.setImage(ResourceManager.getPluginImage("com.sneda.wb.test1", "icons/test.png"));
//btnNewButton.setImage(ResourceManager.getPluginImage("org.eclipse.ui", "/icons/full/etool16/copy_edit.gif"));
}
}
* Add com.sneda.wb.test1 as a plugin dependency
* Manually add (or regenerate) the WindowBuilder classes: ResourceManager & SWTResourceManager.
* Open the class MyComp with WindowBuilder
I couldn't manage to see my image test.png neither in myComponent nor in btnNewButton, unless I import the source of com.sneda.wb.test1 in my WS.
Thanks again,
--andiqo
[Updated on: Mon, 22 August 2011 09:22] Report message to a moderator
|
|
|
|
Powered by
FUDForum. Page generated in 0.01912 seconds