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.
20070130 Tuesday January 30, 2007

A simple System FileSystem Browser with a twist

I have uploaded the System FileSystem and META-INF Services Browser module for Netbeans 5.5 and 6.0 to my NetBeans update center described here.

This modules displays the System FileSystem (resulting from combining all the layer files of installed modules) in a window. To show the System FileSystem and META-INF Services Browser select Window:System FileSystem META-INF Services Browser menu item.

There are other System FileSystem Browser modules but this one has a twist. The special features of this System FileSystem and META-INF Services Browser are:

  • the popup menu on the nodes shows the actions that show the documentation related to the node or it's parent node in the web browser. The documentation may be API, Architecture Descriptions, FAQ, File format documents etc. Try right clicking on the Editor node after showing the System FileSystem Browser. Other nodes that are currently supported are Actions, Menu Bar, Editors, Loaders, Services, Modules, Window2Local. I plan to add more. The actions shown in the popup menu are configured using the FolderLookup mechanism under the special folder called org.netbeans.modules.sfsbrowser in the System FileSystem. The actions can be NetBean platform independent or configured based on the platform cluster folder name in the netbeans.home directory. That way the actions can be made sensitive to the NetBeans platform you are running.
  • the attributes of the file or the folder are shown
  • the registered META-INF/services are shown 

SFS Browser

Fig. SFS Browser and META-INF Services Window

Editor API Description shown in Browser

Fig 2.  Web Browser showing the Editor API Details

 

Over time, I plan to update the module to include links to the documentation of most of the well known folders/files/attributes nodes in the layer file. I can imagine in future that other module writers can add documentation for their extensions by adding the required entries under the org.netbeans.modules.sfsbrowser to their module's layer file.

TODO: Make System FileSystem browser dynamic i.e. respond to changes in System FileSystem.

I will make the sources available soon.

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


Posted by sandipchitale ( Jan 30 2007, 11:02:48 PM PST ) Permalink Comments [4]


20070128 Sunday January 28, 2007

UPDATED: LineTools module - Added select from, after, upto and to specified char actions

I have updated the Line Tools Module on my NetBeans update center described here.

What is new

Char Actions

Action Key bindingScreenshot
From Char Ctrl+Alt+, On MacOS Ctrl+Option+,Select from
After Char Ctrl+Alt+Shift+, On MacOS Ctrl+Option+Shift+,Select after
Upto Char Ctrl+Alt+Shift+. On MacOS Ctrl+Option+.Select upto
To Char Ctrl+Alt+. On MacOS Ctrl+Option+Shift+.

The char actions help you in selecting text from, after, upto or to the specified char (in a text field in the sidebar at the bottom of the editor) on the current line from the current caret position. You can use the char actions to either delete text (DELETE key), or modifying the text - uppercase (Alt+u u) or lowercase (Alt+u l) following the char action. These actions work somewhat like the t, T, f and F commands of Vi. You can type a numeric prefix nn, to find the nnth occurence of the char. If you are trying to operate on a digit you have to type ENTER key.

With the following text on the current line and caret at |

abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ|
invoking From Char Ctrl+Alt+, On MacOS Ctrl+Option+,, specifying c and Match Case selected results in:
abcdefghijklmnopqrstuvwxyzAB|CDEFGHIJKLMNOPQRSTUVWXYZ
invoking From Char Ctrl+Alt+, On MacOS Ctrl+Option+,, specifying c and Match Case unselected results in:
ab|cdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
invoking After Char Ctrl+Alt+Shift+, On MacOS Ctrl+Option+Shift+,, specifying c and Match Case selected results in:
abcdefghijklmnopqrstuvwxyzABC|DEFGHIJKLMNOPQRSTUVWXYZ
invoking After Char Ctrl+Alt+Shift+, On MacOS Ctrl+Option+Shift+,, specifying c and Match Case unselected results in:
abc|defghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ

With the following text on the current line and caret at |

|ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
invoking Upto Char Ctrl+Alt+Shift+. On MacOS Ctrl+Option+., specifying v and Match Case selected results in:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstu|vwxyz
invoking Upto Char Ctrl+Alt+Shift+. On MacOS Ctrl+Option+., specifying v and Match Case unselected results in:
ABCDEFGHIJKLMNOPQRSTU|VWXYZabcdefghijklmnopqrstuvwxyz
invoking To Char Ctrl+Alt+. On MacOS Ctrl+Option+Shift+., specifying v and Match Case selected results in:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv|wxyz
invoking To Char Ctrl+Alt+. On MacOS Ctrl+Option+Shift+., specifying v and Match Case unselected results in:
ABCDEFGHIJKLMNOPQRSTUV|WXYZabcdefghijklmnopqrstuvwxyz

Sources

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


Posted by sandipchitale ( Jan 28 2007, 08:18:58 PM PST ) Permalink Comments [7]


20070123 Tuesday January 23, 2007

Fix CVSROOT module uploaded

Two weeks ago, I talked about a simple program to recursively fix the value CVSROOT in CVS/Root files (see the blog entry for the details on the motivation behind such functionality). I have wrapped that functionality in a simple module Fix CVSROOT.

I have uploaded the Fix CVSROOT module to my Netbeans update center described here.

This module installs the following action in Tools menu.

Action

Description

Fix CVSROOT Recursively fix the CVSROOT in CVS/Root files in the specified directory. The directory of the selected node in the IDE is used at the default top level directory.

Fix CVSROOT Project 

(In case anyone wants to hack this project, it needs to be unzipped in contrib/ directory of NetBeans CVS workspace.)

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


Posted by sandipchitale ( Jan 23 2007, 07:04:36 PM PST ) Permalink Comments [9]


20070114 Sunday January 14, 2007

Sculpture - Silver

Silver


Posted by sandipchitale ( Jan 14 2007, 04:38:39 PM PST ) Permalink Comments [0]


20070113 Saturday January 13, 2007

UPDATED: LineTools module - Added cycle slash (/), backslash(\), dot(.), dash(-) action

I have updated the Line Tools Module on my NetBeans update center described here.

What is new

Added the Cycle Slash (/), Backslash(\), Dot(.), Dash(-) action (CTRL+ALT+O). The action replaces all occurences of / , \ , . & - ,in the selection or current line if the selection is not present, in succesion. If more than one char from the set is present in the text the other chars are replaced with the first one in the first cycle. An example may clarify the functionality.

If one starts with text:

package org.netbeans.modules.linetools.actions; // the package statement

and invokes the Cycle Slash Backslash Dot Dash repeatedly one gets:

    
    
package org.netbeans.modules.linetools.actions; // the package statement
package org-netbeans-modules-linetools-actions; // the package statement
package org/netbeans/modules/linetools/actions; // the package statement
package org\netbeans\modules\linetools\actions; // the package statement

Pretty useless huh?

Sources

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


Posted by sandipchitale ( Jan 13 2007, 12:41:57 PM PST ) Permalink Comments [3]


20070111 Thursday January 11, 2007

A simple program to toggle CVSROOT of existing checked out workspace

One may check out a cvs workspace using a CVSROOT e.g. :pserver:username@extranet.foo.com:/cvs. This value of CVSROOT is recorded in the CVS/Root file in the checkedout directories. At some later time, depending on the network connectivity, it may be faster to use an alternate (aliased) CVSROOT e.g. :pserver:username@intranet.foo.com:/cvs. The following simple program provides the functionality to fix the CVSROOT settings in the CVS/Root file. It skips the entries specified in the .cvsignore file.

CAUTION: Care must be taken to make sure that both cvs servers are really the same servers or mirros that are in sync.

Usage:

java fixcvsroot.Main NEWCVSROOT
DISCLAIMER: This is experimentalcode. So no guarantees. Use the code at your own risk.
package fixcvsroot;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Set;
/**
 * A simple program to fix the CVSROOT. 
 * <p>
 * One may check out a cvs workspace using a CVSROOT e.g.
 * <code>:pserver:username@extranet.foo.com:/cvs</code>. This value of CVSROOT
 * is recorded in the <code>CVS/Root</code> file in the checkedout directories.
 * At some later time, depending on the network connectivity, it may be faster
 * to use an alternate (aliased) CVSROOT e.g.
 * <code>:pserver:username@intranet.foo.com:/cvs</code>.
 *
 * This simple program provides the functionality to fix the CVSROOT settings
 * in the <code>CVS/Root</code> file. It skips the entries specified in the
 * <code>.cvsignore</code> file.
 *
 * <b>CAUTION:</b> Care must be taken to make sure that both cvs servers are
 * really the same servers or mirros that are in sync.
 *
 * Usage:
 * <code>java fixcvsroot.Main NEWCVSROOT</code>
 *
 * <b>DISCLAIMER:</b> This is an experimental program. Use at your own risk.
 *
 * @author Sandip V. Chitale (Sandip.Chitale@Sun.Com)
 */
public class Main {
    private Main() {
    }
    public static void main(String[] args) {
        if (args.length != 1) {
            System.err.println("Usage: java fixcvsroot.Main NEWCVSROOT");
            System.exit(1);
        }
        fixcvsroot(args[0]);
        System.exit(0);
    }
    private static void fixcvsroot(String cvsroot) {
        try {
            fixcvsroot(new File(".").getAbsoluteFile(), cvsroot);
        } catch (IOException ex) {
            System.err.println(ex.getMessage());
            return;
        }
        System.out.println();
        System.out.println("Done.");
    }
    private static void fixcvsroot(File directory, String cvsroot)
            throws IOException {
        if (directory.isDirectory()) {
            if ("CVS".equals(directory.getName()) &&
                    new File(directory, "Entries").exists() &&
                    new File(directory, "Repository").exists()) {
                try {
                    if (Boolean.getBoolean("fixcvsroot.Main.log")) {
                        System.out.println("Writing '" + cvsroot + "' to "
                                + directory.getAbsolutePath()
                                + directory.separator + "Root");
                    } else {
                        System.out.print(".");
                    }
                    PrintWriter out = new PrintWriter(
                            new BufferedWriter(new FileWriter(
                                new File(directory, "Root"))));
                    out.println(cvsroot);
                    out.close();
                } catch (IOException ex) {
                    throw new IOException("Error: " + ex.getMessage()
                            + ": Writing '" + cvsroot
                            + "' to " + directory.getAbsolutePath()
                            + directory.separator + "Root");
                }
            } else {
                // Load .cvsignore
                Set<File> ignored = null;               
                File cvsIgnore = new File(directory, ".cvsignore");
                if (cvsIgnore.exists() && cvsIgnore.isFile()) {
                    ignored = new HashSet<File>();
                    BufferedReader bufferedReader = new BufferedReader(
                            new FileReader(cvsIgnore));
                    String ignoredEntry = null;
                    while ((ignoredEntry = bufferedReader.readLine()) != null) {
                        ignored.add(new File(directory, ignoredEntry));
                    }
                }
                File[] files = directory.listFiles();
                for (File subFile:files) {
                    if (subFile.isDirectory()) {
                        // skip ignored sub directories
                        if (ignored!= null &&
                                ignored.size() > 0 &&
                                ignored.contains(subFile)) {
                            continue;
                        }
                        fixcvsroot(subFile, cvsroot);
                    }
                }
            }
        }
    }
}

Does anyone know other better technics/scripts to solve this problem?


Posted by sandipchitale ( Jan 11 2007, 11:03:09 PM PST ) Permalink Comments [5]


20070110 Wednesday January 10, 2007

Tag, You're it! Meme

It seems the Tag, You're it! Meme is spreading around the blogosphere. I was recently tagged by David Boterill and Charles Ditzel. So here are the five things you may not know about me:

  • Hobbies
    • Painting - Mostly Landscapes and Still life in Water Color, Pastles, Acrylic, Charcole and Oil. When not in the mood I do Abstracts. I paint with my left brain. My paintings were (not any more) on display at my friend John Cribb's  Quintessential  Art Gallery.
    • Collage
    • Sculptures - wood, clay, paper
    • Robotics - I recently bought a Lego Mindstorm set for my son's but I play with it more
    • Origami - the art of paper folding
  • Favorite subjects
    • Physics
    • Mathematics
    • Molecular Biology
    • Genetics
    • Philosophy
  • Favorite Personalities
    • Carl Sagan
    • Richard Dawkins - in fact Richard Dawkins is the one who invented the term Meme.
  • Favorite Movies
  • Favorite Music
    • Classic Rock - Pink Floyd is my favorite band
    • Indian Classical
      • Instrumental
      • Vocal
  • Favorite Book
    • The Fountainhead by Ayn Rand

So there...now I need to find five more people to tag! The Meme is spreading!


Posted by sandipchitale ( Jan 10 2007, 01:52:16 PM PST ) Permalink Comments [0]


20070109 Tuesday January 09, 2007

Declaration and Javadoc module for NetBeans 6.0

I have uploaded the Declaration and Javadoc module for Netbeans 6.0 to my NetBeans update center described here.

This module displays the declration and javadoc of the element under caret in Java editor, in the Declaration and Javadoc windows respectively. Use Window:Declartion and Window:Javadoc menuitems to show the Declaration and Javadoc windows respectively.

Declaration and Javadoc module for Netbeans 6.0 

How does it work?

In some sense it works similar to the WhichElement module. The Declaration and Javadoc module registers a caret aware task:

DeclarationAndJavadocTask implements CancellableTask<CompilationInfo>

using the

DeclarationAndJavadocJavaSourceTaskFactory extends CaretAwareJavaSourceTaskFactory - a factory for creating a task which is run every time the caret position in the Java editor changes. This factory is registered using the: META-INF/services/org.netbeans.api.java.source.JavaSourceTaskFactory file.

In the task it finds the Element at the caret position. Then it gets the Tree using the:

compilationInfo.getTrees().getTree(element);

The compilationInfo object was passed into the task's run(CompilationInfo compilationInfo)method. The above call may return a null Tree . This is the only tricky part. Why does this happen? Well...this happens when the Element at the caret position is not declared in the current file e.g. println() method in the above screenshot. To get the Tree for such Element, it has to be obtained in the context of file that contains the declaration of the Element. The following API is used to get the file where the Element is declared:

FileObject fileObject = SourceUtils.getFile(element, compilationInfo.getClasspathInfo());

Another Javac task fo that file is executed to obtain the Tree for the Element's declaration. It must be noted that one needs to use the ElementHandle for the original Element and resolve it to Element in the new Javac task's context. See Java Developer Guide for more details on this. 

Once the Tree for the Element is obtained it is matter of calling the toString() on it to get the declaration.

The Javadoc is obtained from the Element using the following call:

compilationInfo.getElementUtilities().javaDocFor(element);

The declaration and the javadoc are displayed in the Declaration and Javadoc windows respectively. This is done on the AWT thread using SwingUtilities.invokeLater(). One small trick is to set the content type of the read-only JEditorPanes that display declaration and javadoc to text/x-java and text/html respectively. This enables the syntax coloring of Java code and html formatting of javadoc.  

Sources

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


Posted by sandipchitale ( Jan 09 2007, 11:51:41 PM PST ) Permalink Comments [2]


20070101 Monday January 01, 2007

Beginnings of new Java Navigation module for NetBeans 6.0

Happy 2007 to all!

I have checked in the initial version of Java Navigation module for Netbeans 6.0. It is NB6.0 analog of my Java File Structure module for NB5.5. The difference is that in the new module there are separate actions to show structure of current file vs the structure of type under the caret in the editor. Also it shows the generics in a better way. I also plan to merge the Java Type Hierarchy module's functionality into this module also.

Java Navigation

You can browse the sources here:

http://www.netbeans.org/source/browse/contrib/JavaNavigation/

For now you will have to build the module yourself. May be you can use that as an opportunity to get and build NB6.0. I will post the NBM sometime in near future.

I am exploring the possibility of incorporating this (in some form) in NB6.0.

I am looking forward to all the cool things to become available in NB6.0.


Posted by sandipchitale ( Jan 01 2007, 02:34:40 AM PST ) Permalink Comments [2]










« January 2007 »
SunMonTueWedThuFriSat
 
2
3
4
5
6
7
8
12
15
16
17
18
19
20
21
22
24
25
26
27
29
31
   
       
Today

Get NetBeans 5.5

Locations of visitors to this page

Today's Page Hits: 93


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