Search in sources :

Example 1 with BindingFactory

use of org.pentaho.ui.xul.binding.BindingFactory in project pdi-dataservice-server-plugin by pentaho.

the class ParameterGenerationController method initBindings.

public void initBindings(List<String> supportedSteps) {
    BindingFactory bindingFactory = getBindingFactory();
    XulMenuList<String> stepList = getStepMenuList();
    stepList.setElements(supportedSteps);
    getElementById("param_gen_add").setDisabled(supportedSteps.isEmpty());
    // BI DIRECTIONAL bindings
    bindingFactory.setBindingType(Binding.Type.BI_DIRECTIONAL);
    bindingFactory.createBinding(model, "selectedParameter", "param_gen_list", "selectedItem");
    bindingFactory.createBinding(model, "selectedStep", stepList, "value");
    bindingFactory.createBinding(model, "enabled", "param_gen_enabled", "checked", not());
    // ONE WAY bindings
    bindingFactory.setBindingType(Binding.Type.ONE_WAY);
    bindingFactory.createBinding(model, "parameterMap", "param_gen_list", "elements", keySet());
    bindingFactory.createBinding(model, "selectedParameter", "param_gen_edit", "disabled", stringIsEmpty());
    bindingFactory.createBinding(model, "selectedParameter", "param_gen_remove", "disabled", stringIsEmpty());
    bindingFactory.createBinding(model, "selectedParameter", "param_gen_enabled", "disabled", stringIsEmpty());
    bindingFactory.createBinding(model, "enabled", "param_gen_step", "disabled", not());
    bindingFactory.createBinding(model, "enabled", "param_gen_mapping", "disabled", not());
    bindingFactory.createBinding(model, "mappings", "param_gen_mapping", "elements");
    model.updateParameterMap();
}
Also used : BaseMessages.getString(org.pentaho.di.i18n.BaseMessages.getString) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory)

Example 2 with BindingFactory

use of org.pentaho.ui.xul.binding.BindingFactory in project pdi-dataservice-server-plugin by pentaho.

the class ServiceCacheController method initBindings.

public void initBindings(DataServiceModel model) {
    PushDownOptimizationMeta meta = locateServiceCacheMeta(model);
    ServiceCache serviceCache = (ServiceCache) meta.getType();
    BindingFactory bindingFactory = getBindingFactory();
    XulRadio normalModeRadio = getElementById("regular-type-radio");
    XulTab serviceCacheTab = getElementById("service-cache-tab");
    XulCheckbox serviceCacheCheckBox = getElementById("service-cache-checkbox");
    XulTextbox serviceCacheTextBox = getElementById("service-cache-ttl");
    bindingFactory.setBindingType(Binding.Type.ONE_WAY);
    serviceCacheCheckBox.setChecked(meta.isEnabled());
    serviceCacheTab.setVisible(!model.isStreaming());
    try {
        serviceCacheTextBox.setValue(serviceCache.getConfiguredTimeToLive());
    } catch (Exception e) {
        getLogChannel().logError("Unable to set default TTL", e);
    }
    bindingFactory.createBinding(serviceCacheTextBox, "value", serviceCache, "timeToLive");
    bindingFactory.createBinding(serviceCacheCheckBox, "checked", meta, "enabled");
    bindingFactory.createBinding(serviceCacheCheckBox, "checked", serviceCacheTextBox, "disabled", not());
    bindingFactory.createBinding(normalModeRadio, "selected", serviceCacheTab, "visible");
}
Also used : XulCheckbox(org.pentaho.ui.xul.components.XulCheckbox) XulRadio(org.pentaho.ui.xul.components.XulRadio) ServiceCache(org.pentaho.di.trans.dataservice.optimization.cache.ServiceCache) XulTextbox(org.pentaho.ui.xul.components.XulTextbox) PushDownOptimizationMeta(org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta) XulTab(org.pentaho.ui.xul.components.XulTab) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory)

Example 3 with BindingFactory

use of org.pentaho.ui.xul.binding.BindingFactory in project pdi-dataservice-server-plugin by pentaho.

the class ParameterPushdownController method initBindings.

private void initBindings() {
    BindingFactory bindingFactory = getBindingFactory();
    bindingFactory.setBindingType(Binding.Type.ONE_WAY);
    bindingFactory.createBinding(model, "definitions", "param_definitions", "elements");
    model.reset();
}
Also used : BindingFactory(org.pentaho.ui.xul.binding.BindingFactory)

Example 4 with BindingFactory

use of org.pentaho.ui.xul.binding.BindingFactory in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceDialogControllerTest method testBindingsAux.

private void testBindingsAux() throws Exception {
    final BindingFactory bindingFactory = mock(BindingFactory.class);
    final XulTextbox serviceName = mock(XulTextbox.class);
    final XulMenuList<String> steps = mock(XulMenuList.class);
    final XulRadio streamingModeRadio = mock(XulRadio.class);
    final XulRadio regularModeRadio = mock(XulRadio.class);
    when(document.getElementById("service-name")).thenReturn(serviceName);
    when(document.getElementById("trans-steps")).thenReturn(steps);
    when(document.getElementById("streaming-type-radio")).thenReturn(streamingModeRadio);
    when(document.getElementById("regular-type-radio")).thenReturn(regularModeRadio);
    controller.setBindingFactory(bindingFactory);
    final List<Binding> bindings = Lists.newArrayList();
    when(bindingFactory.createBinding(same(model), anyString(), any(XulComponent.class), anyString())).thenAnswer(invocationOnMock -> {
        Binding binding = mock(Binding.class);
        bindings.add(binding);
        return binding;
    });
    when(bindingFactory.createBinding(same(model), anyString(), any(XulComponent.class), anyString(), any(BindingConvertor.class))).thenAnswer(invocationOnMock -> {
        Binding binding = mock(Binding.class);
        bindings.add(binding);
        return binding;
    });
    controller.init();
    verify(steps).setElements(eq(ImmutableList.of(STEP_ONE_NAME, STEP_TWO_NAME)));
    for (Binding binding : bindings) {
        verify(binding).fireSourceChanged();
    }
}
Also used : Binding(org.pentaho.ui.xul.binding.Binding) XulRadio(org.pentaho.ui.xul.components.XulRadio) XulTextbox(org.pentaho.ui.xul.components.XulTextbox) Matchers.anyString(org.mockito.Matchers.anyString) XulComponent(org.pentaho.ui.xul.XulComponent) BindingConvertor(org.pentaho.ui.xul.binding.BindingConvertor) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory)

Example 5 with BindingFactory

use of org.pentaho.ui.xul.binding.BindingFactory in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceRemapStepChooserDialogControllerTest method testInit.

@Test
public void testInit() throws InvocationTargetException, XulException {
    DataServiceRemapStepChooserModel model = mock(DataServiceRemapStepChooserModel.class);
    DataServiceMeta dataService = mock(DataServiceMeta.class);
    List<String> stepNames = Arrays.asList("step1");
    DataServiceDelegate delegate = mock(DataServiceDelegate.class);
    final SwtLabel label = mock(SwtLabel.class);
    final SwtListbox listbox = mock(SwtListbox.class);
    BindingFactory bindingFactory = mock(BindingFactory.class);
    when(bindingFactory.createBinding(same(model), anyString(), any(XulComponent.class), anyString())).thenReturn(mock(Binding.class));
    DataServiceRemapStepChooserDialogController controller = spy(new DataServiceRemapStepChooserDialogController(model, dataService, stepNames, delegate));
    doAnswer(new Answer() {

        private Object[] returnValues = { label, listbox };

        int invocations = 0;

        @Override
        public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
            return returnValues[invocations++];
        }
    }).when(controller).getElementById(anyString());
    doReturn(bindingFactory).when(controller).getBindingFactory();
    controller.init();
    verify(label).setValue(anyString());
    verify(listbox).setElements(same(stepNames));
    verify(bindingFactory).createBinding(same(model), anyString(), same(listbox), anyString());
}
Also used : Binding(org.pentaho.ui.xul.binding.Binding) DataServiceMeta(org.pentaho.di.trans.dataservice.DataServiceMeta) SwtListbox(org.pentaho.ui.xul.swt.tags.SwtListbox) Matchers.anyString(org.mockito.Matchers.anyString) SwtLabel(org.pentaho.ui.xul.swt.tags.SwtLabel) Answer(org.mockito.stubbing.Answer) Mockito.doAnswer(org.mockito.Mockito.doAnswer) InvocationOnMock(org.mockito.invocation.InvocationOnMock) DataServiceRemapStepChooserModel(org.pentaho.di.trans.dataservice.ui.model.DataServiceRemapStepChooserModel) DataServiceDelegate(org.pentaho.di.trans.dataservice.ui.DataServiceDelegate) XulComponent(org.pentaho.ui.xul.XulComponent) BindingFactory(org.pentaho.ui.xul.binding.BindingFactory) Test(org.junit.Test)

Aggregations

BindingFactory (org.pentaho.ui.xul.binding.BindingFactory)17 GwtBindingFactory (org.pentaho.ui.xul.gwt.binding.GwtBindingFactory)7 ResourceBundle (org.pentaho.gwt.widgets.client.utils.i18n.ResourceBundle)4 GwtDatasourceMessages (org.pentaho.platform.dataaccess.datasource.wizard.GwtDatasourceMessages)3 XulRadio (org.pentaho.ui.xul.components.XulRadio)3 XulTextbox (org.pentaho.ui.xul.components.XulTextbox)3 Matchers.anyString (org.mockito.Matchers.anyString)2 JoinTableModel (org.pentaho.agilebi.modeler.models.JoinTableModel)2 BaseMessages.getString (org.pentaho.di.i18n.BaseMessages.getString)2 XulComponent (org.pentaho.ui.xul.XulComponent)2 Binding (org.pentaho.ui.xul.binding.Binding)2 GwtXulDomContainer (org.pentaho.ui.xul.gwt.GwtXulDomContainer)2 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 List (java.util.List)1 FileObject (org.apache.commons.vfs2.FileObject)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1 SWTException (org.eclipse.swt.SWTException)1 SashForm (org.eclipse.swt.custom.SashForm)1