You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Chris Bartlett <cb...@gmail.com> on 2012/01/03 12:24:13 UTC

Re: ItemRender Layout question

Brendan,

I took a quick look at your code and think the problem is due to the
way you are using the renderer.

The renderer itself is a Component or Container that is populated with
the relevant data for the list item, table row, tree node, etc.  This
is then painted in the correct location.

You seem to want to have a FlowPane inside your renderer as a
placeholder, but then swap it with another FlowPane when the renderer
is painted.  If you want to do this, you will need to remove (or hide)
the placeholder FlowPane from it's parent, and then add the new
FlowPane before the renderer is painted.

You might achieve this by adding a setFlowPane(FlowPane) method to the
renderer.  That method would know about the parent Container for the
FlowPane, so could remove any existing ones and add the new one in the
correct location.

Chris
2011/12/29 Brendan cheng <cc...@hotmail.com>:
> Hi Chris,
>
> I just made a compact version of my program which demonstrating nested
> ListViewItemRenderer can't show up.
> I don't know how to link it to the main program to be shown on screen.
>
> Please advise me!
>
> Brendan
>
>> Date: Wed, 28 Dec 2011 09:25:36 +0000
>> Subject: Re: ItemRender Layout question
>> From: cbartlett.x@gmail.com
>> To: user@pivot.apache.org
>
>>
>> Brendan,
>>
>> Could you please post a small, complete example demonstrating the
>> problem with the FlowPane not showing? Try to keep it simple by only
>> using a custom renderer and not all of your other custom classes.
>>
>> Chris
>>
>> 2011/12/28 Brendan cheng <cc...@hotmail.com>:
>> > Hi,
>> >
>> > in renderer function, is this going to work?
>> >
>> > @Override
>> &g t;
>
>> > public void render(Object item, int index, ListView listView,
>> >
>> > boolean selected, boolean checked, boolean highlighted,
>> >
>> > boolean disabled) {
>> >
>> > if (item != null && item instanceof Tab.LogView) {
>> >
>> > Tab.LogView logview = (Tab.LogView) item;
>> >
>> > fieldsflowPane = logview.fieldsPane;
>> >
>> > }
>> >
>> > }
>> >
>> >
>> > I couldn't get logview.fieldsPane to be shown in fieldsflowPane.
>> >
>> > How to assign the logview.fieldsPane into fieldsflowPane?
>> >
>> > How to change a component's parent reference?
>> >
>> >
>> > Brendan
>> >
>> >
>> > ________________________________
>> > From: ccp999@hotmail.com
>> > To: user@pivot.apache.org
>> > Subject: ItemRender Layout question
>> > Date: Tue, 27 Dec 2011 14:21:45 +0000
>> >
>> >
>> > Hi,
>> >
>> > I'm trying render a list of list view with a nested list view.  Despite
>> > all
>> > my effort,  I can't get it display on screen.
>> >
>> > Here is the snippet of code:
>> >
>> > public void addNode(Person person) throws
>> >
>> > IOException, SerializationException {
>> >
>> >
>> > BXMLSerializer bxmlSerializer = new BXMLSerializer();
>> >
>> > LogItemRenderer logItemRenderer = (LogItemRenderer) bxmlSerializer
>> >
>> > .readObject(getClass().getResource(
>> >
>> > "fullview/LogItemRenderer.bxml"));
>> >
>> >
>> > ListView listView = new ListView();
>> >
>> > listView.setItemRenderer(logItemRenderer);
>> >
>> >
>> > org.apache.pivot.collections.List&lt ;LogView> logviewlist = new
>
>> > org.apache.pivot.collections.ArrayList<LogView>();
>> >
>> > for (Log log : person.getLogs()) {
>> >
>> > if (log instanceof Log) {
>> >
>> > Log restclientlog = (Log) log;
>> >
>> > ListView sysfieldlistView = new ListView();
>> >
>> > sysfieldlistView.setItemRenderer(new FieldItemRenderer());
>> >
>> > org.apache.pivot.collections.List<Field> syslist = new
>> > ArrayList<Field>();
>> >
>> > for (Field field : restclientlog.sysFields) {
>> >
>> >       syslist.add(field);
>> >
>> > }
>> >
>> > sysfieldlistView.setListData(syslist);
>> >
>> > FlowPane flowPane = new FlowPane();
>> >
>> > flowPane.add(sysfieldlistView);
>> >
>> > logviewlist.add(new LogView(log, flowPane));
>> >
>> > }
>> >
>> > }
>> >
>> > listView.setListData(logviewlist);
>> >
>> > Accordion.setHeaderData(listView, "Log");
>> >
>> > centerAccordion.getPanels().add(listView);
>> >
>> >
>> > }
>> >
>> >
>> > Both FieldItemRender and LogItemRenderer follow
>> > your ListViewItemRenderer
>> > and most component show up properly except the content of FlowPane.
>> >
>> >
>> > I have no idea why the content in the FlowPane can't show up.
>> >
>> >
>> > Any help?
>> >
>> >
>> > Brendan
>> >
>> >

RE: ItemRender Layout question

Posted by Brendan cheng <cc...@hotmail.com>.
Chris,
Thank you for spending your time on my issue.
I noticed that because both flow panes has its parent container, they can't be swapped.I also tried to remove it from parent with the follow code:
Container old = fieldsflowPane.getParent();
int oldindex = old.indexOf(fieldsflowPane);
old.remove(fieldsflowPane);
Container newfp = logview.fieldsPane.getParent();
newfp.remove(logview.fieldsPane);
old.insert(logview.fieldsPane, old index);
I'm not sure if this works.Because I can't find a place to place the setFlowPane method which will be called before repaint and after the setRenderer.
Thanks,
Brendan
> Date: Tue, 3 Jan 2012 11:24:13 +0000
> Subject: Re: ItemRender Layout question
> From: cbartlett.x@gmail.com
> To: user@pivot.apache.org
> 
> Brendan,
> 
> I took a quick look at your code and think the problem is due to the
> way you are using the renderer.
> 
> The renderer itself is a Component or Container that is populated with
> the relevant data for the list item, table row, tree node, etc.  This
> is then painted in the correct location.
> 
> You seem to want to have a FlowPane inside your renderer as a
> placeholder, but then swap it with another FlowPane when the renderer
> is painted.  If you want to do this, you will need to remove (or hide)
> the placeholder FlowPane from it's parent, and then add the new
> FlowPane before the renderer is painted.
> 
> You might achieve this by adding a setFlowPane(FlowPane) method to the
> renderer.  That method would know about the parent Container for the
> FlowPane, so could remove any existing ones and add the new one in the
> correct location.
> 
> Chris
> 2011/12/29 Brendan cheng <cc...@hotmail.com>:
> > Hi Chris,
> >
> > I just made a compact version of my program which demonstrating nested
> > ListViewItemRenderer can't show up.
> > I don't know how to link it to the main program to be shown on screen.
> >
> > Please advise me!
> >
> > Brendan
> >
> >> Date: Wed, 28 Dec 2011 09:25:36 +0000
> >> Subject: Re: ItemRender Layout question
> >> From: cbartlett.x@gmail.com
> >> To: user@pivot.apache.org
> >
> >>
> >> Brendan,
> >>
> >> Could you please post a small, complete example demonstrating the
> >> problem with the FlowPane not showing? Try to keep it simple by only
> >> using a custom renderer and not all of your other custom classes.
> >>
> >> Chris
> >>
> >> 2011/12/28 Brendan cheng <cc...@hotmail.com>:
> >> > Hi,
> >> >
> >> > in renderer function, is this going to work?
> >> >
> >> > @Override
> >> &g t;
> >
> >> > public void render(Object item, int index, ListView listView,
> >> >
> >> > boolean selected, boolean checked, boolean highlighted,
> >> >
> >> > boolean disabled) {
> >> >
> >> > if (item != null && item instanceof Tab.LogView) {
> >> >
> >> > Tab.LogView logview = (Tab.LogView) item;
> >> >
> >> > fieldsflowPane = logview.fieldsPane;
> >> >
> >> > }
> >> >
> >> > }
> >> >
> >> >
> >> > I couldn't get logview.fieldsPane to be shown in fieldsflowPane.
> >> >
> >> > How to assign the logview.fieldsPane into fieldsflowPane?
> >> >
> >> > How to change a component's parent reference?
> >> >
> >> >
> >> > Brendan
> >> >
> >> >
> >> > ________________________________
> >> > From: ccp999@hotmail.com
> >> > To: user@pivot.apache.org
> >> > Subject: ItemRender Layout question
> >> > Date: Tue, 27 Dec 2011 14:21:45 +0000
> >> >
> >> >
> >> > Hi,
> >> >
> >> > I'm trying render a list of list view with a nested list view.  Despite
> >> > all
> >> > my effort,  I can't get it display on screen.
> >> >
> >> > Here is the snippet of code:
> >> >
> >> > public void addNode(Person person) throws
> >> >
> >> > IOException, SerializationException {
> >> >
> >> >
> >> > BXMLSerializer bxmlSerializer = new BXMLSerializer();
> >> >
> >> > LogItemRenderer logItemRenderer = (LogItemRenderer) bxmlSerializer
> >> >
> >> > .readObject(getClass().getResource(
> >> >
> >> > "fullview/LogItemRenderer.bxml"));
> >> >
> >> >
> >> > ListView listView = new ListView();
> >> >
> >> > listView.setItemRenderer(logItemRenderer);
> >> >
> >> >
> >> > org.apache.pivot.collections.List&lt ;LogView> logviewlist = new
> >
> >> > org.apache.pivot.collections.ArrayList<LogView>();
> >> >
> >> > for (Log log : person.getLogs()) {
> >> >
> >> > if (log instanceof Log) {
> >> >
> >> > Log restclientlog = (Log) log;
> >> >
> >> > ListView sysfieldlistView = new ListView();
> >> >
> >> > sysfieldlistView.setItemRenderer(new FieldItemRenderer());
> >> >
> >> > org.apache.pivot.collections.List<Field> syslist = new
> >> > ArrayList<Field>();
> >> >
> >> > for (Field field : restclientlog.sysFields) {
> >> >
> >> >       syslist.add(field);
> >> >
> >> > }
> >> >
> >> > sysfieldlistView.setListData(syslist);
> >> >
> >> > FlowPane flowPane = new FlowPane();
> >> >
> >> > flowPane.add(sysfieldlistView);
> >> >
> >> > logviewlist.add(new LogView(log, flowPane));
> >> >
> >> > }
> >> >
> >> > }
> >> >
> >> > listView.setListData(logviewlist);
> >> >
> >> > Accordion.setHeaderData(listView, "Log");
> >> >
> >> > centerAccordion.getPanels().add(listView);
> >> >
> >> >
> >> > }
> >> >
> >> >
> >> > Both FieldItemRender and LogItemRenderer follow
> >> > your ListViewItemRenderer
> >> > and most component show up properly except the content of FlowPane.
> >> >
> >> >
> >> > I have no idea why the content in the FlowPane can't show up.
> >> >
> >> >
> >> > Any help?
> >> >
> >> >
> >> > Brendan
> >> >
> >> >