You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pivot.apache.org by Sandro Martini <sa...@gmail.com> on 2013/10/04 17:39:55 UTC

Inject properties in Application

Hi all,
after doing some test from Groovy, using some Groovy Script to create
minimal Pivot Applications, for more tests on this:
https://issues.apache.org/jira/browse/PIVOT-917
you can find related examples here:
http://svn.codespot.com/a/apache-extras.org/pivot-stuff/trunk/pivot-stuff-common-groovy/

I'm thinking that for 2.1 could be useful to have a way to inject data
inside Applications, for example have some variable (like a
Classloader and maybe others) in a script and inject (or even set by
hand) in the Application.
But of course this requires a little update in that API, like add a
method setExternalProperties(Map <String, Object> properties) or
similar ... and let Applications implement it if needed (or use the
empty version in Application.Adapter) ...


Then, DesktopApplicationContext currently uses a Class instance of
Application (dynamically loading the class instance), so maybe we
could even add a method to get an Application instance already created
...


What do you think ?


Note:
after Groovy, even Scala-2.11.0 (now in Milestone 5) should support
Scripting from shell, so this kind of features could be useful ...
And on Jython I'm sure we'll find a way to make it work the same,
probably the PIVOT-917 issue (see above) will be resolved rewriting
related samples in the "right Pivot-way" :-) ... if someone want to
help us on this, is welcome.

Bye,
Sandro

Re: Inject properties in Application

Posted by Sandro Martini <sa...@gmail.com>.
Hi all,
just committed a starting version of required changes.
This is the related issue: https://issues.apache.org/jira/browse/PIVOT-926

Note that all changes here are mostly additions/new methods and
utility classes, and a minimal test application (as usual).
The main change in DesktopApplicationContext is triggered only when
using (in application code) the new (additional) main method just
created, so all should be good for existing applications.

Tell me for comments/suggestions or of course for problems.

Bye

Re: ListButton - Auto key input completion

Posted by David Ray <da...@barchart.com>.
Thanks Roger!

That's precisely what I was looking for (minus some highlighting which I think I can figure out).

:)

David

On Oct 16, 2013, at 11:11 AM, "Roger L. Whitcomb" <Ro...@actian.com> wrote:

> Hi David,
> 	That's for using Pivot!  Have you looked at SuggestionPopup?
> (see the tutorial here:
> http://pivot.apache.org/tutorials/suggestion-popups.html)
> 
> ~Roger
> 
> -----Original Message-----
> From: David Ray [mailto:david.ray@barchart.com] 
> Sent: Wednesday, October 16, 2013 8:37 AM
> To: dev@pivot.apache.org
> Subject: ListButton - Auto key input completion
> 
> Hi Guys,
> 
> 
> 	By any chance could someone point me to the relevant
> listeners/renderers necessary to implement auto-completion on a
> ListButton?
> 
> 	I know with the degree of polish that pivot has, that there is
> some ready-made implementation, I just wouldn't know where to find the
> 	relevant mechanisms and idioms for usage?
> 
> Much Obliged - and I'm loving Pivot's degree of finish thus far,
> 
> David
> 
> 
> On Oct 10, 2013, at 5:46 PM, Sandro Martini <sa...@gmail.com>
> wrote:
> 
>> Hi Roger, thanks for the feedback.
>> 
>>> I'm thinking there is an elegant solution to this, but I'm not seeing
> it at the moment.
>> me too :-) ...
>> 
>>> But, I do see the idea that you need to pass variables through to the
> application (somehow).
>> ok
>> 
>>> So, the question is:  how to do this best without breaking existing
> programs....
>> but all should be as an addition, no existing methods changes (from an
> 
>> user point of view) ...
>> 
>> 
>>> Maybe a small test case / POC would help to define the problem more
> clearly?!
>> yes, I'll try next week. I'll add a JIRA issue as wish for 2.1 and 
>> attach a patch if possible.
>> 
>> 
>> Of course if others have some comment/suggestion, we are here ...
>> 
>> 
>> Thanks for now.
>> 
>> Bye,
>> Sandro
> 


RE: ListButton - Auto key input completion

Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
Hi David,
	That's for using Pivot!  Have you looked at SuggestionPopup?
(see the tutorial here:
http://pivot.apache.org/tutorials/suggestion-popups.html)

~Roger

-----Original Message-----
From: David Ray [mailto:david.ray@barchart.com] 
Sent: Wednesday, October 16, 2013 8:37 AM
To: dev@pivot.apache.org
Subject: ListButton - Auto key input completion

Hi Guys,


	By any chance could someone point me to the relevant
listeners/renderers necessary to implement auto-completion on a
ListButton?

	I know with the degree of polish that pivot has, that there is
some ready-made implementation, I just wouldn't know where to find the
	relevant mechanisms and idioms for usage?

Much Obliged - and I'm loving Pivot's degree of finish thus far,

David


On Oct 10, 2013, at 5:46 PM, Sandro Martini <sa...@gmail.com>
wrote:

> Hi Roger, thanks for the feedback.
> 
>> I'm thinking there is an elegant solution to this, but I'm not seeing
it at the moment.
> me too :-) ...
> 
>> But, I do see the idea that you need to pass variables through to the
application (somehow).
> ok
> 
>> So, the question is:  how to do this best without breaking existing
programs....
> but all should be as an addition, no existing methods changes (from an

> user point of view) ...
> 
> 
>> Maybe a small test case / POC would help to define the problem more
clearly?!
> yes, I'll try next week. I'll add a JIRA issue as wish for 2.1 and 
> attach a patch if possible.
> 
> 
> Of course if others have some comment/suggestion, we are here ...
> 
> 
> Thanks for now.
> 
> Bye,
> Sandro


ListButton - Auto key input completion

Posted by David Ray <da...@barchart.com>.
Hi Guys,


	By any chance could someone point me to the relevant listeners/renderers necessary to implement auto-completion on a ListButton?

	I know with the degree of polish that pivot has, that there is some ready-made implementation, I just wouldn't know where to find the
	relevant mechanisms and idioms for usage?

Much Obliged - and I'm loving Pivot's degree of finish thus far,

David


On Oct 10, 2013, at 5:46 PM, Sandro Martini <sa...@gmail.com> wrote:

> Hi Roger, thanks for the feedback.
> 
>> I'm thinking there is an elegant solution to this, but I'm not seeing it at the moment.
> me too :-) ...
> 
>> But, I do see the idea that you need to pass variables through to the application (somehow).
> ok
> 
>> So, the question is:  how to do this best without breaking existing programs....
> but all should be as an addition, no existing methods changes (from an
> user point of view) ...
> 
> 
>> Maybe a small test case / POC would help to define the problem more clearly?!
> yes, I'll try next week. I'll add a JIRA issue as wish for 2.1 and
> attach a patch if possible.
> 
> 
> Of course if others have some comment/suggestion, we are here ...
> 
> 
> Thanks for now.
> 
> Bye,
> Sandro


Re: Inject properties in Application

Posted by Sandro Martini <sa...@gmail.com>.
Hi Roger, thanks for the feedback.

> I'm thinking there is an elegant solution to this, but I'm not seeing it at the moment.
me too :-) ...

> But, I do see the idea that you need to pass variables through to the application (somehow).
ok

> So, the question is:  how to do this best without breaking existing programs....
but all should be as an addition, no existing methods changes (from an
user point of view) ...


> Maybe a small test case / POC would help to define the problem more clearly?!
yes, I'll try next week. I'll add a JIRA issue as wish for 2.1 and
attach a patch if possible.


Of course if others have some comment/suggestion, we are here ...


Thanks for now.

Bye,
Sandro

RE: Inject properties in Application

Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
I read through some of the documents you mentioned, but not all yet.

I'm thinking there is an elegant solution to this, but I'm not seeing it
at the moment.

But, I do see the idea that you need to pass variables through to the
application (somehow).
So, the question is:  how to do this best without breaking existing
programs....

Maybe a small test case / POC would help to define the problem more
clearly?!

~Roger


-----Original Message-----
From: Sandro Martini [mailto:sandro.martini@gmail.com] 
Sent: Thursday, October 10, 2013 7:14 AM
To: Developers - Apache Pivot
Subject: Re: Inject properties in Application

Hi all, no comments ?

Bye


2013/10/8 Sandro Martini <sa...@gmail.com>:
> Hi,
> ok, I'll try to better explain my requirements here, if it's not 
> enough clear tell me :-) ...
>
> As starting point, look here:
> http://svn.codespot.com/a/apache-extras.org/pivot-stuff/trunk/pivot-st
> uff-common-groovy/test/pivot_stuff/common_groovy/
> all .gsh files are Groovy Scripts (they could be .groovy, but I rename

> to .gsh to be more clear that they are scripts), and they use some 
> Groovy code (in some case inside the script, in others external in 
> .groovy classes just for convenience).
> And of course Groovy code there extends Pivot Java code ...
> To run examples you can find Windows batch files here:
> http://svn.codespot.com/a/apache-extras.org/pivot-stuff/trunk/pivot-st
> uff-common-groovy/_scripts/
>
> The concept is similar to this:
> http://groovy.codehaus.org/Scripts+and+Classes
>
> Use Case 1:
> a Groovy/Java/Scala/etc application that executes a script, for simple

> (or user-written) things ... but for this probably all is ok (no 
> changes required).
>
> Use Case 2:
> a Groovy (soon Scala) Script that calls Groovy/Java code, and in that 
> script I could define variables/objects (like an external 
> environment), and currently I'm not able to pass to the application 
> unless I use some singleton trick.
> Generally speaking I don't like too much the all-singleton approach 
> ... in a world evolving much more in multi-core/multi-thread (and 
> hard-to-do-well and not-too-much-unnecessary-synchronization) this is 
> a good reason to me.
> But if for all us this is enough I can live with it :-) ...
>
> This is a field where I'd like to push Pivot:
> http://www.reactivemanifesto.org/
> but could be for a long-term roadmap ... I'll post some idea later on 
> this (many of us know that I'm a big fan of Scala and related
> products) because it's a big thing, and not strictly related to this.
>
>
>> I'm thinking that for 2.1 could be useful to have a way to inject 
>> data inside Applications, for example have some variable (like a 
>> Classloader and maybe others) in a script and inject (or even set by
>> hand) in the Application.
>> But of course this requires a little update in that API, like add a 
>> method setExternalProperties(Map <String, Object> properties) or 
>> similar ... and let Applications implement it if needed (or use the 
>> empty version in Application.Adapter) ...
> in this way we could be able to define objects from "outside" and set 
> in Pivot Application, but of course we should create an instance of 
> Application (custom, or Application.Adappter), and then set in it all 
> desired values.
>
>> Then, DesktopApplicationContext currently uses a Class instance of 
>> Application (dynamically loading the class instance), so maybe we 
>> could even add a method to get an Application instance already
created ...
> Here we could add a startup flag that when given (not sure if it's the

> best way, I have to check this), the Application class instance is 
> taken from the externalProperties Map (if found) and used instead of 
> dynamically load it by name, so this small change should only be an 
> addition, reusing existing methods.
> The problem here could be that Application instance should not be 
> already started (but writing in JavaDoc should be enough) ... so the 
> only other problem I see here could be a malicious injection from 
> "outside" in Application, but I don't think this could be a real 
> problem because it's up to the developer to use them.
>
>
> What do you think ?
>
> Bye,
> Sandro

Re: Inject properties in Application

Posted by Sandro Martini <sa...@gmail.com>.
Hi all, no comments ?

Bye


2013/10/8 Sandro Martini <sa...@gmail.com>:
> Hi,
> ok, I'll try to better explain my requirements here, if it's not
> enough clear tell me :-) ...
>
> As starting point, look here:
> http://svn.codespot.com/a/apache-extras.org/pivot-stuff/trunk/pivot-stuff-common-groovy/test/pivot_stuff/common_groovy/
> all .gsh files are Groovy Scripts (they could be .groovy, but I rename
> to .gsh to be more clear that they are scripts), and they use some
> Groovy code (in some case inside the script, in others external in
> .groovy classes just for convenience).
> And of course Groovy code there extends Pivot Java code ...
> To run examples you can find Windows batch files here:
> http://svn.codespot.com/a/apache-extras.org/pivot-stuff/trunk/pivot-stuff-common-groovy/_scripts/
>
> The concept is similar to this:
> http://groovy.codehaus.org/Scripts+and+Classes
>
> Use Case 1:
> a Groovy/Java/Scala/etc application that executes a script, for simple
> (or user-written) things ... but for this probably all is ok (no
> changes required).
>
> Use Case 2:
> a Groovy (soon Scala) Script that calls Groovy/Java code, and in that
> script I could define variables/objects (like an external
> environment), and currently I'm not able to pass to the application
> unless I use some singleton trick.
> Generally speaking I don't like too much the all-singleton approach
> ... in a world evolving much more in multi-core/multi-thread (and
> hard-to-do-well and not-too-much-unnecessary-synchronization) this is
> a good reason to me.
> But if for all us this is enough I can live with it :-) ...
>
> This is a field where I'd like to push Pivot:
> http://www.reactivemanifesto.org/
> but could be for a long-term roadmap ... I'll post some idea later on
> this (many of us know that I'm a big fan of Scala and related
> products) because it's a big thing, and not strictly related to this.
>
>
>> I'm thinking that for 2.1 could be useful to have a way to inject data
>> inside Applications, for example have some variable (like a Classloader
>> and maybe others) in a script and inject (or even set by
>> hand) in the Application.
>> But of course this requires a little update in that API, like add a
>> method setExternalProperties(Map <String, Object> properties) or similar
>> ... and let Applications implement it if needed (or use the empty
>> version in Application.Adapter) ...
> in this way we could be able to define objects from "outside" and set
> in Pivot Application, but of course we should create an instance of
> Application (custom, or Application.Adappter), and then set in it all
> desired values.
>
>> Then, DesktopApplicationContext currently uses a Class instance of
>> Application (dynamically loading the class instance), so maybe we could
>> even add a method to get an Application instance already created ...
> Here we could add a startup flag that when given (not sure if it's the
> best way, I have to check this), the Application class instance is
> taken from the externalProperties Map (if found) and used instead of
> dynamically load it by name, so this small change should only be an
> addition, reusing existing methods.
> The problem here could be that Application instance should not be
> already started (but writing in JavaDoc should be enough) ... so the
> only other problem I see here could be a malicious injection from
> "outside" in Application, but I don't think this could be a real
> problem because it's up to the developer to use them.
>
>
> What do you think ?
>
> Bye,
> Sandro

Re: Inject properties in Application

Posted by Sandro Martini <sa...@gmail.com>.
Hi,
ok, I'll try to better explain my requirements here, if it's not
enough clear tell me :-) ...

As starting point, look here:
http://svn.codespot.com/a/apache-extras.org/pivot-stuff/trunk/pivot-stuff-common-groovy/test/pivot_stuff/common_groovy/
all .gsh files are Groovy Scripts (they could be .groovy, but I rename
to .gsh to be more clear that they are scripts), and they use some
Groovy code (in some case inside the script, in others external in
.groovy classes just for convenience).
And of course Groovy code there extends Pivot Java code ...
To run examples you can find Windows batch files here:
http://svn.codespot.com/a/apache-extras.org/pivot-stuff/trunk/pivot-stuff-common-groovy/_scripts/

The concept is similar to this:
http://groovy.codehaus.org/Scripts+and+Classes

Use Case 1:
a Groovy/Java/Scala/etc application that executes a script, for simple
(or user-written) things ... but for this probably all is ok (no
changes required).

Use Case 2:
a Groovy (soon Scala) Script that calls Groovy/Java code, and in that
script I could define variables/objects (like an external
environment), and currently I'm not able to pass to the application
unless I use some singleton trick.
Generally speaking I don't like too much the all-singleton approach
... in a world evolving much more in multi-core/multi-thread (and
hard-to-do-well and not-too-much-unnecessary-synchronization) this is
a good reason to me.
But if for all us this is enough I can live with it :-) ...

This is a field where I'd like to push Pivot:
http://www.reactivemanifesto.org/
but could be for a long-term roadmap ... I'll post some idea later on
this (many of us know that I'm a big fan of Scala and related
products) because it's a big thing, and not strictly related to this.


> I'm thinking that for 2.1 could be useful to have a way to inject data
> inside Applications, for example have some variable (like a Classloader
> and maybe others) in a script and inject (or even set by
> hand) in the Application.
> But of course this requires a little update in that API, like add a
> method setExternalProperties(Map <String, Object> properties) or similar
> ... and let Applications implement it if needed (or use the empty
> version in Application.Adapter) ...
in this way we could be able to define objects from "outside" and set
in Pivot Application, but of course we should create an instance of
Application (custom, or Application.Adappter), and then set in it all
desired values.

> Then, DesktopApplicationContext currently uses a Class instance of
> Application (dynamically loading the class instance), so maybe we could
> even add a method to get an Application instance already created ...
Here we could add a startup flag that when given (not sure if it's the
best way, I have to check this), the Application class instance is
taken from the externalProperties Map (if found) and used instead of
dynamically load it by name, so this small change should only be an
addition, reusing existing methods.
The problem here could be that Application instance should not be
already started (but writing in JavaDoc should be enough) ... so the
only other problem I see here could be a malicious injection from
"outside" in Application, but I don't think this could be a real
problem because it's up to the developer to use them.


What do you think ?

Bye,
Sandro

RE: Inject properties in Application

Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
Hi Sandro,
	Could you explain the use case a little more for me (injecting
data into Applications)?  Since I don't know Groovy, I'm kind of in the
dark about the requirement that this would satisfy....

Thanks,
~Roger

-----Original Message-----
From: Sandro Martini [mailto:sandro.martini@gmail.com] 
Sent: Friday, October 04, 2013 8:40 AM
To: Developers - Apache Pivot
Subject: Inject properties in Application

Hi all,
after doing some test from Groovy, using some Groovy Script to create
minimal Pivot Applications, for more tests on this:
https://issues.apache.org/jira/browse/PIVOT-917
you can find related examples here:
http://svn.codespot.com/a/apache-extras.org/pivot-stuff/trunk/pivot-stuf
f-common-groovy/

I'm thinking that for 2.1 could be useful to have a way to inject data
inside Applications, for example have some variable (like a Classloader
and maybe others) in a script and inject (or even set by
hand) in the Application.
But of course this requires a little update in that API, like add a
method setExternalProperties(Map <String, Object> properties) or similar
... and let Applications implement it if needed (or use the empty
version in Application.Adapter) ...


Then, DesktopApplicationContext currently uses a Class instance of
Application (dynamically loading the class instance), so maybe we could
even add a method to get an Application instance already created ...


What do you think ?


Note:
after Groovy, even Scala-2.11.0 (now in Milestone 5) should support
Scripting from shell, so this kind of features could be useful ...
And on Jython I'm sure we'll find a way to make it work the same,
probably the PIVOT-917 issue (see above) will be resolved rewriting
related samples in the "right Pivot-way" :-) ... if someone want to help
us on this, is welcome.

Bye,
Sandro