Search in sources :

Example 1 with EObjectBindableInfo

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

the class EmfObserveTypeContainer method createList.

AstObjectInfo createList(AstEditor editor, Expression[] arguments, int startIndex) throws Exception {
    // prepare object
    EObjectBindableInfo eObject = getEObject(arguments[startIndex]);
    if (eObject == null) {
        AbstractParser.addError(editor, MessageFormat.format(Messages.EmfObserveTypeContainer_argumentNotFound, arguments[startIndex]), new Throwable());
        return null;
    }
    // prepare property
    EPropertyBindableInfo eProperty = getEProperty(eObject, arguments[startIndex + 1]);
    // create observable
    ObservableInfo observable = new ListEmfObservableInfo(eObject, eProperty);
    observable.setCodeSupport(new EmfObservableListCodeSupport());
    // 
    return observable;
}
Also used : EObjectBindableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EObjectBindableInfo) MapsEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.MapsEmfObservableInfo) DetailValueEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailValueEmfObservableInfo) ObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo) ListEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.ListEmfObservableInfo) DetailListEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailListEmfObservableInfo) KnownElementsObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo) ValueEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.ValueEmfObservableInfo) ListEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.ListEmfObservableInfo) DetailListEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailListEmfObservableInfo) EmfObservableListCodeSupport(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.EmfObservableListCodeSupport) EPropertyBindableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EPropertyBindableInfo)

Example 2 with EObjectBindableInfo

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

the class EmfObserveTypeContainer method createValue.

AstObjectInfo createValue(AstEditor editor, Expression[] arguments, int startIndex) throws Exception {
    // prepare object
    EObjectBindableInfo eObject = getEObject(arguments[startIndex]);
    if (eObject == null) {
        AbstractParser.addError(editor, MessageFormat.format(Messages.EmfObserveTypeContainer_argumentNotFound, arguments[startIndex]), new Throwable());
        return null;
    }
    // prepare property
    EPropertyBindableInfo eProperty = getEProperty(eObject, arguments[startIndex + 1]);
    // create observable
    ObservableInfo observable = new ValueEmfObservableInfo(eObject, eProperty);
    observable.setCodeSupport(new EmfObservableValueCodeSupport());
    // 
    return observable;
}
Also used : EObjectBindableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EObjectBindableInfo) MapsEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.MapsEmfObservableInfo) DetailValueEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailValueEmfObservableInfo) ObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo) ListEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.ListEmfObservableInfo) DetailListEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailListEmfObservableInfo) KnownElementsObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo) ValueEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.ValueEmfObservableInfo) DetailValueEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailValueEmfObservableInfo) ValueEmfObservableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.ValueEmfObservableInfo) EPropertyBindableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EPropertyBindableInfo) EmfObservableValueCodeSupport(org.eclipse.wb.internal.rcp.databinding.emf.model.observables.EmfObservableValueCodeSupport)

Example 3 with EObjectBindableInfo

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

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

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

the class EmfPropertiesCodeSupport method parseExpression.

// //////////////////////////////////////////////////////////////////////////
// 
// Parser
// 
// //////////////////////////////////////////////////////////////////////////
@Override
public AstObjectInfo parseExpression(AstEditor editor, String signature, MethodInvocation invocation, Expression[] arguments, IModelResolver resolver, IDatabindingsProvider provider) throws Exception {
    // 
    EmfObserveTypeContainer container = (EmfObserveTypeContainer) DatabindingsProvider.cast(provider).getContainer(EmfObserveTypeContainer.TYPE);
    // extract bean expression
    Expression beanExpression;
    if (m_observeSignature0.equals(signature)) {
        beanExpression = arguments[0];
    } else if (m_observeSignature1.equals(signature)) {
        beanExpression = arguments[1];
    } else if (m_observeDetailSignature.equals(signature)) {
        ObservableInfo masterObservable = EmfObserveTypeContainer.getMasterObservable(editor, resolver, arguments[0]);
        Assert.isNotNull(masterObservable);
        // 
        return createDetailObservable(masterObservable, container.getPropertiesSupport());
    } else {
        return null;
    }
    // 
    EObjectBindableInfo eObject = container.getEObject(beanExpression);
    if (eObject == null) {
        AbstractParser.addError(editor, MessageFormat.format(Messages.EmfPropertiesCodeSupport_argumentNotFound, beanExpression), new Throwable());
        return null;
    }
    // create observable
    return createObservable(editor, eObject);
}
Also used : EObjectBindableInfo(org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EObjectBindableInfo) ObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo) Expression(org.eclipse.jdt.core.dom.Expression) EmfObserveTypeContainer(org.eclipse.wb.internal.rcp.databinding.emf.model.EmfObserveTypeContainer)

Aggregations

EObjectBindableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EObjectBindableInfo)7 VariableDeclarationFragment (org.eclipse.jdt.core.dom.VariableDeclarationFragment)3 EPropertyBindableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EPropertyBindableInfo)3 ObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo)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 PropertiesSupport (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport)2 DetailListEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailListEmfObservableInfo)2 DetailValueEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailValueEmfObservableInfo)2 ListEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.ListEmfObservableInfo)2 MapsEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.MapsEmfObservableInfo)2 ValueEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.ValueEmfObservableInfo)2 KnownElementsObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo)2 List (java.util.List)1 Expression (org.eclipse.jdt.core.dom.Expression)1 FieldDeclaration (org.eclipse.jdt.core.dom.FieldDeclaration)1 IObserveInfo (org.eclipse.wb.internal.core.databinding.model.IObserveInfo)1 ChooseClassAndPropertiesConfiguration (org.eclipse.wb.internal.core.databinding.ui.editor.contentproviders.ChooseClassAndPropertiesConfiguration)1 BodyDeclarationTarget (org.eclipse.wb.internal.core.utils.ast.BodyDeclarationTarget)1