sandip chitale's blog    Sandip Chitale's blog (scblog)
NOTE: I have moved many of my modules to NetBeans Plugin Portal . Please check there for latest versions of modules described on this blog.
20080315 Saturday March 15, 2008

Google Talk in your Firefox sidebar

 

Just Create a book like this: 

Google Talk Bookmark

Set the location to:

http://talkgadget.google.com/talkgadget/client?hl=en

Make sure the Load this bookmark in the sidebar is selected. 

Thats all!


Posted by sandipchitale ( Mar 15 2008, 09:23:50 AM PDT ) Permalink Comments [1]


20080312 Wednesday March 12, 2008

Remove unused binding attribute from VisualWeb JSF pages

Prior to NetBeans IDE 6.0 release VisualWeb Pages use to generate a binding attribute in the tag for every component in the page.

For example, when a Grid Panel was dropped on Page1, the following tag was automatically generated in the Page1.jsp file:

<h:panelGrid binding="#{Page1.gridPanel1}" id="gridPanel1" style="height: 96px; left: 24px; top: 24px; position: absolute; width: 96px"/>

and the following field, getter and setter was generated in the Page1.java file:

    private HtmlPanelGrid gridPanel1 = new HtmlPanelGrid();

    public HtmlPanelGrid getGridPanel1() {
        return gridPanel1;
    }

    public void setGridPanel1(HtmlPanelGrid hpg) {
        this.gridPanel1 = hpg;
    }

This was good if you wanted to access the gridPane1 component programmatically. Otherwise it only served to bloat the .jsp and .java files. Therefore starting with NetBeans IDE 6.1 (M1+) release we decided to not generate the binding attribute automatically. Instead you can add and remove the binding attribute (and the corresponding field, getter and setter) by invoking the action in the component's pop up menu. For details, see the mini spec - On-demand binding attribute .

All this is well and good for projects developed using the NetBeans 6.1 (M1+) IDE and later. However the projects developed prior to NetBeanse 6.1 (M1+) IDE, do not benefit from this feature. That is where the new module - Remove unused binding attributes from VisualWeb JSF Pages comes for the rescue. This module installs the action - Remove unused binding attributes in the VisualWeb JSF Pages' in the projects pop up menu. When the action is invoked it shows a confirmation dialog:

Confirm Removing Binding Attributes Dialog 

Once you confirms the action, the unused binding attributes (and the corresponding field, getter and setter in the backing page bean) are removed from all the VisualWeb JSF pages in the VisualWeb project. The output window shows the processing messages. For example:

Removing unused binding attributes for components in the VisualWeb JSF Pages in the Project '/..../NetBeansProjects/WebApplication1'...
Modeling...
Modeling...Done
Processing '.../NetBeansProjects/WebApplication15/web/Page1.jsp'
:
:
:
Removed unused binding attribute for the component 'gridPanel1'.
:
:
:
Processing '.../NetBeansProjects/WebApplication15/web/Page1.jsp' Done

Processing '.../NetBeansProjects/WebApplication15/web/Page2.jsp'
:
:
Processing '.../NetBeansProjects/WebApplication15/web/Page2.jsp' Done
Processing '.../NetBeansProjects/WebApplication15/web/Page3.jsp'
:
:
Processing '.../NetBeansProjects/WebApplication15/web/Page3.jsp' Done
Removing unused binding attributes for components in the VisualWeb JSF Pages in the Project '/.../NetBeansProjects/WebApplication1'...Done

The process may take some time depending on the number of VisualWeb JSF pages in your project.

Please make sure you have backed up your project before you invoke the action. For best results invoke the action as soon as you open the project. Aftre you have processed all you projects you can remove the module by using Tools:Plugin action.

The module is available on the NetBeans 6.1 Beta Update center:

http://updates.netbeans.org/netbeans/updates/6.1/uc/beta/beta/catalog.xml.gz

You can configure the update center in the Tools:Plugins:Setting tab. NetBeans 6.1 Beta IDE is required to use this module.

Please send us your feedback here.

After processing, your project will become lean and mean, VisualWeb machine :)


Posted by sandipchitale ( Mar 12 2008, 08:54:29 AM PDT ) Permalink Comments [5]


20080123 Wednesday January 23, 2008

Improved Callstack information in JavaScript

In this post I blogged about a simple function to get the call stack in JavaScript. Here is an improved variant of the same function:

/**
* This function returns an array of objects that contain the information about call stack.
*/
function callstack() {
function StackFrame(funcName, funcSource, flName, lnNumber) {
this.functionName = funcName;
this.functionSource = funcSource;
this.fileName = flName;
this.lineNumber = lnNumber;
}
StackFrame.prototype.toString = function() {
return 'at ' + this.functionName + '(' + this.fileName + ':' + this.lineNumber + ')' ;
};
StackFrame.prototype.toHtml = function() {
return '<table border="0">' +
'<tr valign="top"><td><b>Name: </b></td><td>' + this.functionName + '</td></tr>' +
'<tr valign="top"><td><b>File: </b></td><td>' + this.fileName + '</td></tr>' +
'<tr valign="top"><td><b>Line: </b></td><td>' + this.lineNumber + '</td></tr>' +
'<tr valign="top"><td><b>Source:</b></td><td>' +
( this.functionSource ?
'<pre>' + this.functionSource.toString().replace(/\</g, '&lt;').replace(/\>/g, '&gt;') + '</pre>' :
'unavailable') + '</td></tr>' +
'</table>'
;

};
var stackFrameStrings = new Error().stack.split('\n');
// remove first two stack frames
stackFrameStrings.splice(0,2);
var stackFrames = [];
for (var i in stackFrameStrings) {
// a stack frame string split into parts
var stackFrame = stackFrameStrings[i].split('@');
if (stackFrame && stackFrame.length == 2) {
stackFrames.push(
// Stackframe object
new StackFrame(stackFrame[0],
eval(stackFrame[0].replace(callstack.sansParenthesisRE,'')),
stackFrame[1].match(callstack.fileNameLineNumberRE)[1], // first group
stackFrame[1].match(callstack.fileNameLineNumberRE)[2] // second group
)
);
}
}
return stackFrames;
}
callstack.sansParenthesisRE = /[(][^)]*[)]/;
callstack.fileNameLineNumberRE = /(.*):(\d+)$/;

Here is how it canbe used. The callstack function code above is assumed to be stored in a file named Utilities.js .

<html>
<head>
<title>Callstack</title>
<script src='Utilities.js'></script>
<script>
function called() {
var cs = callstack();
document.write(cs[0].toHtml());
document.write(cs[1].toHtml());
document.write(cs[2].toHtml());
}
function caller() {
called();
}
</script>
</head>
<body onload="caller();">
</body>
</html>

Here is the output as displayed in the browser (FireFox):

Name: called()
File: file:///languages/javascript/Callstack.html
Line: 7
Source:
function called() {
var cs = callstack();
document.write(cs[0].toHtml());
document.write(cs[1].toHtml());
document.write(cs[2].toHtml());
}
Name: caller()
File: file:///languages/javascript/Callstack.html
Line: 13
Source:
function caller() {
called();
}
Name: onload([object Event])
File: file:///languages/javascript/Callstack.html
Line: 1
Source:
function onload(event) {
caller();
}


 


Posted by sandipchitale ( Jan 23 2008, 07:46:59 AM PST ) Permalink Comments [0]


20080101 Tuesday January 01, 2008

Firefox add-on - YouTube Viewer

Over the holidays I have been hacking Firefox, XULRunner, JavaScript and so on...it has been a lot of fun.

Here is a no-nosense YouTube Viewer add-on for Firefox that came out of that:

YouTube Viewer

If you want to try it, simply download this add-on, install it and launch it using Tools:YouTube Viewer... menu item. The operation is pretty simple, just type the search terms in the Search for: (Alt+f) text field and press Search (Alt+S)button. The list of matching videos will be populated in the listbox on the left. Select a video and type ENTER or double click on it. The video is loaded in the Video panel. The Description text box shows the video title and detailed description.

Watch this space for a tutorial on how I developed this module and which tools and add-ons I used to develop and  debug this add-on.

DISCLAIMER: This add-on is experimental. So no guarantees. Use the add-on at your own risk. 


Posted by sandipchitale ( Jan 01 2008, 04:19:18 PM PST ) Permalink Comments [10]


20071226 Wednesday December 26, 2007

Reorder module on NetBeans Plugin POrtal


I have uploded the Reorder module to the NetBeans Plugin Portal.

The assymetry in the way ,  (comma)  is used to separate the items in parameter and arguments lists always causes problem when one wants to reorder that list in Java editor.  Is that why Java allows trailing commas in array initializer? ;) may be. This module supports single click swapping of a parameter, argument or array initializer expressions with pervious or next item in the list. Each item of the sequence can be a simple literal, an identifier or a more complex function call expression. The comma delimiter is correctly handled.

For example with caret at | in:

void method(int iii, String |sss, boolean bbb){}
pressing CTRL+ALT+. (i.e. period) or invoking Source:Swap Next action yields:
void method(int iii, boolean bbb, String |sss){}
or pressing CTRL+ALT+, (i.e. comma)
or invoking Source:Swap Previous action with the original source yields:
void method(String |sss, int iii, boolean bbb){}

Sources

DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk.


Posted by sandipchitale ( Dec 26 2007, 04:54:22 AM PST ) Permalink Comments [0]


20071224 Monday December 24, 2007

Callstack information in JavaScript

I have started hacking JavaScript. It has been an interesting learning experience and quite different from Java coding. However some things remain same...here is a function to get the information about current call stack:

/**
 * This function returns an array of objects that contains information about the current call stack.
 */
function callstack() {
    var stackFrameStrings = new Error().stack.split('\n');
    stackFrameStrings.splice(0,2);
    var stackFrames = [];
    for (var i in stackFrameStrings) {
        var stackFrame = stackFrameStrings[i].split('@');
        if (stackFrame && stackFrame.length == 2) {      
            stackFrames.push(
            {
            functionName: stackFrame[0],
            functionSource: eval(stackFrame[0].replace(/[(][^)]*[)]/,'')),
            fileName: stackFrame[1].match(/(.*):(\d+)$/)[1],
            lineNumber: stackFrame[1].match(/(.*):(\d*)$/)[2]
            }
            );
        }
    }
    return stackFrames;
}

NOTE: Tested in Firefox.

It uses a mechanism very similar to Java's new Throwable().getStackTrace() to get information about the current call stack. It uses the JavaScript Error object which happens to have a property called stack.  Example usage:

function called() {
    var cs = callstack();
    alert('Self: ' + cs[0].functionName);
    alert('Caller: ' + cs[1].functionName);
}
function caller() {
    called();
}
caller();

This displays two alert dialogs:

Self: called()
Caller: caller()
Please let me know if there is a better way to get similar information. 
Posted by sandipchitale ( Dec 24 2007, 02:02:30 PM PST ) Permalink Comments [2]


20071221 Friday December 21, 2007

NetBeans 6.0 FCS compatible Code Templates Tools on NetBeans Plugin Portal

Only yesterday I discovered that the Code Template Tools module was not working with NetBeans 6.0 FCS. I have fixed the issue and uploaded the module on NetBean Plugin Portal. The older, NetBeans 5.x compatible module can be downloaded from here.

UPDATE: I have improved the Surround With... Action (Ctrl+J T) for interactive use. Now it shows a pop up dialog with a list of templates. You can select a template and type ENTER or double click to insert the template in the editor. If the editor has some selected text then the templates using the ${selection} parameter are shown at the top of the template list. You can just type the template prefix to select a matching template quickly.
 


Posted by sandipchitale ( Dec 21 2007, 10:29:17 AM PST ) Permalink Comments [0]


20071205 Wednesday December 05, 2007

ScreenMetrics tool

Here is a simple (whacky) desktop utility to measure distances on your screen:

Screen Metric

You can drag the thin vertical and horizontal lines, horizontally and vertically respectively to measure distance between them which is displayed in the toolbar like gadgets. The format is max marker location - min marker location = distance. The location and distance values are continuously updated as you drag the lines. You can use the spinner controls to increment or decrement the location of minimum or maximum markers. You can directly type the location value also.You can move the toolbar gadgets around by dragging on the left or right edge of the toolbars.

This is not a NetBeans Module. It is a Desktop utility. It was built using NetBeans of course :)

To run:

Download ScreenMetrics.jar and type:

> java -jar ScreenMetrics.jar

Hacking: 

ScreenMetrics.zip contains the NetBeans project.

TODO:

  • Show the distance value in other units e.g. inches, cms, picas?, em?
  • Show the area
  • Handle multiple monitor scenarios correctly
  • ability to show and hide
  • Precise control on moving using spinners - Done

DISCLAIMER: This module is tool. So no guarantees. Use the module at your own risk.


Posted by sandipchitale ( Dec 05 2007, 07:58:50 AM PST ) Permalink Comments [0]


20071203 Monday December 03, 2007

Add Property module functionality in trunk

With this check in the Add Property module's functionality is available in trunk. Thanks to Jan Lahoda. The functionality is available through the Add Property popup menu in the Generate Code (Alt+Insert) popup menu in Java Editor.
 


Posted by sandipchitale ( Dec 03 2007, 09:22:35 AM PST ) Permalink Comments [3]


20071130 Friday November 30, 2007

Which Tree module on NetBeans Plugin Portal

I have uploaded the WhichTree module to the NetBeans Plugin Portal.

This module shows information about the Javac Tree Path at the caret position in current Java editor in a read-only text field in the status bar. The information is updated as the caret moves. The text field can be hidden and shown using the button on it's left. The tool tip shows the full text so that it can be seen when it is wider than 40 columns.

Which Tree

 

Double clicking on the text field shows a dialog which shows the Tree Path in a tree. The source for the selected Tree is shown in a text area. This is a good tool to understand how the Javac sees the Java source. The IDs shown in the tree are the TreeKind enumeration values.

 

Tree Path details

 

This is along the lines of WhichElement module I blogged about a few months ago. 

 

Sources (on branch release60)

DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk.


Posted by sandipchitale ( Nov 30 2007, 06:24:08 AM PST ) Permalink Comments [0]


20071124 Saturday November 24, 2007

Landscape III

Landscape III


Posted by sandipchitale ( Nov 24 2007, 09:03:51 PM PST ) Permalink Comments [0]


20071123 Friday November 23, 2007

Tip: api to show Java type chooser dialog in NetBeans 6.0

While implementing the Add Property module, Jan Lahoda pointed out an api available in NetBeans 6.0 Java support which can show a Java Type chooser dialog. Here is the snippet of code to show the dialog:

        FileObject fileObject = ...; // Some java file's file object in a NetBeans Project.

ElementHandle<TypeElement> type = TypeElementFinder.find(ClasspathInfo.create(fileObject), null);

if (type != null) {
// use the type somehow

which shows the dialog:

Find Type dialog

You can use this api in your module any time you want to select a Java type. You will have to add the following dependencies to your module:

  • Java Source
  • Java Source UI
  • Java Support APIs
  • Javac API Wrapper

The TypeElementFinder api is implemented in Java Source UI module. You can further customize the dialog by passing the second argument to the find() method.

For some reason this does not appear in the NetBeans 6.0 API docs - probably because this is not an official API yet.


Posted by sandipchitale ( Nov 23 2007, 09:36:49 PM PST ) Permalink Comments [0]


20071121 Wednesday November 21, 2007

JPDA (Java) Debugger Threads View Enhancements module on NetBeans Plugin Portal

I have uploaded the JPDA (Java) Debugger Threads View Enhancements module module to the NetBeans Plugin Portal.

Enhanced Threads View

 
This module unifies Threads and Call stack view (somewhat like Eclipse Java Debugger Threads View). The call stack frames are shown as the children of suspended thread in the Threads view. It supports same actions on as Call Stack view and more. For example, it shows actions to jump to types of local variable of a Call stackframe as well as the Show Classes action. It also shows full method signature of the Call stack frame. It additionally shows the actual class of the 'this' variable if it differs from the class that declares the method of the call stack frames.

The Show Classes action shows all the classes loaded in the JVM along with the loading and initiating ClassLoaders. This is useful for debugging class loading in multi-ClassLoder appications such as NetBeans itself.

Classes view

Sources

DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk.


Posted by sandipchitale ( Nov 21 2007, 02:58:56 PM PST ) Permalink Comments [2]


20071117 Saturday November 17, 2007

Landscape

landscape

Posted by sandipchitale ( Nov 17 2007, 09:31:29 PM PST ) Permalink Comments [0]


20071115 Thursday November 15, 2007

Highlight Boxing Unboxing Varargs module on NetBeans Plugin Portal

I have uploaded the Highlight Boxing Unboxing Varargs module to the NetBeans Plugin Portal. It enables highlighting of occurences of boxing, unboxing and varargs in the Java editor. Obviously this only works for files belonging to projects with source level set to 1.5+.

UPDATE: The download link on the Plugin Portal has now been fixed.

The Java compiler silently applies the boxing and unboxing to the primitive types and the corresponding reference types as needed. This module reveals where that may be happening in your code. This module may help you diagnose mysterious NPEs when a reference type null value is attempted to be unboxed at runtime (well the example in the screen shot is not the best ;) ). To turn the highlighting on or off use the toggle buttons on the toolbar. Here is a screen shot:

NetBeans Java Editor showing highlighted boxing, unboxing and varargs occurences

Jan Lahoda contributed to this module.

Sources

DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk.


Posted by sandipchitale ( Nov 15 2007, 03:19:46 PM PST ) Permalink Comments [0]










« December 2009
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
  
       
Today

Get NetBeans 5.5

Locations of visitors to this page

Today's Page Hits: 154


XML
All
/Creator
/General
/Hobby
/Java
/JavaScript
/Mozilla
/NetBeans
/Ubuntu
/VisualWeb
/VisualWebPack
/Web 2.0

XML
All
/Creator
/General
/Hobby
/Java
/JavaScript
/Mozilla
/NetBeans
/Ubuntu
/VisualWeb
/VisualWebPack
/Web 2.0

scblog
scblog