taT | Play with XML Layer (Part 3)


So, I am writing a third part, Wow 😉 Really, I must admit, I just didn’t thought I would write so frequently, and that too, on NetBeans Platform. Its something, that needs a lot of time to understand its usability, functionality and extensibility… 🙂 Anyways, in my previous entry- Part Two of this series, I wrote on how to transform an Action type from one form to another- CallableSystem TO Cookie! By the way, I have already done the reversal in form of a tutorial, and contributed to the Community Docs.

Here, I present to you tricks to add/remove entries into/from XML Layer, that would enable/disable context-aware actions.


Just have a look at this webpage- Tryst with Platform! Its basically an index of what all documentations (11), I have contributed to the NetBeans Community, be it blogs, tutorials, articles, tips and Tricks, Dzone entries, etc, in the last week of June.

Tips and Tricks

Following tips/tricks apply to CookieAction, not CallableSystemAction! Also, check out the references section (at the end of this entry), this part of blog series is inspired by those references!

Syntax of the MIME Type: type/subtype

Tricks for Context Menu Items

Trick #1 – If making the action, file type context-sensitive. Then, you have to add an entry in folder “Loaders” as follows into XML Layer.

    <folder name="Loaders">
        <folder name="type">
            <folder name="subtype">
                <folder name="Actions">
                    <file name="org-nvarun-tat-SayCheez.instance"/>

Trick #2 – If making the action, editor context-sensitive. Then, you have to add an entry in folder “Editors” as follows into XML Layer.

    <folder name="Editors">
        <folder name="type">
            <folder name="subtype">
                <folder name="Popup">
                    <file name="org-nvarun-tat-SayCheez.instance"/>

Tips To Remember

In our case, I replaced type with text and subtype with x-java! What I did, I registered the Action into the Java Editor Context Menu, i.e. whenever you open a Java File, and do right-click, popup menu would show the above action. Also, when you expand relevant Package Node of a Project Node, to uncover Java File Nodes, right-click to see the Action in the popup menu!

However, it would be still be enabled, if you had earlier chosen EditorCookie, EditCookie, DataObject OR OpenCookie. It would be disabled, if you choose Project interface as Cookie class.

Now, what?

You can find out what all MIME Types are registered into the IDE, by clicking on Tools > Options, and click on button Advanced Options! There you expand nodes in this order- IDE Configuration —> System —> Object Types

Now, select any sub-node, and you could see its property sheet on right panel, where all possible MIME Types for that particular Object Type are listed. Try this on existing MIME Types, also you may do this for your own created languages (which you might like to integrate into the IDE).

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

[A] http://en.wikipedia.org/wiki/MIME#Content-Type
[B] Recognizing a File Type Tutorial
[C] http://wiki.netbeans.org/DevFaqActionAddEditorPopup
[D] http://wiki.netbeans.org/DevFaqActionAddFileMime


2 thoughts on “taT | Play with XML Layer (Part 3)

  1. Pingback: 10 Tips and Tricks « N, Varun

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s