Search in sources :

Example 1 with RepositoriesHelper

use of org.pentaho.di.ui.repository.RepositoriesHelper in project pentaho-kettle by pentaho.

the class RepositoriesController method createBindings.

private void createBindings() {
    loginDialog = (XulDialog) document.getElementById("repository-login-dialog");
    repositoryEditButton = (XulButton) document.getElementById("repository-edit");
    repositoryRemoveButton = (XulButton) document.getElementById("repository-remove");
    username = (XulTextbox) document.getElementById("user-name");
    userPassword = (XulTextbox) document.getElementById("user-password");
    availableRepositories = (XulListbox) document.getElementById("available-repository-list");
    showAtStartup = (XulCheckbox) document.getElementById("show-login-dialog-at-startup");
    okButton = (XulButton) document.getElementById("repository-login-dialog_accept");
    cancelButton = (XulButton) document.getElementById("repository-login-dialog_cancel");
    bf.setBindingType(Binding.Type.BI_DIRECTIONAL);
    bf.createBinding(loginModel, "username", username, "value");
    bf.createBinding(loginModel, "password", userPassword, "value");
    bf.createBinding(loginModel, "availableRepositories", availableRepositories, "elements");
    bf.createBinding(loginModel, "selectedRepository", availableRepositories, "selectedItem");
    bf.createBinding(loginModel, "showDialogAtStartup", showAtStartup, "checked");
    bf.setBindingType(Binding.Type.ONE_WAY);
    bf.createBinding(loginModel, "valid", okButton, "!disabled");
    BindingConvertor<RepositoryMeta, Boolean> buttonConverter = new BindingConvertor<RepositoryMeta, Boolean>() {

        @Override
        public Boolean sourceToTarget(RepositoryMeta value) {
            return (value == null);
        }

        @Override
        public RepositoryMeta targetToSource(Boolean value) {
            return null;
        }
    };
    BindingConvertor<RepositoryMeta, Boolean> userpassConverter = new BindingConvertor<RepositoryMeta, Boolean>() {

        @Override
        public Boolean sourceToTarget(RepositoryMeta value) {
            return (value == null) || !value.getRepositoryCapabilities().supportsUsers();
        }

        @Override
        public RepositoryMeta targetToSource(Boolean value) {
            return null;
        }
    };
    bf.createBinding(loginModel, "selectedRepository", username, "disabled", userpassConverter);
    bf.createBinding(loginModel, "selectedRepository", userPassword, "disabled", userpassConverter);
    bf.createBinding(loginModel, "selectedRepository", repositoryEditButton, "disabled", buttonConverter);
    bf.createBinding(loginModel, "selectedRepository", repositoryRemoveButton, "disabled", buttonConverter);
    final Shell loginShell = (Shell) loginDialog.getRootObject();
    helper = new RepositoriesHelper(loginModel, document, loginShell);
    helper.setPreferredRepositoryName(preferredRepositoryName);
    helper.getMetaData();
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) Shell(org.eclipse.swt.widgets.Shell) RepositoriesHelper(org.pentaho.di.ui.repository.RepositoriesHelper) BindingConvertor(org.pentaho.ui.xul.binding.BindingConvertor)

Aggregations

Shell (org.eclipse.swt.widgets.Shell)1 RepositoryMeta (org.pentaho.di.repository.RepositoryMeta)1 RepositoriesHelper (org.pentaho.di.ui.repository.RepositoriesHelper)1 BindingConvertor (org.pentaho.ui.xul.binding.BindingConvertor)1