Search in sources :

Example 16 with XulException

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

the class DatabaseDialogHarness method showDialog.

private void showDialog() {
    XulDomContainer container = null;
    try {
        DatabaseConnectionDialog dcDialog = new DatabaseConnectionDialog();
        container = dcDialog.getSwtInstance(new Shell(SWT.NONE));
        if (database != null) {
            container.getEventHandler("dataHandler").setData(database);
        }
    } catch (XulException e) {
        e.printStackTrace();
    }
    XulRoot root = (XulRoot) container.getDocumentRoot().getRootElement();
    if (root instanceof XulDialog) {
        ((XulDialog) root).show();
    }
    if (root instanceof XulWindow) {
        ((XulWindow) root).open();
    }
    try {
        database = (DatabaseMeta) container.getEventHandler("dataHandler").getData();
    } catch (Exception e) {
        e.printStackTrace();
    }
    String message = DatabaseDialogHarness.setMessage(database);
    Shell shell = new Shell(SWT.DIALOG_TRIM);
    shell.setLayout(new RowLayout());
    Label label = new Label(shell, SWT.NONE);
    label.setText(message);
    Button button = new Button(shell, SWT.NONE);
    button.setText("Edit Database ...");
    button.addSelectionListener(new SelectionAdapter() {

        public void widgetSelected(SelectionEvent event) {
            try {
                showDialog();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
    shell.pack();
    shell.open();
    while (!shell.isDisposed()) {
        if (!shell.getDisplay().readAndDispatch()) {
            shell.getDisplay().sleep();
        }
    }
}
Also used : SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Label(org.eclipse.swt.widgets.Label) DatabaseConnectionDialog(org.pentaho.ui.database.DatabaseConnectionDialog) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) Shell(org.eclipse.swt.widgets.Shell) XulException(org.pentaho.ui.xul.XulException) XulRoot(org.pentaho.ui.xul.containers.XulRoot) Button(org.eclipse.swt.widgets.Button) RowLayout(org.eclipse.swt.layout.RowLayout) XulDialog(org.pentaho.ui.xul.containers.XulDialog) SelectionEvent(org.eclipse.swt.events.SelectionEvent) XulWindow(org.pentaho.ui.xul.containers.XulWindow)

Example 17 with XulException

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

the class SwingTest method showDialog.

private void showDialog(final Document doc) {
    XulDomContainer container = null;
    try {
        container = new SwingXulLoader().loadXul(DatabaseConnectionDialog.DIALOG_DEFINITION_FILE, Messages.getBundle());
        if (database != null) {
            container.getEventHandler("dataHandler").setData(database);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
    XulDialog dialog = (XulDialog) container.getDocumentRoot().getRootElement();
    container.initialize();
    dialog.show();
    try {
        @SuppressWarnings("unused") Object data = container.getEventHandler("dataHandler").getData();
    } catch (XulException e) {
        System.out.println("Error getting data");
    }
}
Also used : XulException(org.pentaho.ui.xul.XulException) XulDialog(org.pentaho.ui.xul.containers.XulDialog) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) SwingXulLoader(org.pentaho.ui.xul.swing.SwingXulLoader) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException)

Example 18 with XulException

use of org.pentaho.ui.xul.XulException 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 19 with XulException

use of org.pentaho.ui.xul.XulException in project pdi-dataservice-server-plugin by pentaho.

the class ParameterGenerationController method runAutoGenerate.

public void runAutoGenerate() throws XulException {
    DataServiceModel dialogModel = model.getDialogModel();
    try {
        AutoOptimizationService autoOptimizationService = factory.createAutoOptimizationService();
        Collection<PushDownOptimizationMeta> found = autoOptimizationService.apply(dialogModel.getDataService());
        if (dialogModel.addAll(found)) {
            model.updateParameterMap();
        }
        info(getString(PKG, "ParameterGenerationController.AutoGen.Title"), getString(PKG, "ParameterGenerationController.AutoGen.Message", found.size()));
    } catch (Exception e) {
        String message = getString(PKG, "ParameterGenerationController.AutoGen.Error");
        getLogChannel().logError(message, e);
        error(getString(PKG, "ParameterGenerationController.AutoGen.Title"), message);
    }
}
Also used : DataServiceModel(org.pentaho.di.trans.dataservice.ui.model.DataServiceModel) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) AutoOptimizationService(org.pentaho.di.trans.dataservice.optimization.AutoOptimizationService) BaseMessages.getString(org.pentaho.di.i18n.BaseMessages.getString) XulException(org.pentaho.ui.xul.XulException)

Example 20 with XulException

use of org.pentaho.ui.xul.XulException in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceRemapNoStepsDialog method open.

void open() throws KettleException {
    Document xulDocument;
    try {
        xulDocument = initXul(parent, new KettleXulLoader(), new SwtXulRunner());
    } catch (XulException xulException) {
        throw new KettleException("Failed to initialize RemapNoStepsDialog.", xulException);
    }
    ((SwtDialog) xulDocument.getElementById(XUL_DIALOG_ID)).show();
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) XulException(org.pentaho.ui.xul.XulException) SwtDialog(org.pentaho.ui.xul.swt.tags.SwtDialog) KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) Document(org.pentaho.ui.xul.dom.Document) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner)

Aggregations

XulException (org.pentaho.ui.xul.XulException)60 KettleException (org.pentaho.di.core.exception.KettleException)20 Test (org.junit.Test)11 XulMessageBox (org.pentaho.ui.xul.components.XulMessageBox)10 XulComponent (org.pentaho.ui.xul.XulComponent)9 Shell (org.eclipse.swt.widgets.Shell)7 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)7 KettleXulLoader (org.pentaho.di.ui.xul.KettleXulLoader)7 SwtXulRunner (org.pentaho.ui.xul.swt.SwtXulRunner)7 XulDomContainer (org.pentaho.ui.xul.XulDomContainer)6 SwtDialog (org.pentaho.ui.xul.swt.tags.SwtDialog)6 XulRunner (org.pentaho.ui.xul.XulRunner)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 Document (org.pentaho.ui.xul.dom.Document)4 ResourceBundle (java.util.ResourceBundle)3 Mockito.doAnswer (org.mockito.Mockito.doAnswer)3 InvocationOnMock (org.mockito.invocation.InvocationOnMock)3 Answer (org.mockito.stubbing.Answer)3 XulLoader (org.pentaho.ui.xul.XulLoader)3 SwtBindingFactory (org.pentaho.ui.xul.swt.SwtBindingFactory)3