Search in sources :

Example 6 with GwtBindingFactory

use of org.pentaho.ui.xul.gwt.binding.GwtBindingFactory 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)

Example 7 with GwtBindingFactory

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

the class GwtDatasourceSelectionDialog method xulLoaded.

public void xulLoaded(final GwtXulRunner runner) {
    try {
        GwtXulDomContainer container = (GwtXulDomContainer) runner.getXulDomContainers().get(0);
        BindingFactory bf = new GwtBindingFactory(container.getDocumentRoot());
        // begin DatasourceSelectionDialogController setup
        datasourceSelectionDialogController = new DatasourceSelectionDialogController(context);
        datasourceSelectionDialogController.setBindingFactory(bf);
        datasourceSelectionDialogController.setDatasourceService(datasourceService);
        container.addEventHandler(datasourceSelectionDialogController);
        // end DatasourceSelectionDialogController setup
        datasourceSelectionDialogController.setDatasourceDialogController(gwtDatasourceEditor);
        ResourceBundle resBundle = (ResourceBundle) container.getResourceBundles().get(0);
        GwtDatasourceMessages datasourceMessages = new GwtDatasourceMessages();
        datasourceMessages.setMessageBundle(resBundle);
        datasourceSelectionDialogController.setMessageBundle(datasourceMessages);
        runner.initialize();
        runner.start();
        initialized = true;
        if (constructorListener != null) {
            constructorListener.asyncConstructorDone(this);
        }
        datasourceSelectionDialogController.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 8 with GwtBindingFactory

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

the class EmbeddedWizard method xulLoaded.

/*
   * (non-Javadoc)
   * 
   * @see org.pentaho.ui.xul.gwt.util.IXulLoaderCallback#xulLoaded(org.pentaho.ui.xul.gwt.GwtXulRunner)
   */
public void xulLoaded(GwtXulRunner runner) {
    mainWizardContainer = runner.getXulDomContainers().get(0);
    Document rootDocument = mainWizardContainer.getDocumentRoot();
    BindingFactory bf = new GwtBindingFactory(rootDocument);
    ResourceBundle resBundle = (ResourceBundle) mainWizardContainer.getResourceBundles().get(0);
    datasourceMessages = new GwtDatasourceMessages();
    datasourceMessages.setMessageBundle(resBundle);
    MessageHandler.getInstance().setMessages(datasourceMessages);
    connectionController = new ConnectionController(rootDocument);
    connectionController.setDatasourceModel(datasourceModel);
    // connectionController.setService(connectionService);
    mainWizardContainer.addEventHandler(connectionController);
    summaryDialogController.setBindingFactory(bf);
    mainWizardContainer.addEventHandler(summaryDialogController);
    wizardController = new MainWizardController(bf, wizardModel, datasourceService);
    mainWizardContainer.addEventHandler(wizardController);
    dialog = (XulDialog) rootDocument.getElementById(WIZARD_DIALOG_ID);
    MessageHandler.getInstance().setWizardDialog(dialog);
    datasourceController = new WizardDatasourceController();
    datasourceController.setBindingFactory(bf);
    datasourceController.setDatasourceMessages(datasourceMessages);
    mainWizardContainer.addEventHandler(datasourceController);
    mainWizardContainer.addEventHandler(MessageHandler.getInstance());
    // add the steps ..
    // physicalStep = new RelationalPhysicalStep(datasourceService, connectionService, datasourceMessages, this);
    wizardController.addWizardListener(this);
    // Controller for the File Import functionality
    FileImportController fileImportController = new FileImportController(datasourceModel, datasourceMessages);
    mainWizardContainer.addEventHandler(fileImportController);
    // init other controllers
    fileImportController.init();
    MessageHandler.getInstance().init();
    summaryDialogController.init();
    // Create the gui
    try {
        // new WizardContentPanel(wizardController).addContent(mainWizardContainer);
        wizardController.init();
        initialized = true;
    } catch (Exception throwable) {
        throwable.printStackTrace();
    }
    // Remap the upload action in development mode
    if (GWT.isScript() == false) {
        // $NON-NLS-1$
        XulFileUpload upload = (XulFileUpload) rootDocument.getElementById("fileUpload");
        // $NON-NLS-1$
        upload.setAction(GWT.getModuleBaseURL() + "UploadService");
    }
    initialized = true;
    if (asyncConstructorListener != null) {
        asyncConstructorListener.asyncConstructorDone(this);
    }
}
Also used : FileImportController(org.pentaho.platform.dataaccess.datasource.wizard.controllers.FileImportController) XulFileUpload(org.pentaho.ui.xul.components.XulFileUpload) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory) MainWizardController(org.pentaho.platform.dataaccess.datasource.wizard.controllers.MainWizardController) ResourceBundle(org.pentaho.gwt.widgets.client.utils.i18n.ResourceBundle) Document(org.pentaho.ui.xul.dom.Document) ConnectionController(org.pentaho.platform.dataaccess.datasource.wizard.controllers.ConnectionController) WizardDatasourceController(org.pentaho.platform.dataaccess.datasource.wizard.controllers.WizardDatasourceController) DatasourceServiceException(org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory)

Example 9 with GwtBindingFactory

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

the class WizardRelationalDatasourceController method init.

@Bindable
public void init(final DatasourceModel datasourceModel) {
    this.datasourceModel = datasourceModel;
    bf = new GwtBindingFactory(document);
    // $NON-NLS-1$
    sampleDataTree = (XulTree) document.getElementById("relationalSampleDataTable");
    // $NON-NLS-1$
    aggregationEditorDialog = (XulDialog) document.getElementById("relationalAggregationEditorDialog");
    // $NON-NLS-1$
    sampleDataDialog = (XulDialog) document.getElementById("relationalSampleDataDialog");
    // $NON-NLS-1$
    errorDialog = (XulDialog) document.getElementById("errorDialog");
    // $NON-NLS-1$
    errorLabel = (XulLabel) document.getElementById("errorLabel");
    // $NON-NLS-1$
    applyQueryConfirmationDialog = (XulDialog) document.getElementById("applyQueryConfirmationDialog");
    // $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$
    datasourceName = (XulTextbox) document.getElementById("datasourceName");
    // $NON-NLS-1$
    connections = (XulListbox) document.getElementById("connectionList");
    // $NON-NLS-1$
    query = (XulTextbox) document.getElementById("query");
    // $NON-NLS-1$
    connectionDialog = (XulDialog) document.getElementById("connectionDialog");
    // $NON-NLS-1$
    previewResultsDialog = (XulDialog) document.getElementById("previewResultsDialog");
    // $NON-NLS-1$
    previewResultsTable = (XulTree) document.getElementById("previewResultsTable");
    // $NON-NLS-1$
    previewResultsTreeCols = (XulTreeCols) document.getElementById("previewResultsTreeCols");
    // $NON-NLS-1$
    previewLimit = (XulTextbox) document.getElementById("previewLimit");
    // $NON-NLS-1$
    editConnectionButton = (XulButton) document.getElementById("editConnection");
    // $NON-NLS-1$
    removeConnectionButton = (XulButton) document.getElementById("removeConnection");
    // $NON-NLS-1$
    editQueryButton = (XulButton) document.getElementById("editQuery");
    // $NON-NLS-1$
    previewButton = (XulButton) document.getElementById("preview");
    bf.setBindingType(Binding.Type.ONE_WAY);
    bf.createBinding(datasourceModel.getGuiStateModel(), "relationalPreviewValidated", previewButton, // $NON-NLS-1$ //$NON-NLS-2$
    "!disabled");
    List<Binding> bindingsThatNeedInitialized = new ArrayList<Binding>();
    BindingConvertor<IDatabaseConnection, Boolean> buttonConvertor = new BindingConvertor<IDatabaseConnection, Boolean>() {

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

        @Override
        public IDatabaseConnection targetToSource(Boolean value) {
            return null;
        }
    };
    bf.setBindingType(Binding.Type.ONE_WAY);
    final Binding domainBinding = bf.createBinding(datasourceModel.getGuiStateModel(), "connections", this, // $NON-NLS-1$ //$NON-NLS-2$
    "relationalConnections");
    // $NON-NLS-1$
    bf.createBinding(this, connectionNamesListProp, connections, "elements");
    bf.createBinding(datasourceModel, "selectedRelationalConnection", editConnectionButton, "!disabled", // $NON-NLS-1$ //$NON-NLS-2$
    buttonConvertor);
    bf.createBinding(datasourceModel, "selectedRelationalConnection", removeConnectionButton, "!disabled", // $NON-NLS-1$ //$NON-NLS-2$
    buttonConvertor);
    bf.setBindingType(Binding.Type.BI_DIRECTIONAL);
    bf.createBinding(datasourceModel, "selectedRelationalConnection", connections, "selectedIndex", new // $NON-NLS-1$ //$NON-NLS-2$
    BindingConvertor<IDatabaseConnection, Integer>() {

        @Override
        public Integer sourceToTarget(IDatabaseConnection connection) {
            if (connection != null) {
                return datasourceModel.getGuiStateModel().getConnectionIndex(connection);
            }
            return -1;
        }

        @Override
        public IDatabaseConnection targetToSource(Integer value) {
            if (value >= 0) {
                return datasourceModel.getGuiStateModel().getConnections().get(value);
            }
            return null;
        }
    });
    bf.setBindingType(Binding.Type.BI_DIRECTIONAL);
    bf.createBinding(datasourceModel.getGuiStateModel(), "previewLimit", previewLimit, // $NON-NLS-1$ //$NON-NLS-2$
    "value");
    // $NON-NLS-1$ //$NON-NLS-2$
    bf.createBinding(datasourceModel, "query", query, "value");
    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();
    }
    for (Binding b : bindingsThatNeedInitialized) {
        try {
            b.fireSourceChanged();
        } catch (Exception e) {
            System.out.println(e.getMessage());
            e.printStackTrace();
        }
    }
}
Also used : Binding(org.pentaho.ui.xul.binding.Binding) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory) ArrayList(java.util.ArrayList) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) BindingConvertor(org.pentaho.ui.xul.binding.BindingConvertor) XulException(org.pentaho.ui.xul.XulException) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 10 with GwtBindingFactory

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

the class JoinDefinitionsStep method setBindings.

public void setBindings() {
    BindingFactory bf = new GwtBindingFactory(document);
    bf.createBinding(this.joinGuiModel.getLeftTables(), "children", this.leftTables, "elements");
    bf.createBinding(this.joinGuiModel.getRightTables(), "children", this.rightTables, "elements");
    bf.createBinding(this.leftTables, "selectedItem", this.joinGuiModel, "leftJoinTable");
    bf.createBinding(this.rightTables, "selectedItem", this.joinGuiModel, "rightJoinTable");
    bf.createBinding(this.joinGuiModel.getJoins(), "children", this.joinsList, "elements");
    bf.createBinding(this.joinsList, "selectedItem", this.joinGuiModel, "selectedJoin");
    bf.createBinding(this.leftTables, "selectedItem", this.leftKeyFieldList, "elements", new TableSelectionConvertor(this.leftTables));
    bf.createBinding(this.rightTables, "selectedItem", this.rightKeyFieldList, "elements", new TableSelectionConvertor(this.rightTables));
    this.leftKeyFieldBinding = bf.createBinding(this.leftKeyFieldList, "selectedIndex", this.joinGuiModel, "leftKeyField", new BindingConvertor<Integer, JoinFieldModel>() {

        @Override
        public JoinFieldModel sourceToTarget(final Integer index) {
            JoinTableModel joinTable = joinGuiModel.getLeftJoinTable();
            if (joinTable != null) {
                List<JoinFieldModel> fields = joinTable.getFields();
                if (index == -1 || fields.isEmpty()) {
                    return null;
                }
                return fields.get(index);
            }
            return null;
        }

        @Override
        public Integer targetToSource(final JoinFieldModel value) {
            return null;
        }
    });
    this.rightKeyFieldBinding = bf.createBinding(this.rightKeyFieldList, "selectedIndex", this.joinGuiModel, "rightKeyField", new BindingConvertor<Integer, JoinFieldModel>() {

        @Override
        public JoinFieldModel sourceToTarget(final Integer index) {
            JoinTableModel joinTable = joinGuiModel.getRightJoinTable();
            if (joinTable != null) {
                List<JoinFieldModel> fields = joinTable.getFields();
                if (index == -1 || fields.isEmpty()) {
                    return null;
                }
                return fields.get(index);
            }
            return null;
        }

        @Override
        public Integer targetToSource(final JoinFieldModel value) {
            return null;
        }
    });
}
Also used : JoinTableModel(org.pentaho.agilebi.modeler.models.JoinTableModel) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory) JoinFieldModel(org.pentaho.agilebi.modeler.models.JoinFieldModel) BindingConvertor(org.pentaho.ui.xul.binding.BindingConvertor) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory) GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory)

Aggregations

GwtBindingFactory (org.pentaho.ui.xul.gwt.binding.GwtBindingFactory)12 BindingFactory (org.pentaho.ui.xul.binding.BindingFactory)7 ResourceBundle (org.pentaho.gwt.widgets.client.utils.i18n.ResourceBundle)5 GwtDatasourceMessages (org.pentaho.platform.dataaccess.datasource.wizard.GwtDatasourceMessages)3 BindingConvertor (org.pentaho.ui.xul.binding.BindingConvertor)3 Bindable (org.pentaho.ui.xul.stereotype.Bindable)3 ArrayList (java.util.ArrayList)2 JoinTableModel (org.pentaho.agilebi.modeler.models.JoinTableModel)2 XulException (org.pentaho.ui.xul.XulException)2 GwtXulDomContainer (org.pentaho.ui.xul.gwt.GwtXulDomContainer)2 JsArray (com.google.gwt.core.client.JsArray)1 Request (com.google.gwt.http.client.Request)1 RequestBuilder (com.google.gwt.http.client.RequestBuilder)1 RequestCallback (com.google.gwt.http.client.RequestCallback)1 RequestException (com.google.gwt.http.client.RequestException)1 Response (com.google.gwt.http.client.Response)1 MenuBar (com.google.gwt.user.client.ui.MenuBar)1 MenuItem (com.google.gwt.user.client.ui.MenuItem)1 Collection (java.util.Collection)1 List (java.util.List)1