Search in sources :

Example 6 with BindingFactory

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

the class DataServiceDialogController method init.

public void init() throws InvocationTargetException, XulException {
    BindingFactory bindingFactory = getBindingFactory();
    XulTextbox serviceName = getElementById("service-name");
    XulMenuList<String> steps = getElementById("trans-steps");
    XulRadio streamingModeRadio = getElementById("streaming-type-radio");
    XulRadio normalModeRadio = getElementById("regular-type-radio");
    steps.setElements(ImmutableList.copyOf(model.getTransMeta().getStepNames()));
    bindingFactory.setBindingType(Binding.Type.BI_DIRECTIONAL);
    bindingFactory.createBinding(model, "serviceStep", steps, "selectedItem").fireSourceChanged();
    bindingFactory.createBinding(model, "serviceName", serviceName, "value").fireSourceChanged();
    bindingFactory.createBinding(model, "streaming", streamingModeRadio, "selected").fireSourceChanged();
    bindingFactory.createBinding(model, "!streaming", normalModeRadio, "selected").fireSourceChanged();
}
Also used : XulRadio(org.pentaho.ui.xul.components.XulRadio) XulTextbox(org.pentaho.ui.xul.components.XulTextbox) BaseMessages.getString(org.pentaho.di.i18n.BaseMessages.getString) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory)

Example 7 with BindingFactory

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

the class TablesSelectionStep method setBindings.

public void setBindings() {
    BindingFactory bf = new GwtBindingFactory(document);
    bf.createBinding(this.joinGuiModel.getAvailableTables(), "children", this.availableTables, "elements");
    bf.createBinding(this.joinGuiModel.getSelectedTables(), "children", this.selectedTables, "elements");
    bf.createBinding(this.joinGuiModel.getSelectedTables(), "children", this.factTables, "elements", new BindingConvertor<AbstractModelList<JoinTableModel>, Collection<JoinTableModel>>() {

        @Override
        public Collection<JoinTableModel> sourceToTarget(AbstractModelList<JoinTableModel> list) {
            List<JoinTableModel> tables = new ArrayList<JoinTableModel>();
            tables.addAll(list.asList());
            JoinTableModel emptyOption = new JoinTableModel();
            emptyOption.setName(MessageHandler.getString("multitable.SELECT_TABLE"));
            // Empty option must be always 0.
            tables.add(0, emptyOption);
            return tables;
        }

        @Override
        public AbstractModelList<JoinTableModel> targetToSource(final Collection<JoinTableModel> list) {
            return null;
        }
    });
    bf.createBinding(this.joinGuiModel, "schemas", this.schemas, "elements", new BindingConvertor<List<String>, Collection<String>>() {

        @Override
        public Collection<String> sourceToTarget(List<String> list) {
            List<String> tables = new ArrayList<String>();
            tables.addAll(list);
            return tables;
        }

        @Override
        public List<String> targetToSource(final Collection<String> list) {
            return null;
        }
    });
    bf.createBinding(this.factTables, "selectedIndex", this.joinGuiModel, "factTable", new BindingConvertor<Integer, JoinTableModel>() {

        @Override
        public JoinTableModel sourceToTarget(final Integer index) {
            if (index == -1) {
                return null;
            }
            // Index 0 represents [select table] option.
            // To be valid index must not be 0.
            checkValidState();
            int i = (int) index;
            i--;
            return i < 0 ? null : joinGuiModel.getSelectedTables().get(i);
        }

        @Override
        public Integer targetToSource(final JoinTableModel value) {
            return joinGuiModel.getSelectedTables().indexOf(value);
        }
    });
    // use a binding to handle the visibility state of the schema type radio group
    try {
        bf.createBinding(joinGuiModel, "doOlap", "factTableVbox", "visible").fireSourceChanged();
    } catch (Exception e) {
        e.printStackTrace();
        mtdatasource.displayErrors(new JoinError(e.getMessage(), e.getMessage()));
    }
}
Also used : XulException(org.pentaho.ui.xul.XulException) JoinTableModel(org.pentaho.agilebi.modeler.models.JoinTableModel) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory) Collection(java.util.Collection) AbstractModelList(org.pentaho.ui.xul.util.AbstractModelList) XulMenuList(org.pentaho.ui.xul.components.XulMenuList) ArrayList(java.util.ArrayList) List(java.util.List) AbstractModelList(org.pentaho.ui.xul.util.AbstractModelList) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory)

Example 8 with BindingFactory

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

the class GwtDatasourceAdminDialog method xulLoaded.

public void xulLoaded(final GwtXulRunner runner) {
    try {
        GwtXulDomContainer container = (GwtXulDomContainer) runner.getXulDomContainers().get(0);
        BindingFactory bf = new GwtBindingFactory(container.getDocumentRoot());
        ResourceBundle resBundle = (ResourceBundle) container.getResourceBundles().get(0);
        datasourceMessages = new GwtDatasourceMessages();
        datasourceMessages.setMessageBundle(resBundle);
        datasourceAdminDialogController = new DatasourceAdminDialogController();
        datasourceAdminDialogController.setBindingFactory(bf);
        datasourceAdminDialogController.setDatasourceServiceManager(genericDatasourceServiceManager);
        datasourceAdminDialogController.setModelerService(modelerService);
        datasourceAdminDialogController.setDSWService(dswService);
        datasourceAdminDialogController.setEntryPoint(entryPoint);
        datasourceAdminDialogController.setMessageBundle(datasourceMessages);
        container.addEventHandler(datasourceAdminDialogController);
        runner.initialize();
        runner.start();
        initialized = true;
        if (constructorListener != null) {
            constructorListener.asyncConstructorDone(this);
        }
        datasourceAdminDialogController.onDialogReady();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : GwtDatasourceMessages(org.pentaho.platform.dataaccess.datasource.wizard.GwtDatasourceMessages) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory) ResourceBundle(org.pentaho.gwt.widgets.client.utils.i18n.ResourceBundle) GwtXulDomContainer(org.pentaho.ui.xul.gwt.GwtXulDomContainer) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory)

Example 9 with BindingFactory

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

the class GwtImportDialog method xulLoaded.

public void xulLoaded(GwtXulRunner runner) {
    try {
        XulDomContainer container = runner.getXulDomContainers().get(0);
        BindingFactory bf = new GwtBindingFactory(container.getDocumentRoot());
        ResourceBundle resBundle = (ResourceBundle) container.getResourceBundles().get(0);
        datasourceMessages = new GwtDatasourceMessages();
        datasourceMessages.setMessageBundle(resBundle);
        metadataImportDialogController = new MetadataImportDialogController();
        metadataImportDialogController.setBindingFactory(bf);
        container.addEventHandler(metadataImportDialogController);
        metadataImportDialogController.setDatasourceMessages(datasourceMessages);
        analysisImportDialogController = new AnalysisImportDialogController();
        analysisImportDialogController.setBindingFactory(bf);
        container.addEventHandler(analysisImportDialogController);
        analysisImportDialogController.setDatasourceMessages(datasourceMessages);
        importDialogController = new ImportDialogController();
        importDialogController.addImportPerspective(0, metadataImportDialogController);
        importDialogController.addImportPerspective(1, analysisImportDialogController);
        container.addEventHandler(importDialogController);
        runner.initialize();
        runner.start();
        importDialogController.init();
        metadataImportDialogController.init();
        analysisImportDialogController.init();
        if (constructorListener != null) {
            constructorListener.asyncConstructorDone(this);
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : GwtDatasourceMessages(org.pentaho.platform.dataaccess.datasource.wizard.GwtDatasourceMessages) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory) ResourceBundle(org.pentaho.gwt.widgets.client.utils.i18n.ResourceBundle) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory)

Example 10 with BindingFactory

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

the class ModelerDialog method xulLoaded.

public void xulLoaded(GwtXulRunner gwtXulRunner) {
    container = gwtXulRunner.getXulDomContainers().get(0);
    container.addEventHandler(this);
    BogoPojo bogo = new BogoPojo();
    service.gwtWorkaround(bogo, new XulServiceCallback<BogoPojo>() {

        public void success(BogoPojo retVal) {
        }

        public void error(String message, Throwable error) {
        }
    });
    datasourceService = new DSWDatasourceServiceGwtImpl();
    // connectionService = new ConnectionServiceGwtImpl();
    csvService = (ICsvDatasourceServiceAsync) GWT.create(ICsvDatasourceService.class);
    if (wizard == null) {
        wizard = new EmbeddedWizard(false);
        wizard.setDatasourceService(datasourceService);
        // wizard.setConnectionService(connectionService);
        wizard.setCsvDatasourceService(csvService);
        wizard.init(null);
    }
    messages = new GwtModelerMessages((ResourceBundle) container.getResourceBundles().get(0));
    try {
        ModelerMessagesHolder.setMessages(messages);
    } catch (Exception ignored) {
    // Messages may have been set earlier, ignore.
    }
    IModelerWorkspaceHelper workspacehelper = model.getWorkspaceHelper();
    controller = new ModelerController(model);
    controller.setWorkspaceHelper(workspacehelper);
    // controller.setMessages(messages);
    final BindingFactory bf = new GwtBindingFactory(container.getDocumentRoot());
    controller.setBindingFactory(bf);
    container.addEventHandler(controller);
    try {
        controller.init();
    } catch (ModelerException e) {
        e.printStackTrace();
    }
    bf.setBindingType(Binding.Type.ONE_WAY);
    bf.createBinding(model, "valid", "modeler_dialog_accept", "disabled", new BindingConvertor<Boolean, Boolean>() {

        @Override
        public Boolean sourceToTarget(Boolean value) {
            return !value;
        }

        @Override
        public Boolean targetToSource(Boolean value) {
            return !value;
        }
    });
    bf.setBindingType(Binding.Type.BI_DIRECTIONAL);
    // go get the geocontext from the server. Prop forms are initialized after this call returns as they
    // may need them to create the UI
    datasourceService.getGeoContext(new XulServiceCallback<GeoContext>() {

        public void success(GeoContext geoContext) {
            model.setGeoContext(geoContext);
            ModelerUiHelper.configureControllers(container, model, bf, controller, new ColResolverController());
            ModelerDialog.this.constructorListener.asyncConstructorDone(ModelerDialog.this);
        }

        public void error(String s, Throwable throwable) {
            throwable.printStackTrace();
            // put in a stub to ensure the rest of the dialog works
            model.setGeoContext(new GeoContext());
            ModelerUiHelper.configureControllers(container, model, bf, controller, new ColResolverController());
            ModelerDialog.this.constructorListener.asyncConstructorDone(ModelerDialog.this);
        }
    });
}
Also used : ModelerException(org.pentaho.agilebi.modeler.ModelerException) EmbeddedWizard(org.pentaho.platform.dataaccess.datasource.wizard.EmbeddedWizard) ModelerController(org.pentaho.agilebi.modeler.ModelerController) GwtModelerMessages(org.pentaho.agilebi.modeler.gwt.GwtModelerMessages) ModelerException(org.pentaho.agilebi.modeler.ModelerException) GeoContext(org.pentaho.agilebi.modeler.geo.GeoContext) ColResolverController(org.pentaho.agilebi.modeler.ColResolverController) IModelerWorkspaceHelper(org.pentaho.agilebi.modeler.IModelerWorkspaceHelper) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory) ResourceBundle(org.pentaho.gwt.widgets.client.utils.i18n.ResourceBundle) DSWDatasourceServiceGwtImpl(org.pentaho.platform.dataaccess.datasource.wizard.service.impl.DSWDatasourceServiceGwtImpl) BogoPojo(org.pentaho.agilebi.modeler.gwt.BogoPojo) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory)

Aggregations

BindingFactory (org.pentaho.ui.xul.binding.BindingFactory)17 GwtBindingFactory (org.pentaho.ui.xul.gwt.binding.GwtBindingFactory)7 ResourceBundle (org.pentaho.gwt.widgets.client.utils.i18n.ResourceBundle)4 GwtDatasourceMessages (org.pentaho.platform.dataaccess.datasource.wizard.GwtDatasourceMessages)3 XulRadio (org.pentaho.ui.xul.components.XulRadio)3 XulTextbox (org.pentaho.ui.xul.components.XulTextbox)3 Matchers.anyString (org.mockito.Matchers.anyString)2 JoinTableModel (org.pentaho.agilebi.modeler.models.JoinTableModel)2 BaseMessages.getString (org.pentaho.di.i18n.BaseMessages.getString)2 XulComponent (org.pentaho.ui.xul.XulComponent)2 Binding (org.pentaho.ui.xul.binding.Binding)2 GwtXulDomContainer (org.pentaho.ui.xul.gwt.GwtXulDomContainer)2 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 FileObject (org.apache.commons.vfs2.FileObject)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1 SWTException (org.eclipse.swt.SWTException)1 SashForm (org.eclipse.swt.custom.SashForm)1