1. #1
    Ext User
    Join Date
    Feb 2009
    Posts
    29
    Vote Rating
    0
    daeo is on a distinguished road

      0  

    Question How to change a panel content by a Tree event

    How to change a panel content by a Tree event


    Hi,
    I m trying to make a website like a file browser, which is a BorderLayout panel, with a Tree on the West panel, and the Center panel is the display area.

    What i m trying to do is to click on one of the nodes of the tree, and show information in the display area. I've attached an event listener to the tree, but don't know how to get the info displayed.

    The difficulty in my case is that the Tree and the main panel are different classes, they are TreePanel.java, and BorderLayoutPanel.java. Inside the BorderLayoutPanel.java, it instantiates the TreePanel, and adds it to the West pane.

    Does anyone have any idea about how this can be done? or i m on a wrong way that i have to put these two panels within one class?

    Thanks for your help!

  2. #2
    Ext User
    Join Date
    Dec 2007
    Posts
    42
    Vote Rating
    0
    mbenothmane is on a distinguished road

      0  

    Default


    Take a look at the examples : XMLTreeLoader, it is using the technique your are requesting

  3. #3
    Ext User
    Join Date
    Feb 2009
    Posts
    29
    Vote Rating
    0
    daeo is on a distinguished road

      0  

    Default


    Thanks!

  4. #4
    Ext User
    Join Date
    May 2008
    Posts
    1
    Vote Rating
    0
    Wilayers is on a distinguished road

      0  

    Default


    Where can I find this example ?

  5. #5
    Ext User
    Join Date
    Feb 2009
    Posts
    29
    Vote Rating
    0
    daeo is on a distinguished road

      0  

    Cool


    Quote Originally Posted by Wilayers View Post
    Where can I find this example ?
    hi mate,
    i didn't find the example for Ext GWT, i did what i used to do in JAVA Swing application, and solved the problem. Generally i use a getter and setter to get reference of the content panel in the tree panel, like this:

    Code:
    public class MyTreePanel extends LayoutContainer {
       private MyDisplayPanel myPanelReference;
       
       public void setMyPanelReference(ContentPanel c) {
          this.myPanelReference = c;
       }
    
       public void onRender() {
          ...
          Tree myTree = new Tree();
          myTree.addListener(Events.SelectionChange, new Listener<TreeEvent>() {
                public void handleEvent(TreeEvent e) {
                      myPanelReference.buildPanel(); // this is to call the method in MyDisplayPanel class
                }
          });
       }
       ......
    }
    
    
    // this is the panel
    public class MyDisplayPanel extends LayoutContainer {
       public MyPanel() {
          // if you don't want to display anything initially, nothing here
       }
    
       public ContentPanel buildPanel() {
          // do something to construct the panel
          ContentPanel panel = new ContentPanel();
          ......
          ......
          return panel;
       }
    }
    
    // Then at the point that you add the TreePanel and the DisplayPanel, setup the reference to the panel
    // using the setter in the TreePanel class
    
    public class MainPanel extends LayoutContainer {
       public MainPanel() {
          MyTreePanel mtp = new MyTreePanel();
          MyDisplayPanel mdp = new MyDisplayPanel();
    
          mtp.setMyPanelReference(mdp);
    
          add(mtp);
          add(mdp);
       }
    }
    This works for me, i m not sure whether it's the right way of doing it. You are more than welcome to post your solution, or any problem you have.


    Best regards

Thread Participants: 2