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();
}
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");
}
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();
}
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();
}
}
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());
}
Aggregations