Search in sources :

Example 56 with XulException

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

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

the class GwtDatasourceEditorEntryPoint method overwriteFileDialog.

/**
 * used to handle the overwrite in repository message
 *
 * @param parentFormPanel
 * @param message
 * @param controller
 */
public void overwriteFileDialog(final FormPanel parentFormPanel, String message, final IOverwritableController controller) {
    // Experiment
    XulConfirmBox confirm = null;
    try {
        confirm = (XulConfirmBox) wizard.getMainWizardContainer().getDocumentRoot().createElement("confirmbox");
    } catch (XulException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    confirm.setTitle("Confirmation");
    confirm.setMessage(message);
    confirm.setAcceptLabel("Ok");
    confirm.setCancelLabel("Cancel");
    confirm.addDialogCallback(new XulDialogCallback<String>() {

        public void onClose(XulComponent component, Status status, String value) {
            if (status == XulDialogCallback.Status.ACCEPT) {
                controller.setOverwrite(true);
                controller.removeHiddenPanels();
                controller.buildAndSetParameters();
                parentFormPanel.submit();
            }
        }

        public void onError(XulComponent component, Throwable err) {
            return;
        }
    });
    confirm.open();
}
Also used : XulException(org.pentaho.ui.xul.XulException) XulConfirmBox(org.pentaho.ui.xul.components.XulConfirmBox) XulComponent(org.pentaho.ui.xul.XulComponent)

Example 58 with XulException

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

the class AnalysisImportDialogController method overwriteFileDialog.

@Bindable
public void overwriteFileDialog(int code) {
    if (code != PUBLISH_SCHEMA_CATALOG_EXISTS_ERROR && code != PUBLISH_SCHEMA_EXISTS_ERROR) {
        return;
    }
    String msg = messages.getString("Mondrian.OVERWRITE_EXISTING_SCHEMA");
    if (PUBLISH_SCHEMA_CATALOG_EXISTS_ERROR == code) {
        msg = messages.getString("Mondrian.OVERWRITE_EXISTING_CATALOG");
    }
    XulConfirmBox confirm = null;
    try {
        confirm = (XulConfirmBox) document.createElement("confirmbox");
    } catch (XulException e) {
        Window.alert(e.getMessage());
    }
    confirm.setTitle("Confirmation");
    confirm.setMessage(msg);
    confirm.setAcceptLabel("Ok");
    confirm.setCancelLabel("Cancel");
    confirm.addDialogCallback(new XulDialogCallback<String>() {

        public void onClose(XulComponent component, Status status, String value) {
            if (status == XulDialogCallback.Status.ACCEPT) {
                overwrite = true;
                removeHiddenPanels();
                buildAndSetParameters();
                formPanel.submit();
            }
        }

        public void onError(XulComponent component, Throwable err) {
            return;
        }
    });
    confirm.open();
}
Also used : XulException(org.pentaho.ui.xul.XulException) XulConfirmBox(org.pentaho.ui.xul.components.XulConfirmBox) XulComponent(org.pentaho.ui.xul.XulComponent) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 59 with XulException

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

the class DatasourceAdminDialogController method getDatasourceTypes.

private void getDatasourceTypes() {
    List<String> datasourceTypes = manager.getTypes();
    // Clear out the current component list
    List<XulComponent> components = datasourceTypeMenuPopup.getChildNodes();
    // remove exist import and plugins
    for (int i = 0; i < components.size(); i++) {
        XulComponent component = components.get(i);
        if (component.getId() == null) {
            continue;
        }
        if (component.getId().startsWith("import") || component.getId().startsWith("plugin")) {
            // remove import and plugins items
            datasourceTypeMenuPopup.removeComponent(component);
        }
    }
    // find separator
    components = datasourceTypeMenuPopup.getChildNodes();
    int beforePlugins = 0;
    XulComponent beforePluginsMenuItem = null;
    for (int i = 0; i < components.size(); i++) {
        XulComponent component = components.get(i);
        if ("beforePlugins".equals(component.getId())) {
            beforePlugins = i;
            beforePluginsMenuItem = component;
        }
    }
    List<IDatasourceInfo> datasourceInfoList = datasourceAdminDialogModel.getDatasourcesList();
    // Add "Import..." items first
    for (String datasourceType : datasourceTypes) {
        IUIDatasourceAdminService datasourceAdminService = manager.getService(datasourceType);
        if (datasourceAdminService instanceof DSWUIDatasourceService) {
            // Data Source Wizard
            continue;
        }
        if (datasourceAdminService instanceof JdbcDatasourceService) {
            // JDBC
            continue;
        }
        if (// Analysis - import
        !(datasourceAdminService instanceof MondrianUIDatasourceService) && !(datasourceAdminService instanceof MetadataUIDatasourceService)) {
            // Metadata - import
            continue;
        }
        if (!datasourceAdminService.isCreatable()) {
            continue;
        }
        XulMenuitem menuItem;
        try {
            String displayName = DatasourceInfo.getDisplayType(datasourceType, messageBundle);
            String label = messageBundle.getString(IMPORT_MSG_ID, displayName);
            menuItem = (XulMenuitem) document.createElement("menuitem");
            menuItem.setLabel(label);
            menuItem.setCommand(getName() + ".launchNewUI(\"" + datasourceType + "\")");
            menuItem.setId("import" + datasourceType);
            datasourceTypeMenuPopup.addChildAt(menuItem, beforePlugins++);
        } catch (XulException e) {
            throw new RuntimeException(e);
        }
    }
    // Add plugin items
    boolean hasPlugins = false;
    beforePlugins++;
    for (String datasourceType : datasourceTypes) {
        IUIDatasourceAdminService datasourceAdminService = manager.getService(datasourceType);
        if (datasourceAdminService instanceof DSWUIDatasourceService) {
            // Data Source Wizard
            continue;
        }
        if (datasourceAdminService instanceof JdbcDatasourceService) {
            // JDBC
            continue;
        }
        if (datasourceAdminService instanceof MondrianUIDatasourceService) {
            // Analysis - import
            continue;
        } else if (datasourceAdminService instanceof MetadataUIDatasourceService) {
            // Metadata - import
            continue;
        }
        if (!datasourceAdminService.isCreatable()) {
            continue;
        }
        hasPlugins = true;
        XulMenuitem menuItem;
        try {
            String displayName = DatasourceInfo.getDisplayType(datasourceType, messageBundle);
            String label = messageBundle.getString(PLUGIN_MSG_ID, displayName);
            menuItem = (XulMenuitem) document.createElement("menuitem");
            menuItem.setLabel(label);
            menuItem.setCommand(getName() + ".launchNewUI(\"" + datasourceType + "\")");
            menuItem.setId("plugin" + datasourceType);
            datasourceTypeMenuPopup.addChildAt(menuItem, beforePlugins++);
        } catch (XulException e) {
            throw new RuntimeException(e);
        }
    }
    beforePluginsMenuItem.setVisible(hasPlugins);
    datasourceAdminDialogModel.setDatasourceTypeList(datasourceTypes);
}
Also used : JdbcDatasourceService(org.pentaho.platform.dataaccess.datasource.ui.service.JdbcDatasourceService) GwtDatasourceEditorEntryPoint(org.pentaho.platform.dataaccess.datasource.wizard.GwtDatasourceEditorEntryPoint) IUIDatasourceAdminService(org.pentaho.platform.dataaccess.datasource.ui.service.IUIDatasourceAdminService) XulException(org.pentaho.ui.xul.XulException) MondrianUIDatasourceService(org.pentaho.platform.dataaccess.datasource.ui.service.MondrianUIDatasourceService) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) XulComponent(org.pentaho.ui.xul.XulComponent) DSWUIDatasourceService(org.pentaho.platform.dataaccess.datasource.ui.service.DSWUIDatasourceService) IDatasourceInfo(org.pentaho.platform.dataaccess.datasource.IDatasourceInfo) MetadataUIDatasourceService(org.pentaho.platform.dataaccess.datasource.ui.service.MetadataUIDatasourceService)

Example 60 with XulException

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

the class MainWizardController method init.

public void init() {
    // We need the SelectDatasourceStep at all times, add it now
    wizardDialog = (XulDialog) document.getElementById("main_wizard_window");
    summaryDialog = (XulDialog) document.getElementById("summaryDialog");
    finishButton = (XulButton) document.getElementById(FINISH_BTN_ELEMENT_ID);
    // $NON-NLS-1$
    datasourceName = (XulTextbox) document.getElementById("datasourceName");
    bf.createBinding(datasourceName, "value", wizardModel, "datasourceName");
    wizardModel.addPropertyChangeListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
            if (propertyChangeEvent.getPropertyName().equals("datasourceName")) {
                steps.get(activeStep).setValid(steps.get(activeStep).isValid());
            }
        }
    });
    bf.setBindingType(Binding.Type.ONE_WAY);
    datatypeMenuList = (XulMenuList) document.getElementById("datatypeMenuList");
    Binding datasourceBinding = bf.createBinding(wizardModel, "datasources", datatypeMenuList, "elements");
    bf.setBindingType(Binding.Type.ONE_WAY);
    bf.createBinding(datatypeMenuList, "selectedItem", wizardModel, "selectedDatasource");
    bf.setBindingType(Binding.Type.ONE_WAY);
    bf.createBinding(wizardModel, "selectedDatasource", this, "selectedDatasource");
    bf.createBinding(this, ACTIVE_STEP_PROPERTY_NAME, BACK_BTN_ELEMENT_ID, DISABLED_PROPERTY_NAME, new BackButtonBindingConverter());
    dummyDatasource = ((DummyDatasource) wizardModel.getDatasources().iterator().next());
    activeDatasource = dummyDatasource;
    selectDatasourceStep = dummyDatasource.getSelectDatasourceStep();
    try {
        for (IWizardDatasource datasource : wizardModel.getDatasources()) {
            datasource.init(getXulDomContainer(), wizardModel);
        }
        steps.add(selectDatasourceStep);
        selectDatasourceStep.activating();
        setActiveStep(0);
        datasourceBinding.fireSourceChanged();
        setSelectedDatasource(dummyDatasource);
        datasourceService.getDatasourceIllegalCharacters(new XulServiceCallback<String>() {

            @Override
            public void success(String retVal) {
            }

            @Override
            public void error(String message, Throwable error) {
            }
        });
    } catch (XulException e) {
        MessageHandler.getInstance().showErrorDialog("Error", e.getMessage());
        e.printStackTrace();
    } catch (InvocationTargetException e) {
        MessageHandler.getInstance().showErrorDialog("Error", e.getMessage());
        e.printStackTrace();
    }
}
Also used : Binding(org.pentaho.ui.xul.binding.Binding) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) XulException(org.pentaho.ui.xul.XulException) IWizardDatasource(org.pentaho.platform.dataaccess.datasource.wizard.IWizardDatasource) DummyDatasource(org.pentaho.platform.dataaccess.datasource.wizard.sources.dummy.DummyDatasource) InvocationTargetException(java.lang.reflect.InvocationTargetException)

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