Return of Marilyn Monroe

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.

Comments:

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)

Posted by RunningTracker on April 05, 2009 at 04:48 AM PDT #

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.

Posted by Geertjan on April 05, 2009 at 08:20 PM PDT #

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

Posted by RunningTracker on May 21, 2009 at 01:59 AM PDT #

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

Posted by guest on June 26, 2009 at 05:11 PM PDT #

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

Posted by Markus on October 19, 2009 at 08:14 PM PDT #

Here: http://blogs.sun.com/geertjan/entry/yet_another_return_for_marilyn

Posted by Geertjan Wielenga on October 24, 2009 at 10:03 PM PDT #

RunningTracker and 173.24.232.118, both questions are answered here:

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

Posted by Geertjan Wielenga on October 24, 2009 at 10:14 PM PDT #

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

Posted by mkh on February 20, 2012 at 12:39 PM PST #

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?

Posted by guest on February 20, 2012 at 02:49 PM PST #

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.

Posted by mkh on February 20, 2012 at 03:46 PM PST #

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

Posted by Geertjan on February 20, 2012 at 05:55 PM PST #

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.

Posted by guest on February 20, 2012 at 06:50 PM PST #

:-)

Posted by Geertjan on February 20, 2012 at 07:45 PM PST #

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

Posted by mkh on February 21, 2012 at 01:50 PM PST #

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

Posted by Geertjan on February 21, 2012 at 02:11 PM PST #

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

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

Posted by Geertjan on February 21, 2012 at 02:18 PM PST #

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.

Posted by mkh on February 21, 2012 at 03:01 PM PST #

Post a Comment:
  • HTML Syntax: NOT allowed
About

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.

Search

Archives
« March 2015
SunMonTueWedThuFriSat
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
    
       
Today