Search in sources :

Example 1 with XulEventHandler

use of org.pentaho.ui.xul.impl.XulEventHandler in project pentaho-kettle by pentaho.

the class AbstractPreviewRowsXulDialog method initializeXul.

protected void initializeXul(XulLoader loader, BindingFactory bindingFactory, XulRunner runner, Object parent) throws XulException {
    bf = bindingFactory;
    this.runner = runner;
    loader.registerClassLoader(getClass().getClassLoader());
    loader.setSettingsManager(getSettingsManager());
    loader.setOuterContext(parent);
    container = loader.loadXul(xulFile, getResourceBundle());
    bf.setDocument(container.getDocumentRoot());
    for (XulEventHandler h : getEventHandlers()) {
        container.addEventHandler(h);
    }
    this.runner.addContainer(container);
    // try and get the dialog
    xulDialog = (XulDialog) container.getDocumentRoot().getRootElement();
    runner.initialize();
}
Also used : AbstractXulEventHandler(org.pentaho.ui.xul.impl.AbstractXulEventHandler) XulEventHandler(org.pentaho.ui.xul.impl.XulEventHandler)

Example 2 with XulEventHandler

use of org.pentaho.ui.xul.impl.XulEventHandler in project pentaho-kettle by pentaho.

the class SpoonPerspectiveManager method activatePerspective.

/**
 * Activates the given instance of the class literal passed in. Activating a perspective first deactivates the current
 * perspective removing any overlays its applied to the UI. It then switches the main deck to display the perspective
 * UI and applies the optional overlays to the main Spoon XUL container.
 *
 * @param clazz
 *          SpoonPerspective class literal
 * @throws KettleException
 *           throws a KettleException if no perspective is found for the given parameter
 */
public void activatePerspective(Class<? extends SpoonPerspective> clazz) throws KettleException {
    if (this.forcePerspective) {
        // we are currently prevented from switching perspectives
        return;
    }
    SpoonPerspective sp = perspectives.get(clazz);
    if (sp == null) {
        throw new KettleException("Could not locate perspective by class: " + clazz);
    }
    PerspectiveManager perspectiveManager = getPerspectiveManagerMap().get(sp);
    if (perspectiveManager != null) {
        perspectiveManager.initializeIfNeeded();
    }
    unloadPerspective(activePerspective);
    activePerspective = sp;
    List<XulOverlay> overlays = sp.getOverlays();
    if (overlays != null) {
        for (XulOverlay overlay : overlays) {
            try {
                ResourceBundle res = null;
                if (overlay.getResourceBundleUri() != null) {
                    try {
                        res = ResourceBundle.getBundle(overlay.getResourceBundleUri());
                    } catch (MissingResourceException ignored) {
                    // Ignore errors
                    }
                } else {
                    try {
                        res = ResourceBundle.getBundle(overlay.getOverlayUri().replace(".xul", ".properties"));
                    } catch (MissingResourceException ignored) {
                    // Ignore errors
                    }
                }
                if (res == null) {
                    res = new XulSpoonResourceBundle(sp.getClass());
                }
                domContainer.loadOverlay(overlay.getOverlayUri(), res);
            } catch (XulException e) {
                log.logError("Error activate perspective", e);
            }
        }
    }
    List<XulEventHandler> theXulEventHandlers = sp.getEventHandlers();
    if (theXulEventHandlers != null) {
        for (XulEventHandler handler : theXulEventHandlers) {
            domContainer.addEventHandler(handler);
        }
    }
    sp.setActive(true);
    if (sp.equals(activePerspective)) {
        deck.setSelectedIndex(deck.getChildNodes().indexOf(deck.getElementById("perspective-" + sp.getId())));
        getSpoon().enableMenus();
    }
}
Also used : XulOverlay(org.pentaho.ui.xul.XulOverlay) KettleException(org.pentaho.di.core.exception.KettleException) XulException(org.pentaho.ui.xul.XulException) XulEventHandler(org.pentaho.ui.xul.impl.XulEventHandler) MissingResourceException(java.util.MissingResourceException) ResourceBundle(java.util.ResourceBundle)

Example 3 with XulEventHandler

use of org.pentaho.ui.xul.impl.XulEventHandler in project pentaho-kettle by pentaho.

the class BaseStepGenericXulDialog method initializeXul.

protected void initializeXul(XulLoader loader, BindingFactory bindingFactory, XulRunner runner, Object parent) throws XulException {
    bf = bindingFactory;
    this.runner = runner;
    loader.registerClassLoader(getClass().getClassLoader());
    loader.setSettingsManager(getSettingsManager());
    loader.setOuterContext(parent);
    container = loader.loadXul(xulFile, getResourceBundle());
    bf.setDocument(container.getDocumentRoot());
    for (XulEventHandler h : getEventHandlers()) {
        container.addEventHandler(h);
    }
    this.runner.addContainer(container);
    // try and get the dialog
    xulDialog = (XulDialog) container.getDocumentRoot().getRootElement();
    runner.initialize();
}
Also used : AbstractXulEventHandler(org.pentaho.ui.xul.impl.AbstractXulEventHandler) XulEventHandler(org.pentaho.ui.xul.impl.XulEventHandler)

Example 4 with XulEventHandler

use of org.pentaho.ui.xul.impl.XulEventHandler in project pentaho-kettle by pentaho.

the class RepositoryLockController method init.

public void init(Repository rep) throws ControllerInitializationException {
    try {
        if (rep != null && rep.hasService(ILockService.class)) {
            repository = rep;
            service = (ILockService) rep.getService(ILockService.class);
        } else {
            throw new ControllerInitializationException(BaseMessages.getString(PKG, "RepositoryLockController.ERROR_0001_UNABLE_TO_INITIAL_REPOSITORY_SERVICE", // $NON-NLS-1$
            ILockService.class));
        }
        bindingFactory = new DefaultBindingFactory();
        bindingFactory.setDocument(getXulDomContainer().getDocumentRoot());
        // $NON-NLS-1$
        XulEventHandler eventHandler = getXulDomContainer().getEventHandler("browseController");
        if (eventHandler instanceof BrowseController) {
            browseController = (BrowseController) eventHandler;
        }
        // Disable row dragging if it is locked and the user does not have permissions
        // $NON-NLS-1$
        fileTable = (XulTree) getXulDomContainer().getDocumentRoot().getElementById("file-table");
        // $NON-NLS-1$
        folderTree = (XulTree) document.getElementById("folder-tree");
        // $NON-NLS-1$
        lockFileMenuItem = (XulMenuitem) getXulDomContainer().getDocumentRoot().getElementById("file-context-lock");
        // $NON-NLS-1$
        deleteFileMenuItem = (XulMenuitem) getXulDomContainer().getDocumentRoot().getElementById("file-context-delete");
        // $NON-NLS-1$
        renameFileMenuItem = (XulMenuitem) getXulDomContainer().getDocumentRoot().getElementById("file-context-rename");
        // $NON-NLS-1$
        messageBox = (XulMessageBox) document.createElement("messagebox");
        createBindings();
    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}
Also used : DefaultBindingFactory(org.pentaho.ui.xul.binding.DefaultBindingFactory) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException) AbstractXulEventHandler(org.pentaho.ui.xul.impl.AbstractXulEventHandler) XulEventHandler(org.pentaho.ui.xul.impl.XulEventHandler) ILockService(org.pentaho.di.ui.repository.pur.services.ILockService) BrowseController(org.pentaho.di.ui.repository.repositoryexplorer.controllers.BrowseController) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)

Example 5 with XulEventHandler

use of org.pentaho.ui.xul.impl.XulEventHandler in project pentaho-kettle by pentaho.

the class AbstractRepositoryExplorerUISupport method apply.

public void apply(XulDomContainer container) throws XulException {
    this.container = container;
    container.registerClassLoader(getClass().getClassLoader());
    for (XulEventHandler handler : handlers) {
        container.addEventHandler(handler);
    }
    for (XulOverlay overlay : overlays) {
        if (overlay instanceof RepositoryExplorerDefaultXulOverlay) {
            container.loadOverlay(overlay.getOverlayUri(), new XulSpoonResourceBundle(((RepositoryExplorerDefaultXulOverlay) overlay).getPackageClass()));
        } else {
            container.loadOverlay(overlay.getOverlayUri(), overlay.getResourceBundleUri());
        }
    }
}
Also used : XulOverlay(org.pentaho.ui.xul.XulOverlay) XulSpoonResourceBundle(org.pentaho.di.ui.spoon.XulSpoonResourceBundle) XulEventHandler(org.pentaho.ui.xul.impl.XulEventHandler)

Aggregations

XulEventHandler (org.pentaho.ui.xul.impl.XulEventHandler)5 AbstractXulEventHandler (org.pentaho.ui.xul.impl.AbstractXulEventHandler)3 KettleException (org.pentaho.di.core.exception.KettleException)2 XulException (org.pentaho.ui.xul.XulException)2 XulOverlay (org.pentaho.ui.xul.XulOverlay)2 MissingResourceException (java.util.MissingResourceException)1 ResourceBundle (java.util.ResourceBundle)1 ILockService (org.pentaho.di.ui.repository.pur.services.ILockService)1 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)1 BrowseController (org.pentaho.di.ui.repository.repositoryexplorer.controllers.BrowseController)1 XulSpoonResourceBundle (org.pentaho.di.ui.spoon.XulSpoonResourceBundle)1 DefaultBindingFactory (org.pentaho.ui.xul.binding.DefaultBindingFactory)1