/**
   * Initialize this dialog for the job entry instance provided.
   *
   * @param jobEntry The job entry this dialog supports.
   */
  protected void init(E jobEntry) throws XulException {
    SwtXulLoader swtXulLoader = new SwtXulLoader();
    // Register the settings manager so dialog position and size is restored
    swtXulLoader.setSettingsManager(XulSpoonSettingsManager.getInstance());
    swtXulLoader.registerClassLoader(getClass().getClassLoader());
    // Register Kettle's variable text box so we can reference it from XUL
    swtXulLoader.register("VARIABLETEXTBOX", ExtTextbox.class.getName());
    swtXulLoader.setOuterContext(shell);

    // Load the XUL document with the dialog defined in it
    XulDomContainer container = swtXulLoader.loadXul(getXulFile(), bundle);

    // Create the controller with a default binding factory for the document we just loaded
    BindingFactory bf = new DefaultBindingFactory();
    bf.setDocument(container.getDocumentRoot());
    controller = createController(container, jobEntry, bf);
    container.addEventHandler(controller);

    // Load up the SWT-XUL runtime and initialize it with our container
    final XulRunner runner = new SwtXulRunner();
    runner.addContainer(container);
    runner.initialize();
  }
  // private Repository repository;
  public RepositoryExplorer(
      Shell shell,
      final Repository rep,
      RepositoryExplorerCallback callback,
      VariableSpace variableSpace)
      throws XulException {
    KettleXulLoader xulLoader = new KettleXulLoader();
    xulLoader.setIconsSize(24, 24);
    xulLoader.setOuterContext(shell);
    xulLoader.setSettingsManager(XulSpoonSettingsManager.getInstance());
    container =
        xulLoader.loadXul(
            "org/pentaho/di/ui/repository/repositoryexplorer/xul/explorer-layout.xul",
            resourceBundle);

    SpoonPluginManager.getInstance().applyPluginsForContainer("repository-explorer", container);

    final XulRunner runner = new SwtXulRunner();
    runner.addContainer(container);

    mainController.setRepository(rep);
    mainController.setCallback(callback);

    container.addEventHandler(mainController);

    List<IRepositoryExplorerUISupport> uiSupportList =
        new ArrayList<IRepositoryExplorerUISupport>();
    try {
      for (Class<? extends IRepositoryService> sevice : rep.getServiceInterfaces()) {
        IRepositoryExplorerUISupport uiSupport =
            UISupportRegistery.getInstance().createUISupport(sevice);
        if (uiSupport != null) {
          uiSupportList.add(uiSupport);
          uiSupport.apply(container);
        }
      }
    } catch (Exception e) {
      log.error(resourceBundle.getString("RepositoryExplorer.ErrorStartingXulApplication"), e);
      new ErrorDialog(
          ((Spoon) SpoonFactory.getInstance()).getShell(),
          BaseMessages.getString(Spoon.class, "Spoon.Error"),
          e.getMessage(),
          e);
    }
    // Call the init method for all the Active UISupportController
    KettleRepositoryLostException krle = null;
    for (IRepositoryExplorerUISupport uiSupport : uiSupportList) {
      try {
        uiSupport.initControllers(rep);
      } catch (ControllerInitializationException e) {
        log.error(resourceBundle.getString("RepositoryExplorer.ErrorStartingXulApplication"), e);
        krle = KettleRepositoryLostException.lookupStackStrace(e);
        if (krle == null) {
          new ErrorDialog(
              ((Spoon) SpoonFactory.getInstance()).getShell(),
              BaseMessages.getString(Spoon.class, "Spoon.Error"),
              e.getMessage(),
              e);
        } else {
          break;
        }
      }
    }

    if (krle != null) {
      dispose();
      throw krle;
    }

    try {
      runner.initialize();
    } catch (XulException e) {
      log.error(resourceBundle.getString("RepositoryExplorer.ErrorStartingXulApplication"), e);
      new ErrorDialog(
          ((Spoon) SpoonFactory.getInstance()).getShell(),
          BaseMessages.getString(Spoon.class, "Spoon.Error"),
          e.getMessage(),
          e);
    }

    initialized = true;
  }