Getting referenced BXML files of main file into the class

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting referenced BXML files of main file into the class

ajaybhat
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.


Regards,  
Ajay Bhat
Reply | Threaded
Open this post in threaded view
|

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

Roger and Beth Whitcomb
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.


Regards,  
Ajay Bhat

Reply | Threaded
Open this post in threaded view
|

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

ajaybhat
Hi Roger,

On Mon, Sep 2, 2013 at 6:18 AM, Roger and Beth Whitcomb <[hidden email]> 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.
Reply | Threaded
Open this post in threaded view
|

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

ajaybhat
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
Reply | Threaded
Open this post in threaded view
|

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

Sandro Martini
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 <[hidden email]>:

> 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

stylesheet_example.bxml - with stylesheet.launch.zip (836 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

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

Roger Whitcomb-2
In reply to this post by ajaybhat

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:[hidden email]]
Sent: Wednesday, September 04, 2013 8:09 AM
To: [hidden email]
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