Geertjan's Blog

  • October 2, 2009

Creating An Explorer View with the Visual Library

Geertjan Wielenga
Product Manager
Toni has been experimenting with creating new explorer views (here). This one below is the one he got the students to create during the recent training in Goettingen. The lower view below is Toni's new explorer view, based on the Visual Library, which displays the same nodes as are displayed by the ExplorerManager that handles the upper view. My contribution is that selecting a node in the lower view synchronizes it with the upper view (i.e., a SelectProvider):

public class VisualLibraryView extends JScrollPane {
Scene scene;
ExplorerManager em;
public void addNotify() {
em = ExplorerManager.find(this);
if (em != null) {
scene = new Scene();
Node root = em.getRootContext();
addWidgetsForNode(scene, root.getChildren().getNodes());
private void addWidgetsForNode(Scene scene, Node[] nodes) {
for (int i = 0; i < nodes.length; i++) {
Node node = nodes[i];
IconNodeWidget widget = new IconNodeWidget(scene);
widget.getActions().addAction(ActionFactory.createSelectAction(new SelectProviderImpl(node)));
private class SelectProviderImpl implements SelectProvider {
private final Node node;
public SelectProviderImpl(Node node) {
this.node = node;
public boolean isAimingAllowed(Widget widget, Point localLocation, boolean invertSelection) {
return false;
public boolean isSelectionAllowed(Widget widget, Point localLocation, boolean invertSelection) {
return true;
public void select(Widget widget, Point localLocation, boolean invertSelection) {
try {
em.setSelectedNodes(new Node[]{node});
} catch (PropertyVetoException ex) {

Join the discussion

Comments ( 3 )
  • Fabrizio Giudici Saturday, October 3, 2009

    The use of the VL as an Explorer is a very good move. For instance, in blueMarine I'd like to replace all the thumbnail viewers with an implementation based on the VL. At the moment, there's a specific viewer, the Light Table, based on it, with specific capabilities. Joining everything together would simplify the code _and_ allow to seamlessly switch from a function to the other; in addition, you could insert simple animantions à la Mac OS X. I'm really longing to finish the mavenization of the project which is keeping other developments stopped :-)

  • Jaroslav Tulach Sunday, October 4, 2009

    Can you publish this as a module that others can reuse and contribute to? It would be better to mutually fix one module than copy and duplicate not perfect code. Why not perfect, for example your code does not listen on changes in nodes, neither it listens to changes in ExplorerManager.

  • Toni Epple Monday, October 5, 2009


    you're right, the example is very basic and it was only intended as a staring point for creating your own Explorer Views. It would be cool though to build this into a working explorerview, that can also display node hierarchies. It would be cool to have this as an example...

    The basic code is in my slides (Gj has them), so it's publicly available.



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