/** {@inheritDoc} */
 @Override
 public ImageDescriptor getImageDescriptor(final Object object) {
   final BindingNode bind = (BindingNode) object;
   switch (bind.getType()) {
     case CONTEXT:
       return NameBrowserPlugin.getDefault()
           .getImageRegistry()
           .getDescriptor(NameBrowserPlugin.CONTEXT);
     case OBJECT:
       return NameBrowserPlugin.getDefault()
           .getImageRegistry()
           .getDescriptor(NameBrowserPlugin.OBJECT);
     case ROOT:
       return NameBrowserPlugin.getDefault()
           .getImageRegistry()
           .getDescriptor(NameBrowserPlugin.NAMESERVER);
     default:
       return null;
   }
 }
  /** {@inheritDoc} */
  @Override
  public void fetchDeferredChildren(
      final Object object, final IElementCollector collector, final IProgressMonitor monitor) {
    final BindingNode node = (BindingNode) object;
    try {
      if (Display.getCurrent() != null) {
        Display.getCurrent()
            .asyncExec(
                new Runnable() {

                  @Override
                  public void run() {
                    collector.add(node.fetchContents(), monitor);
                  }
                });
      } else {
        if (SWT.getPlatform().startsWith("rap")) {
          Display display = NameBrowserPlugin.getDefault().getDisplay();
          if (display != null) {
            display.asyncExec(
                new Runnable() {

                  @Override
                  public void run() {
                    collector.add(node.fetchContents(), monitor);
                  }
                });
          } else {
            NameBrowserPlugin.getDefault()
                .getLog()
                .log(
                    new Status(
                        Status.ERROR,
                        NameBrowserPlugin.PLUGIN_ID,
                        "Unable to retrieve defrrred children from non-UI thread"));
          }
        } else {
          collector.add(node.fetchContents(), monitor);
        }
      }
    } finally {
      if (Display.getCurrent() != null) {
        Display.getCurrent()
            .asyncExec(
                new Runnable() {

                  @Override
                  public void run() {
                    collector.done();
                  }
                });
      } else {
        if (SWT.getPlatform().startsWith("rap")) {
          Display display = NameBrowserPlugin.getDefault().getDisplay();
          if (display != null) {
            display.asyncExec(
                new Runnable() {

                  @Override
                  public void run() {
                    collector.add(node.fetchContents(), monitor);
                  }
                });
          } else {
            NameBrowserPlugin.getDefault()
                .getLog()
                .log(
                    new Status(
                        Status.ERROR,
                        NameBrowserPlugin.PLUGIN_ID,
                        "Unable to retrieve defrrred children from non-UI thread"));
          }
        } else {
          collector.done();
        }
      }
    }
  }