Search in sources :

Example 16 with XulDomContainer

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

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

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

the class ParameterGenerationOverlayTest method testApply.

@Test
public void testApply() throws Exception {
    ParameterGenerationController controller = mock(ParameterGenerationController.class);
    XulDomContainer xulDomContainer = mock(XulDomContainer.class);
    TransMeta transMeta = mock(TransMeta.class);
    StepMeta supportedStep = new StepMeta("supportedStep", mock(StepMetaInterface.class));
    when(dialog.getModel()).thenReturn(model);
    when(model.getTransMeta()).thenReturn(transMeta);
    when(transMeta.getSteps()).thenReturn(ImmutableList.of(supportedStep, mock(StepMeta.class)));
    when(factory.supportsStep(supportedStep)).thenReturn(true);
    when(factory.createController(model)).thenReturn(controller);
    when(dialog.applyOverlay(same(overlay), anyString())).thenReturn(xulDomContainer);
    overlay.apply(dialog);
    verify(xulDomContainer).addEventHandler(controller);
    verify(controller).initBindings(ImmutableList.of("supportedStep"));
}
Also used : TransMeta(org.pentaho.di.trans.TransMeta) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) StepMeta(org.pentaho.di.trans.step.StepMeta) Test(org.junit.Test)

Example 19 with XulDomContainer

use of org.pentaho.ui.xul.XulDomContainer in project data-access by pentaho.

the class GwtImportDialog method xulLoaded.

public void xulLoaded(GwtXulRunner runner) {
    try {
        XulDomContainer container = runner.getXulDomContainers().get(0);
        BindingFactory bf = new GwtBindingFactory(container.getDocumentRoot());
        ResourceBundle resBundle = (ResourceBundle) container.getResourceBundles().get(0);
        datasourceMessages = new GwtDatasourceMessages();
        datasourceMessages.setMessageBundle(resBundle);
        metadataImportDialogController = new MetadataImportDialogController();
        metadataImportDialogController.setBindingFactory(bf);
        container.addEventHandler(metadataImportDialogController);
        metadataImportDialogController.setDatasourceMessages(datasourceMessages);
        analysisImportDialogController = new AnalysisImportDialogController();
        analysisImportDialogController.setBindingFactory(bf);
        container.addEventHandler(analysisImportDialogController);
        analysisImportDialogController.setDatasourceMessages(datasourceMessages);
        importDialogController = new ImportDialogController();
        importDialogController.addImportPerspective(0, metadataImportDialogController);
        importDialogController.addImportPerspective(1, analysisImportDialogController);
        container.addEventHandler(importDialogController);
        runner.initialize();
        runner.start();
        importDialogController.init();
        metadataImportDialogController.init();
        analysisImportDialogController.init();
        if (constructorListener != null) {
            constructorListener.asyncConstructorDone(this);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : GwtDatasourceMessages(org.pentaho.platform.dataaccess.datasource.wizard.GwtDatasourceMessages) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory) ResourceBundle(org.pentaho.gwt.widgets.client.utils.i18n.ResourceBundle) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory)

Example 20 with XulDomContainer

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

the class FragmentHandlerTest method testRefreshOptions.

@Test
public void testRefreshOptions() throws Exception {
    XulListbox connectionBox = mock(XulListbox.class);
    when(document.getElementById("connection-type-list")).thenReturn(connectionBox);
    when(connectionBox.getSelectedItem()).thenReturn("myDb");
    XulListbox accessBox = mock(XulListbox.class);
    when(document.getElementById("access-type-list")).thenReturn(accessBox);
    when(accessBox.getSelectedItem()).thenReturn("Native");
    DataHandler dataHandler = mock(DataHandler.class);
    when(xulDomContainer.getEventHandler("dataHandler")).thenReturn(dataHandler);
    DatabaseInterface dbInterface = mock(DatabaseInterface.class);
    when(dbInterface.getDefaultDatabasePort()).thenReturn(5309);
    DataHandler.connectionMap.put("myDb", dbInterface);
    XulComponent component = mock(XulComponent.class);
    XulComponent parent = mock(XulComponent.class);
    when(component.getParent()).thenReturn(parent);
    when(document.getElementById("database-options-box")).thenReturn(component);
    XulDomContainer fragmentContainer = mock(XulDomContainer.class);
    Document mockDoc = mock(Document.class);
    XulComponent firstChild = mock(XulComponent.class);
    when(mockDoc.getFirstChild()).thenReturn(firstChild);
    when(fragmentContainer.getDocumentRoot()).thenReturn(mockDoc);
    when(xulDomContainer.loadFragment(anyString(), any(Object.class))).thenReturn(fragmentContainer);
    XulTextbox portBox = mock(XulTextbox.class);
    when(document.getElementById("port-number-text")).thenReturn(portBox);
    fragmentHandler.refreshOptions();
    // Iterate through the other database access types
    when(accessBox.getSelectedItem()).thenReturn("JNDI");
    fragmentHandler.refreshOptions();
    when(accessBox.getSelectedItem()).thenReturn("ODBC");
    fragmentHandler.refreshOptions();
    when(accessBox.getSelectedItem()).thenReturn("OCI");
    fragmentHandler.refreshOptions();
    when(accessBox.getSelectedItem()).thenReturn("Plugin");
    fragmentHandler.refreshOptions();
}
Also used : DatabaseInterface(org.pentaho.di.core.database.DatabaseInterface) XulTextbox(org.pentaho.ui.xul.components.XulTextbox) XulListbox(org.pentaho.ui.xul.containers.XulListbox) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) Document(org.pentaho.ui.xul.dom.Document) XulComponent(org.pentaho.ui.xul.XulComponent) Test(org.junit.Test)

Aggregations

XulDomContainer (org.pentaho.ui.xul.XulDomContainer)33 ResourceBundle (java.util.ResourceBundle)14 KettleXulLoader (org.pentaho.di.ui.xul.KettleXulLoader)12 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)11 XulLoader (org.pentaho.ui.xul.XulLoader)11 ToolBar (org.eclipse.swt.widgets.ToolBar)8 Test (org.junit.Test)8 KettleException (org.pentaho.di.core.exception.KettleException)8 XulException (org.pentaho.ui.xul.XulException)8 XulRunner (org.pentaho.ui.xul.XulRunner)7 Shell (org.eclipse.swt.widgets.Shell)6 XulComponent (org.pentaho.ui.xul.XulComponent)6 XulSpoonResourceBundle (org.pentaho.di.ui.spoon.XulSpoonResourceBundle)5 Document (org.pentaho.ui.xul.dom.Document)5 Before (org.junit.Before)2 KettleValueException (org.pentaho.di.core.exception.KettleValueException)2 TransMeta (org.pentaho.di.trans.TransMeta)2 Spoon (org.pentaho.di.ui.spoon.Spoon)2 DatabaseConnectionDialog (org.pentaho.ui.database.DatabaseConnectionDialog)2 XulDialog (org.pentaho.ui.xul.containers.XulDialog)2