Search in sources :

Example 6 with Binding

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

the class MetadataImportDialogController method init.

public void init() {
    try {
        resBundle = (ResourceBundle) super.getXulDomContainer().getResourceBundles().get(0);
        importDialogModel = new MetadataImportDialogModel();
        localizedBundlesTree = (XulTree) document.getElementById("localizedBundlesTree");
        domainIdText = (XulTextbox) document.getElementById("domainIdText");
        domainIdText.addPropertyChangeListener(new DomainIdChangeListener());
        importDialog = (XulDialog) document.getElementById("importDialog");
        fileLabel = (XulLabel) document.getElementById("fileLabel");
        metaFileLocation = (XulLabel) document.getElementById("uploadFileLabel");
        acceptButton = (XulButton) document.getElementById("importDialog_accept");
        hiddenArea = (XulVbox) document.getElementById("metadataImportCard");
        acceptButton.setDisabled(true);
        bf.setBindingType(Binding.Type.ONE_WAY);
        Binding localizedBundlesBinding = bf.createBinding(importDialogModel, "localizedBundles", localizedBundlesTree, "elements");
        localizedBundlesBinding.fireSourceChanged();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : Binding(org.pentaho.ui.xul.binding.Binding) RequestException(com.google.gwt.http.client.RequestException)

Example 7 with Binding

use of org.pentaho.ui.xul.binding.Binding 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 8 with Binding

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

the class BasicAuthProvider method addBindings.

@Override
protected void addBindings(List<Binding> bindings, BindingFactory bf) {
    Binding b = bf.createBinding(this, "password", "password", "value");
    b.setBindingType(Binding.Type.BI_DIRECTIONAL);
    bindings.add(b);
}
Also used : Binding(org.pentaho.ui.xul.binding.Binding)

Example 9 with Binding

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

the class RevisionController method createBindings.

private void createBindings() {
    // $NON-NLS-1$
    filePropertiesTabbox = (XulTabbox) document.getElementById("file-properties-tabs");
    // $NON-NLS-1$
    historyTab = (XulTab) document.getElementById("history");
    // $NON-NLS-1$
    revisionTable = (XulTree) document.getElementById("revision-table");
    // $NON-NLS-1$
    folderTree = (XulTree) document.getElementById("folder-tree");
    // $NON-NLS-1$
    fileTable = (XulTree) document.getElementById("file-table");
    // Hide the history tab if versioning is off
    historyTab.setVisible(false);
    bf.setBindingType(Binding.Type.ONE_WAY);
    BindingConvertor<int[], Boolean> forButtons = new BindingConvertor<int[], Boolean>() {

        @Override
        public Boolean sourceToTarget(int[] value) {
            return value != null && !(value.length <= 0);
        }

        @Override
        public int[] targetToSource(Boolean value) {
            return null;
        }
    };
    Binding openButtonBinding = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    bf.createBinding(revisionTable, "selectedRows", OPEN_REVISION_BUTTON, "!disabled", forButtons);
    Binding restoreButtonBinding = // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    bf.createBinding(revisionTable, "selectedRows", RESTORE_REVISION_BUTTON, "!disabled", forButtons);
    bf.setBindingType(Binding.Type.ONE_WAY);
    // $NON-NLS-1$  //$NON-NLS-2$
    bf.createBinding(folderTree, "selectedItems", this, "historyTabVisibility");
    // $NON-NLS-1$ //$NON-NLS-2$
    revisionBinding = bf.createBinding(this, "revisionObjects", revisionTable, "elements");
    revisionBinding = // $NON-NLS-1$ //$NON-NLS-2$
    bf.createBinding(// $NON-NLS-1$ //$NON-NLS-2$
    browseController, // $NON-NLS-1$ //$NON-NLS-2$
    "repositoryItems", // $NON-NLS-1$ //$NON-NLS-2$
    this, // $NON-NLS-1$ //$NON-NLS-2$
    "revisionObjects", new BindingConvertor<List<UIRepositoryObject>, UIRepositoryObjectRevisions>() {

        private void disableButtons() {
            document.getElementById(OPEN_REVISION_BUTTON).setDisabled(true);
            document.getElementById(RESTORE_REVISION_BUTTON).setDisabled(true);
        }

        @Override
        public UIRepositoryObjectRevisions sourceToTarget(List<UIRepositoryObject> ro) {
            if (ro == null || ro.isEmpty() || !masterVersioningEnabled) {
                return new UIRepositoryObjectRevisions();
            }
            if (ro.get(0) instanceof UIRepositoryDirectory) {
                historyTab.setVisible(false);
                filePropertiesTabbox.setSelectedIndex(0);
                disableButtons();
                return null;
            }
            UIRepositoryObjectRevisions revisions = null;
            try {
                UIRepositoryContent rc = (UIRepositoryContent) ro.get(0);
                if (rc instanceof IRevisionObject) {
                    Boolean versioningEnabled = ((IRevisionObject) rc).getVersioningEnabled();
                    // Show/hide the Verison History tab
                    historyTab.setVisible(versioningEnabled);
                    if (!versioningEnabled) {
                        return new UIRepositoryObjectRevisions();
                    }
                    Boolean versionCommentEnabled = ((IRevisionObject) rc).getVersionCommentEnabled();
                    // Show/Hide the version comment column
                    setRevisionTableColumns(versionCommentEnabled);
                    revisions = ((IRevisionObject) rc).getRevisions();
                } else {
                    throw new IllegalStateException(BaseMessages.getString(PKG, // $NON-NLS-1$
                    "RevisionsController.RevisionsNotSupported"));
                }
            } catch (KettleException e) {
                if (mainController == null || !mainController.handleLostRepository(e)) {
                    // convert to runtime exception so it bubbles up through the UI
                    throw new RuntimeException(e);
                }
            }
            return revisions;
        }

        @Override
        public List<UIRepositoryObject> targetToSource(UIRepositoryObjectRevisions elements) {
            return null;
        }
    });
    try {
        openButtonBinding.fireSourceChanged();
        restoreButtonBinding.fireSourceChanged();
        revisionBinding.fireSourceChanged();
    } catch (Exception e) {
        if (mainController == null || !mainController.handleLostRepository(e)) {
            // convert to runtime exception so it bubbles up through the UI
            throw new RuntimeException(e);
        }
    }
}
Also used : Binding(org.pentaho.ui.xul.binding.Binding) UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) KettleException(org.pentaho.di.core.exception.KettleException) IRevisionObject(org.pentaho.di.ui.repository.pur.repositoryexplorer.IRevisionObject) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) BindingConvertor(org.pentaho.ui.xul.binding.BindingConvertor) XulException(org.pentaho.ui.xul.XulException) KettleException(org.pentaho.di.core.exception.KettleException) ControllerInitializationException(org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException) UIRepositoryObject(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryObject) UIRepositoryObjectRevisions(org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryObjectRevisions) ArrayList(java.util.ArrayList) List(java.util.List)

Example 10 with Binding

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

the class DataServiceTestController method bindSelectedLogLevel.

private void bindSelectedLogLevel(BindingFactory bindingFactory) throws InvocationTargetException, XulException {
    Binding logBinding = bindingFactory.createBinding(model, "logLevel", logLevels, "selectedItem");
    logBinding.setBindingType(Binding.Type.BI_DIRECTIONAL);
    BindingConvertor logLevelConverter = new BindingConvertor<LogLevel, String>() {

        @Override
        public String sourceToTarget(LogLevel value) {
            return value.getDescription();
        }

        @Override
        public LogLevel targetToSource(String value) {
            for (LogLevel level : LogLevel.values()) {
                if (level.getDescription().equals(value)) {
                    return level;
                }
            }
            throw new IllegalArgumentException(String.format("'%s' does not correspond to a valid LogLevel value.", value));
        }
    };
    logBinding.setConversion(logLevelConverter);
    logBinding.initialize();
    logBinding.fireSourceChanged();
}
Also used : Binding(org.pentaho.ui.xul.binding.Binding) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) BindingConvertor(org.pentaho.ui.xul.binding.BindingConvertor) LogLevel(org.pentaho.di.core.logging.LogLevel)

Aggregations

Binding (org.pentaho.ui.xul.binding.Binding)16 BindingConvertor (org.pentaho.ui.xul.binding.BindingConvertor)6 XulException (org.pentaho.ui.xul.XulException)5 RequestException (com.google.gwt.http.client.RequestException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 ArrayList (java.util.ArrayList)2 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)2 XulTextbox (org.pentaho.ui.xul.components.XulTextbox)2 Bindable (org.pentaho.ui.xul.stereotype.Bindable)2 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1 List (java.util.List)1 Matchers.anyString (org.mockito.Matchers.anyString)1 KettleException (org.pentaho.di.core.exception.KettleException)1 LogLevel (org.pentaho.di.core.logging.LogLevel)1 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)1 IRevisionObject (org.pentaho.di.ui.repository.pur.repositoryexplorer.IRevisionObject)1 UIRepositoryObjectRevisions (org.pentaho.di.ui.repository.pur.repositoryexplorer.model.UIRepositoryObjectRevisions)1 ControllerInitializationException (org.pentaho.di.ui.repository.repositoryexplorer.ControllerInitializationException)1 UIRepositoryContent (org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent)1