use of org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailBeanObservableInfo in project windowbuilder by eclipse.
the class TreeViewerInputBindingInfo method createContentProviders.
// //////////////////////////////////////////////////////////////////////////
//
// Editing
//
// //////////////////////////////////////////////////////////////////////////
@Override
public void createContentProviders(List<IUiContentProvider> providers, IPageListener listener, DatabindingsProvider provider) throws Exception {
// configure page
listener.setTitle(Messages.TreeViewerInputBindingInfo_title);
listener.setMessage(Messages.TreeViewerInputBindingInfo_errorMessage);
//
providers.add(new LabelUiContentProvider(Messages.TreeViewerInputBindingInfo_viewerLabel, m_viewerBindable.getPresentation().getTextForBinding()));
providers.add(new LabelUiContentProvider(Messages.TreeViewerInputBindingInfo_inputLabel, m_inputObservable.getPresentationText()));
//
TreeInputElementUiContentProvider inputEditor = new TreeInputElementUiContentProvider(this, listener, provider);
//
if (m_inputObservable instanceof DetailBeanObservableInfo) {
m_inputObservable.createContentProviders(providers, null, provider);
//
ChooseClassAndPropertiesUiContentProvider masterUIContentProvider = (ChooseClassAndPropertiesUiContentProvider) providers.get(providers.size() - 1);
//
ChooseClassConfiguration configuration = new ChooseClassConfiguration();
configuration.setDialogFieldLabel(Messages.TreeViewerInputBindingInfo_chooseLabel);
configuration.setValueScope("beans1");
configuration.setChooseInterfaces(true);
configuration.setEmptyClassErrorMessage(Messages.TreeViewerInputBindingInfo_chooseEmptyMessage);
configuration.setErrorMessagePrefix(Messages.TreeViewerInputBindingInfo_chooseErrorPrefix);
//
TreeDetailUiContentProvider detailUIContentProvider = new TreeDetailUiContentProvider(configuration, (DetailBeanObservableInfo) m_inputObservable);
providers.add(detailUIContentProvider);
//
new ChooseClassAndPropertiesRouter(masterUIContentProvider, detailUIContentProvider);
new ChooseClassRouter(detailUIContentProvider, new MultiTargetRunnable(detailUIContentProvider, inputEditor.getElementTypeUIProviders()));
}
//
providers.add(inputEditor);
//
super.createContentProviders(providers, listener, provider);
}
use of org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailBeanObservableInfo in project windowbuilder by eclipse.
the class ViewerInputBindingInfo method createContentProviders.
// //////////////////////////////////////////////////////////////////////////
//
// Editing
//
// //////////////////////////////////////////////////////////////////////////
@Override
public void createContentProviders(List<IUiContentProvider> providers, IPageListener listener, DatabindingsProvider provider) throws Exception {
// configure page
listener.setTitle(Messages.ViewerInputBindingInfo_title);
listener.setMessage(Messages.ViewerInputBindingInfo_message);
//
providers.add(new LabelUiContentProvider(Messages.ViewerInputBindingInfo_viewerLabel, m_viewerBindable.getPresentation().getTextForBinding()));
providers.add(new LabelUiContentProvider(Messages.ViewerInputBindingInfo_inputLabel, m_inputObservable.getPresentationText()));
m_labelProvider.createContentProviders(providers, provider, true);
// element type editor
ChooseClassAndPropertiesConfiguration configuration = new ChooseClassAndPropertiesConfiguration();
configuration.setDialogFieldLabel(Messages.ViewerInputBindingInfo_elementClassLabel);
configuration.setValueScope("beans");
configuration.setChooseInterfaces(true);
configuration.setEmptyClassErrorMessage(Messages.ViewerInputBindingInfo_elementClassEmptyMessage);
configuration.setErrorMessagePrefix(Messages.ViewerInputBindingInfo_elementClassErrorPrefix);
configuration.setPropertiesLabel(Messages.ViewerInputBindingInfo_elementClassPropertiesLabel);
configuration.setPropertiesMultiChecked(true);
configuration.setReorderMode(true);
configuration.setShowSelectionButtons(false);
configuration.setLoadedPropertiesCheckedStrategy(ChooseClassAndPropertiesConfiguration.LoadedPropertiesCheckedStrategy.None);
configuration.setPropertiesErrorMessage(Messages.ViewerInputBindingInfo_elementClassPropertiesErrorMessage);
//
if (m_inputObservable instanceof DetailBeanObservableInfo) {
configuration.setDialogFieldEnabled(false);
configuration.setValueScope("beans0");
m_inputObservable.createContentProviders(providers, null, provider);
}
//
GlobalFactoryHelper.configureChooseElementForViewerInput(m_inputObservable, configuration);
//
InputElementUiContentProvider inputUIContentProvider = new InputElementUiContentProvider(configuration, this);
//
if (m_inputObservable instanceof DetailBeanObservableInfo) {
new ChooseClassAndPropertiesRouter((ChooseClassAndPropertiesUiContentProvider) providers.get(providers.size() - 1), inputUIContentProvider);
}
//
providers.add(inputUIContentProvider);
//
super.createContentProviders(providers, listener, provider);
}
use of org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailBeanObservableInfo in project windowbuilder by eclipse.
the class AbstractViewerInputBindingInfo method setNewInputObservable.
/**
* Sets providers for new binding (during edit time).
*/
public final void setNewInputObservable(ObservableInfo input, DatabindingsProvider provider, boolean useViewerSupport) throws Exception {
m_inputObservable = input;
// calculate element type
Class<?> elementType = null;
//
if (m_inputObservable instanceof DetailBeanObservableInfo) {
DetailBeanObservableInfo inputObservable = (DetailBeanObservableInfo) m_inputObservable;
elementType = inputObservable.getDetailPropertyType();
} else if (m_inputObservable instanceof ViewerObservableInfo) {
elementType = getViewerInutElementType(m_inputObservable, provider);
}
// sets providers
if (m_inputObservable instanceof DetailBeanObservableInfo) {
setDefaultProviders(true, elementType, useViewerSupport);
} else {
setDefaultProviders(List.class.isAssignableFrom(m_inputObservable.getBindableProperty().getObjectType()), elementType, useViewerSupport);
}
}
use of org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailBeanObservableInfo in project windowbuilder by eclipse.
the class DirectObservableFactory method forDetailBean.
/**
* Factory with type {@link Type#Detail} for create master-detail observable's.
*/
public static IObservableFactory forDetailBean() {
return new DirectObservableFactory(Type.Detail) {
@Override
protected ObservableInfo createObservable(BeanBindableInfo bindableObject, DirectPropertyBindableInfo property, Type type, boolean version_1_3) throws Exception {
// create master
DirectObservableInfo masterObservable = new DirectObservableInfo(bindableObject, property);
// create detail
DetailBeanObservableInfo observable = null;
switch(type) {
case OnlyValue:
observable = new DetailValueBeanObservableInfo(masterObservable, null, null, null);
if (version_1_3) {
observable.setCodeSupport(new ValuePropertyDetailCodeSupport());
} else {
observable.setCodeSupport(new BeanObservableDetailValueCodeSupport());
}
break;
case OnlyList:
observable = new DetailListBeanObservableInfo(masterObservable, null, null, null);
if (version_1_3) {
observable.setCodeSupport(new ListPropertyDetailCodeSupport());
} else {
observable.setCodeSupport(new BeanObservableDetailListCodeSupport());
}
break;
case OnlySet:
observable = new DetailSetBeanObservableInfo(masterObservable, null, null, null);
if (version_1_3) {
observable.setCodeSupport(new SetPropertyDetailCodeSupport());
} else {
observable.setCodeSupport(new BeanObservableDetailSetCodeSupport());
}
break;
}
Assert.isNotNull(observable);
observable.setPojoBindable(masterObservable.isPojoBindable());
return observable;
}
};
}
use of org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailBeanObservableInfo in project windowbuilder by eclipse.
the class BeanObservableTest method test_observeDetailSet.
public void test_observeDetailSet() throws Exception {
setFileContentSrc("test/TestBean.java", getSourceDQ("package test;", "public class TestBean {", " public String getName() {", " return null;", " }", " public java.util.Set getValues() {", " return null;", " }", "}"));
waitForAutoBuild();
//
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " protected Shell m_shell;", " private DataBindingContext m_bindingContext;", " private TestBean m_bean0;", " public static void main(String[] args) {", " Test test = new Test();", " test.open();", " }", " public void open() {", " Display display = new Display();", " createContents();", " m_shell.open();", " m_shell.layout();", " while (!m_shell.isDisposed()) {", " if (!display.readAndDispatch()) {", " display.sleep();", " }", " }", " }", " protected void createContents() {", " m_shell = new Shell();", " m_bindingContext = initDataBindings();", " }", " private DataBindingContext initDataBindings() {", " IObservableValue observeValue0 = BeansObservables.observeValue(m_bean0, \"name\");", " IObservableSet observeDetailsSet = BeansObservables.observeDetailSet(Realm.getDefault(), observeValue0, \"empty\", boolean.class);", " IObservableSet observeSet1 = BeansObservables.observeSet(Realm.getDefault(), getBean1(), \"values\");", " DataBindingContext bindingContext = new DataBindingContext();", " bindingContext.bindSet(observeDetailsSet, observeSet1, null, null);", " return bindingContext;", " }", " public TestBean getBean1() {", " return null;", " }", "}" });
assertNotNull(shell);
//
DatabindingsProvider provider = getDatabindingsProvider();
List<IBindingInfo> bindings = provider.getBindings();
//
assertNotNull(bindings);
assertEquals(1, bindings.size());
//
BindingInfo binding = (BindingInfo) bindings.get(0);
//
assertInstanceOf(DetailSetBeanObservableInfo.class, binding.getTargetObservable());
DetailBeanObservableInfo targetObservable = (DetailBeanObservableInfo) binding.getTargetObservable();
//
assertNotNull(targetObservable.getMasterObservable());
assertInstanceOf(ValueBeanObservableInfo.class, targetObservable.getMasterObservable());
//
assertSame(targetObservable.getMasterObservable().getBindableObject(), targetObservable.getBindableObject());
BeanBindableTest.assertBindable(FieldBeanBindableInfo.class, null, true, "m_bean0 - TestBean|m_bean0|test.TestBean", targetObservable.getBindableObject());
//
assertSame(targetObservable.getMasterObservable().getBindableProperty(), targetObservable.getBindableProperty());
BeanBindableTest.assertBindable(BeanPropertyDescriptorBindableInfo.class, null, true, "name|\"name\"|java.lang.String", targetObservable.getBindableProperty());
//
assertEquals("\"empty\"", targetObservable.getDetailPropertyReference());
//
assertNotNull(targetObservable.getDetailPropertyType());
assertEquals("boolean", targetObservable.getDetailPropertyType().getName());
//
assertEquals("m_bean0.name.detailSet(\"empty\", boolean.class)", targetObservable.getPresentationText());
}
Aggregations