Custom Widget

SWT Designer allows you to create the views, editors, perspectives, pref pages, composites, etc. that comprise Eclipse SWT & RCP applications and plug-ins.

Moderators: Konstantin.Scheglov, gnebling, Alexander.Mitin, jwren, Eric Clayberg

Custom Widget

Postby ere » Sat Sep 18, 2004 1:51 pm

After reading some forum entries related to custom widgets I've tried one easy as well:

public class BText
extends org.eclipse.swt.widgets.Text
{
}

Afterwards I've tried to add this widge in "Window - Preferences - Designer - SWT - Custom Controls" but I doens't show up.

What did I miss? Do I need to deploy this class somewhere?

TIA
Rene
ere
 
Posts: 6
Joined: Sat Sep 18, 2004 1:47 pm

Re: Custom Widget

Postby Eric Clayberg » Sat Sep 18, 2004 7:05 pm

ere wrote:What did I miss?

You need to define a public two-argument constructor within the class.
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Postby ere » Sat Sep 18, 2004 11:02 pm

Eric, I did (soory I didn't paste the whole class in my initial message)

here we go with the *complete* class:

public class BText
extends org.eclipse.swt.widgets.Text
{
private String capitalization;

public BText(Composite parent, int style)
{
super(parent, style);
}

public String getCapitalization()
{
return capitalization;
}
public void setCapitalization(String capitalization)
{
this.capitalization = capitalization;
}
}

and it doesn't show up
ere
 
Posts: 6
Joined: Sat Sep 18, 2004 1:47 pm

Postby Eric Clayberg » Sun Sep 19, 2004 4:37 am

ere wrote:here we go with the *complete* class

Is that the complete class? I didn't see any imports or package definition.

I tried your class and it worked fine on my end. Here is is showing up in the selection dialog...

Image

...and here it is in use within a test window (note that the custom "capitalization" property shows up)...

Image

If you can't see the class on your end, I would check your classpath to make sure that the custom widget class is visible to the window you want to use it in.

Where do you have it located relative to your window class?

Are you able to select it using the Choose Bean command within the SWT Designer editor itself?
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Postby ere » Sun Sep 19, 2004 7:06 am

you're right, I guess it was to early, here you go with package and import:

package test.uiControls;

import org.eclipse.swt.widgets.Composite;

public class BText
extends org.eclipse.swt.widgets.Text
{
private String capitalization;

public BText(Composite parent, int style)
{
super(parent, style);
}

public String getCapitalization()
{
return capitalization;
}
public void setCapitalization(String capitalization)
{
this.capitalization = capitalization;
}
}

If I change the source of a class to use this BText it works and shows my custom attribute but either "choose bean" nor the preference page can find it. As it is in the same project as where I try to use this widget in an example class (test.plugin.hello.HelloEditor01) I guess it should be on the classpath - right?
ere
 
Posts: 6
Joined: Sat Sep 18, 2004 1:47 pm

Postby Eric Clayberg » Sun Sep 19, 2004 8:10 am

ere wrote:If I change the source of a class to use this BText it works and shows my custom attribute but either "choose bean" nor the preference page can find it. As it is in the same project as where I try to use this widget in an example class (test.plugin.hello.HelloEditor01) I guess it should be on the classpath - right?

Do any widgets show up in the Choose Bean dialog? If so, which ones? Can you send a screen shot of what you see there?
Eric Clayberg
Software Engineering Manager
Google
http://code.google.com/webtoolkit/download.html

Author: "Eclipse Plug-ins"
http://www.qualityeclipse.com
Eric Clayberg
Moderator
 
Posts: 4503
Joined: Tue Sep 30, 2003 6:39 am
Location: Boston, MA USA

Postby ere » Sun Sep 19, 2004 10:03 pm

solved

problem was, that after upgrading from Eclipse 3.0.0 to 3.0.1 I had
ECLIPSE_HOME/plugins/org.eclipse.swt.win32_3.0.0/ws/win32/swt.jar AND ECLIPSE_HOME/plugins/org.eclipse.swt.win32_3.0.1/ws/win32/swt.jar on my classpath.

After disabling the 3.0.0 plugin everything works fine

Thanks to Eric
ere
 
Posts: 6
Joined: Sat Sep 18, 2004 1:47 pm


Return to SWT Designer

Who is online

Users browsing this forum: No registered users and 1 guest