Search in sources :

Example 1 with DetailBeanObservableInfo

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);
}
Also used : ChooseClassAndPropertiesRouter(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesRouter) LabelUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.LabelUiContentProvider) TreeDetailUiContentProvider(org.eclipse.wb.internal.rcp.databinding.ui.contentproviders.TreeDetailUiContentProvider) ChooseClassRouter(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassRouter) TreeInputElementUiContentProvider(org.eclipse.wb.internal.rcp.databinding.ui.contentproviders.TreeInputElementUiContentProvider) ChooseClassAndPropertiesUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesUiContentProvider) MultiTargetRunnable(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.MultiTargetRunnable) DetailBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailBeanObservableInfo) ChooseClassConfiguration(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassConfiguration)

Example 2 with DetailBeanObservableInfo

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);
}
Also used : ChooseClassAndPropertiesRouter(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesRouter) LabelUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.LabelUiContentProvider) InputElementUiContentProvider(org.eclipse.wb.internal.rcp.databinding.ui.contentproviders.InputElementUiContentProvider) ChooseClassAndPropertiesConfiguration(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesConfiguration) DetailBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailBeanObservableInfo)

Example 3 with DetailBeanObservableInfo

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);
    }
}
Also used : ViewerObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.ViewerObservableInfo) ArrayList(java.util.ArrayList) List(java.util.List) DetailBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailBeanObservableInfo)

Example 4 with DetailBeanObservableInfo

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;
        }
    };
}
Also used : SetPropertyDetailCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.properties.SetPropertyDetailCodeSupport) DetailListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo) DetailValueBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailValueBeanObservableInfo) ListPropertyDetailCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.properties.ListPropertyDetailCodeSupport) ValuePropertyDetailCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.properties.ValuePropertyDetailCodeSupport) BeanBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanBindableInfo) BeanObservableDetailValueCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.BeanObservableDetailValueCodeSupport) BeanObservableDetailListCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.BeanObservableDetailListCodeSupport) DetailSetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo) BeanObservableDetailSetCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.BeanObservableDetailSetCodeSupport) DetailBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailBeanObservableInfo)

Example 5 with DetailBeanObservableInfo

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());
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) BindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo) DetailBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailBeanObservableInfo)

Aggregations

DetailBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailBeanObservableInfo)8 IBindingInfo (org.eclipse.wb.internal.core.databinding.model.IBindingInfo)2 ChooseClassAndPropertiesRouter (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesRouter)2 LabelUiContentProvider (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.LabelUiContentProvider)2 DatabindingsProvider (org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider)2 ObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo)2 BindingInfo (org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo)2 CompositeInfo (org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ChooseClassAndPropertiesConfiguration (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesConfiguration)1 ChooseClassAndPropertiesUiContentProvider (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesUiContentProvider)1 ChooseClassConfiguration (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassConfiguration)1 ChooseClassRouter (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassRouter)1 MultiTargetRunnable (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.MultiTargetRunnable)1 BeanBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanBindableInfo)1 CollectionObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.CollectionObservableInfo)1 DetailListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo)1 DetailSetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo)1 DetailValueBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailValueBeanObservableInfo)1