What OTrunk displays depends on what is returned in the getComponent() method in the view associated with an OTObject. OTrunk will automatically call getComponent() on the first child of the otrunk/root element in the otml. It is up to that element's view to render/ignore any children OTObjects.

The view <-> object relationships are defined in the otml -- in this case, since the root OTObject is an OTPasProject, the view that will be displayed is the OTPasProjectView.  It looks like this view is set to instantiate the PasProject object via the controller, and then display a new JLabel("Loading Pas project, " + pasProject.getTitle())... which is what you're seeing.

I just checked in a change to the view to where it grabs the frame from the PasProject, calls showFrame(), and then hides the frame that pops up. It then grabs the main contentPane from the frame and returns that. This seems to work, but it seems kludgey to have to render/hide the PasFrame (it wouldn't show anything without doing that). It will give you a starting point at least.

Update your pas-otrunk project and give it a shot. :-)

-- Aaron

Geoffrey Kwan wrote:
Awesome, I've made a little bit of progress using your help. I now run the code below and the popup window displays and the text within it says "Loading Pas project, Project Title". The window just stays like that and never changes though. Clicking in the window does nothing.


        PasProject pasProject = (PasProject) rootBean;
        otViewerHelper.loadOTrunk(otDb, pasProject.getProjectFrame());

        JDialog popup = new JDialog();
        JPanel panel=new JPanel(new BorderLayout(5, 5));
        OTViewContainerPanel otPanel = null;
        OTFrameManager frameManager =
            (OTFrameManager) viewContext.getViewService(OTFrameManager.class);
        otPanel = new OTViewContainerPanel(frameManager);
        otPanel.setTopLevelContainer(true);
        OTViewFactory viewFactory = viewContext.createChildViewFactory();
        otPanel.setOTViewFactory(viewFactory);
       
        panel.setLayout(new BorderLayout());
        otPanel.setCurrentObject(otrunkRoot);
        panel.add(otPanel, BorderLayout.CENTER);

        popup.add(panel);
        popup.setVisible(true);

Is there something else I need to call to get it moving along past the "Loading Pas project, Project Title" screen?

Thanks,
Geoff

On Mon, Mar 24, 2008 at 4:43 PM, Scott Cytacki <[EMAIL PROTECTED]> wrote:

The loadOTrunk method of otViewerHelper doesn't actually visually show
anything.
The jpanel passed in is just used so that popup error messages are
correctly centered on which ever jpanel
the caller prefers.

To actually display something you will need to do a few more steps.
If you look at the getComponent method
of the OTrunkStep you can see the remaining steps.  That method is doing
other stuff to so I'll try to pick out
just what you need.  It would be really nice to have an example class
that does just these steps inside of the OTrunk
project somewhere.  This code doesn't deal with loading in learner data
or setting up a view mode.

-----------
JPanel panel=new JPanel();
OTDatabase otDB = viewerHelper.loadOTDatabase(getAuthoredDataURL());
viewerHelper.loadOTrunk(otDB, panel);
OTObject root = viewerHelper.getRootObject();
OTViewContainerPanel otPanel = viewerHelper.createViewContainerPanel();

panel.setLayout(new BorderLayout());
panel.add(otPanel, BorderLayout.CENTER);
otPanel.setCurrentObject(root);
----------

Scott


Geoffrey Kwan wrote:
> I still can't get preview project to display any content.
>
> In OTrunkCurnit.java I have tried calling
>
>         otViewerHelper.loadOTrunk(otDb, pasProject.getProjectFrame());
>
> and also subsequently tried
>
>         otViewerHelper.loadOTrunk(otDb,
> pasProject.getProjectFrame().getContentPane());
>
> and then tried calling
>
>         pasProject.getProjectFrame().setVisible(true);
>         pasProject.getProjectFrame().getContentPane().setVisible(true);
>
> Then when I click on the preview button and this code above runs, a
> new window opens up that is meant to display the project but nothing
> shows up in the window. The top of the window does display the title
> of the project so I know that data from the project is successfully
> accessed (at least for the title).
>
> I have even tried to add components to the content pane but the window
> is still blank.
>
> Does anyone have any idea why nothing is being displayed except the
> title of the project.
>
> Thanks,
> Geoff
>
> On Fri, Mar 21, 2008 at 11:25 AM, Geoffrey Kwan
> <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
>
>     This below causes a ClassCastException
>     (java.lang.ClassCastException:
>     org.telscenter.pas.beans.PasProject). Is there another way to
>     obtain the component from the rootBean?
>
>     (BeanContextChildComponentProxy) rootBean
>
>
>
>     Even when I try this below for the sake of seeing if passing the
>     contentPane will work, nothing happens. I step through loadOTrunk
>     and nothing wrong seems to happen, at least to my limited
>     knowledge of OTrunk. There are no exceptions or stack traces.
>
>             PasProject pasProject = (PasProject) rootBean;
>             otViewerHelper.loadOTrunk(otDb,
>     pasProject.getProjectFrame().getContentPane());
>
>     -Geoff
>
>
>     On Thu, Mar 20, 2008 at 7:24 PM, Anthony Perritano
>     <[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]>> wrote:
>
>         thinking about this. we dont want to have the pasproject
>         import in this class. this is sail-otrunk.
>
>         you can get the component of the rootbean with the bean
>         context. Maybe the loadOtrunk doesn't like frames. try getting
>         the child of the frame which the is the contentPane. is there
>         any stack trace? can you investigate a little further, step
>         into loadOtrunk?
>
>         ((JFrame)((BeanContextChildComponentProxy)rootBean).getComponent()).getContentPane();
>
>         -Tony
>
>
>
>         On Mar 20, 2008, at 4:08 PM, Geoffrey Kwan wrote:
>>         We have set up our authoring tool with a preview button and
>>         when the preview button is clicked, this function below gets
>>         called. The loadOTrunk() function gets called but nothing
>>         happens. Am I doing something wrong?
>>
>>
>>             public void previewCurnit() throws Exception {
>>                 if( otDb == null)
>>                     throw new Exception("Curnit has not been
>>         initialized");
>>
>>                 otControllerService.saveRealObject(rootBean, otrunkRoot);
>>
>>
>>                 PasProject pasProject = (PasProject) rootBean;
>>                 otViewerHelper.loadOTrunk(otDb,
>>         pasProject.getProjectFrame()); //this getProjectFrame() is a
>>         JFrame
>>             }
>>
>>
>>         Thanks,
>>         Geoff
>>
>>
>>
>
>
>
>
>
>
> >








--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "SAIL-Dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/SAIL-Dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to