Search in sources :

Example 26 with Bindable

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

the class WizardConnectionController 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("saveConnectionConfirmationDialog");
    overwriteConnectionConfirmationDialog = (XulDialog) document.getElementById("overwriteConnectionConfirmationDialog");
    renameConnectionConfirmationDialog = (XulDialog) document.getElementById("renameConnectionConfirmationDialog");
    // $NON-NLS-1$
    errorDialog = (XulDialog) document.getElementById("errorDialog");
    // $NON-NLS-1$
    errorDetailsDialog = (XulDialog) document.getElementById("errorDetailsDialog");
    // $NON-NLS-1$
    errorLabel = (XulLabel) document.getElementById("errorLabel");
    // $NON-NLS-1$
    successDialog = (XulDialog) document.getElementById("successDialog");
    // $NON-NLS-1$
    successDetailsDialog = (XulDialog) document.getElementById("successDetailsDialog");
    // $NON-NLS-1$
    successLabel = (XulLabel) document.getElementById("successLabel");
    // $NON-NLS-1$
    removeConfirmationDialog = (XulDialog) document.getElementById("removeConfirmationDialog");
}
Also used : XulServiceCallback(org.pentaho.ui.xul.XulServiceCallback) IDatabaseType(org.pentaho.database.model.IDatabaseType) DatabaseTypeHelper(org.pentaho.database.util.DatabaseTypeHelper) ArrayList(java.util.ArrayList) List(java.util.List) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 27 with Bindable

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

the class WizardConnectionController 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 {
        String cacheBuster = String.valueOf(new java.util.Date().getTime());
        // either new connection, or editing involved a name change.
        RequestBuilder getConnectionBuilder = new RequestBuilder(RequestBuilder.GET, ConnectionController.getServiceURL("get", new String[][] { { "name", currentConnection.getName() }, { "ts", cacheBuster } }));
        getConnectionBuilder.setHeader("Content-Type", "application/json");
        try {
            AutoBean<IDatabaseConnection> bean = createIDatabaseConnectionBean(currentConnection);
            getConnectionBuilder.sendRequest(AutoBeanCodex.encode(bean).getPayload(), new RequestCallback() {

                public void onResponseReceived(Request request, Response response) {
                    switch(response.getStatusCode()) {
                        case Response.SC_OK:
                            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) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) RequestException(com.google.gwt.http.client.RequestException) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 28 with Bindable

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

the class WizardDatasourceController method init.

@Bindable
public void init() {
    // $NON-NLS-1$
    clearModelWarningDialog = (XulDialog) document.getElementById("clearModelWarningDialog");
    // $NON-NLS-1$
    csvDataTable = (XulTree) document.getElementById("csvDataTable");
    // $NON-NLS-1$
    modelDataTable = (XulTree) document.getElementById("modelDataTable");
    // $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$
    csvDatasourceName = (XulTextbox) document.getElementById("datasourceName");
    // $NON-NLS-1$
    datasourceDialog = (XulDialog) document.getElementById("datasourceDialog");
    // $NON-NLS-1$
    okButton = (XulButton) document.getElementById("datasourceDialog_accept");
    // $NON-NLS-1$
    cancelButton = (XulButton) document.getElementById("datasourceDialog_cancel");
    // $NON-NLS-1$
    datasourceTabbox = (XulTabbox) document.getElementById("datasourceDialogTabbox");
    bf.setBindingType(Binding.Type.ONE_WAY);
    // $NON-NLS-1$ //$NON-NLS-2$
    bf.createBinding(datasourceModel, "validated", okButton, "!disabled");
    bf.setBindingType(Binding.Type.BI_DIRECTIONAL);
    final Binding domainBinding = bf.createBinding(datasourceModel.getGuiStateModel(), "datasourceName", csvDatasourceName, // $NON-NLS-1$ //$NON-NLS-2$
    "value");
    // $NON-NLS-1$ //$NON-NLS-2$
    bf.createBinding(datasourceModel, "datasourceName", csvDatasourceName, "value");
    BindingConvertor<DatasourceType, Integer> tabIndexConvertor = new BindingConvertor<DatasourceType, Integer>() {

        @Override
        public Integer sourceToTarget(DatasourceType value) {
            Integer returnValue = null;
            if (DatasourceType.SQL == value) {
                returnValue = 0;
            } else if (DatasourceType.CSV == value) {
                returnValue = 1;
            } else if (DatasourceType.OLAP == value) {
                return 2;
            } else if (DatasourceType.NONE == value) {
                return 0;
            }
            return returnValue;
        }

        @Override
        public DatasourceType targetToSource(Integer value) {
            DatasourceType type = null;
            if (value == 0) {
                type = DatasourceType.SQL;
            } else if (value == 1) {
                type = DatasourceType.CSV;
            } else if (value == 2) {
                type = DatasourceType.OLAP;
            }
            return type;
        }
    };
    bf.createBinding(datasourceModel, "datasourceType", datasourceTabbox, "selectedIndex", // $NON-NLS-1$ //$NON-NLS-2$
    tabIndexConvertor);
    okButton.setDisabled(true);
    initialize();
    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();
    }
}
Also used : Binding(org.pentaho.ui.xul.binding.Binding) DatasourceType(org.pentaho.platform.dataaccess.datasource.DatasourceType) BindingConvertor(org.pentaho.ui.xul.binding.BindingConvertor) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 29 with Bindable

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

the class WizardRelationalDatasourceController method setRelationalConnections.

@Bindable
public void setRelationalConnections(List<IDatabaseConnection> connections) {
    List<String> names = new ArrayList<String>();
    for (IDatabaseConnection conn : connections) {
        names.add(conn.getName());
    }
    firePropertyChange(connectionNamesListProp, null, names);
}
Also used : ArrayList(java.util.ArrayList) IDatabaseConnection(org.pentaho.database.model.IDatabaseConnection) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 30 with Bindable

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

the class WizardModel method setSelectedDatasource.

@Bindable
public void setSelectedDatasource(IWizardDatasource datasource) {
    IWizardDatasource prevSelection = selectedDatasource;
    selectedDatasource = datasource;
    firePropertyChange("selectedDatasource", prevSelection, selectedDatasource);
}
Also used : IWizardDatasource(org.pentaho.platform.dataaccess.datasource.wizard.IWizardDatasource) 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