Example #1
0
  /**
   * Callback method for the MantleXulLoader. This is called when the Xul file has been processed.
   *
   * @param runner GwtXulRunner instance ready for event handlers and initializing.
   */
  public void xulLoaded(GwtXulRunner runner) {

    // Add handler to container
    container = (GwtXulDomContainer) runner.getXulDomContainers().get(0);
    container.addEventHandler(controller);

    try {
      runner.initialize();
    } catch (XulException e) {
      Window.alert("Error initializing XUL runner: " + e.getMessage()); // $NON-NLS-1$
      e.printStackTrace();
      return;
    }

    // TODO: remove controller reference from model when Bindings in place
    model = new MainToolbarModel(solutionBrowser, this);
    controller.setModel(model);
    controller.setSolutionBrowser(solutionBrowser);

    // The inital state of the toolbar is unaware of the fact that the browser may be collapsed by
    // default. Explicitly set it's starting state now
    model.setShowBrowserSelected(solutionBrowser.isNavigatorShowing());

    // Get the toolbar from the XUL doc
    Toolbar bar =
        (Toolbar)
            container
                .getDocumentRoot()
                .getElementById("mainToolbar")
                .getManagedObject(); //$NON-NLS-1$
    bar.setStylePrimaryName(
        "pentaho-rounded-panel2-shadowed pentaho-shine pentaho-background"); //$NON-NLS-1$
    this.add(bar);

    // unfortunately hosted mode won't resolve the image with 'mantle/' in it
    cleanImageUrlsForHostedMode();

    fetchOverlays();
  }
  public void xulLoaded(GwtXulRunner gwtXulRunner) {
    container = gwtXulRunner.getXulDomContainers().get(0);
    container.addEventHandler(this);

    BogoPojo bogo = new BogoPojo();
    service.gwtWorkaround(
        bogo,
        new XulServiceCallback<BogoPojo>() {
          public void success(BogoPojo retVal) {}

          public void error(String message, Throwable error) {}
        });

    datasourceService = new DSWDatasourceServiceGwtImpl();
    //    connectionService = new ConnectionServiceGwtImpl();
    csvService = (ICsvDatasourceServiceAsync) GWT.create(ICsvDatasourceService.class);

    if (wizard == null) {
      wizard = new EmbeddedWizard(false);

      wizard.setDatasourceService(datasourceService);
      //      wizard.setConnectionService(connectionService);
      wizard.setCsvDatasourceService(csvService);
      wizard.init(null);
    }

    messages = new GwtModelerMessages((ResourceBundle) container.getResourceBundles().get(0));
    try {
      ModelerMessagesHolder.setMessages(messages);
    } catch (Exception ignored) {
      // Messages may have been set earlier, ignore.
    }

    IModelerWorkspaceHelper workspacehelper = model.getWorkspaceHelper();

    controller = new ModelerController(model);
    controller.setWorkspaceHelper(workspacehelper);
    //    controller.setMessages(messages);
    final BindingFactory bf = new GwtBindingFactory(container.getDocumentRoot());
    controller.setBindingFactory(bf);
    container.addEventHandler(controller);
    try {
      controller.init();
    } catch (ModelerException e) {
      e.printStackTrace();
    }

    bf.setBindingType(Binding.Type.ONE_WAY);
    bf.createBinding(
        model,
        "valid",
        "modeler_dialog_accept",
        "disabled",
        new BindingConvertor<Boolean, Boolean>() {
          @Override
          public Boolean sourceToTarget(Boolean value) {
            return !value;
          }

          @Override
          public Boolean targetToSource(Boolean value) {
            return !value;
          }
        });

    bf.setBindingType(Binding.Type.BI_DIRECTIONAL);

    // go get the geocontext from the server. Prop forms are initialized after this call returns as
    // they
    // may need them to create the UI
    datasourceService.getGeoContext(
        new XulServiceCallback<GeoContext>() {
          public void success(GeoContext geoContext) {
            model.setGeoContext(geoContext);
            ModelerUiHelper.configureControllers(
                container, model, bf, controller, new ColResolverController());
            ModelerDialog.this.constructorListener.asyncConstructorDone(ModelerDialog.this);
          }

          public void error(String s, Throwable throwable) {
            throwable.printStackTrace();
            // put in a stub to ensure the rest of the dialog works
            model.setGeoContext(new GeoContext());
            ModelerUiHelper.configureControllers(
                container, model, bf, controller, new ColResolverController());
            ModelerDialog.this.constructorListener.asyncConstructorDone(ModelerDialog.this);
          }
        });
  }