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