Search in sources :

Example 1 with PropertyInfo

use of org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport.PropertyInfo in project windowbuilder by eclipse.

the class GlobalObservableFactory method automaticWizardGetProperties.

@Override
public List<PropertyAdapter> automaticWizardGetProperties(IJavaProject javaProject, ClassLoader classLoader, Class<?> eObjectClass) throws Exception {
    if (isEMFObject(classLoader, eObjectClass)) {
        List<PropertyAdapter> properties = Lists.newArrayList();
        List<VariableDeclarationFragment> fragments = Collections.emptyList();
        PropertiesSupport propertiesSupport = new PropertiesSupport(javaProject, classLoader, fragments);
        // 
        for (PropertyInfo emfPropertyInfo : propertiesSupport.getProperties(eObjectClass)) {
            properties.add(new PropertyAdapter(emfPropertyInfo.name, emfPropertyInfo.type));
        }
        return properties;
    }
    return null;
}
Also used : VariableDeclarationFragment(org.eclipse.jdt.core.dom.VariableDeclarationFragment) PropertiesSupport(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport) PropertyAdapter(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.PropertyAdapter) PropertyInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport.PropertyInfo)

Example 2 with PropertyInfo

use of org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport.PropertyInfo in project windowbuilder by eclipse.

the class GlobalObservableFactory method filterElementPropertiesForTreeViewerInput.

@Override
public void filterElementPropertiesForTreeViewerInput(ObservableInfo inputObservable, Class<?> elementType, List<PropertyDescriptor> descriptors) throws Exception {
    if (inputObservable instanceof ListEmfObservableInfo || inputObservable instanceof DetailListEmfObservableInfo) {
        descriptors.clear();
        PropertiesSupport propertiesSupport = getPropertiesSupport(inputObservable);
        for (PropertyInfo emfProperty : propertiesSupport.getProperties(elementType)) {
            descriptors.add(createProperty(emfProperty.name, emfProperty.type));
        }
    }
}
Also used : ListEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.ListEmfObservableInfo) DetailListEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailListEmfObservableInfo) DetailListEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailListEmfObservableInfo) PropertiesSupport(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport) PropertyInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport.PropertyInfo)

Example 3 with PropertyInfo

use of org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport.PropertyInfo in project windowbuilder by eclipse.

the class DetailEmfObservableInfo method createContentProviders.

// //////////////////////////////////////////////////////////////////////////
// 
// Editing
// 
// //////////////////////////////////////////////////////////////////////////
@Override
public void createContentProviders(List<IUiContentProvider> providers, BindingUiContentProviderContext context, DatabindingsProvider provider) throws Exception {
    m_masterObservable.createContentProviders(providers, context, provider);
    // 
    ChooseClassAndPropertiesConfiguration configuration = new ChooseClassAndPropertiesConfiguration(getConfiguration());
    configuration.setBaseClassName("org.eclipse.emf.ecore.EObject");
    // 
    providers.add(new ObservableDetailUiContentProvider(configuration, this, provider) {

        @Override
        protected List<PropertyAdapter> getProperties(Class<?> choosenClass) throws Exception {
            List<PropertyAdapter> properties = Lists.newArrayList();
            for (PropertyInfo emfPropertyInfo : m_propertiesSupport.getProperties(choosenClass)) {
                properties.add(new ChooseClassAndTreePropertiesUiContentProvider.ObservePropertyAdapter(null, new EPropertyBindableInfo(m_propertiesSupport, null, emfPropertyInfo.type, emfPropertyInfo.name, emfPropertyInfo.reference)));
            }
            return properties;
        }

        @Override
        protected void setClassNameAndProperties(Class<?> beanClass, String beanClassName, List<String> properties) throws Exception {
            if (beanClassName == null) {
                setClassName(CoreUtils.getClassName(beanClass));
            } else {
                setClassName(beanClassName);
            }
            // 
            EObjectBindableInfo eObject = new EObjectBindableInfo(beanClass, null, m_propertiesSupport, null);
            // 
            Object[] adapters = new Object[properties.size()];
            for (int i = 0; i < adapters.length; i++) {
                adapters[i] = convertPropertyToAdapter(eObject.resolvePropertyReference(properties.get(i)));
            }
            // 
            setCheckedAndExpand(adapters);
            calculatePropertiesFinish();
        }

        @Override
        protected ObservePropertyAdapter convertPropertyToAdapter(IObserveInfo observe) throws Exception {
            if (observe instanceof EPropertyBindableInfo) {
                EPropertyBindableInfo property = (EPropertyBindableInfo) observe;
                ObservePropertyAdapter adapter = new ObservePropertyAdapter(convertPropertyToAdapter(property.getParent()), property);
                adapter.addToParent();
                return adapter;
            }
            return null;
        }
    });
}
Also used : IObserveInfo(org.eclipse.wb.internal.core.databinding.model.IObserveInfo) EObjectBindableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EObjectBindableInfo) ChooseClassAndPropertiesConfiguration(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesConfiguration) ObservableDetailUiContentProvider(org.eclipse.wb.internal.rcp.databinding.ui.contentproviders.ObservableDetailUiContentProvider) List(java.util.List) EPropertyBindableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EPropertyBindableInfo) PropertyInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport.PropertyInfo)

Example 4 with PropertyInfo

use of org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport.PropertyInfo in project windowbuilder by eclipse.

the class DetailEmfObservableInfo method setDetailPropertyReference.

// //////////////////////////////////////////////////////////////////////////
// 
// Constructor
// 
// //////////////////////////////////////////////////////////////////////////
@Override
public void setDetailPropertyReference(Class<?> detailBeanClass, String detailPropertyReference) throws Exception {
    m_detailPropertyReference = detailPropertyReference;
    // 
    if (detailBeanClass == null) {
        if (detailPropertyReference.startsWith("org.eclipse.emf.databinding.FeaturePath.fromList(")) {
            detailPropertyReference = StringUtils.substringBetween(detailPropertyReference, "(", ")");
            String[] references = StringUtils.split(detailPropertyReference, ", ");
            detailPropertyReference = references[references.length - 1];
        }
    } else {
        m_detailBeanClass = detailBeanClass;
    }
    // prepare EMF class info
    Object[] result = m_propertiesSupport.getClassInfoForProperty(detailPropertyReference);
    Assert.isNotNull(result);
    // prepare detail class
    if (detailBeanClass == null) {
        ClassInfo classInfo = (ClassInfo) result[0];
        m_detailBeanClass = classInfo.thisClass;
    }
    // prepare EMF property
    PropertyInfo emfPropertyInfo = (PropertyInfo) result[1];
    Assert.isNotNull(emfPropertyInfo.type);
    m_detailPropertyType = emfPropertyInfo.type;
    // 
    m_detailEMFPropertyName = "\"" + emfPropertyInfo.name + "\"";
}
Also used : PropertyInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport.PropertyInfo) ClassInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport.ClassInfo)

Example 5 with PropertyInfo

use of org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport.PropertyInfo in project windowbuilder by eclipse.

the class MapsEmfObservableInfo method setEMFProperties.

public void setEMFProperties(List<String> referenceProperties) throws Exception {
    Assert.isTrue(!CollectionUtils.isEmpty(referenceProperties));
    // prepare EMF class info
    Object[] firstResult = m_propertiesSupport.getClassInfoForProperty(referenceProperties.get(0));
    Assert.isNotNull(firstResult);
    // 
    m_emfProperties = Lists.newArrayList();
    List<String> properties = Lists.newArrayList();
    HierarchySupport hierarchySupport = new HierarchySupport(m_propertiesSupport, false);
    // prepare EMF properties
    for (String propertyReference : referenceProperties) {
        Object[] result = m_propertiesSupport.getClassInfoForProperty(propertyReference);
        Assert.isNotNull(result);
        ClassInfo classInfo = (ClassInfo) result[0];
        Assert.isNotNull(classInfo.thisClass);
        hierarchySupport.addClass(classInfo);
        // 
        for (PropertyInfo property : classInfo.properties) {
            if (propertyReference.equals(property.reference)) {
                m_emfProperties.add(property);
                properties.add(property.name);
                break;
            }
        }
    }
    // prepare element type
    ClassInfo lastClassInfo = hierarchySupport.getLastClass();
    setElementType(lastClassInfo.thisClass);
    // 
    Assert.equals(referenceProperties.size(), m_emfProperties.size());
    super.setProperties(properties.toArray(new String[properties.size()]));
}
Also used : HierarchySupport(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.HierarchySupport) PropertyInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport.PropertyInfo) ClassInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport.ClassInfo)

Aggregations

PropertyInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport.PropertyInfo)10 PropertiesSupport (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport)3 List (java.util.List)2 PropertyAdapter (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.PropertyAdapter)2 EPropertyBindableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EPropertyBindableInfo)2 ClassInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport.ClassInfo)2 DetailListEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailListEmfObservableInfo)2 ListEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.ListEmfObservableInfo)2 VariableDeclarationFragment (org.eclipse.jdt.core.dom.VariableDeclarationFragment)1 IObserveInfo (org.eclipse.wb.internal.core.databinding.model.IObserveInfo)1 ChooseClassAndPropertiesConfiguration (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesConfiguration)1 IPropertiesFilter (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesConfiguration.IPropertiesFilter)1 EObjectBindableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EObjectBindableInfo)1 HierarchySupport (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.HierarchySupport)1 KnownElementsObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo)1 ObservableDetailUiContentProvider (org.eclipse.wb.internal.rcp.databinding.ui.contentproviders.ObservableDetailUiContentProvider)1