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;
}
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;
}
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);
}
}
}
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;
}
});
}
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);
}
Aggregations