Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » WindowBuilder » Images from component?
Images from component? [message #717077] Fri, 19 August 2011 08:29 Go to next message
andiqo  is currently offline andiqo Friend
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 Go to previous messageGo to next message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
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 Go to previous messageGo to next message
andiqo  is currently offline andiqo Friend
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

Re: Images from component? [message #718188 is a reply to message #717760] Tue, 23 August 2011 14:43 Go to previous message
Konstantin Scheglov is currently offline Konstantin ScheglovFriend
Messages: 555
Registered: July 2009
Senior Member
Fixed in trunk.

Konstantin Scheglov,
Google, Inc.
Previous Topic:NPE in GridLayout2 after adding a getter
Next Topic:A GUI with dynamically changeable "inner view" of other components.
Goto Forum:
  


Current Time: Fri Apr 19 09:34:43 GMT 2024

Powered by FUDForum. Page generated in 0.01912 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top