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










« December 2007 »
SunMonTueWedThuFriSat
      
1
2
4
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
22
23
25
27
28
29
30
31
     
Today

Get NetBeans 5.5

Locations of visitors to this page

Today's Page Hits: 375


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