Archiv für August 2009

More Substance for NetBeans

Mittwoch, 26. August 2009

NetBeans Dream Tem Member Aljosha Ritner has published a new article about his Substance NetBeans plugin (in german):

Mehr Substanz für NetBeans || IT-Republik – JAXenter – Artikel.

Thanks for mentioning the NBTabbedPane project!

OSGi-RestConsole

Montag, 24. August 2009

I recently asked on this blog if anyone knows of a generic REST based OSGi console, because I want a simple solution for remote access to and administration of OSGi frameworks that I can include in VisualOSGi.

It was really odd that I didn’t find anything like that. It’s so obvious that this would be extremely useful. Especially for creating tools for administration. It was especially strange to see plenty of nice web based, HTML-rendering solutions.

So I was happy when OSGi and JavaEE Consultant Filippo Diotalevi told me that he was about to create one and today I received a link from him to Home – OSGi-RestConsole – GitHub. It looks exactly like what I want, and I hope I’ll find some time to try it out later toda. Thanks a lot, Filippo! I’m sure that a lot of people have been waiting for a tool like that.

Simplest possible Drag&Drop implementation for Visual Library

Sonntag, 23. August 2009

Two days ago I blogged about how to create a new ExplorerView by Combining ListView and ChoiceView. Today I’ll show you how to use this view as a palette for a Visual Library scene. It’s very simple, AbstractNodes already implement everything needed for this. In the NestedListView -as in any ListView- dragging is enabled with this line:

listView.setAllowedDragActions(DnDConstants.ACTION_COPY);

Now we need to create a scene and display it in a TopComponent. For adding the scene to the TopComponent check the NetBeans Visual Library Tutorial.

This is a minimal implementation for accepting Nodes:

public class ObjectSceneImpl extends ObjectScene {

    public ObjectSceneImpl() {
        getActions().addAction(ActionFactory.createAcceptAction(new AcceptProvider() {

            @Override
            public ConnectorState isAcceptable(Widget widget, Point point, Transferable transferable) {
                return ConnectorState.ACCEPT;
            }

            @Override
            public void accept(Widget widget, Point point, Transferable transferable) {
                Node node = NodeTransfer.node(transferable, NodeTransfer.DND_COPY);
                Widget w = new LabelWidget(ObjectSceneImpl.this, node.getDisplayName());
                ObjectSceneImpl.this.addChild(w);
                w.setPreferredLocation(widget.convertLocalToScene(point));
            }
        }));
    }
}

If you run this code, you can drag & drop nodes from everywhere onto your TopComponent. If you only want to accept a certain kind of nodes, the easiest way is to create your own node class and check for it:

            public ConnectorState isAcceptable(Widget widget, Point point, Transferable transferable) {
                Node node = NodeTransfer.node(transferable, NodeTransfer.DND_COPY);
                if (node == null | !(node instanceof OSGiRepositoryBundleNode)) {
                    return ConnectorState.REJECT_AND_STOP;
                }
                return ConnectorState.ACCEPT;
            }

Obviously this is almost the simplest possible implementation and as such only a starting point. In VisualOsgi I’m checking the Nodes’ lookup for Bundle info and Install the bundle when everythings fine. If you want to make it look nicer you can check the above mentioned Tutorial for details.

Add a way to mark extension points in the layer!

Samstag, 22. August 2009

Layer is perfect for creating Extension Points and in combination with Lookups much more flexible and simple to use than anything OSGi has. The only thing that’s missing in my opinion is a way to mark up and describe the extension point. For starters it would be enough to have an attribute, e.g.
<attr name=”extensionpoint” stringvalue=”some description”/>
to fix this. I think we don’t need that verbose XML stuff Eclipse has for this. It’s just more work and takes away the simplicity. But an optional way to mark  and describe extension points would be great. It could then be used in various ways, most important:
The UI for displaying “this layer in context” could then use this to display a tooltip text, and eventually badge the folder icon.
Everyone would then be able to easily identify all extension points by browsing the layer and find out, what can be extended. I’ve filed an issue for this:

Issue 170763.

Maybe something for NetDev?

Combining ListView and ChoiceView

Freitag, 21. August 2009

ListView and ChoiceView are two very nice components that can be used to display Node hierarchies. For the RepositoryBrowser Component of my VisualOSGi project I wanted to have a combination of both, a ChoiceView on Top for selecting the Repository and a ListView below for displaying and selecting the individual Bundles. It would be possible to have all the functrionality in a ListView or a BeanTreeView, etc. but I think the combination of a JComboBox and a List is most intuitive.

This is the Node Hierarchy I want to display.

+ Root (AbstractNode)

++ RepositoryNode

+++BundleNode

My first try was using a Palette, but it didn’t play nicely with lazy loading, so I decided to do it myself. The task is now to correctly synchronize the selection between both and still stay in the same Node Hierarchy. My idea was to put the ChoiceView in a JPanel and add a nested JPanel implementing ExplorerManager.Provider with a ListView. The nested Panel then listens for selection changes in the outer Components ExplorerManager to set the root node of it’s own ExplorerManager. So I was very happy to find out that the Rich Client Programming book by Jarda, Tim and Geertjan has an example that is almost exactly what I wanted (Page 186).

I used this code to create a little Component called NestedListView. The View is a JPanel that implements ExplorerManager.Provider to control it’s own Nodes and PropertyChangeListener to listen to changes in the parent. To find the parent, I need to make sure that our component is already added to a parent component, so I’ve put  the addNotify method:

@Override
public void addNotify() {
super.addNotify();
parentManager = ExplorerManager.find(this);
if (parentManager != null) {
parentManager.addPropertyChangeListener(this);
}
}

On receiving an interesting PropertyChangeEvent:

@Override
public void propertyChange(PropertyChangeEvent evt) {
if (ExplorerManager.PROP_SELECTED_NODES.equals(evt.getPropertyName())){
updateRootNode();
}
}

I can update the Node:

public void updateRootNode() {
Node [] n = parentManager.getSelectedNodes();
if (n.length == 0){
explorerManager.setRootContext(new AbstractNode(Children.LEAF));
}
else {
explorerManager.setRootContext(n[0]);
}
}

As the outer component I’ve created another JPanel called ChoiceListView. It contains a ChoiceView to the North.

So now I’ve got a ListView that does exactly what I want:

bild-8

Since I’ve got a ChildFactory for loading the Nodes the ListView will display some visual feedback while the Nodes are loaded, and the UI isn’t blocked. Another detail is, that I also expose the inner Explorermanager from my ChoiceListView:

public ExplorerManager getChildExplorerManager() {
return choiceListView.getExplorerManager();
}

…because it makes more sense to expose the selected Nodes of the nested Component from the TopComponents Lookup:

associateLookup(ExplorerUtils.createLookup(choiceListView.getChildExplorerManager(), getActionMap()));
bild-10

Update : As per Geertjan’s request I’m adding the source code of the two classes. The inner class is called Nested ListView and the Outer class is called ChoiceListView. So you can find the two classes here: choicelistview1, nestedlistview1.

Your TopComponent needs to implement ExplorerManager.Provider and define a variable “ExplorerManger explorerManager= new Explorermanager();”. Here’s some Dummy code you can use inside your TopComponents constructor to get them to work:
setLayout(new BorderLayout());
ChoiceListView choiceListView = new ChoiceListView();
add(choiceListView, BorderLayout.CENTER);
// create a three level node hierarchy, like for a palette
Children.Array outer = new Children.Array();
Node[] outerNodes = new Node[3];
for (int j = 0; j < outerNodes.length; j++) {

Children.Array array = new Children.Array();
Node[] children = new Node[3];
for (int i = 0; i < children.length; i++) {
AbstractNode node = new AbstractNode(Children.LEAF);
node.setDisplayName(“Node ” + j+i);
children[i] = node;
}
array.add(children);
AbstractNode choice = new AbstractNode(array);
choice.setDisplayName(“Choice ” + j);
outerNodes[j] = choice;
}
outer.add(outerNodes);
AbstractNode root = new AbstractNode(outer);
root.setDisplayName(“Select something”);
explorerManager.setRootContext(root);
// this exposes the content of the ListView instead of the ChoiceView
associateLookup(ExplorerUtils.createLookup(choiceListView.getChildExplorerManager(), getActionMap()));

Hadoop Studio – Cool NetBeans based IDE

Freitag, 21. August 2009

Just found this announcement at Freshmeat:

“Hadoop Studio is a map-reduce development environment (IDE) based on Netbeans. It makes it easy to create, understand, and debug map-reduce applications based on Hadoop, without requiring development-time access to a map-reduce cluster. The studio provides a real-time workflow view of a map-reduce job, which displays the individual inputs, outputs, and interactions between the phases of a map-reduce job. The workflow view of a job updates in real time with the developer’s code changes. It then generates Java sources and compiles them into a binary jar file, which can be run on a normal Hadoop cluster.”

screenshot

via Hadoop Studio | freshmeat.net.

That does look cool, right?

VisualOSGi updates

Mittwoch, 19. August 2009

After a bit of “real work” today I took some time this evening to improve my VisualOSGi tool. I’ve added edges to the DependencyViewer and updated the nodes to only display exported packages that are imported in another bundle:

bild-6

I’ve also introduced a new hierarchy level, so more instances of the same Framework can be created with more than one configuration. I’ve added the Sigil core libraries to use them for repository management. The registration format for the layer is ready, I hope I’ll find some time tomorrow to create the node hierarchy.

I’ve got some problems with restarting the framework via the new 4.2 API. After the second start the dependencies on OSGi API packages aren’t resolved. Probably a classloading problem because of my creative use of classloading to separate the API from the implementation – that’s something that always strikes back :-) . I guess I’ve got to think of some new tricks…

Adding more substance to NetBeans

Mittwoch, 19. August 2009

As some of you might have noticed, the plugin that integrates the (kirill)cool Substance look & feel with NetBeans has been discontinued, because it’s so complicated to write all the UIDelegates:

substance-netbeans: Project Home Page.

One of the reasons, why I created NBTabbedPane was, to bring Substance back without the need of creating custom UI Delegates. But it was harder than I thought, because substance checks for violations of the new EDT rules, and in NetBeans there are some.

So I was glad to see that Josh took care of this:

JNBB: Plugin: NetBeans Substance 5.2 Look and Feel.

Now here’s a screenshot of NetBeans with my latest changes to the Tab Component:

bild-4

..and here’s how it looks without:

bild-3

Here’s another screenshot with a different Substance theme and tablayout policy set to scroll:

bild-5

Hello again Substance Look & Feel!


NetBeans Training in Bonn

Montag, 17. August 2009

Last weekend I spent my weekend in Bonn teaching the NetBeans Platform certified course together with Josch and Geertjan at the Bonn University. The weather was gorgeous, so we were very lucky that the students actually showed up :-) .  The training was organized by Aurelius Consult, a student consultancy, and they did a great job. Here are some pictures from the training and our dinner in the city.

Greetings to Bonn, hope we’ll see you again soon for another training, and special thanks to Catarina Henke, Simon Zehnder and the other students from Aurelius Consult for the organization.

OSGi & NetBeans – Teaser

Montag, 17. August 2009

Here’s a screenshot of my new toy, an OSGi admin tool called VisualOSGi:

bild-1

Right now I can run embedded Felix and Knoplerfish, deploy, undeploy, reload, install and uninstall bundles. There’s also basic support for the Felix Remote Shell, so everything I can’t do visually yet is available as well. I’d like to integrate some remote repositories, so downloading will be more convenient.

A big step will be a general remote interface, maybe a RESTful with similar capabilities like the HTTP stuff from Knopflerfish. If you know something that is available already I’d be happy to include it.