Geertjan's Blog

  • February 2, 2010

MyDoggy... Integrated into the NetBeans Platform!!!

Geertjan Wielenga
Product Manager
MyDoggy is a really cool Java docking framework... and not only because of its name! Based on the recent blog entry about creating your own window system... I integrated MyDoggy into my own window system implementation... so that your application can look something like this:

Yes, you see two TopComponents, synchronized explorer views, Nodes... and a completely different appearance to what you'd expect from a NetBeans Platform application (yes, it can really look like the above!), simply because I am using the MyDoggy API, within my WindowManager implementation:

protected void initToolWindowManager() {// Create a new instance of MyDoggyToolWindowManager passing  the frame:
MyDoggyToolWindowManager myDoggyToolWindowManager = new MyDoggyToolWindowManager();// Register the TopComponent providing the bean tree view:
myDoggyToolWindowManager.registerToolWindow("BeanTreeView", // Id
"Bean Tree View", // Title
null, // Icon
new View1TopComponent(), //Component
ToolWindowAnchor.LEFT); // Anchor// Register the TopComponent providing the icon view:
myDoggyToolWindowManager.registerToolWindow("IconView", // Id
"Icon View", // Title
null, // Icon
new View2TopComponent(), //Component
ToolWindowAnchor.TOP); // Anchor// Make all the windows available:
for (ToolWindow window : myDoggyToolWindowManager.getToolWindows()) {
}// Add myDoggyToolWindowManager to the main window (a JFrame).// MyDoggyToolWindowManager is an extension of a JPanel:
mw.add(myDoggyToolWindowManager, TableLayout.CENTER);

Only the following three MyDoggy import statements are needed:

import org.noos.xing.mydoggy.ToolWindow;
import org.noos.xing.mydoggy.ToolWindowAnchor;
import org.noos.xing.mydoggy.plaf.MyDoggyToolWindowManager;


import info.clearthought.layout.TableLayout;

And, then, in the constructor of the WindowManager implementation, right before setting the main window visible, I call the above method. Yes, so the layer.xml registrations are not used at all: in this case we're registering TopComponents within the WindowManager implementation, not ideal, but it's a starting point for further exploration. Wouldn't take much work to read the registrations from the layer.xml file, so that there'd be no hardcoded views within the WindowManager implementation. In other words, all the values for "MyDoggyToolWindowManager.registerToolWindow" would come from the layer.xml file... meaning that TopComponents could be added from external plugins registering their TopComponents in the layer.xml file of the module providing them! And maybe this way it's sufficient already, if you have control over your WindowSystem implementation, i.e., you're creating your own implementation anyway and you're not expecting external contributions via plugins, so then it doesn't matter that your window system isn't extendable and that you're registering your TopComponents right inside of the WindowManager implementation.

Here's another screenshot, this time showing the NetBeans Platform Paint application (one of the demo applications distributed with NetBeans IDE), using the MyDoggy docking framework instead of the default window system provided by the NetBeans Platform:

Modular MyDoggy-based applications... hmmm... sweet. And let the integration of other window systems begin!

Be the first to comment

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