Search in sources :

Example 6 with XulRadio

use of org.pentaho.ui.xul.components.XulRadio in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceTestController method bindStreamingWindowParameters.

private void bindStreamingWindowParameters(BindingFactory bindingFactory) {
    XulGroupbox streamingGroupBox = (XulGroupbox) document.getElementById("streaming-groupbox");
    streamingGroupBox.setVisible(dataService.isStreaming());
    XulRadio timeBasedRadio = (XulRadio) document.getElementById("time-based-radio");
    XulRadio rowBasedRadio = (XulRadio) document.getElementById("row-based-radio");
    XulTextbox sizeTextBox = (XulTextbox) document.getElementById("window-size");
    XulTextbox everyTextBox = (XulTextbox) document.getElementById("window-every");
    XulTextbox limitTextBox = (XulTextbox) document.getElementById("window-limit");
    XulLabel sizeTimeUnitLabel = (XulLabel) document.getElementById("window-size-time-unit");
    XulLabel everyTimeUnitLabel = (XulLabel) document.getElementById("window-every-time-unit");
    XulLabel limitTimeUnitLabel = (XulLabel) document.getElementById("window-limit-time-unit");
    XulLabel sizeRowUnitLabel = (XulLabel) document.getElementById("window-size-row-unit");
    XulLabel everyRowUnitLabel = (XulLabel) document.getElementById("window-every-row-unit");
    XulLabel limitRowUnitLabel = (XulLabel) document.getElementById("window-limit-row-unit");
    model.setWindowMode(IDataServiceClientService.StreamingMode.TIME_BASED);
    timeBasedRadio.setSelected(true);
    rowBasedRadio.setSelected(false);
    sizeTimeUnitLabel.setVisible(true);
    everyTimeUnitLabel.setVisible(true);
    limitTimeUnitLabel.setVisible(false);
    sizeRowUnitLabel.setVisible(false);
    everyRowUnitLabel.setVisible(false);
    limitRowUnitLabel.setVisible(true);
    sizeTextBox.setValue("");
    everyTextBox.setValue("");
    limitTextBox.setValue("");
    bindingFactory.setBindingType(Binding.Type.BI_DIRECTIONAL);
    bindingFactory.createBinding(model, "windowSize", sizeTextBox, "value", BindingConverters.longToStringEmptyZero());
    bindingFactory.createBinding(model, "windowEvery", everyTextBox, "value", BindingConverters.longToStringEmptyZero());
    bindingFactory.createBinding(model, "windowLimit", limitTextBox, "value", BindingConverters.longToStringEmptyZero());
    bindingFactory.createBinding(timeBasedRadio, "selected", sizeTimeUnitLabel, "visible");
    bindingFactory.createBinding(timeBasedRadio, "selected", everyTimeUnitLabel, "visible");
    bindingFactory.createBinding(timeBasedRadio, "!selected", limitTimeUnitLabel, "visible");
    bindingFactory.createBinding(timeBasedRadio, "!selected", sizeRowUnitLabel, "visible");
    bindingFactory.createBinding(timeBasedRadio, "!selected", everyRowUnitLabel, "visible");
    bindingFactory.createBinding(timeBasedRadio, "selected", limitRowUnitLabel, "visible");
    bindingFactory.createBinding(rowBasedRadio, "!selected", sizeTimeUnitLabel, "visible");
    bindingFactory.createBinding(rowBasedRadio, "!selected", everyTimeUnitLabel, "visible");
    bindingFactory.createBinding(rowBasedRadio, "selected", limitTimeUnitLabel, "visible");
    bindingFactory.createBinding(rowBasedRadio, "selected", sizeRowUnitLabel, "visible");
    bindingFactory.createBinding(rowBasedRadio, "selected", everyRowUnitLabel, "visible");
    bindingFactory.createBinding(rowBasedRadio, "!selected", limitRowUnitLabel, "visible");
}
Also used : XulRadio(org.pentaho.ui.xul.components.XulRadio) XulTextbox(org.pentaho.ui.xul.components.XulTextbox) XulLabel(org.pentaho.ui.xul.components.XulLabel) XulGroupbox(org.pentaho.ui.xul.containers.XulGroupbox)

Example 7 with XulRadio

use of org.pentaho.ui.xul.components.XulRadio in project pdi-dataservice-server-plugin by pentaho.

the class StreamingController method initBindings.

/**
 * Inits the controller-ui bindings.
 *
 * @param model - The {@link org.pentaho.di.trans.dataservice.ui.model.DataServiceModel} dataservice model.
 * @throws InvocationTargetException
 * @throws XulException
 */
public void initBindings(DataServiceModel model) throws InvocationTargetException, XulException, KettleException {
    BindingFactory bindingFactory = getBindingFactory();
    XulRadio streamingRadioButton = getElementById("streaming-type-radio");
    XulTab streamingTab = getElementById("streaming-tab");
    XulTextbox streamingMaxRows = getElementById("streaming-max-rows");
    XulTextbox streamingMaxTime = getElementById("streaming-max-time");
    bindingFactory.setBindingType(Binding.Type.BI_DIRECTIONAL);
    // Set streaming max rows and time limit value on the text boxes.
    // Get the values from the model first and fallback to the appropriate Kettle Properties
    // if they don't exist in the mode.
    int modelStreamingMaxRows = model.getServiceMaxRows();
    streamingMaxRows.setValue(modelStreamingMaxRows > 0 ? Integer.toString(modelStreamingMaxRows) : kettleUtils.getKettleProperty("KETTLE_STREAMING_ROW_LIMIT", Integer.toString(DataServiceConstants.KETTLE_STREAMING_ROW_LIMIT)));
    long modelStreamingMaxTime = model.getServiceMaxTime();
    streamingMaxTime.setValue(modelStreamingMaxTime > 0 ? Long.toString(modelStreamingMaxTime) : kettleUtils.getKettleProperty("KETTLE_STREAMING_TIME_LIMIT", Integer.toString(DataServiceConstants.KETTLE_STREAMING_TIME_LIMIT)));
    streamingTab.setVisible(model.isStreaming());
    bindingFactory.createBinding(model, "serviceMaxRows", streamingMaxRows, "value", BindingConvertor.integer2String());
    bindingFactory.createBinding(model, "serviceMaxTime", streamingMaxTime, "value", BindingConvertor.long2String());
    bindingFactory.createBinding(streamingRadioButton, "selected", streamingTab, "visible");
}
Also used : XulRadio(org.pentaho.ui.xul.components.XulRadio) XulTextbox(org.pentaho.ui.xul.components.XulTextbox) XulTab(org.pentaho.ui.xul.components.XulTab) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory)

Example 8 with XulRadio

use of org.pentaho.ui.xul.components.XulRadio in project data-access by pentaho.

the class AnalysisImportDialogController method editDatasource.

public void editDatasource(final IDatasourceInfo datasourceInfo) {
    this.datasourceInfo = datasourceInfo;
    boolean isEditMode = datasourceInfo != null;
    // MONDRIAN-1731 uploadAnalysisButton.setDisabled(isEditMode);
    acceptButton.setLabel(isEditMode ? resBundle.getString("importDialog.SAVE") : resBundle.getString("importDialog.IMPORT"));
    if (!isEditMode) {
        return;
    }
    String url = GWT.getModuleBaseURL();
    int indexOfContent = url.indexOf("content");
    if (indexOfContent > -1) {
        url = url.substring(0, indexOfContent);
        url = url + "plugin/data-access/api/datasource/" + NameUtils.URLEncode(datasourceInfo.getId()) + "/getAnalysisDatasourceInfo";
    }
    RequestBuilder requestBuilder = new RequestBuilder(RequestBuilder.GET, url);
    requestBuilder.setHeader("If-Modified-Since", "01 Jan 1970 00:00:00 GMT");
    try {
        requestBuilder.sendRequest(null, new RequestCallback() {

            public void onError(Request request, Throwable e) {
                logger.log(Level.ALL, e.getMessage());
            }

            public void onResponseReceived(Request request, final Response response) {
                boolean paramHandled, hasParameters = false;
                String responseValue = response.getText();
                StringBuilder name = new StringBuilder();
                StringBuilder value = new StringBuilder();
                int state = 0;
                char ch;
                int i, len = responseValue.length();
                for (i = 0; i < len; i++) {
                    ch = responseValue.charAt(i);
                    switch(state) {
                        case // new name/value pair
                        0:
                            paramHandled = handleParam(name, value);
                            if (!hasParameters) {
                                hasParameters = paramHandled;
                            }
                            switch(ch) {
                                case ';':
                                    break;
                                default:
                                    state = 1;
                                    name.append(ch);
                            }
                            break;
                        case // looking for equals
                        1:
                            switch(ch) {
                                case '=':
                                    state = 2;
                                    break;
                                default:
                                    name.append(ch);
                            }
                            break;
                        case // about to parse the value
                        2:
                            switch(ch) {
                                case '"':
                                    state = 3;
                                    break;
                                case ';':
                                    state = 0;
                                    break;
                                default:
                                    value.append(ch);
                                    state = 4;
                            }
                            break;
                        case // parse value till closing quote.
                        3:
                            switch(ch) {
                                case '"':
                                    state = 0;
                                    break;
                                default:
                                    value.append(ch);
                            }
                            break;
                        case 4:
                            switch(ch) {
                                case ';':
                                    state = 0;
                                    break;
                                default:
                                    value.append(ch);
                            }
                            break;
                        default:
                    }
                }
                paramHandled = handleParam(name, value);
                if (!hasParameters) {
                    hasParameters = paramHandled;
                }
                schemaNameLabel.setValue(datasourceInfo.getId() + ".mondrian.xml");
                importDialogModel.setUploadedFile(datasourceInfo.getId());
                int preference;
                XulRadio radio;
                if (hasParameters) {
                    preference = PARAMETER_MODE;
                    radio = manualRadio;
                } else {
                    preference = DATASOURCE_MODE;
                    radio = availableRadio;
                }
                setPreference(preference);
                radio.setSelected(true);
            }
        });
    } catch (Exception e) {
        logger.log(Level.ALL, e.getMessage());
    }
}
Also used : Response(com.google.gwt.http.client.Response) XulRadio(org.pentaho.ui.xul.components.XulRadio) RequestBuilder(com.google.gwt.http.client.RequestBuilder) RequestCallback(com.google.gwt.http.client.RequestCallback) Request(com.google.gwt.http.client.Request) XulException(org.pentaho.ui.xul.XulException) RequestException(com.google.gwt.http.client.RequestException)

Aggregations

XulRadio (org.pentaho.ui.xul.components.XulRadio)8 XulTextbox (org.pentaho.ui.xul.components.XulTextbox)5 BindingFactory (org.pentaho.ui.xul.binding.BindingFactory)4 XulException (org.pentaho.ui.xul.XulException)2 XulTab (org.pentaho.ui.xul.components.XulTab)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 Matchers.anyString (org.mockito.Matchers.anyString)1 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)1 BaseMessages.getString (org.pentaho.di.i18n.BaseMessages.getString)1 IDataServiceClientService (org.pentaho.di.trans.dataservice.client.api.IDataServiceClientService)1 AnnotationsQueryService (org.pentaho.di.trans.dataservice.clients.AnnotationsQueryService)1 Query (org.pentaho.di.trans.dataservice.clients.Query)1 PushDownOptimizationMeta (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)1 ServiceCache (org.pentaho.di.trans.dataservice.optimization.cache.ServiceCache)1 XulComponent (org.pentaho.ui.xul.XulComponent)1 Binding (org.pentaho.ui.xul.binding.Binding)1