Search in sources :

Example 61 with Bindable

use of org.pentaho.ui.xul.stereotype.Bindable in project data-access by pentaho.

the class ConnectionController method toggleDetails.

@Bindable
public void toggleDetails() {
    // $NON-NLS-1$
    XulHbox details = (XulHbox) document.getElementById("details_hider");
    details.setVisible(!details.isVisible());
}
Also used : XulHbox(org.pentaho.ui.xul.containers.XulHbox) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 62 with Bindable

use of org.pentaho.ui.xul.stereotype.Bindable in project data-access by pentaho.

the class ConnectionController method handleDialogAccept.

@Bindable
public void handleDialogAccept() {
    // first, test the connection
    RequestBuilder testConnectionBuilder = new RequestBuilder(RequestBuilder.PUT, ConnectionController.getServiceURL("test"));
    testConnectionBuilder.setHeader("Content-Type", "application/json");
    try {
        // AutoBean<IDatabaseConnection> bean = AutoBeanUtils.getAutoBean(currentConnection);
        AutoBean<IDatabaseConnection> bean = createIDatabaseConnectionBean(currentConnection);
        testConnectionBuilder.sendRequest(AutoBeanCodex.encode(bean).getPayload(), new RequestCallback() {

            @Override
            public void onError(Request request, Throwable exception) {
                saveConnectionConfirmationDialog.show();
            }

            @Override
            public void onResponseReceived(Request request, Response response) {
                try {
                    if (response.getStatusCode() == Response.SC_OK) {
                        // test is ok, now check if we are renaming
                        renameCheck();
                    } else {
                        // confirm if we should continu saving this invalid connection.
                        saveConnectionConfirmationDialog.show();
                    }
                } 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) 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)

Example 63 with Bindable

use of org.pentaho.ui.xul.stereotype.Bindable in project data-access by pentaho.

the class ConnectionController method overwriteConnection.

@Bindable
public void overwriteConnection() {
    if (!saveConnectionConfirmationDialog.isHidden()) {
        closeSaveConnectionConfirmationDialog();
    }
    if (!renameConnectionConfirmationDialog.isHidden()) {
        closeRenameConnectionConfirmationDialog();
    }
    if (!overwriteConnectionConfirmationDialog.isHidden()) {
        overwriteConnectionConfirmationDialog.hide();
    }
    existingConnectionName = currentConnection.getName();
    currentConnection.setId(existingConnectionId);
    if (previousConnectionName != null) {
        RequestBuilder deleteConnectionBuilder = new RequestBuilder(RequestBuilder.DELETE, getServiceURL("deletebyname", new String[][] { { "name", previousConnectionName } }));
        try {
            deleteConnectionBuilder.sendRequest(null, 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) {
                            openErrorDialog(MessageHandler.getString("ERROR"), // $NON-NLS-1$
                            MessageHandler.getString(// $NON-NLS-1$
                            "ConnectionController.ERROR_0002_UNABLE_TO_DELETE_CONNECTION"));
                        }
                    } catch (Exception e) {
                        displayErrorMessage(e);
                    }
                }
            });
        } catch (RequestException e) {
            displayErrorMessage(e);
        }
    }
    updateConnection();
}
Also used : Response(com.google.gwt.http.client.Response) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) Request(com.google.gwt.http.client.Request) RequestException(com.google.gwt.http.client.RequestException) RequestException(com.google.gwt.http.client.RequestException) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 64 with Bindable

use of org.pentaho.ui.xul.stereotype.Bindable in project data-access by pentaho.

the class ConnectionController method testConnection.

@Bindable
public void testConnection() {
    RequestBuilder testConnectionBuilder = new RequestBuilder(RequestBuilder.PUT, getServiceURL("test"));
    testConnectionBuilder.setHeader("Content-Type", "application/json");
    try {
        AutoBean<IDatabaseConnection> bean = AutoBeanUtils.getAutoBean(currentConnection);
        testConnectionBuilder.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) {
                Boolean testPassed = new Boolean(response.getText());
                try {
                    if (testPassed) {
                        openSuccesDialog(MessageHandler.getString("SUCCESS"), // $NON-NLS-1$
                        MessageHandler.getString(// $NON-NLS-1$
                        "ConnectionController.CONNECTION_TEST_SUCCESS"));
                    } else {
                        openErrorDialog(MessageHandler.getString("ERROR"), // $NON-NLS-1$
                        MessageHandler.getString(// $NON-NLS-1$
                        "ConnectionController.ERROR_0003_CONNECTION_TEST_FAILED"));
                    }
                } 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) 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)

Example 65 with Bindable

use of org.pentaho.ui.xul.stereotype.Bindable in project data-access by pentaho.

the class ConnectionController method updateConnection.

@Bindable
public void updateConnection() {
    RequestBuilder updateConnectionBuilder = new RequestBuilder(RequestBuilder.POST, ConnectionController.getServiceURL("update"));
    updateConnectionBuilder.setHeader("Content-Type", "application/json");
    try {
        AutoBean<IDatabaseConnection> bean = createIDatabaseConnectionBean(currentConnection);
        updateConnectionBuilder.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().updateConnection(existingConnectionName, 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_0004_UNABLE_TO_UPDATE_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

Bindable (org.pentaho.ui.xul.stereotype.Bindable)71 Request (com.google.gwt.http.client.Request)15 RequestBuilder (com.google.gwt.http.client.RequestBuilder)15 RequestCallback (com.google.gwt.http.client.RequestCallback)15 RequestException (com.google.gwt.http.client.RequestException)15 Response (com.google.gwt.http.client.Response)15 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)15 ArrayList (java.util.ArrayList)10 List (java.util.List)7 OpenFileCommand (org.pentaho.mantle.client.commands.OpenFileCommand)5 IDatasourceInfo (org.pentaho.platform.dataaccess.datasource.IDatasourceInfo)5 XulHbox (org.pentaho.ui.xul.containers.XulHbox)4 SaveCommand (org.pentaho.mantle.client.commands.SaveCommand)3 XulComponent (org.pentaho.ui.xul.XulComponent)3 XulException (org.pentaho.ui.xul.XulException)3 XulLabel (org.pentaho.ui.xul.components.XulLabel)3 IDatabaseType (org.pentaho.database.model.IDatabaseType)2 DatabaseTypeHelper (org.pentaho.database.util.DatabaseTypeHelper)2 FilePropertiesCommand (org.pentaho.mantle.client.commands.FilePropertiesCommand)2 NewDropdownCommand (org.pentaho.mantle.client.commands.NewDropdownCommand)2