Search in sources :

Example 1 with PropertiesSupport

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

the class EmfObserveTypeContainer method createObservables.

// //////////////////////////////////////////////////////////////////////////
// 
// Parse
// 
// //////////////////////////////////////////////////////////////////////////
@Override
public void createObservables(JavaInfo root, IModelResolver resolver, AstEditor editor, TypeDeclaration rootNode) throws Exception {
    m_javaInfoRoot = root;
    m_observables = Lists.newArrayList();
    // 
    IJavaProject javaProject = editor.getJavaProject();
    ClassLoader classLoader = JavaInfoUtils.getClassLoader(m_javaInfoRoot);
    List<VariableDeclarationFragment> fragments = CoreUtils.getFieldFragments(rootNode);
    // 
    m_propertiesSupport = new PropertiesSupport(javaProject, classLoader, fragments);
    // 
    for (VariableDeclarationFragment fragment : fragments) {
        try {
            // prepare type
            Type type = CoreUtils.getType(fragment, true);
            // prepare bean class
            Class<?> eObjectClass = loadClass(AstNodeUtils.getFullyQualifiedName(type, true));
            // 
            if (eObjectClass.isInterface() && (m_propertiesSupport.getEObjectClass().isAssignableFrom(eObjectClass) || CoreUtils.isAssignableFrom(m_propertiesSupport.getIObservableValue(), eObjectClass))) {
                m_observables.add(new EObjectBindableInfo(eObjectClass, fragment, m_propertiesSupport, resolver));
            }
        } catch (ClassNotFoundException e) {
            AbstractParser.addError(editor, "ClassNotFoundException: " + fragment, new Throwable());
        } catch (Throwable e) {
            throw ReflectionUtils.propagate(e);
        }
    }
}
Also used : EObjectBindableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EObjectBindableInfo) Type(org.eclipse.jdt.core.dom.Type) ObserveType(org.eclipse.wb.internal.core.databinding.ui.ObserveType) IJavaProject(org.eclipse.jdt.core.IJavaProject) VariableDeclarationFragment(org.eclipse.jdt.core.dom.VariableDeclarationFragment) PropertiesSupport(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport)

Example 2 with PropertiesSupport

use of org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport 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 3 with PropertiesSupport

use of org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport 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 4 with PropertiesSupport

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

the class EmfObserveTypeContainer method synchronizeObserves.

@Override
public void synchronizeObserves(JavaInfo root, final AstEditor editor, TypeDeclaration rootNode) throws Exception {
    IJavaProject javaProject = editor.getJavaProject();
    ClassLoader classLoader = JavaInfoUtils.getClassLoader(m_javaInfoRoot);
    List<VariableDeclarationFragment> fragments = CoreUtils.getFieldFragments(rootNode);
    m_propertiesSupport = new PropertiesSupport(javaProject, classLoader, fragments);
    // 
    for (Iterator<VariableDeclarationFragment> I = fragments.iterator(); I.hasNext(); ) {
        try {
            VariableDeclarationFragment fragment = I.next();
            Type type = CoreUtils.getType(fragment, false);
            Class<?> eObjectClass = loadClass(AstNodeUtils.getFullyQualifiedName(type, true));
            // 
            if (!eObjectClass.isInterface() || !m_propertiesSupport.getEObjectClass().isAssignableFrom(eObjectClass) && !CoreUtils.isAssignableFrom(m_propertiesSupport.getIObservableValue(), eObjectClass)) {
                I.remove();
            }
        } catch (ClassNotFoundException e) {
            I.remove();
        }
    }
    // 
    SynchronizeManager.synchronizeObjects(m_observables, fragments, new ISynchronizeProcessor<VariableDeclarationFragment, EObjectBindableInfo>() {

        @Override
        public boolean handleObject(EObjectBindableInfo object) {
            return true;
        }

        @Override
        public VariableDeclarationFragment getKeyObject(EObjectBindableInfo eObject) {
            return eObject.getFragment();
        }

        @Override
        public boolean equals(VariableDeclarationFragment key0, VariableDeclarationFragment key1) {
            return key0 == key1;
        }

        @Override
        public EObjectBindableInfo findObject(Map<VariableDeclarationFragment, EObjectBindableInfo> keyObjectToObject, VariableDeclarationFragment key) throws Exception {
            return null;
        }

        @Override
        public EObjectBindableInfo createObject(VariableDeclarationFragment fragment) throws Exception {
            try {
                Type type = CoreUtils.getType(fragment, true);
                // prepare bean class
                Class<?> eObjectClass = loadClass(AstNodeUtils.getFullyQualifiedName(type, true));
                return new EObjectBindableInfo(eObjectClass, fragment, m_propertiesSupport, null);
            } catch (ClassNotFoundException e) {
                AbstractParser.addError(editor, "ClassNotFoundException: " + fragment, new Throwable());
                return null;
            }
        }

        @Override
        public void update(EObjectBindableInfo object) throws Exception {
        }
    });
}
Also used : EObjectBindableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EObjectBindableInfo) PropertiesSupport(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport) Type(org.eclipse.jdt.core.dom.Type) ObserveType(org.eclipse.wb.internal.core.databinding.ui.ObserveType) IJavaProject(org.eclipse.jdt.core.IJavaProject) VariableDeclarationFragment(org.eclipse.jdt.core.dom.VariableDeclarationFragment)

Example 5 with PropertiesSupport

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

the class GlobalObservableFactory method configureChooseElementForViewerInput.

// //////////////////////////////////////////////////////////////////////////
// 
// IGlobalObservableFactory: UI
// 
// //////////////////////////////////////////////////////////////////////////
@Override
public void configureChooseElementForViewerInput(ObservableInfo inputObservable, ChooseClassAndPropertiesConfiguration configuration) throws Exception {
    if (inputObservable instanceof ListEmfObservableInfo || inputObservable instanceof DetailListEmfObservableInfo) {
        final PropertiesSupport propertiesSupport = getPropertiesSupport(inputObservable);
        configuration.setBaseClassName("org.eclipse.emf.ecore.EObject");
        configuration.addPropertiesFilter(new IPropertiesFilter() {

            @Override
            public List<PropertyAdapter> filterProperties(Class<?> choosenClass, List<PropertyAdapter> properties) throws Exception {
                properties = Lists.newArrayList();
                for (PropertyInfo emfPropertyInfo : propertiesSupport.getProperties(choosenClass)) {
                    properties.add(new ChooseClassAndTreePropertiesUiContentProvider.ObservePropertyAdapter(null, new EPropertyBindableInfo(propertiesSupport, null, emfPropertyInfo.type, emfPropertyInfo.name, "\"" + emfPropertyInfo.name + "\"")));
                }
                return properties;
            }
        });
    }
}
Also used : ListEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.ListEmfObservableInfo) DetailListEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailListEmfObservableInfo) PropertiesSupport(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport) DetailListEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailListEmfObservableInfo) List(java.util.List) IPropertiesFilter(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesConfiguration.IPropertiesFilter) PropertyAdapter(org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.PropertyAdapter) EPropertyBindableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EPropertyBindableInfo) PropertyInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport.PropertyInfo)

Aggregations

PropertiesSupport (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport)6 VariableDeclarationFragment (org.eclipse.jdt.core.dom.VariableDeclarationFragment)3 EObjectBindableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EObjectBindableInfo)3 PropertyInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport.PropertyInfo)3 DetailListEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailListEmfObservableInfo)3 ListEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.ListEmfObservableInfo)3 IJavaProject (org.eclipse.jdt.core.IJavaProject)2 Type (org.eclipse.jdt.core.dom.Type)2 ObserveType (org.eclipse.wb.internal.core.databinding.ui.ObserveType)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 List (java.util.List)1 IPropertiesFilter (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesConfiguration.IPropertiesFilter)1 DetailEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailEmfObservableInfo)1 DetailValueEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailValueEmfObservableInfo)1 EmfObservableDetailListCodeSupport (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.EmfObservableDetailListCodeSupport)1 EmfObservableDetailValueCodeSupport (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.EmfObservableDetailValueCodeSupport)1 MapsEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.MapsEmfObservableInfo)1 EmfListPropertyDetailCodeSupport (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.properties.EmfListPropertyDetailCodeSupport)1 EmfValuePropertyDetailCodeSupport (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.properties.EmfValuePropertyDetailCodeSupport)1