Search in sources :

Example 66 with Bindable

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

the class FileImportController method init.

@Bindable
public void init() {
    bf = new GwtBindingFactory(document);
    // $NON-NLS-1$
    fileUpload = (XulFileUpload) document.getElementById("fileUpload");
    // $NON-NLS-1$
    datasourceDialog = (XulDialog) document.getElementById("fileImportEditorWindow");
    // $NON-NLS-1$
    errorLabel = (XulLabel) document.getElementById("errorLabel");
    // $NON-NLS-1$
    errorDialog = (XulDialog) document.getElementById("errorDialog");
    BindingConvertor<String, Boolean> isDisabledConvertor = new BindingConvertor<String, Boolean>() {

        @Override
        public Boolean sourceToTarget(String aValue) {
            return (aValue == null || "".equals(aValue));
        }

        @Override
        public String targetToSource(Boolean aValue) {
            return null;
        }
    };
    bf.createBinding("fileUpload", "selectedFile", "okButton", "disabled", // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
    isDisabledConvertor);
}
Also used : GwtBindingFactory(org.pentaho.ui.xul.gwt.binding.GwtBindingFactory) BindingConvertor(org.pentaho.ui.xul.binding.BindingConvertor) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 67 with Bindable

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

the class MainWizardController method finish.

@Bindable
public // TODO: migrate to CSV datasource
void finish() {
    if (finishButton.isDisabled()) {
        return;
    }
    finishButton.setDisabled(true);
    final String datasourceName = this.wizardModel.getDatasourceName();
    // Validating whether the datasource name contains any illegal characters
    if (isDatasourceNameValid(datasourceName)) {
        UIDatasourceServiceManager manager = UIDatasourceServiceManager.getInstance();
        manager.getIds(new XulServiceCallback<List<IDatasourceInfo>>() {

            @Override
            public void success(List<IDatasourceInfo> datasourceInfos) {
                finishButton.setDisabled(false);
                boolean isEditing = wizardModel.isEditing();
                List<String> datasourceNames = new ArrayList<String>();
                for (IDatasourceInfo datasourceInfo : datasourceInfos) {
                    if (datasourceInfo.getType().equals("Data Source Wizard") || datasourceInfo.getType().equals("Analysis")) {
                        datasourceNames.add(datasourceInfo.getName());
                    }
                }
                if (datasourceNames.contains(datasourceName) && !isEditing) {
                    showWarningDialog();
                } else {
                    setFinished();
                }
            }

            @Override
            public void error(String s, Throwable throwable) {
                finishButton.setDisabled(false);
                throwable.printStackTrace();
                MessageHandler.getInstance().showErrorDialog(throwable.getMessage());
            }
        });
    } else {
        finishButton.setDisabled(false);
        MessageHandler.getInstance().showErrorDialog("Error", // $NON-NLS-1$
        MessageHandler.getString("DatasourceEditor.ERROR_0005_INVALID_DATASOURCE_NAME", NameUtils.reservedCharListForDisplay(" ")), // $NON-NLS-1$
        true);
    }
}
Also used : XulMenuList(org.pentaho.ui.xul.components.XulMenuList) ArrayList(java.util.ArrayList) List(java.util.List) IDatasourceInfo(org.pentaho.platform.dataaccess.datasource.IDatasourceInfo) UIDatasourceServiceManager(org.pentaho.platform.dataaccess.datasource.ui.service.UIDatasourceServiceManager) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 68 with Bindable

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

the class DatasourceSelectionDialogController method removeDatasourceConfirm.

@Bindable
public void removeDatasourceConfirm() {
    if (messageBundle != null) {
        XulLabel removeDatasourceConfirmationDialogLabel = (XulLabel) removeDatasourceConfirmationDialog.getElementById("removeDatasourceConfirmationDialogLabel");
        LogicalModelSummary logicalModelSummary = getDialogResult();
        if (removeDatasourceConfirmationDialogLabel != null && logicalModelSummary != null) {
            removeDatasourceConfirmationDialogLabel.setValue(messageBundle.getString(REMOVE_DS_MSG_ID, logicalModelSummary.getModelName()));
        }
    }
    removeDatasourceConfirmationDialog.show();
}
Also used : LogicalModelSummary(org.pentaho.platform.dataaccess.datasource.beans.LogicalModelSummary) XulLabel(org.pentaho.ui.xul.components.XulLabel) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 69 with Bindable

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

the class DatasourceSelectionDialogController method init.

// ~ Methods =========================================================================================================
/**
 * Sets up bindings.
 */
@Bindable
public void init() {
    internalInit();
    // $NON-NLS-1$
    final String url = GWT.getHostPageBaseURL() + "plugin/data-access/api/permissions/hasDataAccess";
    RequestBuilder builder = new RequestBuilder(RequestBuilder.GET, url);
    builder.setHeader("accept", "application/json");
    builder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    try {
        builder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable exception) {
                // $NON-NLS-1$
                showMessagebox("Error", exception.getLocalizedMessage());
            }

            public void onResponseReceived(Request request, Response response) {
                boolean hasDataAccess = new Boolean(response.getText());
                DatasourceSelectionDialogController.this.administrator = hasDataAccess;
                addDatasourceButton.setVisible(hasDataAccess);
                editDatasourceButton.setVisible(hasDataAccess);
                removeDatasourceButton.setVisible(hasDataAccess);
                try {
                    removeDatasourceButtonBinding.fireSourceChanged();
                    editDatasourceButtonBinding.fireSourceChanged();
                } catch (Exception e) {
                    // $NON-NLS-1$
                    showMessagebox("Error", e.getLocalizedMessage());
                }
            }
        });
    } catch (RequestException e) {
    // Do Nothing
    }
}
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) XulException(org.pentaho.ui.xul.XulException) RequestException(com.google.gwt.http.client.RequestException) Bindable(org.pentaho.ui.xul.stereotype.Bindable)

Example 70 with Bindable

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

the class ColumnInfo method getAvailableDataTypes.

@Bindable
public static List<DataType> getAvailableDataTypes() {
    if (availableDataTypes == null || availableDataTypes.size() == 0) {
        ArrayList<DataType> types = new ArrayList<DataType>();
        DataType[] dt = DataType.values();
        for (DataType dataType : dt) {
            // don't support url, binary, unknown, or image in csv
            switch(dataType) {
                case URL:
                case BINARY:
                case IMAGE:
                case UNKNOWN:
                    break;
                default:
                    // types.add(dataType.getDescription());
                    types.add(dataType);
                    break;
            }
        }
        availableDataTypes = types;
    }
    return availableDataTypes;
}
Also used : ArrayList(java.util.ArrayList) DataType(org.pentaho.metadata.model.concept.types.DataType) 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