[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
RE: [platform-swt-dev] ordering problem adding buttons to a GridLayout
|
Randy,
Thanks
for the code. I'm aware of this technique, and in fact your code gives a
really good example to be discussed. Here's some questions that illustrate
the issues with imposing the lack of zero-arg constructors for
Controls:
1. In order to create the button instance, you absolutely have to
have carnal knowledge of the constructor and class you are working with.
Otherwise, you don't know which Constructor to use, or how to address
it.
2. This code makes the assumption that the final parent shell
instance is available at the time the button instance needs to be created.
This shouldn't always have to be the case.
3.
From a previous thread, it is apparent that a control cannot be added / removed
from a composite at runtime, but only associated with a single parent via its
constructor argument on creation. So rather than builder being able to add
/ remove Controls from parents, they have to be continually disposed and
recreated (with all of its children).
Anyway, thanks for the reply.
BradO
-----Original Message-----
From:
platform-swt-dev-admin@xxxxxxxxxxx
[mailto:platform-swt-dev-admin@xxxxxxxxxxx]On Behalf Of Randy
Hudson
Sent: Thursday, October 23, 2003 10:53 AM
To:
platform-swt-dev@xxxxxxxxxxx
Subject: RE: [platform-swt-dev] ordering
problem adding buttons to a GridLayout
Try this code:
import
java.lang.reflect.Constructor;
import
org.eclipse.swt.layout.RowLayout;
import
org.eclipse.swt.widgets.Display;
import
org.eclipse.swt.widgets.Shell;
public
class Main {
public
static void main(String[] args)
throws Exception {
Display display = new Display();
Shell shell = new Shell();
shell.setLayout(new RowLayout());
Class clazz = Class.forName("org.eclipse.swt.widgets.Button");
Constructor c = clazz.getConstructors()[0];
c.newInstance(new Object[] {shell,
new Integer(0)});
shell.setSize(400,300);
shell.open();
while (!shell.isDisposed())
if
(!display.readAndDispatch())
display.sleep();
}
}
| "Brad O'Hearne"
<brado@xxxxxxxxxxxxx> Sent by: platform-swt-dev-admin@xxxxxxxxxxx
10/22/2003 01:30 PM Please respond to platform-swt-dev
| To:
<platform-swt-dev@xxxxxxxxxxx> cc:
Subject: RE: [platform-swt-dev]
ordering problem adding buttons to a
GridLayout |
Steve,
Thanks for the response. I have a couple of
comments below:
> 1) Fixed > 20031022
Based on your next
two points, I'm a bit confused -- what was fixed?
> 2) From the SWT
Home Page, "SWT component is designed to provide
> efficient, portable,
access to the user-interface facilitites of
> the operating system", not
facilitate GUI builders.
I'm not going to debate this one with you, but
this statement doesn't
preclude or forbid thoughtful design decisions to
facilitate easier use of
the API. I have a hard time believing the
SWT effort was launched with a
staunch "developer programming only" intent
and aimed to be deaf to the
concerns of API usage. Perhaps it is a
style choice, perhaps it is
something more significant, but that will
remain a matter of opinion I
suppose. I read the last thread many
months ago on this, and if history
serves, I don't see another debate as
ending in something productive. I'll
just leave it with this piece of
advice: any API that intends to be as
user-friendly as possible and desires
to see extensive automation built on
top of it needs to provide classes
with parameterless (default)
constructors....period. Otherwise,
dynamically creating instances via
ClassLoaders cannot be done.
>
3) Layout is not automatic when a child is added or deleted or hidden
etc.
This was done for efficiency.
I don't quite follow the
rationale here. I'm not sure what purpose there is
in efficiency when
expected behavior is broken. The Javadoc states:
"Widgets are
laid out in columns from left to right,"
but the behavior isn't
consistent -- left to right in one case and right to
left in another.
I can't think of a use-case where a user would want their
layout to
completely violate expected behavior because a child is added
or
deleted.
Steve, please forgive me if this sounds a bit curt.
It is not my intention.
I am sure you are a terrific guy, with all
good intents, but after reading
the list thread touching on the issue many
months ago, and receiving
essentially the same RTFM response here, I am a
bit disappointed. I guess I
hoped that an honest technical suggestion
would be met with an honest
technical answer on its merits/weaknesses
provided the suggestion was in
scope....and I have a hard time
understanding how the usage of the SWT API
is out of the bounds of the
scope of the SWT project.
Anyway, I'll figure out a way around
this.
Cheers,
BradO
_______________________________________________
platform-swt-dev
mailing
list
platform-swt-dev@xxxxxxxxxxx
http://dev.eclipse.org/mailman/listinfo/platform-swt-dev