Re: [nbusers] Does NetBeans support Beans.isDesignTime() calls ?
Trung Duc Tran 28 November 2000 19:59:10
On Tue, 21 Nov 2000 14:10:40 +0100 "Patrick Ruzand" <pruzand@ilog.fr> wrote:
Hello all,>
[NB 3.1 beta bld.7]>
I'm currently working on a Bean class. This class> is a graphical representation of a set of data contained in> a data model. Typically (aka by code), the data model would be > first populated then attached to the graphics representation (the bean).> To avoid to have an empty Bean when using it inside an ide,> I populate it with a default datamodel, but only at design time.> It gives something like :>
public Foobar() {> ...> if (Beans.isDesignTime()) {> setModel(new DefaultModel());> }> }>
This works well under most of the ide, except under our> favorite one : NetBeans, where I don't have the expected result> (nothing happens).>
So, does NetBeans support the Beans.isDesignTime() API ?
not now. This is actually very interesting issue. I'm glad you brought it up. You're probably one of very rare developers who take advantage of Beans.isDesignTime().
To make Beans.isDesignTime() to return true for your beans inside the IDE is simple and tricky at the same time. The IDE can just add a single call Beans.setDesignTime(true) somewhere during startup. The tricky part is that your bean's code lives in the same JVM as the IDE. By settings designTime to true for your beans we set it true for the whole IDE. As of now no beans which I know, or at least not those standard ones used by the IDE differentiate their behavior based on Beans.isDesignTime(). So I could do it safely. But things will stop working if someone starts using your beans in some IDE modules.
I cc nbdev mailing lists. If someone has some bright ideas, please, let me and the list know
Patrick Ruzand 22 November 2000 10:42:41 [ permanent link ]
Hi Trung,
So, does NetBeans support the Beans.isDesignTime() API ?>
not now. This is actually very interesting issue. I'm glad you brought> it up. You're probably one of very rare developers who take advantage> of Beans.isDesignTime().
According to the huge number of reactions , it seems so...
To make Beans.isDesignTime() to return true for your beans inside the> IDE is simple and tricky at the same time. The IDE can just add a> single call Beans.setDesignTime(true) somewhere during startup. The> tricky part is that your bean's code lives in the same JVM as the IDE.> By settings designTime to true for your beans we set it true for the> whole IDE. As of now no beans which I know, or at least not those> standard ones used by the IDE differentiate their behavior based on> Beans.isDesignTime(). So I could do it safely. But things will stop> working if someone starts using your beans in some IDE modules.
I understand your point. But maybe it could be the default behavior. I'm really convinced that NB should be able to return whether we are in design time : adapting the behavior of a bean depending on when it is used is a possibility offers by the Bean specs and should be supported by Bean boxes. Furthermore, setting Beans.designTime to true when the ide starts should have less side effects than the contrary. The advantage is that all the beans will work as expected, the only drawback is that only modules that use a bean that uses itself the isDesignTime() feature will not work. I don't know NB enough but are there a lot of such modules out there ?
Finally, but it may be a stupid idea (since as I told you my knowledge of the way NB works internally is near zero) don't you think it could be set only at GUI Design time ? For example, when the GUI Editing workspace is activated (provided of course it is the only way to use the form editor) ?
Just my 2 cts on this subject. (Of course, my opinion is perhaps a little subjective... .
Anyway, for the time being, your workaround will do the trick. I will do that.
Thanks a lot, and congratulation for this great tool that NB is.
Trung Duc Tran 22 November 2000 19:46:39 [ permanent link ]
On Wed, 22 Nov 2000 08:42:41 +0100 "Patrick Ruzand" <pruzand@ilog.fr> wrote:
Hi Trung,>
So, does NetBeans support the Beans.isDesignTime() API ?> >
not now. This is actually very interesting issue. I'm glad you brought> > it up. You're probably one of very rare developers who take advantage> > of Beans.isDesignTime().>
According to the huge number of reactions , it seems so...>
To make Beans.isDesignTime() to return true for your beans inside the> > IDE is simple and tricky at the same time. The IDE can just add a> > single call Beans.setDesignTime(true) somewhere during startup. The> > tricky part is that your bean's code lives in the same JVM as the IDE.> > By settings designTime to true for your beans we set it true for the> > whole IDE. As of now no beans which I know, or at least not those> > standard ones used by the IDE differentiate their behavior based on> > Beans.isDesignTime(). So I could do it safely. But things will stop> > working if someone starts using your beans in some IDE modules.>
I understand your point. > But maybe it could be the default behavior. I'm really convinced> that NB should be able to return whether we are in design time :> adapting the behavior of a bean depending on when it is used is a> possibility offers by the Bean specs and should be supported by> Bean boxes.> Furthermore, setting Beans.designTime to true when the ide starts> should have less side effects than the contrary. The> advantage is that all the beans will work as expected, the only> drawback is that only modules that use a bean that uses itself the> isDesignTime() feature will not work. I don't know NB enough but> are there a lot of such modules out there ?
Beans.isDesignTime() returns 'true' now, this will appear in the next NB 3.1beta build. Please have a look and tell us if this change satisfies your needs.
Bill Shannon 23 November 2000 03:36:35 [ permanent link ]
Shouldn't you also add support for java.beans.DesignMode so that beans that might actually be used in the IDE itself can be told that it's *not* design time, while simple beans being designed in the IDE can use the global Beans.isDesignTime?
Patrick Ruzand 28 November 2000 12:18:39 [ permanent link ]
Hello Trung,
----- Original Message ----- From: "Trung Duc Tran" <trung.duc.tran@netbeans.com> To: <nbusers@netbeans.org> Cc: <nbdev@netbeans.org>
Beans.isDesignTime() returns 'true' now, this will appear in the next NB> 3.1beta build. Please have a look and tell us if this change satisfies> your needs.
At first, I'm sorry to get back to you so late. The patch does the trick. It's perfect.
Trung Duc Tran 28 November 2000 19:59:10 [ permanent link ]
On Wed, 22 Nov 2000 16:36:35 -0800 (PST) Bill Shannon <Bill.Shannon@Eng.Sun.COM> wrote:
Shouldn't you also add support for java.beans.DesignMode so that beans> that might actually be used in the IDE itself can be told that it's> *not* design time, while simple beans being designed in the IDE can> use the global Beans.isDesignTime?
good idea. I'll add support for java.beans.DesignMode in the list of features planed for the next release (3.2)