Search in sources :

Example 1 with TreeObservableLabelProviderInfo

use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo in project windowbuilder by eclipse.

the class TreeViewerInputBindingInfo method setDefaultProviders.

@Override
public void setDefaultProviders(boolean asList, Class<?> elementType, boolean useViewerSupport) throws Exception {
    // create advisor
    TreeBeanAdvisorInfo advisor = GlobalFactoryHelper.createTreeBeanAdvisor(m_inputObservable);
    if (advisor == null) {
        advisor = new TreeBeanAdvisorInfo();
    }
    advisor.setElementType(elementType);
    // create factory
    BeansObservableFactoryInfo factory = GlobalFactoryHelper.createTreeObservableFactory(m_inputObservable, asList);
    if (factory == null) {
        factory = asList ? new BeansListObservableFactoryInfo() : new BeansSetObservableFactoryInfo();
    }
    factory.setElementType(elementType);
    // create content provider
    m_contentProvider = asList ? new ObservableListTreeContentProviderInfo(factory, advisor) : new ObservableSetTreeContentProviderInfo(factory, advisor);
    // create label provider
    KnownElementsObservableInfo allElementsObservable = new KnownElementsObservableInfo(m_contentProvider);
    TreeObservableLabelProviderInfo labelProvider = GlobalFactoryHelper.createTreeLabelProvider(m_inputObservable, allElementsObservable);
    if (labelProvider == null) {
        labelProvider = new TreeObservableLabelProviderInfo(allElementsObservable);
    }
    labelProvider.setElementType(elementType);
    m_labelProvider = labelProvider;
}
Also used : BeansSetObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansSetObservableFactoryInfo) TreeObservableLabelProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo) TreeBeanAdvisorInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeBeanAdvisorInfo) BeansObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansObservableFactoryInfo) BeansListObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansListObservableFactoryInfo)

Example 2 with TreeObservableLabelProviderInfo

use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo in project windowbuilder by eclipse.

the class TreeContentLabelProvidersUiContentProvider method updateFromObject.

// //////////////////////////////////////////////////////////////////////////
// 
// Update
// 
// //////////////////////////////////////////////////////////////////////////
@Override
public void updateFromObject() throws Exception {
    if (m_binding.isDesignerMode()) {
        Class<?> elementType = m_binding.getElementType();
        if (elementType != null) {
            // set element type
            setElementType(elementType);
            // prepare checked groups
            List<Object> checkedObjects = Lists.newArrayList();
            // check parent/children/has children
            TreeBeanAdvisorInfo advisor = (TreeBeanAdvisorInfo) m_binding.getContentProvider().getAdvisorInfo();
            extractProperties(checkedObjects, PARENT_GROUP_NAME, advisor.getParentProperty());
            extractProperties(checkedObjects, CHILDREN_GROUP_NAME, advisor.getChildrenProperty());
            extractProperties(checkedObjects, HAS_CHILDREN_GROUP_NAME, advisor.getHasChildrenProperty());
            // check text/image
            TreeObservableLabelProviderInfo labelProvider = (TreeObservableLabelProviderInfo) m_binding.getLabelProvider();
            extractProperties(checkedObjects, TEXT_GROUP_NAME, labelProvider.getTextProperty());
            extractProperties(checkedObjects, IMAGE_GROUP_NAME, labelProvider.getImageProperty());
            // apply checked
            if (!checkedObjects.isEmpty()) {
                m_propertiesViewer.setCheckedElements(checkedObjects.toArray());
            }
        }
    }
    // 
    calculateFinish();
}
Also used : TreeObservableLabelProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo) TreeBeanAdvisorInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeBeanAdvisorInfo)

Example 3 with TreeObservableLabelProviderInfo

use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo in project windowbuilder by eclipse.

the class TreeContentLabelProvidersUiContentProvider method saveToObject.

@Override
public void saveToObject() throws Exception {
    // prepare content provider
    ObservableCollectionTreeContentProviderInfo contentProvider = m_binding.getContentProvider();
    // prepare factory
    BeansObservableFactoryInfo factory = (BeansObservableFactoryInfo) contentProvider.getFactoryInfo();
    // prepare advisor
    TreeBeanAdvisorInfo advisor = (TreeBeanAdvisorInfo) contentProvider.getAdvisorInfo();
    // prepare label provider
    TreeObservableLabelProviderInfo labelProvider = (TreeObservableLabelProviderInfo) m_binding.getLabelProvider();
    // extract checked properties
    for (Object element : m_propertiesViewer.getCheckedElements()) {
        if (element instanceof TreePropertyWrapper) {
            TreePropertyWrapper wrapper = (TreePropertyWrapper) element;
            String propertyName = wrapper.descriptor.getName();
            String groupName = wrapper.parent.name;
            // check group
            if (PARENT_GROUP_NAME.equals(groupName)) {
                advisor.setParentProperty(propertyName);
            } else if (CHILDREN_GROUP_NAME.equals(groupName)) {
                advisor.setChildrenProperty(propertyName);
                factory.setPropertyName(propertyName);
            } else if (HAS_CHILDREN_GROUP_NAME.equals(groupName)) {
                advisor.setHasChildrenProperty(propertyName);
            } else if (TEXT_GROUP_NAME.equals(groupName)) {
                labelProvider.setTextProperty(propertyName);
            } else if (IMAGE_GROUP_NAME.equals(groupName)) {
                labelProvider.setImageProperty(propertyName);
            }
        }
    }
}
Also used : ObservableCollectionTreeContentProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableCollectionTreeContentProviderInfo) TreeObservableLabelProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo) TreeBeanAdvisorInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeBeanAdvisorInfo) BeansObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansObservableFactoryInfo)

Example 4 with TreeObservableLabelProviderInfo

use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo in project windowbuilder by eclipse.

the class TreeInputElementUiContentProvider method createDesignerElementTypeUIProvider.

private ChooseClassUiContentProvider createDesignerElementTypeUIProvider() throws Exception {
    ChooseClassConfiguration configuration = new ChooseClassConfiguration();
    configuration.setDialogFieldLabel(Messages.TreeInputElementUiContentProvider_chooseDesigner);
    configuration.setValueScope("beans");
    configuration.setChooseInterfaces(true);
    configuration.setEmptyClassErrorMessage(Messages.TreeInputElementUiContentProvider_chooseDesignerEmptyMessage);
    configuration.setErrorMessagePrefix(Messages.TreeInputElementUiContentProvider_chooseDesignerErrorPrefix);
    // 
    GlobalFactoryHelper.configureChooseElementForTreeViewerInput(m_binding.getInputObservable(), configuration);
    // 
    return new ChooseClassUiContentProvider(configuration) {

        @Override
        public void updateFromObject() throws Exception {
            Class<?> elementType = m_binding.getElementType();
            if (elementType != null) {
                setClassName(CoreUtils.getClassName(elementType));
            } else {
                calculateFinish();
            }
        }

        @Override
        protected void calculateFinish() {
            super.calculateFinish();
            if (getErrorMessage() == null) {
                // route choose class events to properties editor
                ExecutionUtils.runLog(new RunnableEx() {

                    @Override
                    public void run() throws Exception {
                        m_contentLabelProvidersEditor.setElementType(getChoosenClass());
                    }
                });
            }
        }

        @Override
        public void saveToObject() throws Exception {
            // store element type
            Class<?> elementType = getChoosenClass();
            // 
            ObservableCollectionTreeContentProviderInfo contentProvider = m_binding.getContentProvider();
            // to factory
            BeansObservableFactoryInfo factory = (BeansObservableFactoryInfo) contentProvider.getFactoryInfo();
            factory.setElementType(elementType);
            // to advisor
            TreeBeanAdvisorInfo advisor = (TreeBeanAdvisorInfo) contentProvider.getAdvisorInfo();
            advisor.setElementType(elementType);
            // to label provider
            TreeObservableLabelProviderInfo labelProvider = (TreeObservableLabelProviderInfo) m_binding.getLabelProvider();
            labelProvider.setElementType(elementType);
            // to input
            InputElementUiContentProvider.setElementTypeToInput(m_binding, elementType);
        }
    };
}
Also used : ObservableCollectionTreeContentProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableCollectionTreeContentProviderInfo) TreeObservableLabelProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo) TreeBeanAdvisorInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeBeanAdvisorInfo) RunnableEx(org.eclipse.wb.internal.core.utils.execution.RunnableEx) ChooseClassUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassUiContentProvider) BeansObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansObservableFactoryInfo) ChooseClassConfiguration(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassConfiguration)

Example 5 with TreeObservableLabelProviderInfo

use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo in project windowbuilder by eclipse.

the class TreeInputElementUiContentProvider method createDesignerProviders.

/**
 * Fill Designer page.
 */
private List<IUiContentProvider> createDesignerProviders() {
    List<IUiContentProvider> providers = Lists.newArrayList();
    providers.add(m_elementTypeDesignerUIProvider);
    // 
    if (m_binding.isDesignerMode()) {
        // add life objects
        createDefaultProviders(providers, true);
    } else {
        // create fake objects
        ObservableCollectionTreeContentProviderInfo contentProvider = m_binding.getContentProvider();
        // create factory
        boolean asList = contentProvider instanceof ObservableListTreeContentProviderInfo;
        BeansObservableFactoryInfo factory = null;
        try {
            factory = GlobalFactoryHelper.createTreeObservableFactory(m_binding.getInputObservable(), asList);
        } catch (Throwable e) {
            DesignerPlugin.log(e);
        }
        if (factory == null) {
            factory = asList ? new BeansListObservableFactoryInfo() : new BeansSetObservableFactoryInfo();
        }
        // 
        m_defaultObjects.add(factory);
        factory.createContentProviders(providers, m_provider);
        // create advisor
        TreeBeanAdvisorInfo advisor = null;
        try {
            advisor = GlobalFactoryHelper.createTreeBeanAdvisor(m_binding.getInputObservable());
        } catch (Throwable e) {
            DesignerPlugin.log(e);
        }
        if (advisor == null) {
            advisor = new TreeBeanAdvisorInfo();
        }
        m_defaultObjects.add(advisor);
        advisor.createContentProviders(providers, m_provider);
        // content provider always exist
        contentProvider.createContentProviders(providers, m_provider, true);
        // create label provider
        KnownElementsObservableInfo allElementsObservable = new KnownElementsObservableInfo(contentProvider);
        TreeObservableLabelProviderInfo labelProvider = null;
        try {
            labelProvider = GlobalFactoryHelper.createTreeLabelProvider(m_binding.getInputObservable(), allElementsObservable);
        } catch (Throwable e) {
            DesignerPlugin.log(e);
        }
        if (labelProvider == null) {
            labelProvider = new TreeObservableLabelProviderInfo(allElementsObservable);
        }
        m_defaultObjects.add(labelProvider);
        labelProvider.createContentProviders(providers, m_provider, true);
    }
    // content provider for properties: parent/children/has children/text/image
    m_contentLabelProvidersEditor = new TreeContentLabelProvidersUiContentProvider(m_binding);
    providers.add(m_contentLabelProvidersEditor);
    return providers;
}
Also used : ObservableCollectionTreeContentProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableCollectionTreeContentProviderInfo) BeansSetObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansSetObservableFactoryInfo) TreeBeanAdvisorInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeBeanAdvisorInfo) IUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider) BeansObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansObservableFactoryInfo) BeansListObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansListObservableFactoryInfo) TreeObservableLabelProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo) KnownElementsObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo) ObservableListTreeContentProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableListTreeContentProviderInfo)

Aggregations

TreeBeanAdvisorInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeBeanAdvisorInfo)8 TreeObservableLabelProviderInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo)8 BeansObservableFactoryInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansObservableFactoryInfo)5 BeansListObservableFactoryInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansListObservableFactoryInfo)4 BeansSetObservableFactoryInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansSetObservableFactoryInfo)4 MapsBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.MapsBeanObservableInfo)3 KnownElementsObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo)3 ObservableCollectionTreeContentProviderInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableCollectionTreeContentProviderInfo)3 IBindingInfo (org.eclipse.wb.internal.core.databinding.model.IBindingInfo)2 IObserveInfo (org.eclipse.wb.internal.core.databinding.model.IObserveInfo)2 DatabindingsProvider (org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider)2 ObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo)2 DetailListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo)2 DetailSetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo)2 ListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ListBeanObservableInfo)2 SetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.SetBeanObservableInfo)2 WritableListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableListBeanObservableInfo)2 WritableSetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableSetBeanObservableInfo)2 ObservableListTreeContentProviderInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableListTreeContentProviderInfo)2 TreeViewerInputBindingInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.TreeViewerInputBindingInfo)2