Search in sources :

Example 1 with DatasourceType

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

the class WizardDatasourceController method init.

@Bindable
public void init() {
    // $NON-NLS-1$
    clearModelWarningDialog = (XulDialog) document.getElementById("clearModelWarningDialog");
    // $NON-NLS-1$
    csvDataTable = (XulTree) document.getElementById("csvDataTable");
    // $NON-NLS-1$
    modelDataTable = (XulTree) document.getElementById("modelDataTable");
    // $NON-NLS-1$
    errorDialog = (XulDialog) document.getElementById("errorDialog");
    // $NON-NLS-1$
    errorLabel = (XulLabel) document.getElementById("errorLabel");
    // $NON-NLS-1$
    successDialog = (XulDialog) document.getElementById("successDialog");
    // $NON-NLS-1$
    successLabel = (XulLabel) document.getElementById("successLabel");
    // $NON-NLS-1$
    csvDatasourceName = (XulTextbox) document.getElementById("datasourceName");
    // $NON-NLS-1$
    datasourceDialog = (XulDialog) document.getElementById("datasourceDialog");
    // $NON-NLS-1$
    okButton = (XulButton) document.getElementById("datasourceDialog_accept");
    // $NON-NLS-1$
    cancelButton = (XulButton) document.getElementById("datasourceDialog_cancel");
    // $NON-NLS-1$
    datasourceTabbox = (XulTabbox) document.getElementById("datasourceDialogTabbox");
    bf.setBindingType(Binding.Type.ONE_WAY);
    // $NON-NLS-1$ //$NON-NLS-2$
    bf.createBinding(datasourceModel, "validated", okButton, "!disabled");
    bf.setBindingType(Binding.Type.BI_DIRECTIONAL);
    final Binding domainBinding = bf.createBinding(datasourceModel.getGuiStateModel(), "datasourceName", csvDatasourceName, // $NON-NLS-1$ //$NON-NLS-2$
    "value");
    // $NON-NLS-1$ //$NON-NLS-2$
    bf.createBinding(datasourceModel, "datasourceName", csvDatasourceName, "value");
    BindingConvertor<DatasourceType, Integer> tabIndexConvertor = new BindingConvertor<DatasourceType, Integer>() {

        @Override
        public Integer sourceToTarget(DatasourceType value) {
            Integer returnValue = null;
            if (DatasourceType.SQL == value) {
                returnValue = 0;
            } else if (DatasourceType.CSV == value) {
                returnValue = 1;
            } else if (DatasourceType.OLAP == value) {
                return 2;
            } else if (DatasourceType.NONE == value) {
                return 0;
            }
            return returnValue;
        }

        @Override
        public DatasourceType targetToSource(Integer value) {
            DatasourceType type = null;
            if (value == 0) {
                type = DatasourceType.SQL;
            } else if (value == 1) {
                type = DatasourceType.CSV;
            } else if (value == 2) {
                type = DatasourceType.OLAP;
            }
            return type;
        }
    };
    bf.createBinding(datasourceModel, "datasourceType", datasourceTabbox, "selectedIndex", // $NON-NLS-1$ //$NON-NLS-2$
    tabIndexConvertor);
    okButton.setDisabled(true);
    initialize();
    try {
        // Fires the population of the model listbox. This cascades down to the categories and columns. In essence, this
        // call initializes the entire UI.
        domainBinding.fireSourceChanged();
    } catch (Exception e) {
        System.out.println(e.getMessage());
        e.printStackTrace();
    }
}
Also used : Binding(org.pentaho.ui.xul.binding.Binding) DatasourceType(org.pentaho.platform.dataaccess.datasource.DatasourceType) BindingConvertor(org.pentaho.ui.xul.binding.BindingConvertor) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 2 with DatasourceType

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

the class DatasourceModel method setDatasourceType.

@Bindable
public void setDatasourceType(DatasourceType datasourceType) {
    DatasourceType previousVal = this.datasourceType;
    this.datasourceType = datasourceType;
    // $NON-NLS-1$
    this.firePropertyChange("datasourceType", previousVal, datasourceType);
    validate();
}
Also used : DatasourceType(org.pentaho.platform.dataaccess.datasource.DatasourceType) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Aggregations

DatasourceType (org.pentaho.platform.dataaccess.datasource.DatasourceType)2 Bindable (org.pentaho.ui.xul.stereotype.Bindable)2 Binding (org.pentaho.ui.xul.binding.Binding)1 BindingConvertor (org.pentaho.ui.xul.binding.BindingConvertor)1