N, Varun

taT | Play with XML Layer June 23, 2008

Filed under: NetBeans, Platform, Tips|Tricks, XML — Varun @ 2:29 pm

Hey,

As I mentioned in my previous entry, that I am starting with a new blog series. This is it- Part One, of Blog Series: XML Layer! Hope you would enjoy, following it. Anyways, coming back to the point. Let me share with you another trick, which I was observing for few weeks, and its really cool! Its based on NetBeans Platform. This is my first full-fledged post on NetBeans Platform, as I’m dealing with it almost daily for over a week, for some cool plugin development.

Pre-requisites

This trick makes use of the existing tutorial, which is the base on which I have carried out the trick. Also, you must read this tutorial, if you don’t have prior experience with NetBeans Platform. Hey, give this a read as well,

This overview will quickly familiarize you with how NetBeans plug-in modules interact with the NetBeans infrastructure and with each other.

Problem Description

As mentioned in the tutorial, I created an Action Type (CallableSystemAction), made it a Global MenuItem and Toolbar Button. I named the Action Type (Java file) as SayCheez, and display Name as Say Cheez…

Now, I have made this action, as expected in the tutorial. Now, right-click Project & click on Install/Reload in Target Platform in the context-sensitive popup menu (context-menu). Its running successfully!

Now, let me show you the structure of XML Layer (layer.xml), its similar to the one shown in the tutorial, i.e. how it registers the action into the NetBeans IDE. See this image;

So, the trick is how to play with the Layer and don’t waste time, placing actions anywhere else in the IDE, by recreating them.

Solution

Note, all the following tricks would work for CallableSystemAction only, I have not tested for CookieAction, though it should work for CookieAction as well, if you are working with only MenuItem, Toolbar Button OR Shortcut Keys! For Editor and File Type Context MenuItem, there would be some other way round, I will see if its comfortable playing with them as well ;)

By Code Deduction

Trick #1- If you want to remove either one of the separators, OR even both of them, then see the following image, the code present in that remove it from the XML Layer, as per your need.

Trick #2 – If you want to remove the Action, from Toolbar, then remove the following code;

Trick #3 – If you want to remove the Action from Tools Menu, and retain it only on the Toolbar, then remove the following code;

By Code Replacement

Trick #4 – If you want to make a Shortcut key for this action, add the following code,

Trick #5 – Sometimes, it might happen, that your action is not suitable for any existing Menu, and you are looking to create your own Menu. By the time, you get ready with your Menu, you can just have this Shortcut Keys alone, i.e. no Menu Item, no Toolbar Button.

Tips to remember

This code has a shortcut key “Alt+F3″, which is represented as “O-F3.shadow”, so this means, if you have some key combination, that uses “Alt”, then use “O”, and for each “+” sign use “-” ,finally concatenate with the just formed combination with “.shadow”! If you use “Ctrl”, then use “D” and for “Shift”, use “S”!

Following are some key equivalents used in XML Layer;

  1. A to Z (as it is), F1 to F12 (as it is), 0 to 9 (as it is)
  2. / as SLASH, as BACK_SLASH
  3. ; as SEMI_COLON
  4. . as PERIOD
  5. as QUOTE

These were some of the frequently used keys in Shortcut Key combination, if you want to know some more, you can post a comment over here. I would be glad to help you out!

Actually, I was developing a module for past one week, and more intensely on the weekend, and have observed this by hit-and-trial, and thought of sharing the trick with you people. By the way, there’s a surprise! Any guesses, well no prizes for guessing!

HINT
Its related to the module, I’m working on for past one week.

Playing with XML Layer, reminded me that I have to resume working on XML Hyperlink Module as well :) Anyways, thanks for following, enjoy and have fun! To know more about the surprise, keep an eye on my blog!

Previously Posted on NetBeans Zone -
Update on Issue #136216: MySQL Server Node Error

This blog has been contributed to NetBeans Community Docs Program and for latest updates on this content, refer to the contribution.

Add to Technorati Favorites

sTay Tuned for More…

 

9 Responses to “taT | Play with XML Layer”

  1. Angad Singh Says:

    Awesome post. I didn’t know this. Will save me a lot of time. :)

  2. Varun Says:

    Guys,
    Its coming soon on your favorite Community Docs & NetBeans Zone, with proper syntax-highlighted code snippets! Stay tuned…

    @Angad,
    Yes, it really saves a lot of time! ;)

  3. Vaibhav Says:

    Nice blog ! Informative.

  4. Varun Says:

    @Vaibhav
    Thank you, Sir!

  5. [...] enjoying playing with XML Layer. I had mentioned an important note in my previous blog entry- Part One of this series! Its time to work with the CookieAction, i.e. make some Conditionally Enabled [...]

  6. [...] wrote a blog entry, basically another edition of tips and Tricks, this time focus being on NetBeans Platform, and that [...]

  7. [...] taT-03 | Play with XML Layer [...]

  8. Порно Says:

    Классно, штука полезная!

    Translated to English- “Cool, useful thing!”


Leave a Reply