Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » Visual Editor (VE) » Extending and adding a SWT Button as a new control in Visual Editor
Extending and adding a SWT Button as a new control in Visual Editor [message #135056] Fri, 19 January 2007 01:40 Go to next message
Eclipse UserFriend
Originally posted by: sunil_ramaiah.intuit.com

Hi,

I am trying to add a new Control in the palette. I am extending the Button
widget and added some attributes. I can see this control in the palette,
following the example on VE.

When I drop this on a Composite, the bounds is set to x, y, -1, -1 and in
the Bean property tree it says error with bounds. If I change in this in
the code, then it says -

SWTException(Subclassing not allowed)

Any ideas on what I am doing wrong ?

Thanks,
Sunil.
Re: Extending and adding a SWT Button as a new control in Visual Editor [message #135069 is a reply to message #135056] Fri, 19 January 2007 15:35 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Button is not intended to be subclasses outside of SWT itself. So there
may be SWT problems with doing this. That is what is producing the
SWTException(Subclassing not allowed) message. SWT is not allowing you
to do this.

The javadoc for Button says:

* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.

> SWTException(Subclassing not allowed)
>
> Any ideas on what I am doing wrong ?
> Thanks,
> Sunil.
>

--
Thanks,
Rich Kulp
Re: Extending and adding a SWT Button as a new control in Visual Editor [message #135095 is a reply to message #135056] Sat, 20 January 2007 17:33 Go to previous message
Eric Clayberg is currently offline Eric ClaybergFriend
Messages: 979
Registered: July 2009
Location: Boston, MA
Senior Member
"Sunil Ramaiah" <sunil_ramaiah@intuit.com> wrote in message
news:361a92633a506256678e77268f9d9c67$1@www.eclipse.org...
>
> I am trying to add a new Control in the palette. I am extending the Button
> widget and added some attributes. I can see this control in the palette,
> following the example on VE.
> When I drop this on a Composite, the bounds is set to x, y, -1, -1 and in
> the Bean property tree it says error with bounds. If I change in this in
> the code, then it says -
> SWTException(Subclassing not allowed)
>
> Any ideas on what I am doing wrong ?

If you want to create custom Button, you should either wrapper it it a
Composite or subclass Button and override the checkSubclass() method to do
nothing. E.g.,

protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}

Note that to safely subclass Button (or any other SWT widget), it is
important that your subclass only access its state through public accessors.
Do not access any state via fields because the implementation of the widget
might be very different on different platforms.

-Eric Clayberg
Sr. Vice President of Product Development
Instantiations, Inc.
http://www.instantiations.com
http://www.windowbuilderpro.com/

Author: "Eclipse: Building Commercial Quality Plug-ins"
http://www.awprofessional.com/title/0321228472
Re: Extending and adding a SWT Button as a new control in Visual Editor [message #615009 is a reply to message #135056] Fri, 19 January 2007 15:35 Go to previous message
Eclipse UserFriend
Originally posted by: richkulp.us.NO_SPAM.ibm.com

Button is not intended to be subclasses outside of SWT itself. So there
may be SWT problems with doing this. That is what is producing the
SWTException(Subclassing not allowed) message. SWT is not allowing you
to do this.

The javadoc for Button says:

* IMPORTANT: This class is intended to be subclassed <em>only</em>
* within the SWT implementation.

> SWTException(Subclassing not allowed)
>
> Any ideas on what I am doing wrong ?
> Thanks,
> Sunil.
>

--
Thanks,
Rich Kulp
Re: Extending and adding a SWT Button as a new control in Visual Editor [message #615011 is a reply to message #135056] Sat, 20 January 2007 17:33 Go to previous message
Eric Clayberg is currently offline Eric ClaybergFriend
Messages: 979
Registered: July 2009
Location: Boston, MA
Senior Member
"Sunil Ramaiah" <sunil_ramaiah@intuit.com> wrote in message
news:361a92633a506256678e77268f9d9c67$1@www.eclipse.org...
>
> I am trying to add a new Control in the palette. I am extending the Button
> widget and added some attributes. I can see this control in the palette,
> following the example on VE.
> When I drop this on a Composite, the bounds is set to x, y, -1, -1 and in
> the Bean property tree it says error with bounds. If I change in this in
> the code, then it says -
> SWTException(Subclassing not allowed)
>
> Any ideas on what I am doing wrong ?

If you want to create custom Button, you should either wrapper it it a
Composite or subclass Button and override the checkSubclass() method to do
nothing. E.g.,

protected void checkSubclass() {
// Disable the check that prevents subclassing of SWT components
}

Note that to safely subclass Button (or any other SWT widget), it is
important that your subclass only access its state through public accessors.
Do not access any state via fields because the implementation of the widget
might be very different on different platforms.

-Eric Clayberg
Sr. Vice President of Product Development
Instantiations, Inc.
http://www.instantiations.com
http://www.windowbuilderpro.com/

Author: "Eclipse: Building Commercial Quality Plug-ins"
http://www.awprofessional.com/title/0321228472
Previous Topic:Extending Visual Editor to generate XML instead of Java code
Next Topic:VE Won't Start Without Error
Goto Forum:
  


Current Time: Fri Apr 19 23:55:26 GMT 2024

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

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

Back to the top