Search in sources :

Example 1 with IWizardDatasource

use of org.pentaho.platform.dataaccess.datasource.wizard.IWizardDatasource in project data-access by pentaho.

the class MainWizardController method setSelectedDatasource.

@Bindable
public void setSelectedDatasource(IWizardDatasource datasource) {
    IWizardDatasource prevSelection = activeDatasource;
    activeDatasource = datasource;
    if (datasource == null || prevSelection == activeDatasource) {
        return;
    }
    try {
        datasource.activating();
        if (prevSelection != null) {
            steps.removeAll(prevSelection.getSteps());
            prevSelection.deactivating();
        }
        for (int i = 1; i < datasource.getSteps().size(); i++) {
            steps.add(datasource.getSteps().get(i));
        }
        steps.addAll(datasource.getSteps());
        wizardModel.setSelectedDatasource(datasource);
        activeStep = 0;
        updateBindings();
    } catch (XulException e) {
        // To change body of catch statement use File | Settings | File Templates.
        e.printStackTrace();
    }
}
Also used : XulException(org.pentaho.ui.xul.XulException) IWizardDatasource(org.pentaho.platform.dataaccess.datasource.wizard.IWizardDatasource) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 2 with IWizardDatasource

use of org.pentaho.platform.dataaccess.datasource.wizard.IWizardDatasource in project data-access by pentaho.

the class WizardModel method setSelectedDatasource.

@Bindable
public void setSelectedDatasource(IWizardDatasource datasource) {
    IWizardDatasource prevSelection = selectedDatasource;
    selectedDatasource = datasource;
    firePropertyChange("selectedDatasource", prevSelection, selectedDatasource);
}
Also used : IWizardDatasource(org.pentaho.platform.dataaccess.datasource.wizard.IWizardDatasource) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 3 with IWizardDatasource

use of org.pentaho.platform.dataaccess.datasource.wizard.IWizardDatasource in project data-access by pentaho.

the class WizardModel method removeDatasourceByType.

@Override
public void removeDatasourceByType(Class<? extends IWizardDatasource> datasource) {
    ignoredDatasources.add(datasource);
    IWizardDatasource matchedSource = null;
    for (IWizardDatasource source : datasources) {
        if (source.getClass().equals(datasource)) {
            matchedSource = source;
            break;
        }
    }
    if (matchedSource != null) {
        datasources.remove(matchedSource);
    }
}
Also used : IWizardDatasource(org.pentaho.platform.dataaccess.datasource.wizard.IWizardDatasource)

Example 4 with IWizardDatasource

use of org.pentaho.platform.dataaccess.datasource.wizard.IWizardDatasource in project data-access by pentaho.

the class WizardModel method reset.

@Override
public void reset() {
    this.setDatasourceName("");
    this.setSelectedDatasource(datasources.iterator().next());
    this.setReportingOnlyValid(true);
    for (IWizardDatasource source : datasources) {
        source.reset();
    }
}
Also used : IWizardDatasource(org.pentaho.platform.dataaccess.datasource.wizard.IWizardDatasource)

Example 5 with IWizardDatasource

use of org.pentaho.platform.dataaccess.datasource.wizard.IWizardDatasource 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

IWizardDatasource (org.pentaho.platform.dataaccess.datasource.wizard.IWizardDatasource)5 XulException (org.pentaho.ui.xul.XulException)2 Bindable (org.pentaho.ui.xul.stereotype.Bindable)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 DummyDatasource (org.pentaho.platform.dataaccess.datasource.wizard.sources.dummy.DummyDatasource)1 Binding (org.pentaho.ui.xul.binding.Binding)1