Search in sources :

Example 16 with Document

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

the class DataServiceRemapStepChooserDialogTest method testOpen.

@Test
public void testOpen() throws XulException, KettleException {
    Shell shell = mock(Shell.class);
    final Document document = mock(Document.class);
    SwtDialog swtDialog = mock(SwtDialog.class);
    when(document.getElementById(DataServiceRemapStepChooserDialog.XUL_DIALOG_ID)).thenReturn(swtDialog);
    DataServiceRemapStepChooserDialogController controller = mock(DataServiceRemapStepChooserDialogController.class);
    DataServiceRemapStepChooserDialog dialog = spy(new DataServiceRemapStepChooserDialog(shell, controller));
    doAnswer(new Answer() {

        private int invocations = 0;

        @Override
        public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
            if (invocations == 0) {
                invocations++;
                return document;
            } else {
                throw new XulException("");
            }
        }
    }).when(dialog).initXul(same(shell), any(XulLoader.class), any(XulRunner.class));
    dialog.open();
    verify(dialog).initXul(same(shell), any(XulLoader.class), any(XulRunner.class));
    verify(swtDialog).show();
    try {
        dialog.open();
    } catch (Exception e) {
        Assert.assertTrue(e instanceof KettleException);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) DataServiceRemapStepChooserDialogController(org.pentaho.di.trans.dataservice.ui.controller.DataServiceRemapStepChooserDialogController) XulLoader(org.pentaho.ui.xul.XulLoader) Document(org.pentaho.ui.xul.dom.Document) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) Shell(org.eclipse.swt.widgets.Shell) XulException(org.pentaho.ui.xul.XulException) SwtDialog(org.pentaho.ui.xul.swt.tags.SwtDialog) InvocationOnMock(org.mockito.invocation.InvocationOnMock) XulRunner(org.pentaho.ui.xul.XulRunner) Test(org.junit.Test)

Example 17 with Document

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

the class EmbeddedWizard method xulLoaded.

/*
   * (non-Javadoc)
   * 
   * @see org.pentaho.ui.xul.gwt.util.IXulLoaderCallback#xulLoaded(org.pentaho.ui.xul.gwt.GwtXulRunner)
   */
public void xulLoaded(GwtXulRunner runner) {
    mainWizardContainer = runner.getXulDomContainers().get(0);
    Document rootDocument = mainWizardContainer.getDocumentRoot();
    BindingFactory bf = new GwtBindingFactory(rootDocument);
    ResourceBundle resBundle = (ResourceBundle) mainWizardContainer.getResourceBundles().get(0);
    datasourceMessages = new GwtDatasourceMessages();
    datasourceMessages.setMessageBundle(resBundle);
    MessageHandler.getInstance().setMessages(datasourceMessages);
    connectionController = new ConnectionController(rootDocument);
    connectionController.setDatasourceModel(datasourceModel);
    // connectionController.setService(connectionService);
    mainWizardContainer.addEventHandler(connectionController);
    summaryDialogController.setBindingFactory(bf);
    mainWizardContainer.addEventHandler(summaryDialogController);
    wizardController = new MainWizardController(bf, wizardModel, datasourceService);
    mainWizardContainer.addEventHandler(wizardController);
    dialog = (XulDialog) rootDocument.getElementById(WIZARD_DIALOG_ID);
    MessageHandler.getInstance().setWizardDialog(dialog);
    datasourceController = new WizardDatasourceController();
    datasourceController.setBindingFactory(bf);
    datasourceController.setDatasourceMessages(datasourceMessages);
    mainWizardContainer.addEventHandler(datasourceController);
    mainWizardContainer.addEventHandler(MessageHandler.getInstance());
    // add the steps ..
    // physicalStep = new RelationalPhysicalStep(datasourceService, connectionService, datasourceMessages, this);
    wizardController.addWizardListener(this);
    // Controller for the File Import functionality
    FileImportController fileImportController = new FileImportController(datasourceModel, datasourceMessages);
    mainWizardContainer.addEventHandler(fileImportController);
    // init other controllers
    fileImportController.init();
    MessageHandler.getInstance().init();
    summaryDialogController.init();
    // Create the gui
    try {
        // new WizardContentPanel(wizardController).addContent(mainWizardContainer);
        wizardController.init();
        initialized = true;
    } catch (Exception throwable) {
        throwable.printStackTrace();
    }
    // Remap the upload action in development mode
    if (GWT.isScript() == false) {
        // $NON-NLS-1$
        XulFileUpload upload = (XulFileUpload) rootDocument.getElementById("fileUpload");
        // $NON-NLS-1$
        upload.setAction(GWT.getModuleBaseURL() + "UploadService");
    }
    initialized = true;
    if (asyncConstructorListener != null) {
        asyncConstructorListener.asyncConstructorDone(this);
    }
}
Also used : FileImportController(org.pentaho.platform.dataaccess.datasource.wizard.controllers.FileImportController) XulFileUpload(org.pentaho.ui.xul.components.XulFileUpload) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory) MainWizardController(org.pentaho.platform.dataaccess.datasource.wizard.controllers.MainWizardController) ResourceBundle(org.pentaho.gwt.widgets.client.utils.i18n.ResourceBundle) Document(org.pentaho.ui.xul.dom.Document) ConnectionController(org.pentaho.platform.dataaccess.datasource.wizard.controllers.ConnectionController) WizardDatasourceController(org.pentaho.platform.dataaccess.datasource.wizard.controllers.WizardDatasourceController) DatasourceServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory)

Aggregations

Document (org.pentaho.ui.xul.dom.Document)17 Test (org.junit.Test)7 KettleException (org.pentaho.di.core.exception.KettleException)7 XulException (org.pentaho.ui.xul.XulException)7 XulDomContainer (org.pentaho.ui.xul.XulDomContainer)5 SwtDialog (org.pentaho.ui.xul.swt.tags.SwtDialog)5 Shell (org.eclipse.swt.widgets.Shell)4 XulComponent (org.pentaho.ui.xul.XulComponent)4 XulRunner (org.pentaho.ui.xul.XulRunner)4 XulMenuitem (org.pentaho.ui.xul.components.XulMenuitem)4 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 XulMenu (org.pentaho.ui.xul.containers.XulMenu)3 Action (org.eclipse.jface.action.Action)2 Before (org.junit.Before)2 NotePadMeta (org.pentaho.di.core.NotePadMeta)2 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)2 Point (org.pentaho.di.core.gui.Point)2