Announcement Announcement Module
Collapse
No announcement yet.
View with JTree on Left, TreeNode Properties on Right Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • View with JTree on Left, TreeNode Properties on Right

    I'm trying to create a View that has a JTree on the left and a JPanel on the right that shows the properties of the currently selected TreeNode. Ideally, the JTree and the JPanel would be contained by a JSplitPane.

    The data in the JTree is a tree of countries, each country's provinces (i.e. states) and each province's cities. For example:

    Code:
    Countries (root node)
    |----Canada
          |----British Columbia
                |----Vancouver
                |----Victoria
          |----Ontario
                |----Ottawa
                |----Toronto
    |----USA
          |----California
                |----San Francisco
                |----San Jose
          |----Washington
                |----Seattle
                |----Redmond
    When you select a country in the tree, the properties panel on the right displays that country's name, country code and other properties. When you select a province, the panel displays that province's name, province code and other properties. When you select a city...well, you get the idea! Of course, the exact properties that get displayed on the panel depend on the type of the selected tree node.

    Using the VetManagerView in the Petclinic sample as a starting point, I was easily and quickly able to display the tree and populate it with data. Now I want to add the properties panel to the right side. How should I structure this in terms of Spring Rich Client classes? In other words, which Spring Rich Client classes should I be using? In particular, which implementation of FormModel (if any) should I use as backing for the properties panel?

    I looked for examples in this forum but I couldn't find anything that exactly fit my requirements. Any help (especially sample code) would be greatly appreciated. For now, I'll keep plugging away at it.

    Joe

  • #2
    when you create the control of your view, create a JSplitPane, with on the left the tree and on the right a JPanel with CardLayout.

    add the possible form components to the panel with the cardlayout, also add an empty JPanel.

    add selectionlisteners to the tree that show the appropriate panel on the right, and set the selected item as the formmodel. If the selection is invalid (multiple selection or no selection at all), show the empty panel.

    If the user makes a selection and the current formmodel is dirty, commit the changes.

    Hope this helps.

    Peter

    Comment


    • #3
      I try integrate infonode docking window in rcp
      I finish for 2-3 days

      first screenshot :

      http://www.snpe.co.yu/spring-idw.png

      regards

      Comment


      • #4
        snpe,

        This looks great. Is it possible you can share your code with us. Also is InfoNode open source and available under GPL?

        Amad

        Comment


        • #5
          yes,
          It don't work too good for now.I have a problem with empty tabWindow (when user close all view in any tab) and when I resolve this I will send code

          infonode is GPL and I don't know can be integrate with (Apache licence), but Linux is GPL, too

          regards

          Comment


          • #6
            Originally posted by pdbruycker
            when you create the control of your view, create a JSplitPane, with on the left the tree and on the right a JPanel with CardLayout.

            add the possible form components to the panel with the cardlayout, also add an empty JPanel.

            add selectionlisteners to the tree that show the appropriate panel on the right, and set the selected item as the formmodel. If the selection is invalid (multiple selection or no selection at all), show the empty panel.

            If the user makes a selection and the current formmodel is dirty, commit the changes.

            Hope this helps.

            Peter
            Thanks, Pete. That approach worked fine for me. Due to my lack of experience with the Spring Rich Client API, I assumed the solution would be more complicated and involve more of the API's classes and less Swing. I'm glad to see it was quite easy.

            Cheers,
            Joe

            Comment


            • #7
              Keith make big changes with ApplicationWindow and ApplicationPage

              I neee more times for integrate docking window

              regards

              Comment


              • #8
                Hopefully you'll find it easier now snpe, that refining was overdue :-)

                Looking forward to seeing it - Keith

                Comment


                • #9
                  see my another trade (or rcp-dev mailing list) - I make simple example

                  I need setter for contro and pagel in ApplicationWindow

                  It isn't easer for me , it is same like before - I have to learn again

                  regards

                  Comment


                  • #10
                    snpe, the link you had provided is broken.

                    http://www.snpe.co.yu/snpepeclinic.tar.bz2

                    Amad

                    Comment


                    • #11
                      Link is http://www.snpe.co.yu/snpepetclinic.tar.bz2
                      I'm sorry

                      Comment


                      • #12
                        Snpe,

                        Why do you need a setter for the window control? ApplicationWindow is a factory for its swing control (JFrame): I'd rather not make that mutable. The same concern apply's to a window's page: the page area should only manipulatable through the showPage method.

                        Can you subclass Window and Page to get what you need? There should be neccessary hooks. What do you need?

                        Comment


                        • #13
                          Keith,
                          I must change showPage in DefaultApplicationWindow - see my code in src
                          DefaultApplicationWindow is ugly - you have field control and local variable control in method
                          createWindowControl

                          I have to set my page and my control variable, because DefaultApplicationPage is not good for me - I don't show view in page - I show docking window layout

                          - I want that DefaultApplicationWindow call page with bean "applicationPage" in createPage method with default to DefaltApplicationPage like bean 'applicationWindow'

                          I can implement interface ApplicationWindow and don't extends DefaultApplicationWindow, too, but it isn't too smart

                          ApplicationWindow and ApplicationPage was better before change

                          If You want I can make this change

                          regards

                          Comment


                          • #14
                            Snpe,

                            Well, the vision is to make the Views themselves the dockable components. We may also introduce the concept of an "Editor" component, with a different lifecycle than a View (for example, one with explicit saving.)

                            Specifically the "ViewPanes" -- which are SimpleInternalFrames right now, by default, are what I envision to be dockable. We'd like to have multiple views per page, with the ApplicationPage class managing the individual views (tracking the active view, as well as the initial page layout.) This is similiar in concept to how Eclipse RCP works: and I think it's a solid design. Is there a chance you could fit into this model?

                            Here it is summed up:
                            - There is one Application per VM
                            - There are one or more ApplicationWindows per VM. Each window is realized by a JFrame component.
                            - There is exactly one ApplicationPage area for each window. Each page has a singleton ApplicationPageDescriptor, which encapsulates rules on how to initially layout that page using the ApplicationPageLayoutBuilder (this interface is really bare right now) In the future, we want to support remembering custom (changed at runtime) layout settings: e.g page-specific user preferences.
                            - Each ApplicationPage is defined by one or more dockable views declaratively placed in different areas of the page area (left, bottom, center, etc). A view is also defined by a singleton ViewDdescriptor. View instances may be stacked, tabbed, etc. The same view may be open on different pages in different windows--but only one view instance per view descripor is allowed per page.
                            - When views are added to a page, the page creates a ViewPane which manages the visual presentation of the View. Currently this is realized by a SimpleInternalFrame in the default implementation. The page also tracks and notifies of view lifecycle events: creation, focus gained, focus lost, destruction. The page caches view instances, and informs the views when they are activated/deactivated/disposed.

                            I hope this description helps! The design is MUCH better and more formalized than it was before.

                            Comment


                            • #15
                              Keith,
                              Can You add next, only:

                              - setter for control and page in DefaultApplicationWindow
                              - instantation ApplicationPage with 'applicationPage' bean in ApplicationWindow#createPage
                              - change reference like this.control and this.page with getControl() and getPage()

                              Docking window (infonode) have a lot features and it is possible make this with separate window and page
                              In fact, I don't need page, but I want integrate docking window in RCP

                              If you want I can make this changes or add new ApplicationWindow/Page implementations, for instance DockingApplicationWindow and DockingApplicationPage

                              regards

                              Comment

                              Working...
                              X