Thursday December 27, 2007
NetBeans APIs Meet the Web
A pretty small and pointless experiment:
Line 29 shows the NbPreferences class from the NetBeans APIs. In a web application. The preference is stored and loaded, however I have no idea where it is stored. Not in the NetBeans user directory, which was the point of the exercise. Maybe in internal memory or something like that. Still, despite the overhead of all the JARs, it is fun to see this on the web. There can only be very limited situations where the NetBeans APIs can be useful on the web, since they're intended for desktop development.
Dec 27 2007, 12:43:39 PM PST Permalink
More Power to Code Completion
I put a new plugin in the Plugin Portal, under the name Spiced Up Code Completion. It lets you supplement the code completion box (for all file types) with a list of new words. You can decide what the new words are, which could be code or could be actual words, in whatever language you like. The list of supplemental code completion items is set in the Options window. And then the words end up in the code completion box, as shown below for three different file types (in this case the words come from an English dictionary text file):
es
The third screenshot above shows that the new words end up below all the existing ones (so that they don't get in the way, especially since they're unlikely to be applicable to all file types at the same time). The above is the result of a tutorial I wrote sometime ago, but that hasn't been updated to 6.0 yet. However, aside from its value as a tutorial sample, I think it could also be useful to users in general, i.e., those who don't want to build the whole plugin from scratch via a tutorial. Hope it proves useful. It could be expanded in various ways.
Happy Christmas.
Dec 25 2007, 04:16:02 AM PST Permalink
How To Provide New Releases While Doing Nothing
Several plugins in the NetBeans Plugin Portal can be used in applications other than NetBeans IDE. Sure, many of them relate to editor functionality, hence those would probably apply mainly/only to NetBeans IDE. Others, however, could be used in any other application that is based on the NetBeans Platform. Here, for example, is the YouTube Player from the Plugin Portal installed in the JFugue Music NotePad:
So, if you're creating applications on top of the NetBeans Platform, I advise you to have a look at the Plugin Portal from that perspective, i.e., not from the perspective of NetBeans IDE, but from the perspective of your own application. Who knows, maybe you could even come out with a whole new release with features provided by plugins that you've grabbed from the Plugin Portal...
Dec 14 2007, 12:57:13 PM PST Permalink
Scene Graph API on the NetBeans Platform
Stone age experiments with the brand new Scene Graph API on the NetBeans Platform. Stone age in the sense that I'm just doing whatever I find in code completion to make what I need to work succeed. Okay, stone age people didn't have code completion. Never mind, bad rambling comparison. Anyway, not very finely finetuned, but I have a wandering monk, departing from the square on the left when I click it, and then moving to the right of the IDE, at which point "he" stops. Then I click him and he returns from whence he came:
Not only stone age methods were used, but also the end result is pretty pointless. However, the larger lesson is that I think the Scene Graph API is going to be useful in combination with the Visual Library API, or separate from it, whatever makes sense. For example, if you want tight integration with the NetBeans Platform, you won't use the Scene Graph API, because it has no connection with the Nodes API, unlike the Visual Library API. (So, you're not going to be able to integrate with a NetBeans Property Sheet, for example.) On the other hand, it does have a concept of "nodes", so at least there is a sharing of terminology. (Perhaps "false friends", but perhaps the basis of a merger.) However, I imagine that animation and timing framework related activities are handled better in the Scene Graph API. So, my guess is that one will be able to mix and match. Note also Josh's thoughts at the end of this article, where he imagines a future where the Visual Library API will be underpinned by the Scene Graph API. That makes sense to me and sounds like it would be the best of both worlds.
PS: In case you're wondering why I chose a monk—I wanted to use an image of a person. However, my knowledge of this API is currently microscopic, hence I knew I wouldn't be able to manage the movement of the person's legs. "Without that, it would look weird and incomplete", I thought. So, I decided to cheat. I googled for a picture of a monk, because I anticipated the picture would include a robe that would reach down over the shoes, so that the whole lack-of-authentic-leg-movement-animation-thing wouldn't be an eyesore. But I couldn't find a monk with the requisite robe length, so I gave up and went with this one, because of the white background... And, so, anyway, that's how it ended up being a monk. Pity he's got a bad habit.
Dec 13 2007, 12:44:26 AM PST Permalink
Hello Google Web Toolkit (Part 3)
I separated seven Google Web Toolkit samples from the source files and descriptions provided by the book mentioned yesterday. Now the GWT Starter Kit provides the following:
Each sample only contains the absolute minimum necessary to illustrate a very specific GWT feature. For example, the GWT Sortable Table application gives you this in a web page, i.e., there's only a table with headers that can be clicked to sort the columns, but there is nothing else (no text, no bells, no whistles, only the table itself):
In this case, the sample source structure is as follows, with the only files you really need to work with highlighted:
All seven samples are of a very similar size and structure, so the above should give you an idea of what to expect. When you go to the GWT Starter Kit page, you will see a list of screenshots at the bottom of the page, each illustrating the specific feature that each of the samples provides. My intention is to provide a sequel to Introduction to the Google Web Toolkit Framework, covering at least two or three of the samples provided by the GWT Starter Kit.
Dec 12 2007, 04:19:36 PM PST Permalink
Hello Google Web Toolkit (Part 2)
I asked and received permission from Packt Publishing to turn the samples from "Google Web Toolkit: GWT Java AJAX Programming", by Prabhakar Chaganti, into NetBeans projects and distribute them. Great. Here's the next one, available here in the Plugin Portal, together with the one from yesterday. The new one looks as follows:
Deploy it and you have an asynchronous auto complete box:
A problem with many of the samples in the book is that they're intertwined, sharing some of the same classes. I'm trying to separate them so that the samples can become small and self-contained. I haven't completely finished that with the above sample, but I've done enough to get it basically working, as far as I can tell. I want to take this specific sample and write a sequel to the new Introduction to the Google Web Toolkit Framework. The support that the IDE provides for GWT is really good. I've been impressed so far, anyway.
Dec 11 2007, 01:03:49 PM PST Permalink
Hello Google Web Toolkit (Part 1)
I've been reading "Google Web Toolkit: GWT Java AJAX Programming" by Prabhakar Chaganti. It is a very good book, very practical, perfect for my first introduction to GWT. Did you know that NetBeans IDE has a very advanced plugin that provides a lot of support for this framework? I didn't, until today. As a result, there's a new tutorial that gets you started, as well as a plugin in the Plugin Portal. The plugin provides the sample that you get at the end of the tutorial. The GWT NetBeans Plugin, which provides the wizards and other code generators, is, as explained in the tutorial, available in the Plugin Manager.
To summarize, here are the links:
- Introduction to the Google Web Toolkit Framework. A complete tutorial, introducing you to GWT and showing you the various tools provided by the GWT NetBeans Plugin. The tutorial closely follows chapter 2 of the abovementioned book.
- GWT Starter Kit. A sample that illustrates GWT in action; the result of following the above tutorial. Use it for troubleshooting if/when things go wrong in the tutorial. Or use it as the basis of a more complex application. Take careful note of how to set up the sample, as explained on the page above.
I like how GWT takes care of cross-browser compatibility. Plus, it's pretty interesting how you can apply a stylesheet to a user interface component in Java. And seeing AJAX in action, as a result of one's own coding, is cool. I also like how one can program purely in Java and how GWT converts the Java code to HTML.
Dec 10 2007, 05:31:15 PM PST Permalink
YouTube Movie Player in Plugin Portal
I reimplemented the YouTube Player as a TopComponent (in its own brand new mode), with the titles listed in the Navigator. Get it here:
http://plugins.netbeans.org/PluginPortal/faces/PluginDetailPage.jsp?pluginid=4437
The YouTube Search window should open when you've installed the two modules you get from the ZIP that you download above. If it doesn't, open it from the Window menu. Type something in the window and press Enter. The Navigator is opened as usual, via Ctrl-7. Here's how it all looks:
When you double-click an item in the Navigator, the browser opens and the movie is displayed. Then you can watch it. Once we have an embedded native browser component in the IDE, you'll be able to set that in the Options window, then you'll be able to watch the movie inside the IDE.
Dec 07 2007, 01:11:47 PM PST Permalink
Architecture of NetBeans YouTube Integration
The architecture of the YouTube integration that I showed yesterday is kind of interesting. To ensure that anyone can plug in their own embedded browser component, I separated the WebRenderer API and its implementation into a separate module suite from where the YouTube API and its implementation are found:
As a result, there could be several other browser components too, just like the WebRenderer API and implementation above. For example, you could make a suite called "YouTubeJDICWindow". It would contain the JDIC API together with a module containing a window that implements the API. Then, the user would be able to choose whether they want to install the WebRenderer modules or the JDIC modules.
And how do the window modules interact with the YouTube toolbar? There's only one point where interaction is necessary. That's when the user clicks on a title in the list. At that point, the window should open, displaying the selected movie. But, the window is in a different module to the toolbar, and both are in different module suites, so that no dependencies can be declared between them. So... how is the window opened by the toolbar?
And the answer is... the TopComponentGroup interface. When the user clicks the title in the list and the movie is correctly retrieved from YouTube, the following code is used to open the window:
TopComponentGroup group = WindowManager.getDefault().findTopComponentGroup("YouTubeGroup");
if (group == null) {
return;
}
group.open();
Hence, the WebRenderer implementation module registers its TopComponent in a TopComponent group called "YouTubeGroup". Any other module could do so too. But, since the user is only going to be using one window to display their movie (i.e., either the WebRenderer window, or the JDIC window, or the XYZ web component window), there will always only be one TopComponent registered in the group. And that's the TopComponent that will open when the above code is executed.
In this way, despite having no dependencies of any kind on each other, the two modules can interact (indirectly), thanks to the NetBeans System Filesystem. The end user notices nothing of all this, of course. All this happens seamlessly under the hood, but lets the developer provide a range of different user interfaces for the same YouTube movies.
Dec 06 2007, 01:22:44 PM PST Permalink
YouTubifying NetBeans IDE
I'm learning about NetBeans mobility functionality via YouTube movies, which I am watching inside the IDE while developing a mobile application. Below, you see the head of the Mobility team, Martin Ryzl, introducing a presentation, where he goes through lots of slides and demos about mobile development in the IDE (the movie was loaded when I clicked in the list shown in the top right of the screenshot below, which is a list of YouTube movies that match the search string 'NetBeans' that I typed into the text field to the left of the list):
The only real stumbling block (or 'challenge') standing between us and having this YouTube integration is... lack of native browser support in the IDE. Once we have that, the above will be possible, assuming we can bundle the YouTube Data Library (which works under the hood to let the user send queries to YouTube) with the IDE. I read somewhere that JDK 7 will fix the heavyweight/lightweight component conflict, which would simplify native browser integration. In the end, I envision situations like this—I would be designing a mobile application layout while looking at the slide (and listening to the presenter) that tells me how to do so:
I have an image in my head of Roumen, in the YouTubePlayer window, literally pointing with his finger at different parts of the IDE (kind of like Clippy, basically), or turning his head and saying things like: "Above me, you see the Projects window. It shows the logical views of your projects. Now, click Ctrl-2..." And so on... (Of course, the window could be moved around and then such instructions would be meaningless. However, if we give clear instructions about the optimal position of the window, i.e., in the Navigator view, in my opinion, I think we'd be okay.)
At that stage, many of our tutorials could be movies made available via YouTube, rerouted to NetBeans IDE via the above functionality. Similarly, if we put http://www.netbeans.tv/ movies on YouTube, we could route them into the IDE as well. I imagine that one would be able to load movies into the IDE after setting filters in the Options window and specifying whether notifications should be received when new movies belonging to specified categories are uploaded to YouTube. We would then be using YouTube as a delivery mechanism for the NetBeans IDE learning environment. It would also let NetBeans IDE integrate even more closely with the broader NetBeans community, many of whom have NetBeans-oriented movies on YouTube already. (It would be a cool way of sharing tips and tricks, for example.) Looked at from another angle—we would be opening up NetBeans IDE to YouTube. To me, this seems like a Win/Win scenario for Sun and for Google.
Dec 05 2007, 04:59:23 AM PST Permalink
Watching YouTube in NetBeans IDE 6.0
Managed to integrate the YouTube Player into the IDE. Unfortunately, because I'm using WebRenderer, a commercial web browser component, I can't distribute it. And I don't know whether I can distribute the Google API either. It was pretty cool to port the application to the NetBeans Platform, because it meant I was basically recreating it, thus optimizing the code as I went along the second time.
For example, there was no need for the Tidy API at all! In fact, I didn't need to do any HTML parsing. I wrote the temporary HTML file, inserted the short string that identifies YouTube movies, after extracting it from the movie's URL, and that's it. That's all that was needed. I didn't need that embedded element in the HTML at all, I could simply predefine it and insert the absolute minimum level of information into it.
Below is the result thus far. The user types something into the text field, presses Enter, and the list is populated with titles from YouTube containing the entered text. When an item in the list is double-clicked, a new window opens and the YouTube movie begins:

Another improvement is how WebRenderer is integrated. It is wonderfully simple. After the user double-clicks in the list (which is populated by the text field to its left, both of which can be seen in the screenshot above), the TopComponent opens. Then, code in the TopComponent loads the WebRenderer component, to which I pass the temporary file. The temporary file is recreated every time an item in the list is double-clicked, which is also the only time when the TopComponent opens (i.e., there's no menu item for opening it). And, whenever it opens, it loads the temporary file, which has new content each time. Wonderfully simple.
Pity I can't distribute it, though. Maybe I'll write a tutorial describing how you can do it yourself. That way, there'll be no licensing issues from my side, because you'll simply need to get whatever web browser component you like. For example, if JDIC works for you, you could get JDIC and plug it in. Not hard, as described above. Watch this space for a tutorial along these lines.
Dec 04 2007, 01:56:10 PM PST Permalink
Swing YouTube Player
NetBeans IDE 6 is out. Time to hurry to http://www.netbeans.tv/ and check for movies. Another place is YouTube, a few interesting things can be found there too. Here's one way of doing it, using a Swing YouTube Player:
YouTube is really well integrated here, for example, you can scroll through related movies within the browser component, i.e., note the "left" and "right" arrows on the two sides of the screenshot below. And, at the bottom of the currently playing movie, you can see small Ajaxy thumbnails, which move in and out as the mouse hovers over them and which you can click, at which point the selected movie starts instead of the current one:
Ingredients:
- YouTube Data API. Pulls the information from YouTube.
- HTML Tidy. Parses the returned HTML page, looking for the OBJECT element and extracts the embedded URL from there.
- WebRenderer. Provides the embedded browser component.
The latter of the three above was the hardest bit, and it still isn't perfect. First, I searched in vain for a Flash API. One that works on Linux, up to date with the latest Flash versions and, preferably, free and open source. Nothing out there meets these requirements. Secondly, I wrestled with JDIC and then gave up. Simply doesn't work with FireFox. Mozilla and Internet Explorer only, neither of which are an option. I also played with Rich Unger's JDIC Browser plugin from java.net, to no avail. I got quite far, but for the same FireFox reasons, couldn't succeed.
I then basically threw my hands in the air until I suddenly thought: "Who said that JDIC is the only available browser component?" Then I googled around and found WebRenderer. Not ideal, at all, because it is commercial. On the other hand, it doesn't involve native libraries, unlike JDIC, which is a big plus in my book. So, because I simply wanted to get something working, I got the evaluation download. Everything works as expected, basically, except that I'm having problems reloading new movies. (I write a temporary HTML file, as suggested by Sandip in the comments of the previous blog entry.) I don't want to invest too much time on this part, because WebRenderer can't be the real solution. I also get annoying messages about this being an evaluation version, as one might expect. So, my question is, does anyone know of other browser components? I would be so grateful if I could finish this application. And then port it to the NetBeans Platform, of course.
Dec 03 2007, 01:32:07 PM PST Permalink
YouTube Swing Browser
I took the principles outlined here and now I have a Swing browser for YouTube. It opens the browser when I click "Go there", displaying whatever is selected in the list. Entries appear in the list when I type something in one of the Search fields and then press Enter. Here's how it looks:
It's already more useful than YouTube itself. There's just way too much stuff going on on that site. Just give me the movies and let me watch them, that's all I ask. Don't overload me with a zillion odds and ends. I wish the API was able to access the actual Flash movie that is played, but that doesn't seem possible. You can get the whole YouTube page, as shown above, but not the movie itself. Or maybe I overlooked it in the Javadoc. But that would be cool to extract, because then I would be able to play it in my Swing app, assuming I bundled a Flash API with it. Pity most of the ones that are up to date are not free, though.
Dec 01 2007, 01:32:11 AM PST Permalink


