Quantcast
Channel: Oracle Bloggers
Viewing all articles
Browse latest Browse all 19780

Extending the NetBeans Favorites Window

$
0
0

URLs registered in the Favorites folder are rendered in the Favorites window. Rendering is done by the FavoritesNode, which is an internal class in the Favorites module, for each URL registered in the Favorites folder.

For example, here I've created a URL:

package org.my.fav;

import java.io.File;
import java.net.MalformedURLException;
import java.net.URL;
import org.openide.filesystems.FileUtil;
import org.openide.util.Utilities;

public class ConfigRootNode {

     public static URL getNetBeansUser() throws MalformedURLException {
        String s = System.getProperty("netbeans.user"); // NOI18N
        File userDir = new File(s);
        userDir = FileUtil.normalizeFile(userDir);
        return Utilities.toURI(userDir).toURL();
    }
}

And here the URL above is registered:

<folder name="Favorites"><file name="UserDir.shadow"><attr name="originalFile"
                 methodvalue="org.my.fav.ConfigRootNode.getNetBeansUser"/><attr name="position" intvalue="200"/></file></folder>

Therefore, note that the only thing you can pass into the Favorites folder is a URL, nothing else, i.e., you have no control over the rendered Node, e.g., over its children. If that's what you want, either create a Node and register it in the Services window as shown here (assuming you're extending NetBeans IDE, since that's where that window comes from, not the NetBeans Platform) or simply create your own TopComponent and render your Nodes there.


Viewing all articles
Browse latest Browse all 19780

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>