Search in sources :

Example 1 with ObservableCollectionTreeContentProviderInfo

use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableCollectionTreeContentProviderInfo 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 2 with ObservableCollectionTreeContentProviderInfo

use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableCollectionTreeContentProviderInfo 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 3 with ObservableCollectionTreeContentProviderInfo

use of org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableCollectionTreeContentProviderInfo 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)

Example 4 with ObservableCollectionTreeContentProviderInfo

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

the class TreeInputElementUiContentProvider method saveToObject.

@Override
public void saveToObject() throws Exception {
    // check change mode
    boolean editorMode = isDesignerMode();
    if (m_binding.isDesignerMode() != editorMode) {
        ObservableCollectionTreeContentProviderInfo contentProvider = m_binding.getContentProvider();
        contentProvider.setFactoryInfo((ObservableFactoryInfo) m_defaultObjects.get(0));
        contentProvider.setAdvisorInfo((TreeStructureAdvisorInfo) m_defaultObjects.get(1));
        m_binding.setLabelProvider((LabelProviderInfo) m_defaultObjects.get(2));
    }
    // save edit objects
    if (editorMode) {
        m_designerComposite.performFinish();
    } else {
        m_jfaceComposite.performFinish();
        saveJFaceObjects();
    }
}
Also used : ObservableCollectionTreeContentProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableCollectionTreeContentProviderInfo)

Example 5 with ObservableCollectionTreeContentProviderInfo

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

the class TreeInputElementUiContentProvider method saveJFaceObjects.

private void saveJFaceObjects() throws Exception {
    ObservableCollectionTreeContentProviderInfo contentProvider = m_binding.getContentProvider();
    ObservableFactoryInfo factoryInfo = contentProvider.getFactoryInfo();
    if (factoryInfo instanceof AbstractFactoryInfo) {
        AbstractFactoryInfo aFactoryInfo = (AbstractFactoryInfo) factoryInfo;
        // 
        if (aFactoryInfo.isCancel()) {
            // 
            ObservableFactoryInfo newFactoryInfo = new ObservableFactoryInfo(aFactoryInfo.getOriginalClassName());
            newFactoryInfo.setVariableIdentifier(aFactoryInfo.getVariableIdentifier());
            contentProvider.setFactoryInfo(newFactoryInfo);
            // 
            boolean version_1_3 = Activator.getStore().getBoolean(IPreferenceConstants.GENERATE_CODE_FOR_VERSION_1_3);
            ObservableInfo inputObservable = m_binding.getInputObservable();
            ObservableInfo newInputObservable = null;
            if (contentProvider instanceof ObservableListTreeContentProviderInfo) {
                newInputObservable = new ListBeanObservableInfo((BeanBindableInfo) inputObservable.getBindableObject(), (BeanPropertyBindableInfo) inputObservable.getBindableProperty());
                if (version_1_3) {
                    newInputObservable.setCodeSupport(new ListPropertyCodeSupport());
                } else {
                    newInputObservable.setCodeSupport(new BeanObservableListCodeSupport());
                }
            } else {
                newInputObservable = new SetBeanObservableInfo((BeanBindableInfo) inputObservable.getBindableObject(), (BeanPropertyBindableInfo) inputObservable.getBindableProperty());
                if (version_1_3) {
                    newInputObservable.setCodeSupport(new SetPropertyCodeSupport());
                } else {
                    newInputObservable.setCodeSupport(new BeanObservableSetCodeSupport());
                }
            }
            newInputObservable.setVariableIdentifier(inputObservable.getVariableIdentifier());
            m_binding.setInputObservable(newInputObservable);
        }
    } else if (factoryInfo.getClassName().startsWith("listFactory(") || factoryInfo.getClassName().startsWith("setFactory(")) {
        // 
        AbstractFactoryInfo newFactoryInfo = null;
        // 
        if (contentProvider instanceof ObservableListTreeContentProviderInfo) {
            newFactoryInfo = new BeansObservableListFactoryInfo();
        } else {
            newFactoryInfo = new BeansObservableSetFactoryInfo();
        }
        // 
        ObservableInfo inputObservable = m_binding.getInputObservable();
        // 
        newFactoryInfo.setPropertyName(inputObservable.getBindableProperty().getReference());
        newFactoryInfo.setElementType(inputObservable.getBindableObject().getObjectType());
        newFactoryInfo.setVariableIdentifier(factoryInfo.getVariableIdentifier());
        contentProvider.setFactoryInfo(newFactoryInfo);
        // 
        m_binding.setInputObservable(new BeanFieldInputObservableInfo(inputObservable.getBindableObject(), inputObservable.getBindableProperty()));
    }
}
Also used : ObservableCollectionTreeContentProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableCollectionTreeContentProviderInfo) SetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.SetBeanObservableInfo) ObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo) BeanFieldInputObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.BeanFieldInputObservableInfo) KnownElementsObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo) MapsBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.MapsBeanObservableInfo) ListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ListBeanObservableInfo) BeansObservableSetFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.BeansObservableSetFactoryInfo) SetBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.SetBeanObservableInfo) ListBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ListBeanObservableInfo) ListPropertyCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.properties.ListPropertyCodeSupport) BeanBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanBindableInfo) BeanPropertyBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanPropertyBindableInfo) BeanFieldInputObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.BeanFieldInputObservableInfo) BeansListObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansListObservableFactoryInfo) BeansSetObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansSetObservableFactoryInfo) BeansObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansObservableFactoryInfo) ObservableFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableFactoryInfo) AbstractFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.AbstractFactoryInfo) SetPropertyCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.properties.SetPropertyCodeSupport) BeanObservableSetCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.BeanObservableSetCodeSupport) ObservableListTreeContentProviderInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableListTreeContentProviderInfo) BeanObservableListCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.standard.BeanObservableListCodeSupport) BeansObservableListFactoryInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.BeansObservableListFactoryInfo)

Aggregations

ObservableCollectionTreeContentProviderInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableCollectionTreeContentProviderInfo)6 BeansObservableFactoryInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansObservableFactoryInfo)4 TreeBeanAdvisorInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeBeanAdvisorInfo)3 TreeObservableLabelProviderInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.TreeObservableLabelProviderInfo)3 KnownElementsObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo)2 ObservableListTreeContentProviderInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ObservableListTreeContentProviderInfo)2 BeansListObservableFactoryInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansListObservableFactoryInfo)2 BeansSetObservableFactoryInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.designer.BeansSetObservableFactoryInfo)2 IUiContentProvider (org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider)1 ChooseClassConfiguration (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassConfiguration)1 ChooseClassUiContentProvider (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassUiContentProvider)1 RunnableEx (org.eclipse.wb.internal.core.utils.execution.RunnableEx)1 ObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo)1 BeanBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanBindableInfo)1 BeanPropertyBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanPropertyBindableInfo)1 ListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ListBeanObservableInfo)1 MapsBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.MapsBeanObservableInfo)1 SetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.SetBeanObservableInfo)1 ListPropertyCodeSupport (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.properties.ListPropertyCodeSupport)1 SetPropertyCodeSupport (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.properties.SetPropertyCodeSupport)1