Search in sources :

Example 16 with Bindable

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

the class ConnectionController method overwriteCheck.

@Bindable
public void overwriteCheck() {
    if (!saveConnectionConfirmationDialog.isHidden()) {
        closeSaveConnectionConfirmationDialog();
    }
    if (!renameConnectionConfirmationDialog.isHidden()) {
        closeRenameConnectionConfirmationDialog();
    }
    if (datasourceModel.isEditing() && previousConnectionName.equals(currentConnection.getName())) {
        // if editing and no name change, proceed.
        updateConnection();
    } else {
        // either new connection, or editing involved a name change.
        RequestBuilder checkConnectionBuilder = new RequestBuilder(RequestBuilder.GET, getServiceURL("getid", new String[][] { { "name", currentConnection.getName() } }));
        checkConnectionBuilder.setHeader("Content-Type", "application/json");
        try {
            checkConnectionBuilder.sendRequest(null, new RequestCallback() {

                public void onResponseReceived(Request request, Response response) {
                    switch(response.getStatusCode()) {
                        case Response.SC_OK:
                            existingConnectionId = response.getText();
                            showOverwriteConnectionConfirmationDialog();
                            break;
                        case Response.SC_NOT_FOUND:
                            saveConnection();
                            break;
                        default:
                            // TODO: error message
                            saveConnection();
                    }
                }

                public void onError(Request request, Throwable exception) {
                    displayErrorMessage(exception);
                }
            });
        } catch (Exception 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) RequestException(com.google.gwt.http.client.RequestException) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 17 with Bindable

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

the class ConnectionController method deleteConnection.

@Bindable
public void deleteConnection() {
    removeConfirmationDialog.hide();
    RequestBuilder deleteConnectionBuilder = new RequestBuilder(RequestBuilder.DELETE, getServiceURL("deletebyname", new String[][] { { "name", datasourceModel.getSelectedRelationalConnection().getName() } }));
    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) {
                        openSuccesDialog(MessageHandler.getString("SUCCESS"), // $NON-NLS-1$
                        MessageHandler.getString(// $NON-NLS-1$
                        "ConnectionController.CONNECTION_DELETED"));
                        datasourceModel.getGuiStateModel().deleteConnection(datasourceModel.getSelectedRelationalConnection().getName());
                        List<IDatabaseConnection> connections = datasourceModel.getGuiStateModel().getConnections();
                        if (connections != null && connections.size() > 0) {
                            datasourceModel.setSelectedRelationalConnection(connections.get(connections.size() - 1));
                        } else {
                            datasourceModel.setSelectedRelationalConnection(null);
                        }
                    } else {
                        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);
    }
}
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) ArrayList(java.util.ArrayList) IDatabaseConnectionList(org.pentaho.ui.database.event.IDatabaseConnectionList) List(java.util.List) RequestException(com.google.gwt.http.client.RequestException) RequestException(com.google.gwt.http.client.RequestException) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 18 with Bindable

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

the class ConnectionController method init.

@Bindable
public void init() {
    XulServiceCallback<List<IDatabaseType>> callback = new XulServiceCallback<List<IDatabaseType>>() {

        public void error(String message, Throwable error) {
            error.printStackTrace();
        }

        public void success(List<IDatabaseType> retVal) {
            databaseTypeHelper = new DatabaseTypeHelper(retVal);
        }
    };
    dialectService.getDatabaseTypes(callback);
    saveConnectionConfirmationDialog = // $NON-NLS-1$
    (XulDialog) document.getElementById("saveConnectionConfirmationDialogConnectionController");
    overwriteConnectionConfirmationDialog = (XulDialog) document.getElementById("overwriteConnectionConfirmationDialogConnectionController");
    renameConnectionConfirmationDialog = (XulDialog) document.getElementById("renameConnectionConfirmationDialogConnectionController");
    // $NON-NLS-1$
    errorDialog = (XulDialog) document.getElementById("errorDialog");
    // $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$
    removeConfirmationDialog = (XulDialog) document.getElementById("removeConfirmationDialogConnectionController");
    // $NON-NLS-1$
    successDetailsDialog = (XulDialog) document.getElementById("successDetailsDialogConnectionController");
}
Also used : XulServiceCallback(org.pentaho.ui.xul.XulServiceCallback) IDatabaseType(org.pentaho.database.model.IDatabaseType) DatabaseTypeHelper(org.pentaho.database.util.DatabaseTypeHelper) ArrayList(java.util.ArrayList) IDatabaseConnectionList(org.pentaho.ui.database.event.IDatabaseConnectionList) List(java.util.List) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 19 with Bindable

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

the class MainWizardController method setSelectedDatasource.

@Bindable
public void setSelectedDatasource(IWizardDatasource datasource) {
    IWizardDatasource prevSelection = activeDatasource;
    activeDatasource = datasource;
    if (datasource == null || prevSelection == activeDatasource) {
        return;
    }
    try {
        datasource.activating();
        if (prevSelection != null) {
            steps.removeAll(prevSelection.getSteps());
            prevSelection.deactivating();
        }
        for (int i = 1; i < datasource.getSteps().size(); i++) {
            steps.add(datasource.getSteps().get(i));
        }
        steps.addAll(datasource.getSteps());
        wizardModel.setSelectedDatasource(datasource);
        activeStep = 0;
        updateBindings();
    } catch (XulException e) {
        // To change body of catch statement use File | Settings | File Templates.
        e.printStackTrace();
    }
}
Also used : XulException(org.pentaho.ui.xul.XulException) IWizardDatasource(org.pentaho.platform.dataaccess.datasource.wizard.IWizardDatasource) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 20 with Bindable

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

the class DatasourceSelectionDialogController method removeDatasourceAccept.

@Bindable
public void removeDatasourceAccept() {
    if (removeDatasourceButton.isDisabled()) {
        return;
    }
    removeDatasourceButton.setDisabled(true);
    LogicalModelSummary logicalModelSummary = getDialogResult();
    datasourceService.deleteLogicalModel(logicalModelSummary.getDomainId(), logicalModelSummary.getModelId(), new XulServiceCallback<Boolean>() {

        public void error(String message, Throwable error) {
            // $NON-NLS-1$
            showMessagebox("Error", error.getLocalizedMessage());
            removeDatasourceButton.setDisabled(false);
        }

        public void success(Boolean retVal) {
            refreshDatasources(null, null);
            removeDatasourceConfirmationDialog.hide();
            removeDatasourceButton.setDisabled(false);
        }
    });
}
Also used : LogicalModelSummary(org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary) 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