use of org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo 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.model.ObservableInfo in project windowbuilder by eclipse.
the class EmfObserveTypeContainer method createDetailValue.
AstObjectInfo createDetailValue(AstEditor editor, Expression[] arguments, int startIndex, IModelResolver resolver) throws Exception {
// prepare master
ObservableInfo masterObservable = getMasterObservable(editor, resolver, arguments[startIndex]);
if (masterObservable == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.EmfObserveTypeContainer_masterObservableArgumentNotFound, arguments[startIndex]), new Throwable());
return null;
}
// prepare detail property
addEMFPackage(arguments[startIndex + 1]);
String detailPropertyReference = CoreUtils.getNodeReference(arguments[startIndex + 1]);
// create observable
DetailValueEmfObservableInfo observeDetailValue = new DetailValueEmfObservableInfo(masterObservable, m_propertiesSupport);
observeDetailValue.setDetailPropertyReference(null, detailPropertyReference);
observeDetailValue.setCodeSupport(new EmfObservableDetailValueCodeSupport());
//
return observeDetailValue;
}
use of org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo 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.model.ObservableInfo in project windowbuilder by eclipse.
the class ViewerInputParser method parseExpression.
@Override
public AstObjectInfo parseExpression(AstEditor editor, String signature, MethodInvocation invocation, Expression[] arguments, IModelResolver resolver) throws Exception {
if (signature.endsWith("setContentProvider(org.eclipse.jface.viewers.IContentProvider)")) {
// prepare viewer
WidgetBindableInfo viewerBindable = m_widgetsContainer.getBindableWidget(invocation.getExpression());
if (viewerBindable == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_viewerNotFound, invocation.getExpression()), new Throwable());
return null;
}
// prepare binding
AbstractViewerInputBindingInfo viewerBinding = getViewerBindingInfo(viewerBindable);
if (viewerBinding == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_modelViewerNotFound, invocation.getExpression()), new Throwable());
return null;
}
//
if (viewerBinding instanceof TreeViewerInputBindingInfo) {
// prepare content provider
ObservableCollectionTreeContentProviderInfo contentProvider = (ObservableCollectionTreeContentProviderInfo) resolver.getModel(arguments[0]);
if (contentProvider == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_contentProviderNotFound, arguments[0]), new Throwable());
return null;
}
TreeViewerInputBindingInfo viewerInputBinding = (TreeViewerInputBindingInfo) viewerBinding;
viewerInputBinding.setContentProvider(contentProvider);
} else if (viewerBinding instanceof ViewerInputBindingInfo) {
// prepare content provider
ObservableCollectionContentProviderInfo contentProvider = (ObservableCollectionContentProviderInfo) resolver.getModel(arguments[0]);
if (contentProvider == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_contentProviderNotFound, arguments[0]), new Throwable());
return null;
}
ViewerInputBindingInfo viewerInputBinding = (ViewerInputBindingInfo) viewerBinding;
viewerInputBinding.setContentProvider(contentProvider);
} else {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_contentProviderNotFound, arguments[0]), new Throwable());
return null;
}
} else if (signature.endsWith("setLabelProvider(org.eclipse.jface.viewers.IBaseLabelProvider)")) {
// prepare viewer
WidgetBindableInfo viewerBindable = m_widgetsContainer.getBindableWidget(invocation.getExpression());
if (viewerBindable == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_viewerNotFound, invocation.getExpression()), new Throwable());
return null;
}
// prepare binding
AbstractViewerInputBindingInfo viewerBinding = getViewerBindingInfo(viewerBindable);
if (viewerBinding == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_modelViewerNotFound, invocation.getExpression()), new Throwable());
return null;
}
//
if (viewerBinding instanceof ViewerInputBindingInfo) {
// prepare label provider
ObservableMapLabelProviderInfo labelProvider = (ObservableMapLabelProviderInfo) resolver.getModel(arguments[0]);
if (labelProvider == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_labelProviderArgumentNotFound, arguments[0]), new Throwable());
//
m_viewers.remove(viewerBindable);
m_contextInfo.getBindings().remove(viewerBinding);
//
return null;
}
// sets label provider
ViewerInputBindingInfo viewerInputBinding = (ViewerInputBindingInfo) viewerBinding;
viewerInputBinding.setLabelProvider(labelProvider);
} else if (viewerBinding instanceof TreeViewerInputBindingInfo) {
// prepare label provider
AbstractLabelProviderInfo labelProvider = (AbstractLabelProviderInfo) resolver.getModel(arguments[0]);
if (labelProvider == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_labelProviderArgumentNotFound, arguments[0]), new Throwable());
//
m_viewers.remove(viewerBindable);
m_contextInfo.getBindings().remove(viewerBinding);
//
return null;
}
// sets label provider
TreeViewerInputBindingInfo viewerInputBinding = (TreeViewerInputBindingInfo) viewerBinding;
viewerInputBinding.setLabelProvider(labelProvider);
} else {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_labelProviderArgumentNotFound, arguments[0]), new Throwable());
return null;
}
} else if (signature.endsWith("setInput(java.lang.Object)")) {
// prepare viewer
WidgetBindableInfo viewerBindable = m_widgetsContainer.getBindableWidget(invocation.getExpression());
if (viewerBindable == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_viewerNotFound, invocation.getExpression()), new Throwable());
return null;
}
// prepare binding
AbstractViewerInputBindingInfo viewerBinding = m_viewers.get(viewerBindable);
if (viewerBinding == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_viewerInputModelNotFound, invocation.getExpression()), new Throwable());
return null;
}
// prepare input observable
ObservableInfo inputObservable = (ObservableInfo) resolver.getModel(arguments[0]);
if (inputObservable == null) {
//
if (viewerBinding instanceof TreeViewerInputBindingInfo) {
BeanBindableInfo bindableObject = m_beansContainer.getBindableObject(arguments[0]);
if (bindableObject != null) {
TreeViewerInputBindingInfo treeViewerBinding = (TreeViewerInputBindingInfo) viewerBinding;
ObservableFactoryInfo factoryInfo = treeViewerBinding.getContentProvider().getFactoryInfo();
//
if (factoryInfo instanceof BeansObservableFactoryInfo) {
BeansObservableFactoryInfo beansFactoryInfo = (BeansObservableFactoryInfo) factoryInfo;
String propertyName = beansFactoryInfo.getPropertyName();
PropertyBindableInfo propertyObject = propertyName == null ? null : bindableObject.resolvePropertyReference(propertyName);
//
if (propertyObject != null) {
inputObservable = new BeanFieldInputObservableInfo(bindableObject, propertyObject);
}
}
}
}
//
if (inputObservable == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_viewerInputArgumentNotFound, arguments[0]), new Throwable());
//
m_viewers.remove(viewerBindable);
m_contextInfo.getBindings().remove(viewerBinding);
//
return null;
}
}
// sets input observable
viewerBinding.setInputObservable(inputObservable);
} else if (VIEWER_SUPPORT_LIST_SIGNATURE.equals(signature) || VIEWER_SUPPORT_SET_SIGNATURE.equals(signature)) {
// prepare viewer
WidgetBindableInfo viewerBindable = m_widgetsContainer.getBindableWidget(arguments[0]);
if (viewerBindable == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_viewerNotFound, arguments[0]), new Throwable());
return null;
}
if (m_viewers.get(viewerBindable) != null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_viewerDoubleInvocation, invocation, arguments[0]), new Throwable());
return null;
}
// prepare input observable
ObservableInfo inputObservable = (ObservableInfo) resolver.getModel(arguments[1]);
if (inputObservable == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_viewerInputArgumentNotFound, arguments[1]), new Throwable());
return null;
}
// prepare label provider properties
Assert.instanceOf(MethodInvocation.class, arguments[2]);
MethodInvocation labelPropertiesMethod = (MethodInvocation) arguments[2];
String labelPropertiesSignature = CoreUtils.getMethodSignature(labelPropertiesMethod);
Assert.isTrue(BEAN_PROPERTIES_VALUES.equals(labelPropertiesSignature) || POJO_PROPERTIES_VALUES.equals(labelPropertiesSignature));
List<Expression> labelPropertiesArguments = DomGenerics.arguments(labelPropertiesMethod);
// prepare element type
Class<?> elementType = CoreUtils.evaluate(Class.class, editor, labelPropertiesArguments.get(0));
// prepare properties
String[] properties = CoreUtils.evaluate(String[].class, editor, labelPropertiesArguments.get(1));
// create binding
ViewerInputBindingInfo viewerBinding = new ViewerInputBindingInfo(viewerBindable);
viewerBinding.setInputObservable(inputObservable);
viewerBinding.setDefaultProviders(VIEWER_SUPPORT_LIST_SIGNATURE.equals(signature), elementType, true);
viewerBinding.getLabelProvider().getMapsObservable().setProperties(properties);
// add binding
m_contextInfo.getBindings().add(viewerBinding);
m_viewers.put(viewerBindable, viewerBinding);
} else if (OBSERVABLE_VALUE_EDITING_SUPPORT.equals(signature)) {
// prepare viewer
WidgetBindableInfo viewerBindable = m_widgetsContainer.getBindableWidget(arguments[0]);
if (viewerBindable == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_viewerNotFound, arguments[0]), new Throwable());
return null;
}
//
AbstractViewerInputBindingInfo viewerBinding = m_viewers.get(viewerBindable);
if (viewerBinding == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_viewerNotFound, arguments[0]), new Throwable());
return null;
}
// prepare context
DataBindingContextInfo bindingContextInfo = (DataBindingContextInfo) resolver.getModel(arguments[1]);
if (bindingContextInfo != m_contextInfo) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_undefinedDataBindingContext, arguments[1]), new Throwable());
return null;
}
// prepare CellEditor
CellEditorInfo cellEditorInfo = (CellEditorInfo) resolver.getModel(arguments[2]);
if (cellEditorInfo == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_cellEditorNotFound, arguments[2]), new Throwable());
return null;
}
// prepare CellEditor property
CellEditorValuePropertyCodeSupport cellEditorProperty = null;
AstObjectInfo cellEditorPropertyInfo = resolver.getModel(arguments[3]);
//
if (cellEditorPropertyInfo instanceof CellEditorValuePropertyCodeSupport) {
cellEditorProperty = (CellEditorValuePropertyCodeSupport) cellEditorPropertyInfo;
} else if (cellEditorPropertyInfo instanceof ValuePropertyCodeSupport) {
ValuePropertyCodeSupport value = (ValuePropertyCodeSupport) cellEditorPropertyInfo;
cellEditorProperty = new CellEditorValuePropertyCodeSupport(value);
}
//
if (cellEditorProperty == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_cellEditorPropertyNotFound, arguments[3]), new Throwable());
return null;
}
// prepare element property
ValuePropertyCodeSupport elementProperty = (ValuePropertyCodeSupport) resolver.getModel(arguments[4]);
if (elementProperty == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_elementPropertyNotFound, arguments[4]), new Throwable());
return null;
}
//
return new EditingSupportInfo(viewerBinding, cellEditorInfo, cellEditorProperty, elementProperty);
} else if (VIEWER_COLUMN_SET_EDITING_SUPPORT.equals(signature)) {
// prepare viewer column
WidgetBindableInfo viewerColumnBindable = m_widgetsContainer.getBindableWidget(invocation.getExpression());
if (viewerColumnBindable == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_viewerColumnNotFound, invocation.getExpression()), new Throwable());
return null;
}
// prepare support
EditingSupportInfo editingSupportInfo = (EditingSupportInfo) resolver.getModel(arguments[0]);
if (editingSupportInfo == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.ViewerInputParser_editingSupportNotFound, arguments[0]), new Throwable());
return null;
}
//
editingSupportInfo.setViewerColumn(viewerColumnBindable);
} else if (CELL_EDITOR_PROPERTIES_CONTROL.equals(signature)) {
// CellEditor
return new CellEditorControlPropertyCodeSupport();
}
return null;
}
use of org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo in project windowbuilder by eclipse.
the class BeansObserveTypeContainer method createDetailSet.
/**
* Create {@link DetailSetBeanObservableInfo}.
*/
AstObjectInfo createDetailSet(AstEditor editor, Expression[] arguments, IModelResolver resolver, int startIndex, boolean isPojo) throws Exception {
// prepare master
ObservableInfo masterObservable = getMasterObservable(editor, resolver, arguments[startIndex]);
if (masterObservable == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.BeansObserveTypeContainer_masterObservableArgumentNotFound, arguments[startIndex]), new Throwable());
return null;
}
// prepare detail property
String detailPropertyReference = "\"" + CoreUtils.evaluate(String.class, editor, arguments[startIndex + 1]) + "\"";
Class<?> detailPropertyType = CoreUtils.evaluate(Class.class, editor, arguments[startIndex + 2]);
// create observable
DetailSetBeanObservableInfo observable = new DetailSetBeanObservableInfo(masterObservable, null, detailPropertyReference, detailPropertyType);
observable.setPojoBindable(isPojo);
observable.setCodeSupport(new BeanObservableDetailSetCodeSupport());
return observable;
}
Aggregations