Search in sources :

Example 1 with XulRunner

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

the class FileOverwriteDialogController method getInstance.

public static FileOverwriteDialogController getInstance(Shell shell, List<UIRepositoryObject> objects) {
    try {
        KettleXulLoader swtLoader = new KettleXulLoader();
        swtLoader.setOuterContext(shell);
        swtLoader.setSettingsManager(XulSpoonSettingsManager.getInstance());
        XulDomContainer container = swtLoader.loadXul("org/pentaho/di/ui/repository/repositoryexplorer/xul/file-overwrite-dialog.xul", resourceBundle);
        final XulRunner runner = new SwtXulRunner();
        runner.addContainer(container);
        FileOverwriteDialogController dialogController = new FileOverwriteDialogController(container, objects);
        container.addEventHandler(dialogController);
        runner.initialize();
        return dialogController;
    } catch (Exception e) {
        return null;
    }
}
Also used : KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) XulRunner(org.pentaho.ui.xul.XulRunner) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner)

Example 2 with XulRunner

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

the class DataServiceRemapNoStepsDialogTest method testInitXul.

@Test
public void testInitXul() throws KettleException, XulException {
    Shell shell = mock(Shell.class);
    XulLoader xulLoader = mock(XulLoader.class);
    XulRunner xulRunner = mock(XulRunner.class);
    XulDomContainer xulDomContainer = mock(XulDomContainer.class);
    when(xulLoader.loadXul(anyString(), any(ResourceBundle.class))).thenReturn(xulDomContainer);
    DataServiceRemapNoStepsDialog dialog = mock(DataServiceRemapNoStepsDialog.class);
    when(dialog.initXul(shell, xulLoader, xulRunner)).thenCallRealMethod();
    dialog.initXul(shell, xulLoader, xulRunner);
    verify(xulLoader).setOuterContext(shell);
    verify(xulLoader).registerClassLoader(any(ClassLoader.class));
    verify(xulRunner).addContainer(xulDomContainer);
    verify(xulRunner).initialize();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) XulLoader(org.pentaho.ui.xul.XulLoader) ResourceBundle(java.util.ResourceBundle) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) XulRunner(org.pentaho.ui.xul.XulRunner) Test(org.junit.Test)

Example 3 with XulRunner

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

the class DriverDetailsDialogTest method testInitXul.

@Test
public void testInitXul() throws Exception {
    DriverDetailsDialog dialog = mock(DriverDetailsDialog.class);
    Shell parentShell = mock(Shell.class);
    AbstractXulLoader xulLoader = mock(AbstractXulLoader.class);
    XulRunner xulRunner = mock(XulRunner.class);
    Document document = mock(Document.class);
    XulDomContainer container = mock(XulDomContainer.class);
    doReturn(container).when(xulLoader).loadXul(anyString(), any(ResourceBundle.class));
    doReturn(document).when(container).getDocumentRoot();
    doCallRealMethod().when(dialog).initXul(parentShell, xulLoader, xulRunner);
    assertThat(document, is(sameInstance(dialog.initXul(parentShell, xulLoader, xulRunner))));
    verify(xulLoader).setOuterContext(parentShell);
    verify(xulLoader).registerClassLoader(dialog.getClass().getClassLoader());
    verify(xulLoader).loadXul(anyString(), any(ResourceBundle.class));
    verify(container).addEventHandler(any(DriverDetailsDialogController.class));
    verify(container).getDocumentRoot();
    verify(xulRunner).addContainer(container);
    verify(xulRunner).initialize();
}
Also used : DriverDetailsDialogController(org.pentaho.di.trans.dataservice.ui.controller.DriverDetailsDialogController) Shell(org.eclipse.swt.widgets.Shell) AbstractXulLoader(org.pentaho.ui.xul.impl.AbstractXulLoader) ResourceBundle(java.util.ResourceBundle) Document(org.pentaho.ui.xul.dom.Document) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) XulRunner(org.pentaho.ui.xul.XulRunner) Test(org.junit.Test)

Example 4 with XulRunner

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

the class DataServiceTestDialog method initXul.

private Document initXul(Composite parent) throws KettleException {
    try {
        SwtXulLoader swtLoader = new KettleXulLoader();
        swtLoader.setOuterContext(parent);
        swtLoader.registerClassLoader(getClass().getClassLoader());
        XulDomContainer container = swtLoader.loadXul(XUL_PATH, resourceBundle);
        container.addEventHandler(dataServiceTestController);
        final XulRunner runner = new SwtXulRunner();
        runner.addContainer(container);
        runner.initialize();
        return container.getDocumentRoot();
    } catch (XulException xulException) {
        throw new KettleException("Failed to initialize DataServicesTestDialog.", xulException);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) XulException(org.pentaho.ui.xul.XulException) KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) SwtXulLoader(org.pentaho.ui.xul.swt.SwtXulLoader) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) XulRunner(org.pentaho.ui.xul.XulRunner) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner)

Example 5 with XulRunner

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

the class DataServiceDialogTest method testLoadXul.

@Test
public void testLoadXul() throws Exception {
    Shell shell = mock(Shell.class);
    XulLoader xulLoader = mock(XulLoader.class);
    XulRunner xulRunner = mock(XulRunner.class);
    XulDomContainer xulDomContainer = mock(XulDomContainer.class);
    final ResourceBundle resourceBundle = mock(ResourceBundle.class);
    DataServiceDialog dialog = new DataServiceDialog(controller, model) {

        @Override
        protected ResourceBundle createResourceBundle(Class<?> packageClass) {
            assertThat(packageClass, equalTo((Class) DataServiceDialog.class));
            assertThat(super.createResourceBundle(packageClass), isA(ResourceBundle.class));
            return resourceBundle;
        }
    };
    when(xulLoader.loadXul(anyString(), same(resourceBundle))).thenReturn(xulDomContainer);
    dialog.loadXul(shell, xulLoader, xulRunner);
    verify(xulLoader).setOuterContext(shell);
    verify(xulLoader).registerClassLoader(any(ClassLoader.class));
    verify(xulDomContainer).addEventHandler(controller);
    verify(xulRunner).addContainer(xulDomContainer);
    verify(xulRunner).initialize();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) XulLoader(org.pentaho.ui.xul.XulLoader) ResourceBundle(java.util.ResourceBundle) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) XulRunner(org.pentaho.ui.xul.XulRunner) SwtXulRunner(org.pentaho.ui.xul.swt.SwtXulRunner) Test(org.junit.Test)

Aggregations

XulRunner (org.pentaho.ui.xul.XulRunner)8 XulDomContainer (org.pentaho.ui.xul.XulDomContainer)7 ResourceBundle (java.util.ResourceBundle)5 Shell (org.eclipse.swt.widgets.Shell)5 Test (org.junit.Test)5 XulLoader (org.pentaho.ui.xul.XulLoader)4 SwtXulRunner (org.pentaho.ui.xul.swt.SwtXulRunner)4 KettleXulLoader (org.pentaho.di.ui.xul.KettleXulLoader)3 XulException (org.pentaho.ui.xul.XulException)2 SwtXulLoader (org.pentaho.ui.xul.swt.SwtXulLoader)2 DisposeEvent (org.eclipse.swt.events.DisposeEvent)1 DisposeListener (org.eclipse.swt.events.DisposeListener)1 KettleException (org.pentaho.di.core.exception.KettleException)1 PurRepositoryMeta (org.pentaho.di.repository.pur.PurRepositoryMeta)1 DriverDetailsDialogController (org.pentaho.di.trans.dataservice.ui.controller.DriverDetailsDialogController)1 Document (org.pentaho.ui.xul.dom.Document)1 AbstractXulLoader (org.pentaho.ui.xul.impl.AbstractXulLoader)1