|
|
|
Re: Custom Widgets how to ? [message #450489 is a reply to message #450484] |
Mon, 14 February 2005 11:36 |
Eclipse User |
|
|
|
Originally posted by: ekkehardREMOVE_NO_SPAM.gentz-software.de
subclassing is by default not allowed,
but I think you can do it if you do no strange things
if you subclass and add
protected void checkSubclass() {
// this eliminitates the check and allows subclassing
}
then there'll be no exception.
of course be prepared to change your code if future eclipse releases
change things
regards
ekkehard
Michael Borchert schrieb:
> Maybe this is a silly question. But I want SWT Widgets to have a general
> behaviour.
> E.g. adding FocusListener to change color when entering and leaving.
> In Swing I would do this with subclassing the widgets. How can I do that
> with SWT as
> it is not allowed to subclass a widget.
>
> Many thanks
> Michael
>
>
|
|
|
|
|
Re: Custom Widgets how to ? [message #450529 is a reply to message #450488] |
Tue, 15 February 2005 07:55 |
Peter Goetz Messages: 38 Registered: July 2009 |
Member |
|
|
Michael Borchert wrote:
> Thank you very much,
>
> can you please post me an example of such a wrapper ?
unfortunately I am not allowed to give the code away. But I can give you
an overview of the structure of our controls.
We have an abstract control which encapsulates an Object (the widget), a
SecurityContext (our class for defining rights), and some other Strings
and booleans to hold the state of the control (enabled, disabled,
read-only, ...). In the abstract control class we define internal
methods to instantiate the right stuff and the widget.
Every one of our control classes inherits from the abstract class. We
have something like MyButton, MyText, MyCombo, ...
The MyText, for example, defines his own instance variables for perhaps
the data type or a regular expression that the input must match. There
are several constructors in the control class to instantiate controls
with and without rights or data type checks plus the necessary
information for swt (parent control and style bits). With these the real
widget is instantiated. The real widget can be got as a reference via a
get method so you can use methods like clearSelection without having to
implement these in the control class and giving it to the widget. But
there are also convenience methods in the control class like setIntValue
to check the input from the user on data integrity.
The layout of the widgets is also done direct on the widgets via the get
method of the control.
That's it. The principles are very simple, we just have a control that
encapsulates the widget and looks for rights, data integrity and other
convenience cases.
I hope that helps you, although you don't get any code from me.
Peter
|
|
|
|
Re: Custom Widgets how to ? [message #450882 is a reply to message #450529] |
Sat, 19 February 2005 12:16 |
Michael Borchert Messages: 27 Registered: July 2009 |
Junior Member |
|
|
Hello Peter,
thank you very much.
I'll try this today, maybe have some other questions.
Michael
"Peter Goetz" <kingofbrain@web.de> schrieb im Newsbeitrag
news:cusa01$j22$1@www.eclipse.org...
> Michael Borchert wrote:
>> Thank you very much,
>>
>> can you please post me an example of such a wrapper ?
>
> unfortunately I am not allowed to give the code away. But I can give you
> an overview of the structure of our controls.
> We have an abstract control which encapsulates an Object (the widget), a
> SecurityContext (our class for defining rights), and some other Strings
> and booleans to hold the state of the control (enabled, disabled,
> read-only, ...). In the abstract control class we define internal methods
> to instantiate the right stuff and the widget.
> Every one of our control classes inherits from the abstract class. We have
> something like MyButton, MyText, MyCombo, ...
> The MyText, for example, defines his own instance variables for perhaps
> the data type or a regular expression that the input must match. There are
> several constructors in the control class to instantiate controls with and
> without rights or data type checks plus the necessary information for swt
> (parent control and style bits). With these the real widget is
> instantiated. The real widget can be got as a reference via a get method
> so you can use methods like clearSelection without having to implement
> these in the control class and giving it to the widget. But there are also
> convenience methods in the control class like setIntValue to check the
> input from the user on data integrity.
> The layout of the widgets is also done direct on the widgets via the get
> method of the control.
> That's it. The principles are very simple, we just have a control that
> encapsulates the widget and looks for rights, data integrity and other
> convenience cases.
>
> I hope that helps you, although you don't get any code from me.
>
> Peter
|
|
|
Powered by
FUDForum. Page generated in 0.02246 seconds