Search in sources :

Example 1 with ConnectionController

use of org.pentaho.platform.dataaccess.datasource.wizard.controllers.ConnectionController in project data-access by pentaho.

the class QueryPhysicalStep method init.

@Bindable
public void init(IWizardModel wizardModel) throws XulException {
    // $NON-NLS-1$
    datasourceNameTextBox = (XulTextbox) document.getElementById("datasourceName");
    wizardConnectionController = new WizardConnectionController(document);
    wizardConnectionController.setDatasourceModel(datasourceModel);
    // wizardConnectionController.setConnectionService(connectionService);
    getXulDomContainer().addEventHandler(wizardConnectionController);
    wizardConnectionController.init();
    databaseConnectionController = new ConnectionController(document);
    databaseConnectionController.setDatasourceModel(datasourceModel);
    // databaseConnectionController.setService(connectionService);
    databaseConnectionController.reloadConnections();
    WizardRelationalDatasourceController relationalDatasourceController = new WizardRelationalDatasourceController();
    relationalDatasourceController.setService(datasourceService);
    getXulDomContainer().addEventHandler(relationalDatasourceController);
    relationalDatasourceController.init(datasourceModel);
    initialize();
    datasourceModel.clearModel();
    super.init(wizardModel);
}
Also used : WizardRelationalDatasourceController(org.pentaho.platform.dataaccess.datasource.wizard.controllers.WizardRelationalDatasourceController) WizardConnectionController(org.pentaho.platform.dataaccess.datasource.wizard.controllers.WizardConnectionController) ConnectionController(org.pentaho.platform.dataaccess.datasource.wizard.controllers.ConnectionController) WizardConnectionController(org.pentaho.platform.dataaccess.datasource.wizard.controllers.WizardConnectionController) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 2 with ConnectionController

use of org.pentaho.platform.dataaccess.datasource.wizard.controllers.ConnectionController in project data-access by pentaho.

the class GwtDatasourceEditorEntryPoint method showEditDatabaseDialog.

public void showEditDatabaseDialog(final DialogListener dialogListener, final String databaseName) {
    String cacheBuster = String.valueOf(new java.util.Date().getTime());
    String url = ConnectionController.getServiceURL("get", new String[][] { { "name", databaseName }, { "ts", cacheBuster } });
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
    builder.setHeader("Accept", "application/json");
    try {
        builder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
                Window.alert(exception.toString());
            }

            @SuppressWarnings("deprecation")
            public void onResponseReceived(Request request, Response response) {
                IDatabaseConnection conn = null;
                if (response.getStatusCode() == Response.SC_OK) {
                    AutoBean<IDatabaseConnection> bean = AutoBeanCodex.decode(connectionAutoBeanFactory, IDatabaseConnection.class, response.getText());
                    conn = bean.as();
                }
                ConnectionController connectionController = wizard.getConnectionController();
                connectionController.init();
                DatasourceModel datasourceModel = connectionController.getDatasourceModel();
                if (datasourceModel == null) {
                    datasourceModel = new DatasourceModel();
                }
                datasourceModel.setSelectedRelationalConnection(conn);
                // This is important for edit mode of datasource model
                datasourceModel.setEditing(true);
                connectionController.setDatasourceModel(datasourceModel);
                connectionController.showEditConnectionDialog(dialogListener, conn);
            }
        });
    } catch (Exception e) {
        Window.alert("Cannot edit datasource");
    }
}
Also used : RequestBuilder(com.google.gwt.http.client.RequestBuilder) Request(com.google.gwt.http.client.Request) AutoBean(com.google.web.bindery.autobean.shared.AutoBean) XulException(org.pentaho.ui.xul.XulException) RequestException(com.google.gwt.http.client.RequestException) Response(com.google.gwt.http.client.Response) DatasourceModel(org.pentaho.platform.dataaccess.datasource.wizard.models.DatasourceModel) RequestCallback(com.google.gwt.http.client.RequestCallback) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) ConnectionController(org.pentaho.platform.dataaccess.datasource.wizard.controllers.ConnectionController)

Example 3 with ConnectionController

use of org.pentaho.platform.dataaccess.datasource.wizard.controllers.ConnectionController 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 4 with ConnectionController

use of org.pentaho.platform.dataaccess.datasource.wizard.controllers.ConnectionController in project data-access by pentaho.

the class GwtDatasourceEditorEntryPoint method showDatabaseDialog.

public void showDatabaseDialog(final DialogListener<IDatabaseConnection> listener) {
    ConnectionController connectionController = wizard.getConnectionController();
    connectionController.init();
    DatasourceModel datasourceModel = connectionController.getDatasourceModel();
    if (datasourceModel == null) {
        datasourceModel = new DatasourceModel();
    }
    connectionController.setDatasourceModel(datasourceModel);
    connectionController.showAddConnectionDialog(listener);
}
Also used : DatasourceModel(org.pentaho.platform.dataaccess.datasource.wizard.models.DatasourceModel) ConnectionController(org.pentaho.platform.dataaccess.datasource.wizard.controllers.ConnectionController)

Aggregations

ConnectionController (org.pentaho.platform.dataaccess.datasource.wizard.controllers.ConnectionController)4 DatasourceModel (org.pentaho.platform.dataaccess.datasource.wizard.models.DatasourceModel)2 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 AutoBean (com.google.web.bindery.autobean.shared.AutoBean)1 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)1 ResourceBundle (org.pentaho.gwt.widgets.client.utils.i18n.ResourceBundle)1 FileImportController (org.pentaho.platform.dataaccess.datasource.wizard.controllers.FileImportController)1 MainWizardController (org.pentaho.platform.dataaccess.datasource.wizard.controllers.MainWizardController)1 WizardConnectionController (org.pentaho.platform.dataaccess.datasource.wizard.controllers.WizardConnectionController)1 WizardDatasourceController (org.pentaho.platform.dataaccess.datasource.wizard.controllers.WizardDatasourceController)1 WizardRelationalDatasourceController (org.pentaho.platform.dataaccess.datasource.wizard.controllers.WizardRelationalDatasourceController)1 DatasourceServiceException (org.pentaho.platform.dataaccess.datasource.wizard.service.DatasourceServiceException)1 XulException (org.pentaho.ui.xul.XulException)1 BindingFactory (org.pentaho.ui.xul.binding.BindingFactory)1 XulFileUpload (org.pentaho.ui.xul.components.XulFileUpload)1 Document (org.pentaho.ui.xul.dom.Document)1