Geertjan's Blog

  • November 20, 2005

Simple Extension of NetBeans Component Palette

Geertjan Wielenga
Product Manager
A while ago I blogged about the new Component Palette. You can drag and drop various common JSP and HTML items onto a JSP or HTML page. But what if you're missing some items? Are you doomed to wait until the next release? No, not now that it's much easier to create NetBeans modules. Look, I added two very simple items myself today, for those moments where I just can't be bothered to type in paragraph tags and break tags. Now all I need to do is double-click in the Component Palette and the IDE creates the tag for me:

If you'd like to try out my new module (because you're just as lazy as me when it comes to paragraph tags and break tags), follow the tutorial: https://platform.netbeans.org/tutorials/nbm-palette-api1.html

(I've just noticed that the tags are only available for JSP pages, not HTML pages. I know how to fix that—just a minor tweak in the layer.xml file—but just thought you should know about this current limitation.)

Join the discussion

Comments ( 10 )
  • Kovica Sunday, November 20, 2005
    I've been thinking about a snippet module since the 3.6 times, but the module development back them was very hard (at least for me), with 5.0 became a lot easier. My idea was to be able to store any kind of snippets, HTML, Java, properties, text, ... When I say the palette I thought: "Oh, well. They were too fast :) :) :)" Looking at your module I don't find it very intuitive. For only adding two simple snippets to the palette there is a lot of code.
    What do you think about adding snippets like this: you edit a file, select a text, right click and select Add to palette. Then a dialog opens asking you into what category to add selected text.
    I hope you can and will do this. Please :))
  • Geertjan Monday, November 21, 2005
    Firstly, how could you see my code? I only enclosed a binary NBM file. I'm curious... Secondly, I didn't only add two simple snippets. I also added a new category called 'Simple HTML'. And I also added the category and the snippets to the customizer (Tools > Palette Manager > HTML/JSP Code Clips). I plan to blog about the simplest way of adding code clips. And then you'll see just how simple it can be. Finally, the way you describe adding snippets is probably (I guess) the way it will be done eventually, but not for 5.0. I will forward a link to this blog entry as well as these comments to Libor, the NetBeans developer who implemented the HTML/JSP code clips. Let's see if he's got something to add here!
  • Geertjan Tuesday, November 22, 2005
    By the way, Kovica, when you say this: "you edit a file, select a text, right click and select Add to palette. Then a dialog opens asking you into what category to add selected text", you are not talking about creating a NetBeans module that contains code snippets. You are simply talking about adding code snippets to the Component Palette (i.e., you're not creating a module at all). Sure, that should be part of post-5.0, I think. But that wouldn't require any coding on your part at all. On the other hand, when creating NetBeans modules, you've always got to do a bit of coding, but not much in this case if you see the next blog entry about how to create a BR snippet. Does this clarify this issue for you?
  • Charles Ditzel Thursday, November 24, 2005
    I think Kovica is thinking of something like Java Studio Creator's Code Clips. Is there a 'code clips' equivalent in NetBeans 5.0 ? Am I missing something obvious ? I don't think of Palette as being "Code Clips" - but may be wrong. Creator treats them separately - and I think they are separate items. Although I like what Geertjan is offering which is a method of extending the Palette is really great and very useful. I also find Creator's Code Clips very nice. You can find the distinctions between "Code Clips" and the Palette in Creator here. Maybe there is a 'Code Clips' module that could be included and note that the Creator group has a code clip site. This is an excellent idea if NetBeans.next offers a Code Clips.



  • Geertjan Thursday, November 24, 2005
    My understanding is that these are code clips. I don't see the difference between code clips in Creator and code clips (or code snippets, as I've been calling them here) in NetBeans...
  • Charles Ditzel Thursday, November 24, 2005
    That may be the case and I could be wrong in the way I understand or look at this but Creator has both a Palette and Code Clips - so at least in Java Studio Creator there is a difference.
  • Geertjan Friday, November 25, 2005
    Fair comment. I'll look at it (I installed it for the first time a few days ago) and at the doc that you referenced (which looks really useful) and leave another comment.
  • Said Bakr Monday, March 5, 2012

    I wonder, why not palettes has a simple scripting like code templates that allows code snipes to pop up window like those in the Form or table.

    For example,

    I will create new category called CakePHP, the I drag the following code to be snipts in the palette:

    <?php echo $form->create('<# varID='model', varVal='Bar', prompt=true #>');?>

    So, when I drag the code from the palette and drop it into the editor it will prompt requiring the varVal and then set it to the string as follows:

    suppose I set varVal = Car, so:

    <?php ech $form->create('Car');?>

    Or the above scripting style may be applied in the Content box of Add to Palette dialogue.

  • guest Thursday, July 4, 2013
  • Geertjan Thursday, July 4, 2013

    This is a blog entry from 2005... do you think the NBM would still work in 2013? No, I don't.

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