X

Geertjan's Blog

  • April 5, 2009

Return of Marilyn Monroe

Geertjan Wielenga
Product Manager
I'm rewriting the world famous Marilyn Monroe sample, using the various improvements/simplifications that have occurred since the time I first wrote it years ago—OutlineView instead of BeanTreeView, ChildFactory instead of Children.Keys, and the JDK 6 for-loop instead of the old iterators.

The result looks as follows:

If you want to take a look at it, especially if you want to learn about OutlineView, get it here:

http://blogs.sun.com/geertjan/resource/Marilyn-2.zip

Note that I haven't added the cut/copy/delete actions yet. So, right now the sample only shows how to create nodes and properties and how to display those in an OutlineView.

To me, the most interesting thing is how the property gets the current Movie object:

Property[] props = new Property[]{
new ReviewProperty(em.getExploredContext().getLookup().lookup(Movie.class))
};
outlineView1.setProperties(props);

That's possible because when the MovieNode is created, it adds the current Movie object into the Lookup, which is then available to the ExplorerManager:

public MovieNode(Movie item) {
super(Children.LEAF, Lookups.singleton(item));
this.movie = item;
setDisplayName(item.getTitle());
setIconBaseWithExtension("/org/demo/marilyn/resources/marilyn.gif");
}

Slightly more advanced version of the above, using the CheckableNode class:

What's interesting about the above is that I now have three modules: the "Marilyn" display window, the "Selected Movies" window, and the API consisting of the domain objects shared between the other two. Whenever a movie is selected, it is added to the InstanceContent (a dynamic travel bag of objects placed in the application's context). The "Selected Movies" window listens to the context for the introduction of movies into it. At that point, the method for returning the title is called on the movie object, which is then added to the text area in the "Selected Movies" window.

Join the discussion

Comments ( 17 )
  • RunningTracker Sunday, April 5, 2009

    Thanks for the project ! How do you define a dependency on ConvertAsProperties? Is there an extra Jar file to include? (org.netbeans.api.settings.ConvertAsProperties)


  • Geertjan Monday, April 6, 2009

    You need to be using some recent dev build of NetBeans IDE 6.7, which is where I developed the sample and which includes that JAR. It relates to a new annotation for handling persistence of topcomponents.


  • RunningTracker Thursday, May 21, 2009

    @Geertjan: do you know a way to remove the "..." button from the review column?


  • guest Saturday, June 27, 2009

    How do you change the text of the first column header from "Node"?


  • Markus Tuesday, October 20, 2009

    Hi Geertjan, could you please post the code for the Video Store (Return of Marilyn Monroe). I managed to get the same behavior as shown in the example, but I don't like my code. Maybe I get some ideas from your code.

    Thanks Markus


  • Geertjan Wielenga Sunday, October 25, 2009
  • Geertjan Wielenga Sunday, October 25, 2009

    RunningTracker and 173.24.232.118, both questions are answered here:

    http://blogs.sun.com/geertjan/entry/from_beantreeview_to_outlineview


  • mkh Monday, February 20, 2012

    Is there a new location for the "Marilyn-2.zip" file? (getting error 404, probably due to Sun>Oracle move)


  • guest Monday, February 20, 2012

    No, that's not the reason at all. There is simply too much uploaded into this blog, so I removed some things. What exactly is it that you need?


  • mkh Monday, February 20, 2012

    Oracle running out of disk space? ;)

    I'm just learning about OutlineView and wanted to see the complete code example as referenced near the beginning of the post ("http://blogs.sun.com/geertjan/resource/Marilyn-2.zip").

    I have seen other examples (eg. http://layerxml.wordpress.com/2010/10/01/the-basic-of-nodes/), but not one showing a nested structure which apparently Marilyn does.


  • Geertjan Tuesday, February 21, 2012

    No, not Oracle running out of disk space. Everyone gets a limited amount of space, under Sun too, and I have exceeded it.

    And here is an example of a nested structure:

    http://java.net/projects/nb-api-samples/sources/api-samples/show/versions/7.1/courses/MovieAnalyzer


  • guest Tuesday, February 21, 2012

    Excellent! Just what I was looking for. Thanks.

    PS. I really think you need to have more disk space allocated to you. This is very useful material for anyone trying to learn Netbeans RCP. It's not as if you're blogging about your weekends.


  • Geertjan Tuesday, February 21, 2012

    :-)


  • mkh Tuesday, February 21, 2012

    For anybody else reading this: the MovieAnalyzer sample does not show OutlineView - it uses BeanTreeView, however it does provide an example of nested Node structure that utilizes BeanNode and ChildFactory. It also shows different Node subclasses on same level (eg. Movie Actors and Director on the Person level).

    I'm assuming the only difference to OutlineView is in populating additional columns (nevertheless, if there are any complete OutlineView examples I would be interested to see them).


  • Geertjan Tuesday, February 21, 2012

    The sample is incredibly simple to switch to use OutlineView. Instead of declaring and instantiating BeanTreeView, just declare and instantiate OutlineView. The fact that you don't know this implies that you don't understand the concept of explorer views and ExplorerManager. Please read the tutorials, especially the 4 part series that starts here:

    http://platform.netbeans.org/tutorials/nbm-selection-1.html


  • Geertjan Tuesday, February 21, 2012

    And about 5 seconds of googling finds you this complete example for OutlineView:

    https://blogs.oracle.com/geertjan/entry/simple_example_for_an_outlineview


  • mkh Tuesday, February 21, 2012

    I understand the difference though clearly OutlineView has a little more to offer over BeanTreeView.

    Yes, I saw your '5 sec search' example prior to my initial request for 'Marilyn-2.zip'. If you don't get what I've been asking for and my subsequent clarification comment for future readers then just don't worry about it.


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha
Oracle

Integrated Cloud Applications & Platform Services