You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by "B.L. Zeebub" <ro...@googlemail.com> on 2010/06/24 11:58:41 UTC

Advice for a newbie

Hi

New to Pivot and GUI programming - I want to try out Pivot to provide a
front-end gui to an existing Java application. Amongst other things, the
application tracks it's progress by posting status messages to anything that
is registered as a listener. So the first thing I want to do is set myself
up as a listener and display the status messages as they appear. The
pivot-app needs to be able to scroll backward and forward through the
messages and update itself when new messages arrive. In effect what I want
is some sort of console view.

I've been through the tutorials but I'm not sure which set of components I
should select to acheive the intent of the view. I would appreciate
suggestions as to which components I should use. 

Regards
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Advice-for-a-newbie-tp919140p919140.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Advice for a newbie

Posted by Chris Bartlett <cb...@googlemail.com>.
Apologies, I didn't read your email closely enough.
I was thinking about just putting the GenesisEvent into the List.

On Thu, Jun 24, 2010 at 7:59 PM, Chris Bartlett
<cb...@googlemail.com>wrote:

> I think you can just change name attribute/property to match the getter in
> GenesisEvent
> so
> <TableView.Column name="info" width="500" headerData="Header"/>
> becomes
> <TableView.Column name="message" width="500" headerData="Header"/>
>
>
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/tableviews/
>
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/tableviews/basic_table_view.bxml
>
> http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/tableviews/OlympicStanding.java
>
> Chris
>
> On Thu, Jun 24, 2010 at 7:43 PM, B.L. Zeebub <ro...@googlemail.com>wrote:
>
>>
>> Chris,
>>
>> Thanks for the response. I'd already started with the TableView. You say
>> that I can use just a Pivot List for my datasource. I couldn't get it to
>> work with a simple list unless my Pivot list was a list of maps. I've
>> attached my wtkx file and the code I use to load it below. How do I modify
>> it to use a simple list of strings?
>>
>> Regards
>>
>>
>> To initialize the tableview;
>>
>>                messages = new ArrayList<Map<String,String>>();
>>                TableView tv = (TableView) wtkxSerializer.get("tableView");
>>                tv.setTableData(messages);
>>
>> to load it;
>> public void notify(GenesisEvent event) {
>>                HashMap<String,String> map = new HashMap<String,String>();
>>                map.put("info",event.getMessage());
>>                messages.add(map);
>>
>>        }
>>
>>
>>
>> <Window title="Genesis Client" maximized="true"
>>            xmlns:wtkx="http://pivot.apache.org/wtkx"
>>            xmlns="org.apache.pivot.wtk">
>>        <content>
>>        <Border styles="{color:10}">
>>                    <content>
>>                        <ScrollPane>
>>                            <view>
>>                                                        <TableView
>> wtkx:id="tableView">
>>                                    <columns>
>>                                        <TableView.Column name="info"
>> width="500"
>> headerData="Header"/>
>>                                    </columns>
>>                                </TableView>
>>                            </view>
>>                        </ScrollPane>
>>                    </content>
>>                </Border>
>>            </content>
>>        </Window>
>>
>>
>> --
>> View this message in context:
>> http://apache-pivot-users.399431.n3.nabble.com/Advice-for-a-newbie-tp919140p919398.html
>> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>>
>
>

Re: Advice for a newbie

Posted by Chris Bartlett <cb...@googlemail.com>.
I think you can just change name attribute/property to match the getter in
GenesisEvent
so
<TableView.Column name="info" width="500" headerData="Header"/>
becomes
<TableView.Column name="message" width="500" headerData="Header"/>

http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/tableviews/
http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/tableviews/basic_table_view.bxml
http://svn.apache.org/repos/asf/pivot/trunk/tutorials/src/org/apache/pivot/tutorials/tableviews/OlympicStanding.java

Chris

On Thu, Jun 24, 2010 at 7:43 PM, B.L. Zeebub <ro...@googlemail.com>wrote:

>
> Chris,
>
> Thanks for the response. I'd already started with the TableView. You say
> that I can use just a Pivot List for my datasource. I couldn't get it to
> work with a simple list unless my Pivot list was a list of maps. I've
> attached my wtkx file and the code I use to load it below. How do I modify
> it to use a simple list of strings?
>
> Regards
>
>
> To initialize the tableview;
>
>                messages = new ArrayList<Map<String,String>>();
>                TableView tv = (TableView) wtkxSerializer.get("tableView");
>                tv.setTableData(messages);
>
> to load it;
> public void notify(GenesisEvent event) {
>                HashMap<String,String> map = new HashMap<String,String>();
>                map.put("info",event.getMessage());
>                messages.add(map);
>
>        }
>
>
>
> <Window title="Genesis Client" maximized="true"
>            xmlns:wtkx="http://pivot.apache.org/wtkx"
>            xmlns="org.apache.pivot.wtk">
>        <content>
>        <Border styles="{color:10}">
>                    <content>
>                        <ScrollPane>
>                            <view>
>                                                        <TableView
> wtkx:id="tableView">
>                                    <columns>
>                                        <TableView.Column name="info"
> width="500"
> headerData="Header"/>
>                                    </columns>
>                                </TableView>
>                            </view>
>                        </ScrollPane>
>                    </content>
>                </Border>
>            </content>
>        </Window>
>
>
> --
> View this message in context:
> http://apache-pivot-users.399431.n3.nabble.com/Advice-for-a-newbie-tp919140p919398.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>

Re: Advice for a newbie

Posted by "B.L. Zeebub" <ro...@googlemail.com>.
Chris,

Thanks for the response. I'd already started with the TableView. You say
that I can use just a Pivot List for my datasource. I couldn't get it to
work with a simple list unless my Pivot list was a list of maps. I've
attached my wtkx file and the code I use to load it below. How do I modify
it to use a simple list of strings? 

Regards


To initialize the tableview;

		messages = new ArrayList<Map<String,String>>();
		TableView tv = (TableView) wtkxSerializer.get("tableView");
		tv.setTableData(messages);

to load it;
public void notify(GenesisEvent event) {
		HashMap<String,String> map = new HashMap<String,String>();
		map.put("info",event.getMessage());
		messages.add(map);
		
	}



<Window title="Genesis Client" maximized="true"
	    xmlns:wtkx="http://pivot.apache.org/wtkx"
	    xmlns="org.apache.pivot.wtk">
	<content>	
	<Border styles="{color:10}">
	            <content>
	                <ScrollPane>
	                    <view>
							<TableView wtkx:id="tableView">
	                            <columns>
	                                <TableView.Column name="info" width="500"
headerData="Header"/>
	                            </columns>
	                        </TableView>    	
	                    </view>
	                </ScrollPane>
	            </content>
	        </Border>
	    </content>
   	</Window>


-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Advice-for-a-newbie-tp919140p919398.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Advice for a newbie

Posted by Chris Bartlett <cb...@googlemail.com>.
The Pivot Team can provide a definitive answer.

I have found it very useful to download the Pivot source (
http://pivot.apache.org/download.cgi#1.5)
and to look through the code & wtkx in the following directories
- demos
- tests
- tools
- tutorials

There is all sorts in there, but just poking around I discovered various
things.
Being able to modify and execute the changes obviously helps a lot too.

Chris

On Thu, Jun 24, 2010 at 8:35 PM, B.L. Zeebub <ro...@googlemail.com>wrote:

>
> Excellent - that worked a treat! Are there any other beginner
> tutorials/examples around other than those on pivot.apache.org?
>
> Regards
> --
> View this message in context:
> http://apache-pivot-users.399431.n3.nabble.com/Advice-for-a-newbie-tp919140p919493.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>

Re: Advice for a newbie

Posted by Greg Brown <gk...@mac.com>.
Oh, and I'll be doing a Pivot training session at ApacheCon in November.

On Jun 24, 2010, at 9:35 AM, B.L. Zeebub wrote:

> 
> Excellent - that worked a treat! Are there any other beginner
> tutorials/examples around other than those on pivot.apache.org?
> 
> Regards
> -- 
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Advice-for-a-newbie-tp919140p919493.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: Advice for a newbie

Posted by Greg Brown <gk...@mac.com>.
I have written a few articles about Pivot over the past couple of years. Most of them are a bit outdated now, though this one is probably still mostly relevant (it is based on Pivot 1.3):

http://www.ibm.com/developerworks/xml/tutorials/x-pivottut/index.html

I am actually hoping to convince O'Reilly to let me write a book about Pivot. If you think this is something you might be interested in, it couldn't hurt to let them know. Might help my chances of getting it approved.  :-)

G

On Jun 24, 2010, at 9:35 AM, B.L. Zeebub wrote:

> 
> Excellent - that worked a treat! Are there any other beginner
> tutorials/examples around other than those on pivot.apache.org?
> 
> Regards
> -- 
> View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Advice-for-a-newbie-tp919140p919493.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.


Re: Advice for a newbie

Posted by "B.L. Zeebub" <ro...@googlemail.com>.
Excellent - that worked a treat! Are there any other beginner
tutorials/examples around other than those on pivot.apache.org?

Regards
-- 
View this message in context: http://apache-pivot-users.399431.n3.nabble.com/Advice-for-a-newbie-tp919140p919493.html
Sent from the Apache Pivot - Users mailing list archive at Nabble.com.

Re: Advice for a newbie

Posted by Chris Bartlett <cb...@googlemail.com>.
Take a look at this demo.  It sounds like it might be a useful starting
point.

http://pivot.apache.org/demos/rss-feed.html
http://svn.apache.org/repos/asf/pivot/trunk/demos/src/org/apache/pivot/demos/rss/

It shows a ListView with custom rendered items inside a ScrollPane.

By setting the ListView's data source to a Pivot List (as opposed to a
java.util.List), it will show updates automatically when the contents of the
List change.
The listener for your external application would simply need to manage the
data in the List.

If required you can set a Comparator for the List which will subsequently
maintain the ordering in the ListView.
Pivot also has a FilteredList class which can filter an underlying List (and
can have it own Comparator)
ListViews can also be supplied with a Filter to determine which items are
rendered as enabled or disabled.

If you need a more tabular format, then TableView may be more appropriate.
It also takes a Pivot List as its data source, so can be filtered etc as
above.

With both of these components it is possible to get the bounds of a
particular item and programmatically scroll to ensure it is visible.

Regards,

Chris

On Thu, Jun 24, 2010 at 4:58 PM, B.L. Zeebub <ro...@googlemail.com>wrote:

>
> Hi
>
> New to Pivot and GUI programming - I want to try out Pivot to provide a
> front-end gui to an existing Java application. Amongst other things, the
> application tracks it's progress by posting status messages to anything
> that
> is registered as a listener. So the first thing I want to do is set myself
> up as a listener and display the status messages as they appear. The
> pivot-app needs to be able to scroll backward and forward through the
> messages and update itself when new messages arrive. In effect what I want
> is some sort of console view.
>
> I've been through the tutorials but I'm not sure which set of components I
> should select to acheive the intent of the view. I would appreciate
> suggestions as to which components I should use.
>
> Regards
> --
> View this message in context:
> http://apache-pivot-users.399431.n3.nabble.com/Advice-for-a-newbie-tp919140p919140.html
> Sent from the Apache Pivot - Users mailing list archive at Nabble.com.
>