public void changeConnectionType() {
    XulListitem selectedItem = (XulListitem) connectionType.getSelectedItem();
    String selectedValue = selectedItem.getLabel();

    if (selectedValue.equals("Oracle")) {
      try {
        XulDomContainer container =
            this.xulDomContainer.loadFragment("org/pentaho/ui/xul/samples/datasource_oracle.xul");
        XulGroupbox newBox = (XulGroupbox) container.getDocumentRoot().getRootElement();
        XulGroupbox oldBox = (XulGroupbox) document.getElementById("database-options-box");

        document.getElementById("button-box").replaceChild(oldBox, newBox);

      } catch (Exception e) {
        System.out.println("XulException loading fragment: " + e.getMessage());
        e.printStackTrace(System.out);
      }
    }

    // hostName.setValue( String.format("%s host name", selectedValue) );
    // databaseName.setValue( String.format("%s database name", selectedValue) );
    // portNumber.setValue( String.format("%s port number", selectedValue) );
    // username.setValue( String.format("%s username", selectedValue) );
    // password.setValue( String.format("%s password", selectedValue) );
    //
  }
Ejemplo n.º 2
0
  public static InputStream loadResourceAsStream(String src, XulDomContainer domContainer)
      throws FileNotFoundException {
    if (src == null || src.equals("")) {
      return null;
    }
    InputStream in =
        (InputStream)
            domContainer
                .getXulLoader()
                .getResourceAsStream(domContainer.getXulLoader().getRootDir() + src);
    if (in == null) {
      File f = new File(src);
      if (f.exists() == false) {
        f = new File(domContainer.getXulLoader().getRootDir() + src);
      }
      if (f.exists()) {
        in = new FileInputStream(f);
        return in;
      }
    }

    if (in == null) {
      in = (InputStream) domContainer.getXulLoader().getResourceAsStream(src);
    }

    if (in == null) {
      throw new FileNotFoundException("Could not locate resource: " + src);
    }
    return in;
  }
Ejemplo n.º 3
0
  public XulDomContainer loadXul(Document xulDocument, Object context)
      throws IllegalArgumentException, XulException {

    setOuterContext(context);
    XulDomContainer domC = super.loadXul(xulDocument);

    // SWT has no notion of an "onload" event, so we must simulate it...
    // This needs to be replaced by an agnostic listener pattern.

    XulComponent maybeWindow = domC.getDocumentRoot().getRootElement();
    if (maybeWindow instanceof SwtWindow) {
      SwtWindow window = (SwtWindow) maybeWindow;
      window.notifyListeners(XulRoot.EVENT_ON_LOAD);
      defaultParent = window;
    }

    XulComponent maybeDialog = domC.getDocumentRoot().getRootElement();
    if (maybeWindow instanceof SwtDialog) {
      SwtDialog dialog = (SwtDialog) maybeDialog;
      dialog.notifyListeners(XulRoot.EVENT_ON_LOAD);
      defaultParent = dialog;
    }

    return domC;
  }
Ejemplo n.º 4
0
 protected void showErrorDialog(String title, String message) {
   errorDialog = (XulDialog) container.getDocumentRoot().getElementById("errorDialog");
   XulLabel errorLabel = (XulLabel) container.getDocumentRoot().getElementById("errorLabel");
   errorDialog.setTitle(title);
   errorLabel.setValue(message);
   errorDialog.show();
 }
Ejemplo n.º 5
0
 @Override
 public void init(XulDomContainer container, IWizardModel wizardModel) throws XulException {
   this.wizardModel = wizardModel;
   bindingFactory = new GwtBindingFactory(document);
   container.addEventHandler(csvStep);
   container.addEventHandler(stageStep);
   csvStep.init(wizardModel);
   stageStep.init(wizardModel);
 }
Ejemplo n.º 6
0
  /**
   * This call tells the Spoon Plugin to make it's modification to the particular area in Spoon
   * (category). The current possible areas are: trans-graph, job-graph, database_dialog and spoon.
   *
   * @param category Area to modify
   * @param container The XUL-document for the particular category.
   * @throws XulException
   */
  public void applyToContainer(String category, XulDomContainer container) throws XulException {
    if (category.equals(SPOON_CATEGORY)) {
      this.container = container;
      container.registerClassLoader(getClass().getClassLoader());
      container.loadOverlay(OVERLAY_FILE_PATH);
      container.addEventHandler(this.getMenuHandler());

      // refresh menus
      this.getSpoon().enableMenus();
    }
  }
  @Before
  public void setUp() throws Exception {

    container = new SwingXulLoader().loadXul("resource/documents/tabpanel.xul");
    doc = container.getDocumentRoot();
    tabbox = (XulTabbox) doc.getElementById("myTabList");
  }
Ejemplo n.º 8
0
 public void dispose() {
   super.dispose();
   List<XulComponent> pops = xulDomContainer.getDocumentRoot().getElementsByTagName("menupopup");
   for (XulComponent pop : pops) {
     ((MenuManager) pop.getManagedObject()).dispose();
   }
 }
Ejemplo n.º 9
0
 protected XulMenupopup getXulPopupMenu(String id, String documentPath, IPentahoSession session) {
   XulDomContainer container = getXulContainer(documentPath, session);
   if (container != null) {
     List<XulComponent> components =
         container.getDocumentRoot().getElementsByTagName("menupopup"); // $NON-NLS-1$
     for (XulComponent component : components) {
       if (component.getId().equals(id) && component instanceof XulMenupopup) {
         return (XulMenupopup) component;
       }
     }
   }
   Logger.error(
       getClass().getName(),
       Messages.getErrorString(
           "BaseMenuProvider.ERROR_0003_COULD_NOT_GET_POPUP_MENU")); //$NON-NLS-1$
   return null;
 }
Ejemplo n.º 10
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();
    }
  }
  @Before
  public void setUp() throws Exception {

    // Do not run on headless environment
    Assume.assumeTrue(!GraphicsEnvironment.isHeadless());

    container = new SwingXulLoader().loadXul("resource/documents/menulist.xul");

    doc = container.getDocumentRoot();
    list = (XulMenuList) doc.getElementById("list");
  }
  public SwtWindow(Element self, XulComponent parent, XulDomContainer container, String tagName) {
    super(tagName);

    Shell possibleParent = null;

    orient = Orient.VERTICAL;

    if (container.getOuterContext() != null
        && container.getOuterContext() instanceof Shell
        && (self != null && self.getAttributeValue("proxyoutercontext") != null)) {
      shell = (Shell) container.getOuterContext();
    } else {

      // First, check to see if an outer context was passed before parser started...
      if (container.getOuterContext() != null && container.getOuterContext() instanceof Shell) {
        possibleParent = (Shell) container.getOuterContext();
      }

      // If not, then try to use the API's parent parameter...
      if ((possibleParent == null) && (parent != null)) {
        possibleParent = (Shell) parent.getManagedObject();
      }

      // Otherwise, you're on your own...
      shell =
          (possibleParent != null)
              ? new Shell(possibleParent, SWT.SHELL_TRIM)
              : new Shell(SWT.SHELL_TRIM);
    }

    shell.setLayout(new GridLayout());
    shell.setBackgroundMode(SWT.INHERIT_DEFAULT);
    setManagedObject(shell);
    xulDomContainer = container;
  }
Ejemplo n.º 13
0
  protected XulMenubar getXulMenubar(String id, String documentPath, IPentahoSession session) {
    XulDomContainer container = getXulContainer(documentPath, session);
    if (container == null) {
      return null;
    }
    List<XulComponent> components =
        container.getDocumentRoot().getElementsByTagName("menubar"); // $NON-NLS-1$
    for (XulComponent component : components) {
      if (component instanceof XulMenubar && component.getId().equals(id)) {
        XulMenubar menubar = (XulMenubar) component;
        // now get customizations to it
        IPluginManager pluginManager = PentahoSystem.get(IPluginManager.class, session);
        List<?> menuCustomizations = pluginManager.getMenuCustomizations();
        for (Object custom : menuCustomizations) {
          if (custom instanceof IMenuCustomization) {
            IMenuCustomization item = (IMenuCustomization) custom;
            try {
              // apply each customization and log any failures
              MenuUtil.customizeMenu(menubar, item, getXulLoader());
            } catch (Exception e) {
              session.error(
                  Messages.getString(
                      "BaseMenuProvider.ERROR_0004_COULD_NOT_CUSTOMIZE_MENU",
                      item.getId(),
                      item.getLabel()),
                  e); //$NON-NLS-1$
            }
          }
        }

        return menubar;
      }
    }
    Logger.error(
        getClass().getName(),
        Messages.getErrorString(
            "BaseMenuProvider.ERROR_0002_COULD_NOT_GET_MENUBAR")); //$NON-NLS-1$
    return null;
  }
  /**
   * 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();
  }
 public void show() {
   XulDialog dialog =
       (XulDialog) container.getDocumentRoot().getElementById("repository-explorer-dialog");
   dialog.show();
 }
Ejemplo n.º 16
0
  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);
          }
        });
  }
Ejemplo n.º 17
0
 public Composite getMainPanel() {
   if (container == null) {
     return null;
   }
   return (Composite) container.getDocumentRoot().getElementById("mainPanel").getManagedObject();
 }
  // 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 dispose() {
   SwtDialog dialog =
       (SwtDialog) container.getDocumentRoot().getElementById("repository-explorer-dialog");
   dialog.dispose();
   initialized = false;
 }
Ejemplo n.º 20
0
 @Override
 protected XulDialog getDialog() {
   return (XulDialog) container.getDocumentRoot().getElementById("modeler_dialog");
 }