You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@pivot.apache.org by Ajay Bhat <a....@gmail.com> on 2013/09/01 06:22:08 UTC

Getting referenced BXML files of main file into the class

In the tutorial for UI Markup using Stock Tracker App [1] [2], there's this
bit of code.

<Border styles="{padding:6, color:10}">
            <bxml:include bxml:id="detailPane" src="detail_pane.bxml"/>
</Border>

Suppose I wish to manipulate styles of the entire app, and so I traverse
through all the components starting from the main BXML file. When I reach
the right side of Split Pane I encounter a ref to another BXML file i.e
detail pane. How can I get the components of that detail pane into my
class? I've tried using (Border) component.getContent() but all I get is
the name of the file, not the component.

[1] http://pivot.apache.org/tutorials/stock-tracker.ui.html

[2] http://pivot.apache.org/tutorials/stock-tracker.html
 <http://pivot.apache.org/tutorials/stock-tracker.ui.html>--
Regards,
Ajay Bhat

Re: Getting referenced BXML files of main file into the class

Posted by Sandro Martini <sa...@gmail.com>.
Hi,
on the problem of "Applying a style to all elements of a control" I
just get this old thread:

http://apache-pivot-users.399431.n3.nabble.com/Applying-a-style-to-all-elements-of-a-control-td2713309.html

could be useful to your initial case, but sorry probably not on your
last email (Roger can help there)

In attach I put (inside the zip) my eclipse launch file to run that
sample in a simple way with all arguments setup.


Bye,
Sandro


2013/9/4 Ajay Bhat <a....@gmail.com>:
> Okay, I fixed the earlier problem somewhat by making all names inline, but
> now I've encountered a new one. It would be nice if someone could help me
> with it.
>
> I have defined a border and its children as:
>
> <TablePane.Row height="1*">
> <TabPane bxml:id="tabPane">
> <tabs>
> <Border>
>                            <content>
>                      <bxml:include bxml:id="infoTab" src="InfoTab.bxml"
> inline="true" />
>                             </content>
>                      </Border>
>           //many other tabs and rows
>          </TabPane>
> </TablePane.Row>
>
> In the InfoTab.bxml I have.
>
> <luke:InfoTab xmlns:bxml="http://pivot.apache.org/bxml"
> xmlns:content="org.apache.pivot.wtk.content" xmlns="org.apache.pivot.wtk"
> xmlns:luke="org.apache.lucene.luke.ui" >
>          <top>
>               <Border>
>                    <content>
>                            <ScrollPane
> horizontalScrollBarPolicy="fill_to_capacity">
>                            //many other components
> </ScrollPane>
> </content>
> </Border>
> </top>
> <bottom>
> <Border>
> <content>
> <TablePane bxml:id="bottomTable">
>                                  //many other components
> </TablePane>
> </content>
> </Border>
> </bottom>
> </luke:InfoTab>
>
> In my main Java file I have a method to recursively change style of all
> components.
>
> private void recChangeStyle(Component component) {
> if (component instanceof Border) {
> //apply style to border
> System.out.println("style applied to Border");
> component = ((Border) component).getContent();
> recChangeStyle(component);
> }
>   else if //deal with other components
> }
>
> So when reaching the InfoTab aka the border shown above I can't access the
> content of the border, all I get is a null on checking the content of
> border. Can anyone help me out here?
> Regards,
> Ajay Bhat

RE: Getting referenced BXML files of main file into the class

Posted by "Roger L. Whitcomb" <Ro...@actian.com>.
I don't see anything in the BXMLSerializer code that would seem to be a
problem.  The content should be set by the included source.  I'm
wondering if there is a problem because of the namespace of your
included file.... Does it make any difference if you make the "infoTab"
into a regular component (maybe SplitPane, I'm guessing?) rather than
using your custom component?

 

~Roger

 

From: Ajay Bhat [mailto:a.ajay.bhat@gmail.com] 
Sent: Wednesday, September 04, 2013 8:09 AM
To: user@pivot.apache.org
Subject: Re: Getting referenced BXML files of main file into the class

 

Okay, I fixed the earlier problem somewhat by making all names inline,
but now I've encountered a new one. It would be nice if someone could
help me with it.

 

I have defined a border and its children as:

 

<TablePane.Row height="1*">

            <TabPane bxml:id="tabPane">

                        <tabs>

                         <Border>

                           <content>
                     <bxml:include bxml:id="infoTab" src="InfoTab.bxml"
inline="true" />
                            </content>
                     </Border>

          //many other tabs and rows

         </TabPane>

</TablePane.Row>

 

In the InfoTab.bxml I have.

 

<luke:InfoTab xmlns:bxml="http://pivot.apache.org/bxml"
xmlns:content="org.apache.pivot.wtk.content"
xmlns="org.apache.pivot.wtk" xmlns:luke="org.apache.lucene.luke.ui" >
         <top>
              <Border>
                   <content>
                           <ScrollPane
horizontalScrollBarPolicy="fill_to_capacity">

                           //many other components

                                                </ScrollPane>

                                    </content>

                        </Border>

            </top>

            <bottom>

                        <Border>

                                    <content>

                                                <TablePane
bxml:id="bottomTable">

                                 //many other components

                                                </TablePane>

                                    </content>

                        </Border>

            </bottom>

</luke:InfoTab>

 

In my main Java file I have a method to recursively change style of all
components.

 

private void recChangeStyle(Component component) {

if (component instanceof Border) {

//apply style to border

System.out.println("style applied to Border");

component = ((Border) component).getContent();

recChangeStyle(component);

}

  else if //deal with other components

}

 

So when reaching the InfoTab aka the border shown above I can't access
the content of the border, all I get is a null on checking the content
of border. Can anyone help me out here?

Regards,

Ajay Bhat


Re: Getting referenced BXML files of main file into the class

Posted by Ajay Bhat <a....@gmail.com>.
Okay, I fixed the earlier problem somewhat by making all names inline, but
now I've encountered a new one. It would be nice if someone could help me
with it.

I have defined a border and its children as:

<TablePane.Row height="1*">
 <TabPane bxml:id="tabPane">
<tabs>
<Border>
                           <content>
                     <bxml:include bxml:id="infoTab"
src="InfoTab.bxml" inline="true" />
                            </content>
                     </Border>
          //many other tabs and rows
         </TabPane>
</TablePane.Row>

In the InfoTab.bxml I have.

<luke:InfoTab xmlns:bxml="http://pivot.apache.org/bxml
"  xmlns:content="org.apache.pivot.wtk.content" xmlns="org.apache.pivot.wtk"
xmlns:luke="org.apache.lucene.luke.ui" >
         <top>
              <Border>
                   <content>
                           <ScrollPane
horizontalScrollBarPolicy="fill_to_capacity">
                           //many other components
 </ScrollPane>
</content>
</Border>
 </top>
<bottom>
<Border>
<content>
 <TablePane bxml:id="bottomTable">
                                 //many other components
</TablePane>
 </content>
</Border>
</bottom>
</luke:InfoTab>

In my main Java file I have a method to recursively change style of all
components.

private void recChangeStyle(Component component) {
if (component instanceof Border) {
 //apply style to border
System.out.println("style applied to Border");
 component = ((Border) component).getContent();
recChangeStyle(component);
 }
  else if //deal with other components
}

So when reaching the InfoTab aka the border shown above I can't access the
content of the border, all I get is a null on checking the content of
border. Can anyone help me out here?
 Regards,
Ajay Bhat

Re: Getting referenced BXML files of main file into the class

Posted by Ajay Bhat <a....@gmail.com>.
Hi Roger,

On Mon, Sep 2, 2013 at 6:18 AM, Roger and Beth Whitcomb <
RogerandBeth@rbwhitcomb.com> wrote:

>  Hi Ajay,
>     I assume you are doing this in Javascript from inside the bxml file
> itself?!  You should be able to read the included file from there, but I
> can't tell you right now how you would do that.
>

It's not through the Javascript from inside. It's through the code from
Java itself. Here's what I'm trying to do.

protected void changeStyle() {
Component component = Window.getActiveWindow();
if (component instanceof Window) {
 //apply style
System.out.println("style applied");
}
 component = Window.getActiveWindow().getContent();
System.out.println(component);
recChangeStyle(component);
 }

private void recChangeStyle(Component component) {
if (component instanceof Border) {
 //apply style to border
System.out.println("style applied to Border");
component = ((Border) component).getContent();
 recChangeStyle(component, theme);
else if (component.toString().startsWith("org.ajay.stocktrackerapp")) {
 if (component.toString().endsWith("detailPane))
component = (Border) new BXMLSerializer().getNamespace().get(
 "detailPane");
recChangeStyle(component, theme);
} else {
 //applied style to other component
}

}



> If I was doing this, I would wait and do the whole thing in Java after the
> whole hierarchy is loaded, but before displaying anything.  So, my feeling
> is that even if you could get the included file loaded that it still
> wouldn't work right because you would be catching the included file before
> it was loaded, and so your styles would end up getting overridden when it
> did get loaded.
>     Anyone else have a comment??
>
> Thanks,
> ~Roger
>
>
I think that's pretty much what I'm trying to do. I have StockTrackerapp
detailPane as org.ajay.stocktracker.detailPane.bxml.

Hopefully this has made what I'm trying to do more clear.

Re: Getting referenced BXML files of main file into the class

Posted by Roger and Beth Whitcomb <Ro...@rbwhitcomb.com>.
Hi Ajay,
     I assume you are doing this in Javascript from inside the bxml file 
itself?!  You should be able to read the included file from there, but I 
can't tell you right now how you would do that.  If I was doing this, I 
would wait and do the whole thing in Java after the whole hierarchy is 
loaded, but before displaying anything.  So, my feeling is that even if 
you could get the included file loaded that it still wouldn't work right 
because you would be catching the included file before it was loaded, 
and so your styles would end up getting overridden when it did get loaded.
     Anyone else have a comment??

Thanks,
~Roger

On 8/31/13 9:22 PM, Ajay Bhat wrote:
> In the tutorial for UI Markup using Stock Tracker App [1] [2], there's 
> this bit of code.
>
> <Border styles="{padding:6, color:10}">
>          <bxml:include bxml:id="detailPane" src="detail_pane.bxml"/>
> </Border>||
>
> Suppose I wish to manipulate styles of the entire app, and so I 
> traverse through all the components starting from the main BXML file. 
> When I reach the right side of Split Pane I encounter a ref to another 
> BXML file i.e detail pane. How can I get the components of that detail 
> pane into my class? I've tried using (Border) component.getContent() 
> but all I get is the name of the file, not the component.
>
> [1] http://pivot.apache.org/tutorials/stock-tracker.ui.html
>
> [2] http://pivot.apache.org/tutorials/stock-tracker.html
> <http://pivot.apache.org/tutorials/stock-tracker.ui.html>--
> Regards,
> Ajay Bhat