X

Geertjan's Blog

  • February 18, 2008

Utility Method for Retrieving Current Hints

Geertjan Wielenga
Product Manager
I believe it would be really cool if we had a Hints wizard, which would generate the basic stubs for new hints for NetBeans IDE. Imagine if we had that—wouldn't that increase the chance (a lot) of NetBeans IDE getting hint contributions from the broader community? And getting more hints is one significant step to NetBeans IDE's editor (especially its Java editor) becoming an even more valuable tool to its users.

One part of such a wizard would let the hint developer register the hint in the layer file via the wizard, i.e., without actually needing to touch the layer file itself. So, here's a utility method for retrieving the currently registered hints, which would probably end up in some kind of list in the wizard. For testing purposes, I've put the code into a CallableSystemAction.performAction, which results in this:

Here's the code itself:

public void performAction() {
try {//Prepare Output window:
OutputWriter writer;
InputOutput io = IOProvider.getDefault().getIO("Hint Folders", false);
writer = io.getOut();
writer.reset();
io.select();//Get Hints folder:
FileObject hintObject = Repository.getDefault().getDefaultFileSystem().getRoot().
getFileObject("org-netbeans-modules-java-hints/rules/hints");
DataFolder hintFolder = DataFolder.findFolder(hintObject);//Work with children of Hints folder:
DataObject[] hintFolderKids = hintFolder.getChildren();
for (int i = 0; i < hintFolderKids.length; i++) {
DataFolder oneHintFolderKid = (DataFolder) hintFolderKids[i];//Work with grandchildren of Hints folder:
DataObject[] oneHintFolderGrandKids = oneHintFolderKid.getChildren();
StringBuilder builder = new StringBuilder();
for (int j = 0; j < oneHintFolderGrandKids.length; j++) {
DataObject oneHintFilderGrandKid = oneHintFolderGrandKids[j];
builder.append("-- " + oneHintFilderGrandKid.getNodeDelegate().getDisplayName() + "\\n");
}//Create message, consisting of one child, plus all related grandchildren:
String msg = "\\n" + oneHintFolderKid.getNodeDelegate().getDisplayName() + "\\n" + builder;//Write to Output window:
writer.println(msg);
}
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}

Anyone want to work with me on a hint wizard? Let me know—it would be of great benefit to many people.

Join the discussion

Comments ( 4 )
  • raveman Monday, February 18, 2008

    im not netbeans user, but cool idea


  • Thomas Zillinger Tuesday, February 19, 2008

    I also think this is a GREAT idea!


  • Geertjan Tuesday, February 19, 2008

    Thanks for the support, raveman and Thomas! Watch this blog for developments....


  • Jan Lahoda Wednesday, February 20, 2008

    I have actually once started to work on such a wizard - I did not have time to really finish it though....


Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.