The Source for Java Technology Collaboration
User: Password:



Tim Boudreau's Blog

April 2006 Archives


Most Poetic Commit Log of the Year Award

Posted by timboudreau on April 29, 2006 at 01:12 AM | Permalink | Comments (4)

I was going through old email, and my friend Jesse had pointed up my friend Jarda's commit log message as a candidate "Most Poetic Commit Log of the Year Award". What's the most amusing commit message you've read but neither incited nor written yourself? Here's Jarda's:

Hopeless in my own destiny, strugling to really improve the speedup of startup at least a bit, but always loosing my improvements as Sisyphus his stone, I am adding this little change to prevent tons and tons of ClassLoaderCache objects from creation. Now only a resonable number shall get created during 2nd and subsequent startup.

Of course, you can only do this award once - after that, everyone will be trying to be poetic in their commit messages and it all becomes meaningless :-)

Directory: /core/startup/src/org/netbeans/core/startup/
=======================================================

File [changed]: ClassLoaderCache.java
Url: http://core.netbeans.org/source/browse/core/startup/src/org/netbeans/core/startup/ClassLoaderCache.java?r1=1.2&r2=1.3
Delta lines:  +2 -2
-------------------
--- ClassLoaderCache.java	4 Aug 2005 13:13:48 -0000	1.2
+++ ClassLoaderCache.java	5 Aug 2005 13:18:28 -0000	1.3
@@ -171,8 +171,8 @@
                 return null;
             }
             
-            
-            node = find (next);
+            // effectively node = find(next);
+            node.pos = next * NODE_SIZE;
         }
         
         return resIndex;


Deliver your beans in a NetBeans module (the hard way)

Posted by timboudreau on April 05, 2006 at 05:13 PM | Permalink | Comments (6)

In Monday's blog, I announced a webstart-enabled standalone tool that will generate a NetBeans plug-in module that takes a JAR of Swing components, putting them on the component palette for users to drag and drop. Here I describe how to do the same thing using the plug-in development tools inside NetBeans.

I had actually written this up a couple of weeks ago, and it was my friend and colleague Trung Duc Tran who said "there should be a tool to do that." He was right. So I held this blog and wrote BeanNetter.

Nonetheless, the step-by-step here is worth posting, since you can see what's being generated by the tool under the hood, and it's useful if you're making a module already. So here's how you'd do the same things by hand:

  1. The first thing you want to do is set your JavaBean up as a Library in NetBeans - that's a library that can be shared among projects you're working on. Go to Tools | Library Manager, and add your component's JAR as a library you'd use in normal development - you'll see why in a minute
  2. The second thing you want to do is create a plug-in project. That's easy and it's built right into NetBeans. Just go to New | New Project, and choose NetBeans Plug-In Modules | Module Project
  3. On the next screen, provide a name - short and clear is usually good, same name as your component would also make sense
  4. For code name base, just use the fully qualified name of your component. Don't worry about it too much, it just needs to be unique.
  5. For module display name, type in some nice human readable name for your component(s)
  6. Your project will open, and you'll have a package with the same name as the code name you entered. Select the package and choose New | File
  7. Select NetBeans Module Development | J2SE Library Descriptor. What's that?

    Well, NetBeans already has a way to embed "libraries" in a module and have them show up in the list of libraries a user can use. So the only thing we're going to need to do in addition is add a little metadata to put the bean(s) on the Component Palette

  8. Click next and finish. You'll see an XML file is created. Don't worry about it, we're not going to need to touch that.
  9. Now we get to add a little bit of metadata that puts an entry on the component palette.
  10. Select your package again and choose File | New, and in the new file dialog, create a new empty XML file. Call it something like MyBeanPaletteItem. Paste the following content into it, substituting the fully qualified name of one JavaBean and the name of the library:
    <?xml version="1.0" encoding="UTF-8"?>
    <palette_item version="1.0">
      <component classname="org.netbeans.swing.colorchooser.ColorChooser" />
      <classpath>
          <resource type="library" name="ColorBean" />
      </classpath>
    </palette_item>
    
  11. There's only one step left - open the layer.xml file in your package. Add the highlighted portion you see below, substituting the palette item xml file you just created for the one listed here.
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE filesystem PUBLIC "-//NetBeans//DTD Filesystem 1.1//EN" "http://www.netbeans.org/dtds/filesystem-1_1.dtd">
    <filesystem>
        <folder name="org-netbeans-api-project-libraries">
            <folder name="Libraries">
                <file name="ColorBean.xml" url="ColorBean.xml"/>
            </folder>
        </folder>
    
        <folder name="FormDesignerPalette">
            <folder name="Beans">
                <file name="ColorChooser.palette_item" url="ColorBeanPaletteItem.xml"/>
            </folder>
        </folder>
    
    </filesystem>
    
    
  12. Right click the project and choose Create NBM. When it's done, you've got a NetBeans module that will auto-install your JavaBean into a user's component palette. Try it out on an instance of NetBeans that knows nothing about your library - just start NetBeans from the command line, e.g. nb -userdir /tmp/foo. When it comes up, choose Tools | Update Center. Select the Install Manually Downloaded Modules option, and find the NBM file that was created (hint: look in the output window of the instance of NetBeans you built it in).

And poof, you've got a NetBeans plugin that delivers your components right onto the component palette of any NetBeans 5.0 user.

If you have some problems, this usually means one of the strings in one of the XML files is not correct. Try starting the instance of NetBeans you install the module in, from the command line, and add the line switch -J-Dnetbeans.logger.console=true to get an idea of where the problem might be.

Got JavaBeans? Here's a way to distribute them...

Posted by timboudreau on April 03, 2006 at 11:53 AM | Permalink | Comments (10)

BeanNetter - the NetBeans Module Generator

So NetBeans has this cool component palette from which you can drag and drop components onto Swing componentPalette.png

forms. But where are all the cool components? NetBeans just shows the default JDK Swing components - but there are lots of components out there. Wouldn't it be nicer if you could make them just appear in your IDE? And there are sites such as nbextras.org with NetBeans plug-ins, and there is an update facility built into NetBeans - so why shouldn't you be able to download JavaBeans straight into the IDE from them? Well, first, it needs to be easy to create a NetBeans module that embeds JavaBeans and puts them on the Component Palette.

So I wrote a small tool that generates a NetBeans plugin. It's a wizard, and you point it at a JAR file with some Swing components in it. It finds all the declared JavaBeans that are there, and lets you choose to add or remove other classes. Then it asks for some info like the name of the library - this will be your Beans' category on the Component Palette.

When you complete it, it generates a complete, redistributable NetBeans Module (.nbm file - the distribution format for plug-ins - a glorified zip file), and all of the components you selected will show up on the Component Palette in their own category as soon as you install it in the IDE. Now...how to distribute these glorious plugins?

What to do with the results

Now you've got a module, but the point is to get that module to other people. How to do that? Well, first, if the components are open source, I bet the folks at nbextras.org would happily host them, and that site's been getting a lot of attention lately. If they're commercial, there is the Third Party update center that every release copy of NetBeans checks for plug-ins, and that could be a good place - the partner page would be a good place to start.

Sources and Screen Shots

Sources are in contrib/Beans2nbm/beans2nbm in CVS on NetBeans.org. The tool also happens to showcase one of my (far too many) weekend projects, the Wizard project.

wizardPanel2.png
BeanNetter - the NetBeans Module Generator

wizardLicense.png
Choosing a License - Extra points if you can identify the text above




Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds