pivot-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Greg Brown <gkbr...@mac.com>
Subject Re: Trouble adding components dynamically
Date Mon, 01 Mar 2010 16:28:42 GMT
Yeah, your understanding is correct.

I don't immediately see the problem - anyone else have any ideas?

On Mar 1, 2010, at 11:23 AM, David McNelis wrote:

> I’m including the “parent” inside the tab in the ‘grandparent’ wtkx file, which
is structured thusly:
>  
> <?xml version="1.0" encoding="UTF-8"?>
> <Window title="Template Builder UI!" maximized="true" xmlns:wtkx="http://pivot.apache.org/wtkx"
xmlns="org.apache.pivot.wtk">
> <content>
> <Border styles="{padding:12}">
>  
> <content>
>                                
>                 <BoxPane>
>                 <TabPane>
>                 <tabs>
>                                 <BoxPane TabPane.label="tab number 1"
>                                                 styles="{horizontalAlignment:'center',
verticalAlignment:'center'}"
>                                                 wtkx:id="tab1">
>                                                                
>                                                                 <!-- content -->
>                                 </BoxPane>
>  
>                                 <BoxPane wtkx:id="tab2" TabPane.label="tab number
2"
>                                                 styles="{horizontalAlignment:'center',
verticalAlignment:'center'}">
>                                                 <wtkx:include
>                                                                 src="parent.xml">
>                                                 </wtkx:include>
>                                 </BoxPane>
>  
> </tabs></TabPane></BoxPane></content></Border></content></Window>
>  
> My understanding is that the parent.xml would be compiled into the ‘grandparent’
file and would end up in the tab panes sequence.  Do I understand that correctly? 
>  
>  
> From: Greg Brown [mailto:gkbrown@mac.com] 
> Sent: Monday, March 01, 2010 10:11 AM
> To: user@pivot.apache.org
> Subject: Re: Trouble adding components dynamically
>  
> Are you adding the parent to the tab pane's tab sequence, or directly to the tab pane
itself? If you are doing the latter, it could definitely be the cause of the problem.
>  
> On Mar 1, 2010, at 11:08 AM, David McNelis wrote:
> 
> 
> I also tried adding a test label to my parent wtkx, then loading it into the code, with
>  
> Label testLabel = (Label) parentSerializer.get(“testLabel”);
>  
> I then spit out the current label text.  Then set the label to different text.  However
the new text value never ends up being re-painted on the screen, despite direct calls to repaint
the label, the box pane, the window…  but when I spit the testLabel.getText() to system
out again, it does contain the new value.
>  
> I don’t know if it makes any difference but the parent component hear is living inside
a TabPane…I had left that out previously because it seems kind of inconsequential…and
in my other TabPanes I haven’t had issues adding or removing components.
>  
> From: David McNelis [mailto:Dmcnelis@sharedmarketing.com] 
> Sent: Monday, March 01, 2010 9:03 AM
> To: user@pivot.apache.org
> Subject: RE: Trouble adding components dynamically
>  
> Hopefully this doesn’t get too jacked up in email, but here is an excerpt of the code
and the wtkx files that I’m using.    I also tried just adding a test label to the containerPane
as well and that did not show up either.  But if I wtkx:include the child component as a child
of the “containerPane” then the child component does display.
>  
> Code:
>  
> containerPane = (BoxPane)parentSerializer.get("containerPane");
>  
> for(int i=0, n=array.getLength(); i<n; i++){           
>                 WTKXSerializer wtkx = new WTKXSerializer();
>                 BoxPane singlePane = null;
>  
>                 try {
>                                 singlePane = (BoxPane)wtkx.readObject(this, "child.wtkx");
>                 } catch (IOException e) {
>                                                                
>                                 e.printStackTrace();
>                 } catch (SerializationException e) {
>                                                
>                                 e.printStackTrace();
>                 }
>                                
>                 singlePane.setVisible(true);
>                                
>                 containerPane.add(singlePane);
> }
>  
>  
> Parent component:
>  
> <Border xmlns:wtkx="http://pivot.apache.org/wtkx" xmlns="org.apache.pivot.wtk" preferredWidth="800"
preferredHeight="600">
>                
> <content>
>  
> <ScrollPane horizontalScrollBarPolicy="fill" verticalScrollBarPolicy="fill">
>  
>                 <view>
>  
>                                 <BoxPane orientation="vertical" wtkx:id="containerPane">
>                 </BoxPane>
> </view></ScrollPane></content></Border>
>  
> Child component:
>  
> <BoxPane xmlns:wtkx="http://pivot.apache.org/wtkx"
> xmlns="org.apache.pivot.wtk" preferredWidth="800" preferredHeight="600" orientation="vertical">
 
>  
> <BoxPane orientation="vertical" wtkx:id="childPane">
>  
>                                
> <BoxPane orientation="horizontal">
>                                 <Label text="Blah blah"></Label>
>                                 <ListButton wtkx:id="button1"></ListButton>
>                                 <Label text="Blah blah:"></Label>
>                                 <ListButton wtkx:id="button2"></ListButton>
>                 </BoxPane>
>                 <BoxPane orientation="vertical">
>                 <Label text="Filler:"></Label>
>  
>                 <Border>
>                 <content>
>                 <ScrollPane preferredHeight="25"
>                                 horizontalScrollBarPolicy="fill"
>                                 verticalScrollBarPolicy="fill_to_capacity">
>                 <view>
>                 <TextArea wtkx:id="textarea1"
>                                 preferredWidth="600" text="Sample Text">
>                 </TextArea>
>                 </view>
>                 </ScrollPane>
>                 </content>
>                 </Border>
>                 </BoxPane>
>                 <BoxPane orientation="vertical">
>                 <Label text="More stuff:"></Label>
>  
>                 <Border>
>                 <content>
>                 <ScrollPane preferredHeight="100"
>                 horizontalScrollBarPolicy="fill"
>                 verticalScrollBarPolicy="fill_to_capacity">
>                 <view>
>                                 <TextArea wtkx:id="textarea2"
>                                                 preferredWidth="600" text="Sample Text">
>                                 </TextArea>
>                 </view>
>                 </ScrollPane>
>                 </content>
>                 </Border>
> </BoxPane>
> </BoxPane>
> </BoxPane>
>  
> From: Greg Brown [mailto:gkbrown@mac.com] 
> Sent: Monday, March 01, 2010 8:40 AM
> To: user@pivot.apache.org
> Subject: Re: Trouble adding components dynamically
>  
> That sounds like it should work. Can you provide some sample code? That might help identify
the issue.
>  
> On Mar 1, 2010, at 9:28 AM, David McNelis wrote:
>  
> 
> Morning,
>  
> I have a situation where I am cycling through an array and for each element in the array
I need to add a set of components to a BoxPane.  To do this, I wrote a wtkx file that contained
the components that I need to create each time I go through the array.  As I go through an
iteration I read in the wtkx file with a WTKXSerializer.readObject, casting into another BoxPane,
then attempt to add the new object to my parent.  Essentially like so:
>  
> WTKXSerializer wtkx = new WTKXSerializer();
> BoxPane child = (BoxPane) wtxk.readObject(this,”myfile.wtkx”);
>  
> parent.add(child);
>  
> This as I go through my application I get no errors, no warnings, but myfile.wtkx does
not actually display.  I tried doing something akin to child.setVisible(true), but it hasn’t
made any difference. 
>  
> I thought that maybe there was an issue with my parent BoxPane, so I tried including
myfile.wtkx as a wtkx:include parameter in the parent file, and to my surprise the components
in myfile.wtkx displayed as I would have expected it to using the programmatic method.  Am
I doing something clearly wrong?  Is there likely an issue with my parent or child wtkx file
that I should be looking for?
>  
> Also, the parent.add(child) is executing…its not like I never get to that block of
code…feel like I need to mention that since it’s the first thing that comes to mind as
a simple issue.
>  
> Thanks for any thoughts.
>  
> David
>  
>  
>  
>  


Mime
View raw message