Search in sources :

Example 1 with DialogListener

use of org.pentaho.ui.xul.util.DialogController.DialogListener in project data-access by pentaho.

the class GwtDatasourceEditorEntryPoint method showMetadataImportDialog.

private void showMetadataImportDialog(final JavaScriptObject callback) {
    final DialogListener<MetadataImportDialogModel> listener = new DialogListener<MetadataImportDialogModel>() {

        public void onDialogCancel() {
        }

        public void onDialogAccept(final MetadataImportDialogModel importDialogModel) {
            MetadataDatasourceServiceGwtImpl service = new MetadataDatasourceServiceGwtImpl();
            service.importMetadataDatasource(importDialogModel.getDomainId(), importDialogModel.getUploadedFile(), importDialogModel.getLocalizedBundleEntries(), new XulServiceCallback<String>() {

                @Override
                public void success(String retVal) {
                    notifyDialogCallbackSuccess(callback, retVal);
                }

                @Override
                public void error(String message, Throwable error) {
                    notifyDialogCallbackError(callback, message);
                }
            });
        }

        public void onDialogReady() {
        }

        @Override
        public void onDialogError(String errorMessage) {
        // TODO Auto-generated method stub
        }
    };
    showMetadataImportDialog(listener);
}
Also used : MetadataDatasourceServiceGwtImpl(org.pentaho.platform.dataaccess.datasource.wizard.service.impl.MetadataDatasourceServiceGwtImpl) DialogListener(org.pentaho.ui.xul.util.DialogController.DialogListener) MetadataImportDialogModel(org.pentaho.platform.dataaccess.datasource.ui.importing.MetadataImportDialogModel)

Example 2 with DialogListener

use of org.pentaho.ui.xul.util.DialogController.DialogListener in project data-access by pentaho.

the class GwtDatasourceEditorEntryPoint method showWizardEdit.

/**
 * edit entry-point from Javascript, responds to provided callback with the following:
 * <p>
 * onOk(String JSON, String mqlString);
 * onCancel();
 * onError(String errorMessage);
 *
 * @param callback
 */
private void showWizardEdit(final String domainId, final String modelId, final String perspective, boolean reportingOnlyValid, final JavaScriptObject callback) {
    final DialogListener<Domain> listener = new DialogListener<Domain>() {

        public void onDialogCancel() {
            modeler.removeDialogListener(this);
            if (callback != null) {
                notifyCallbackCancel(callback);
            }
        }

        public void onDialogAccept(final Domain domain) {
            modeler.removeDialogListener(this);
            WAQRTransport transport = WAQRTransport.createFromMetadata(domain);
            notifyCallbackSuccess(callback, true, transport);
        }

        public void onDialogReady() {
            if (callback != null) {
                notifyCallbackReady(callback);
            }
        }

        @Override
        public void onDialogError(String errorMessage) {
            notifyCallbackError(callback, errorMessage);
        }
    };
    showWizardEdit(domainId, modelId, perspective, reportingOnlyValid, listener);
}
Also used : WAQRTransport(org.pentaho.platform.dataaccess.datasource.wizard.jsni.WAQRTransport) DialogListener(org.pentaho.ui.xul.util.DialogController.DialogListener) Domain(org.pentaho.metadata.model.Domain)

Example 3 with DialogListener

use of org.pentaho.ui.xul.util.DialogController.DialogListener in project data-access by pentaho.

the class GwtDatasourceEditorEntryPoint method showAnalysisImportDialog.

public void showAnalysisImportDialog(final DialogListener listener) {
    final DialogListener<AnalysisImportDialogModel> importDialoglistener = new DialogListener<AnalysisImportDialogModel>() {

        public void onDialogCancel() {
            final AnalysisImportDialogController controller = importDialog.getAnalysisImportDialogController();
            final FormPanel analysisDataFormPanel = controller.getFormPanel();
            controller.removeHiddenPanels();
            controller.buildAndSetParameters();
            analysisDataFormPanel.removeFromParent();
            RootPanel.get().add(analysisDataFormPanel);
        }

        public void onDialogAccept(final AnalysisImportDialogModel importDialogModel) {
            final AnalysisImportDialogController controller = importDialog.getAnalysisImportDialogController();
            final FormPanel analysisDataFormPanel = controller.getFormPanel();
            controller.removeHiddenPanels();
            controller.buildAndSetParameters();
            analysisDataFormPanel.removeFromParent();
            RootPanel.get().add(analysisDataFormPanel);
            analysisDataFormPanel.addSubmitCompleteHandler(new SubmitCompleteHandler() {

                @Override
                public void onSubmitComplete(SubmitCompleteEvent event) {
                    String results = event.getResults();
                    String message = controller.convertToNLSMessage(results, controller.getFileName());
                    if (!SUCCESS_3.equals(results)) {
                        if (OVERWRITE_8.equals(results) || OVERWRITE__CATALOG_7.equals(results)) {
                            overwriteFileDialog(analysisDataFormPanel, message, controller);
                        } else {
                            listener.onDialogError(message);
                        }
                    } else {
                        analysisDataFormPanel.removeFromParent();
                        listener.onDialogAccept(null);
                    }
                }
            });
            analysisDataFormPanel.submit();
        }

        public void onDialogReady() {
        }

        @Override
        public void onDialogError(String errorMessage) {
            listener.onDialogError(errorMessage);
        }
    };
    final AsyncConstructorListener<GwtImportDialog> constructorListener = new AsyncConstructorListener<GwtImportDialog>() {

        public void asyncConstructorDone(GwtImportDialog dialog) {
            dialog.showAnalysisImportDialog(importDialoglistener);
        }
    };
    if (importDialog == null) {
        importDialog = new GwtImportDialog(constructorListener);
    } else {
        importDialog.showAnalysisImportDialog(importDialoglistener);
    }
}
Also used : AnalysisImportDialogController(org.pentaho.platform.dataaccess.datasource.ui.importing.AnalysisImportDialogController) FormPanel(com.google.gwt.user.client.ui.FormPanel) DialogListener(org.pentaho.ui.xul.util.DialogController.DialogListener) SubmitCompleteEvent(com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent) SubmitCompleteHandler(com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler) GwtImportDialog(org.pentaho.platform.dataaccess.datasource.ui.importing.GwtImportDialog) AsyncConstructorListener(org.pentaho.ui.xul.gwt.util.AsyncConstructorListener) AnalysisImportDialogModel(org.pentaho.platform.dataaccess.datasource.ui.importing.AnalysisImportDialogModel)

Example 4 with DialogListener

use of org.pentaho.ui.xul.util.DialogController.DialogListener in project data-access by pentaho.

the class GwtDatasourceEditorEntryPoint method showAnalysisImportDialog.

private void showAnalysisImportDialog(final JavaScriptObject callback) {
    final DialogListener<AnalysisImportDialogModel> listener = new DialogListener<AnalysisImportDialogModel>() {

        public void onDialogCancel() {
        }

        public void onDialogAccept(final AnalysisImportDialogModel importDialogModel) {
            AnalysisDatasourceServiceGwtImpl service = new AnalysisDatasourceServiceGwtImpl();
            service.importAnalysisDatasource(importDialogModel.getUploadedFile(), importDialogModel.getConnection().getName(), importDialogModel.getParameters(), new XulServiceCallback<String>() {

                @Override
                public void success(String retVal) {
                    notifyDialogCallbackSuccess(callback, retVal);
                }

                @Override
                public void error(String message, Throwable error) {
                    notifyDialogCallbackError(callback, message);
                }
            });
        }

        public void onDialogReady() {
        }

        @Override
        public void onDialogError(String errorMessage) {
        // TODO Auto-generated method stub
        }
    };
    showAnalysisImportDialog(listener);
}
Also used : AnalysisDatasourceServiceGwtImpl(org.pentaho.platform.dataaccess.datasource.wizard.service.impl.AnalysisDatasourceServiceGwtImpl) DialogListener(org.pentaho.ui.xul.util.DialogController.DialogListener) AnalysisImportDialogModel(org.pentaho.platform.dataaccess.datasource.ui.importing.AnalysisImportDialogModel)

Example 5 with DialogListener

use of org.pentaho.ui.xul.util.DialogController.DialogListener in project data-access by pentaho.

the class ConnectionController method addConnection.

@Bindable
public void addConnection() {
    RequestBuilder addConnectionBuilder = new RequestBuilder(RequestBuilder.POST, ConnectionController.getServiceURL("add"));
    addConnectionBuilder.setHeader("Content-Type", "application/json");
    try {
        AutoBean<IDatabaseConnection> bean = createIDatabaseConnectionBean(currentConnection);
        addConnectionBuilder.sendRequest(AutoBeanCodex.encode(bean).getPayload(), new RequestCallback() {

            @Override
            public void onError(Request request, Throwable exception) {
                displayErrorMessage(exception);
            }

            @Override
            public void onResponseReceived(Request request, Response response) {
                try {
                    if (response.getStatusCode() == Response.SC_OK) {
                        datasourceModel.getGuiStateModel().addConnection(currentConnection);
                        datasourceModel.setSelectedRelationalConnection(currentConnection);
                        DialogListener dialogListener = connectionSetter.getOuterListener();
                        if (dialogListener != null) {
                            dialogListener.onDialogAccept(currentConnection);
                        }
                    } else {
                        openErrorDialog(MessageHandler.getString("ERROR"), // $NON-NLS-1$
                        MessageHandler.getString(// $NON-NLS-1$
                        "ConnectionController.ERROR_0001_UNABLE_TO_ADD_CONNECTION"));
                    }
                } catch (Exception e) {
                    displayErrorMessage(e);
                }
            }
        });
    } catch (RequestException e) {
        displayErrorMessage(e);
    }
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) DialogListener(org.pentaho.ui.xul.util.DialogController.DialogListener) ConnectionDialogListener(org.pentaho.platform.dataaccess.datasource.wizard.ConnectionDialogListener) DatabaseDialogListener(org.pentaho.ui.database.event.DatabaseDialogListener) Request(com.google.gwt.http.client.Request) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) RequestException(com.google.gwt.http.client.RequestException) RequestException(com.google.gwt.http.client.RequestException) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Aggregations

DialogListener (org.pentaho.ui.xul.util.DialogController.DialogListener)9 FormPanel (com.google.gwt.user.client.ui.FormPanel)3 AnalysisImportDialogModel (org.pentaho.platform.dataaccess.datasource.ui.importing.AnalysisImportDialogModel)3 GwtImportDialog (org.pentaho.platform.dataaccess.datasource.ui.importing.GwtImportDialog)3 AsyncConstructorListener (org.pentaho.ui.xul.gwt.util.AsyncConstructorListener)3 Request (com.google.gwt.http.client.Request)2 RequestBuilder (com.google.gwt.http.client.RequestBuilder)2 RequestCallback (com.google.gwt.http.client.RequestCallback)2 RequestException (com.google.gwt.http.client.RequestException)2 Response (com.google.gwt.http.client.Response)2 SubmitCompleteEvent (com.google.gwt.user.client.ui.FormPanel.SubmitCompleteEvent)2 SubmitCompleteHandler (com.google.gwt.user.client.ui.FormPanel.SubmitCompleteHandler)2 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)2 Domain (org.pentaho.metadata.model.Domain)2 AnalysisImportDialogController (org.pentaho.platform.dataaccess.datasource.ui.importing.AnalysisImportDialogController)2 MetadataImportDialogModel (org.pentaho.platform.dataaccess.datasource.ui.importing.MetadataImportDialogModel)2 ConnectionDialogListener (org.pentaho.platform.dataaccess.datasource.wizard.ConnectionDialogListener)2 WAQRTransport (org.pentaho.platform.dataaccess.datasource.wizard.jsni.WAQRTransport)2 DatabaseDialogListener (org.pentaho.ui.database.event.DatabaseDialogListener)2 Bindable (org.pentaho.ui.xul.stereotype.Bindable)2