Readonly Editors Mode Module
I just uploaded the Readonly Editors Mode module to the NetBeans Plugin Portal.
This
module controls the editable property of the text editors. The initial
state of the editable property of text editor is controlled by the Tools:Options:Miscellaneous:Read Only Editors Mode:Open editors in read-only mode
option. The user can toggle the read-only mode using the editor toolbar
action (button with open/closed lock icon). The default key binding for
the toggle action is CTRL+R.
Screenshots:
Options:

Toggle Readonly mode button on editor toolbar:

The sources can be found in main/contrib repository.
DISCLAIMER: This module is experimental. So no guarantees. Use the module at your own risk.
Posted by sandipchitale
( May 30 2008, 03:47:36 PM PDT ) Permalink
Trunk NetBeans cluster dependency graph generated using dot
Here is a cluster dependency graph for the NetBeans trunk (post-6.1 aka 6.5) build. The graph was generated using the dot program from graphviz package on my Ubuntu laptop.

To produce the necessary input file for the dot program I hacked the following method:
private void generateGroupDependencies (File output, boolean implementationOnly) throws BuildException, IOException {
PrintWriter w = new PrintWriter (new FileWriter (output));
Map<Dependency,Set<ModuleInfo>> referrers = new HashMap<Dependency,Set<ModuleInfo>>();
TreeMap<String, Set<Dependency>> groups = new TreeMap<String, Set<Dependency>>();
for (ModuleInfo m : modules) {
if (regexp != null && !regexp.matcher(m.group).matches()) {
continue;
}
Set<Dependency> l = groups.get(m.group);
if (l == null) {
l = new TreeSet<Dependency>();
groups.put(m.group, l);
}
l.addAll(m.depends);
for (Dependency d : m.depends) {
Set<ModuleInfo> r = referrers.get(d);
if (r == null) {
r = new HashSet<ModuleInfo>();
referrers.put(d, r);
}
r.add(m);
}
}
w.println("digraph G {");
w.println(" ratio=auto;");
w.println(" concentrate=true;");
w.println(" node[shape=box,tailport=s];");
for (Map.Entry<String,Set<Dependency>> e : groups.entrySet()) {
String groupName = e.getKey();
Set<Dependency> depends = e.getValue();
Set<String> seenGroup = new HashSet<String>();
boolean first = true;
for (Dependency d : depends) {
String print = " REQUIRES ";
if (d.exact && d.compare != null) {
// ok, impl deps
} else {
if (implementationOnly) {
continue;
}
}
// special dependencies are ignored
if (d.isSpecial ()) {
continue;
}
// dependencies within one group are not important
Set<ModuleInfo> r = referrers.get(d);
ModuleInfo ref = findModuleInfo(d, r.size() == 1 ? r.iterator().next() : null);
if (groupName.equals (ref.group)) {
continue;
}
// Have we seen this group already - group == cluster
if(seenGroup.contains(ref.group)) {
// skip
continue;
}
seenGroup.add(ref.group);
w.print (" ");
w.print (groupName);
w.print (" -> ");
w.print (ref.group);
w.print (";");
w.println ();
}
}
w.println("}");
w.close ();
}
in nbbuild/antsrc/org/netbeans/nbbuild/ModuleDependencies.java file. Then I built and ran the ant task like this:
> cd nbbuild
> ant bootstrap generate-golden-files
to generate the dependency files in nbbuild/build/generated. This produced the following contents:
digraph G {
ratio=auto;
concentrate=true;
node[shape=box,tailport=s];
apisupport -> ide;
apisupport -> java;
apisupport -> platform;
apisupport -> harness;
cnd -> platform;
cnd -> ide;
gsf -> platform;
gsf -> ide;
harness -> platform;
ide -> platform;
identity -> java;
identity -> platform;
identity -> j2ee;
identity -> ide;
j2ee -> java;
j2ee -> ide;
j2ee -> platform;
j2ee -> gsf;
java -> platform;
java -> ide;
mobility -> java;
mobility -> platform;
mobility -> ide;
mobility -> j2ee;
nb -> platform;
nb -> ide;
profiler -> java;
profiler -> platform;
profiler -> ide;
profiler -> j2ee;
ruby -> platform;
ruby -> ide;
ruby -> gsf;
soa -> java;
soa -> ide;
soa -> platform;
soa -> j2ee;
soa -> xml;
uml -> platform;
uml -> java;
uml -> ide;
visualweb -> java;
visualweb -> platform;
visualweb -> j2ee;
visualweb -> ide;
visualweb -> nb;
xml -> platform;
xml -> ide;
}
in nbbuild/build/generated/cluster-deps.txt and then I ran the following command on the file:
> cd build/generated
> dot -Tpng cluster-deps.txt -o cluster-deps.png
and we have the graph in cluster-deps.png file.
Similar technique could be applied to generate dependency graphs for modules dependencies etc. I will look into making it part of the build which could be invoked on demand to produce the dependency graphs.
Posted by sandipchitale
( May 23 2008, 06:12:33 PM PDT ) Permalink
DOM Inspector in Firefox Sidebar
In this entry I talked about how to show Google Talk in Firefox Sidebar. Using the same technique you can show the DOM Inspector in the Firefox Sidebar. That way you can get the DOM Inspector in the same window as the page you are inspecting.
UPDATE: You can simply install this add-on in the Firefox browser. It will add a new menu item Tools:DOM Inspector in sidebar .
Selecting this menu item will show the DOM Inspector in the Firefox sidebar. It also makes the sidebar resizable.
Here is the NetBeans 6.1 project to build the extension.
Here is how. Just create a bookmark like this:

and then invoke the bookmark. Then use the File:Inspect Window > menu item to select the window you are browsing in. You will see something like this

Unfortunately the Sidebar is not resizable. However this could be tweaked using the property overlay incantation overrding the flex attribute of the sidebar box. Also the popup dialogs to search for nodes does not work. Once again some XUL overlay gimmickry could come handy here.
Useful? You decide.
Posted by sandipchitale
( May 16 2008, 08:45:44 PM PDT ) Permalink
E4X assignment gotcha
Obscure TIP Warning
E4X allows direct embedding of XML literals inside JavaScript which make it very easy to work with XML inside JavaScript. Recently while working on a Firefox extension I got bit by some unexpected behavior of an XML variable assignment operator (=). Basically it clones the XML document fragment on the right hand side of assignment operator. The following program demonstrates the behavior.
<html>
<head>
<title>E4X</title>
<script>
function e4x() {
var languages = <languages></languages>;
alert("initial value of variable 'languages'=:\n" + languages.toXMLString());
var javascript = <scripting>JavaScript</scripting>
alert("initial value of variable 'javascript':\n" + javascript.toXMLString());
languages.scripting = javascript;
alert("after adding 'javascript' variable as a child node - value of variable 'languages':\n" + languages.toXMLString());
javascript.version = <version>1.2</version>
alert("after adding version node - value of variable 'javascript':\n" + javascript.toXMLString());
alert("after adding version node to variable 'javascript' - value of variable 'languages':\n" +
languages.toXMLString() +
"\nvalue of variable 'languages' does not reflect the changes made to the value of variable 'javascript'.");
}
</script>
</head>
<body onload="e4x();">
</body>
</html>
You can try this program (if you are using Firefox) by clicking here.
Posted by sandipchitale
( May 11 2008, 07:25:00 PM PDT ) Permalink
NetBeans 6.1 and trunk compatible Code Template Tools NBMs
NetBeans 6.1 is out!
I have updated the Code Template Tools module to work with NetBeans 6.1 FCS and trunk. Here are the NBMs"
NetBeans 6.1 FCS compatible Code Templates Tools NBM
post 6.1 main compatible Code Templates Tools NBM
I need to figure out how to publish multiple NBMs on Plugin Portal. In the mean time you will have to use these.
Posted by sandipchitale
( May 08 2008, 01:31:29 PM PDT ) Permalink