@Bindable
  public void setSelectedDatasource(IWizardDatasource datasource) {
    IWizardDatasource prevSelection = activeDatasource;
    activeDatasource = datasource;
    if (datasource == null || prevSelection == activeDatasource) {
      return;
    }
    try {
      datasource.activating();
      if (prevSelection != null) {
        steps.removeAll(prevSelection.getSteps());
        prevSelection.deactivating();
      }

      for (int i = 1; i < datasource.getSteps().size(); i++) {
        steps.add(datasource.getSteps().get(i));
      }
      steps.addAll(datasource.getSteps());
      wizardModel.setSelectedDatasource(datasource);
      activeStep = 0;

      updateBindings();

    } catch (XulException e) {
      e
          .printStackTrace(); // To change body of catch statement use File | Settings | File
                              // Templates.
    }
  }
 private void showMessage(String message) {
   try {
     XulMessageBox box = (XulMessageBox) document.createElement("messagebox"); // $NON-NLS-1$
     box.setMessage(message);
     box.open();
   } catch (XulException e) {
     System.out.println("Error creating messagebox " + e.getMessage());
   }
 }
Exemplo n.º 3
0
  public EditorUI(EditorModel model) {
    this.model = model;
    try {
      SwtXulLoader loader = new SwtXulLoader();
      loader.registerClassLoader(getClass().getClassLoader());

      container =
          loader.loadXul(
              "org/pentaho/di/plugins/examples/texteditor/res/notepad.xul",
              new PDIMessages(getClass())); // $NON-NLS-1$

      EditorController controller = new EditorController(model);
      container.addEventHandler(controller);
      container.initialize();
    } catch (XulException e) {
      e.printStackTrace();
    }
  }
Exemplo n.º 4
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();
  }
  // 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;
  }
  public void init() {

    // We need the SelectDatasourceStep at all times, add it now

    wizardDialog = (XulDialog) document.getElementById("main_wizard_window");

    summaryDialog = (XulDialog) document.getElementById("summaryDialog");

    finishButton = (XulButton) document.getElementById(FINISH_BTN_ELEMENT_ID);

    datasourceName = (XulTextbox) document.getElementById("datasourceName"); // $NON-NLS-1$
    bf.createBinding(datasourceName, "value", wizardModel, "datasourceName");
    wizardModel.addPropertyChangeListener(
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            if (propertyChangeEvent.getPropertyName().equals("datasourceName")) {
              steps.get(activeStep).setValid(steps.get(activeStep).isValid());
            }
          }
        });

    bf.setBindingType(Binding.Type.ONE_WAY);

    datatypeMenuList = (XulMenuList) document.getElementById("datatypeMenuList");

    Binding datasourceBinding =
        bf.createBinding(wizardModel, "datasources", datatypeMenuList, "elements");
    bf.setBindingType(Binding.Type.ONE_WAY);
    bf.createBinding(datatypeMenuList, "selectedItem", wizardModel, "selectedDatasource");

    bf.setBindingType(Binding.Type.ONE_WAY);
    bf.createBinding(wizardModel, "selectedDatasource", this, "selectedDatasource");
    bf.createBinding(
        this,
        ACTIVE_STEP_PROPERTY_NAME,
        BACK_BTN_ELEMENT_ID,
        DISABLED_PROPERTY_NAME,
        new BackButtonBindingConverter());

    dummyDatasource = ((DummyDatasource) wizardModel.getDatasources().iterator().next());
    activeDatasource = dummyDatasource;
    selectDatasourceStep = dummyDatasource.getSelectDatasourceStep();

    try {
      for (IWizardDatasource datasource : wizardModel.getDatasources()) {
        datasource.init(getXulDomContainer(), wizardModel);
      }
      steps.add(selectDatasourceStep);
      selectDatasourceStep.activating();
      setActiveStep(0);
      datasourceBinding.fireSourceChanged();
      setSelectedDatasource(dummyDatasource);
      datasourceService.getDatasourceIllegalCharacters(
          new XulServiceCallback<String>() {
            @Override
            public void success(String retVal) {}

            @Override
            public void error(String message, Throwable error) {}
          });
    } catch (XulException e) {
      MessageHandler.getInstance().showErrorDialog("Error", e.getMessage());
      e.printStackTrace();
    } catch (InvocationTargetException e) {
      MessageHandler.getInstance().showErrorDialog("Error", e.getMessage());
      e.printStackTrace();
    }
  }