07.07.08

taT | Play with XML Layer (Part 3)

Posted in NetBeans, Platform, Tips|Tricks, XML, nb-60 at 7:02 pm by Varun

Hey,

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.

Pre-requisites

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"/>
                </folder>
            </folder>
        </folder>
    </folder>

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"/>
                </folder>
            </folder>
        </folder>
    </folder>

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).

References
[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

eNjoy Technology…

07.01.08

Article | NetBeans Reloaded

Posted in NetBeans, Platform, nb-60, nb-61 at 6:57 pm by Varun

Hi,

What happens when you developed a module, and test it by Install/Reload in Target Platform? New instance of NetBeans Target Platform starts running with your module installed in it.

Though, the statusbar in the IDE, shows a name to the left of the progress bar, which is something like org.netbeans.modules.something (reload)

Ever thought, why its reload, not install? Think after you read this blog.

Discovery

Why does every discovery occurs by accident? Yes, another accident lead to a discovery. When this instance is running, you could do changes in your code, and Run F6, this reloads the already running instance. So, no need to stop the build, and rebuild to run! Make changes, whether drastic OR not, it would reload, saving a lot of time.

Accident

I was testing one of my recently contributed tutorials at Community Docs, and while making some changes, I forgot there’s already an instance that’s running, and I accidentally Press F6, thinking that there would be 2 Target Platform’s running, apart from Development Platform, where I made changes. To my surprise, there was only single Target Platform running, which just got reloaded within few seconds. Isn’t it cool?

Your Thoughts

So, did you knew about it, you don’t? Do comment if you find it useful! If you have some tricks to share, do join Community Docs, right now and start contributing!

eNjoy Technology…

06.24.08

taT | Play with XML Layer (Part 2)

Posted in NetBeans, Platform, Tips|Tricks, XML, nb-60 at 5:15 pm by Varun

Wow!

I am really 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 Actions and play with it.

By the way, I came to know, that CookieAction does support Shortcut Keys, however I used to think it doesn’t as it was always disabled, when I used Action Wizard to create it.
Its a bug, that’s present since 5.5 and I never realised- I have filed a bug report!

Pre-requisites

Read my previous blog entry- Part One of this series! You should be thorough with all that was explained previously. If not, get it clarified by me OR on Netbeans Community mailing lists.

Problem Description

Here, we are going to transform an Action from one type to another, i.e. from CallableSystemAction TO CookieAction, sounds cool! Though, never tried. Well, here I am sharing with you another trick to make it possible, without using New File Type Wizard. We will make use of SayCheez.java, which was made in previous entry.

Solution

So, to start with, remove the CallableSystemAction and let the class SayCheez extend CookieAction, like this;

public final class SayCheez extends CookieAction {

Now, don’t remove the already existing implementations of abstract methods of CallableSystemAction, just add following two to let the class SayCheez implement all the abstract methods defined by CookieAction.

@Override
protected Class<?>[] cookieClasses() {
return new Class[]{{$Interface}.class};
}

protected int mode() {
return CookieAction.{$mode};
}

Please note, that {$Interface} needs to be replaced by appropriate interface, i.e. it could be either of the following Cookie class(es), which are basically interfaces/abstract class(es);

  1. Project
  2. OpenCookie
  3. EditCookie
  4. EditorCookie
  5. DataObject (Abstract Class, NOT an Interface)

Also, {$mode} needs to be replaced with either MODE_EXACTLY_ONE[1] or MODE_ALL[2].

  1. User Selects One Node
  2. User May Select Multiple Nodes

MODE_EXACTLY_ONE -
Action will be enabled if there is exactly one selected node and it supports the given cookies.

MODE_ALL -
Action will be enabled if there are one or more selected nodes and all of them support the given cookies.

In our case, its EditorCookie!

Now, alter the performAction method like this,

protected void performAction(Node[] activatedNodes) {
{$Interface} ref = activatedNodes[0].getLookup().lookup({$Interface}.class);
// TODO use {$Interface}
}

Here, ref is basically the reference to either the interface/class being made, which is being assigned a subclass reference, it could be of great use. Now, add your code for DialogDisplayer used in previous blog entry, in place of TODO comment.

See, it was too easy! Anyways, the changes in XML Layer, which shall be done with respect to the change in the Action type, some of them are as follows and rest will be the mentioned in the next part of this series.

Tricks for Menu Item, Toolbar Button, Shortcut Keys

Trick #1 - If you had made a Global Menu Item OR Toolbar Button with CallableSystemAction, then no changes required.

Trick #2 - If you had made use of Shortcut Keys earlier, now you have to remove them, as CookieAction doesn’t support Shortcut Keys! Well, I don’t know why. So, remove following code from our XML Layer, formed earlier.

Thanks for following, enjoy and have fun! Surprise to be revealed soon…keep an eye on my blog!

Previously posted on NetBeans Zone -
Playing with NetBeans XML Layer Files (Part 1)

Add to Technorati Favorites

sTay Tuned for More…

06.23.08

taT | Play with XML Layer

Posted in NetBeans, Platform, Tips|Tricks, XML, nb-60 at 2:29 pm by Varun

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

Add to Technorati Favorites

sTay Tuned for More…

05.28.08

dotNet - Code Completion - NetBeans

Posted in .NET, Blog Contest, NetBeans, Reviews, nb-60, nb-61 at 11:37 pm by Varun

Code Completion, Intellisense…

These are some jargons which I came across, when I started working on C# using Visual Studio 2003 .NET! It was then I got familiarize with Intellisense.

At that time, it looked like the coolest thing which a developer could have ever dreamt of. I was adept at using Turbo C/C++ Borland IDE, before switching over to .NET temporarily.

I would never ever thought in my wildest of dreams, that I would come across such brilliance. During that time, I came across another IDE, NetBeans 5.5, as I was not happy to use J# supported by .NET, it was really disappointing! So, I tried various softwares before finalizing NetBeans for my 1st ever Java-based project.

I tried JCreator and Eclipse before trying out NetBeans. The reason why I not choose Eclipse isn’t relevant to discuss here. If you have interest in reading about it, refer to my NetBeans Testimonial (see Varun Nischal).

dotNet -

Till date, I have never regretted using Intellisense, which is beautifully supported by .NET Framework, its really excellent tool to use, sometimes I make switch to dotNet, just to use this feature, which really helps me code fast and intelligently.

NetBeans -

They named it Code Completion, I used to regret using it and it was so slow too, while Intellisense was quick! Over the past 1 year, with the release of NetBeans 6.0 and 6.1, there has been tremendous improvement, esp. 6.1 which has really improved a lot! Latest performance enhancements have lead to smarter parsing, which enables faster code completion. So, they are moving in the right direction.

Current Status -

I recently used dotNet 2008, I was really surprised that they too have improved speed of the Intellisense, its fast and furious…
Even though, NetBeans have shown improvement in that context, still there’s some distance left to cover, before they can give competition to Intellisense.

Note -
These are my views, as programmer and its upto you to take it seriously or not, but during this series of blogs, I won’t be bias, yet would be fair to both. Its not meant to degrade certain IDE’s image.

eNjoy Technology…

This is being submitted for review to the blogging contest - Student Reviews NetBeans 6.1 and OpenSolaris!
Author - Varun Nischal, University - JIIT University

Add to Technorati Favorites

« Older entries