use of org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo in project windowbuilder by eclipse.
the class ViewerPropertySingleSelectionCodeSupport method createObservable.
@Override
protected ObservableInfo createObservable(WidgetBindableInfo bindableWidget, WidgetPropertyBindableInfo bindableProperty, int delayValue) throws Exception {
SingleSelectionObservableInfo observable = new SingleSelectionObservableInfo(bindableWidget, bindableProperty);
observable.setDelayValue(delayValue);
return observable;
}
use of org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo in project windowbuilder by eclipse.
the class BeansObserveTypeContainer method createSingleSelection.
AstObjectInfo createSingleSelection(AstEditor editor, Expression[] arguments, IModelResolver resolver) throws Exception {
BeanBindableInfo bindableObject = m_rootJavaInfo.getChildRepresentedBy(arguments[0]) == null ? getBindableObject(arguments[0]) : null;
if (bindableObject != null) {
SingleSelectionObservableInfo observable = new SingleSelectionObservableInfo(bindableObject);
observable.setCodeSupport(new SingleSelectionObservableCodeSupport());
return observable;
}
return null;
}
use of org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo in project windowbuilder by eclipse.
the class CodeGenerationTest method test_ViewerObservableInfo.
public void test_ViewerObservableInfo() throws Exception {
CompositeInfo shell = DatabindingTestUtils.parseTestSource(this, new String[] { "public class Test {", " protected Shell m_shell;", " private CheckboxTableViewer m_viewer;", " public static void main(String[] args) {", " Test test = new Test();", " test.open();", " }", " public void open() {", " Display display = new Display();", " createContents();", " m_shell.open();", " m_shell.layout();", " while (!m_shell.isDisposed()) {", " if (!display.readAndDispatch()) {", " display.sleep();", " }", " }", " }", " protected void createContents() {", " m_shell = new Shell();", " m_shell.setLayout(new FillLayout());", " m_viewer = new CheckboxTableViewer(m_shell, SWT.NONE);", " }", "}" });
assertNotNull(shell);
//
DatabindingsProvider provider = getDatabindingsProvider();
List<IObserveInfo> observes = provider.getObserves(ObserveType.WIDGETS);
//
WidgetBindableInfo viewerBindable = (WidgetBindableInfo) observes.get(0).getChildren(ChildrenContext.ChildrenForMasterTable).get(0).getChildren(ChildrenContext.ChildrenForMasterTable).get(0);
//
WidgetPropertyBindableInfo singleSelection = (WidgetPropertyBindableInfo) viewerBindable.getChildren(ChildrenContext.ChildrenForPropertiesTable).get(0);
assertObservableInfo(new SingleSelectionObservableInfo(viewerBindable, singleSelection), new SingleSelectionObservableCodeSupport(), "viewerObservable", "org.eclipse.core.databinding.observable.value.IObservableValue viewerObservable = org.eclipse.jface.databinding.viewers.ViewersObservables.observeSingleSelection(m_viewer);", "org.eclipse.core.databinding.observable.value.IObservableValue viewerObserveSingleSelection = org.eclipse.jface.databinding.viewers.ViewersObservables.observeSingleSelection(m_viewer);");
//
WidgetPropertyBindableInfo multiSelection = (WidgetPropertyBindableInfo) viewerBindable.getChildren(ChildrenContext.ChildrenForPropertiesTable).get(2);
assertObservableInfo(new MultiSelectionObservableInfo(viewerBindable, multiSelection), new MultiSelectionObservableCodeSupport(), "viewerObservable", "org.eclipse.core.databinding.observable.list.IObservableList viewerObservable = org.eclipse.jface.databinding.viewers.ViewersObservables.observeMultiSelection(m_viewer);", "org.eclipse.core.databinding.observable.list.IObservableList viewerObserveMultiSelection = org.eclipse.jface.databinding.viewers.ViewersObservables.observeMultiSelection(m_viewer);");
//
CheckedElementsObservableInfo checkedObservable = new CheckedElementsObservableInfo(viewerBindable);
checkedObservable.setElementType(String.class);
assertObservableInfo(checkedObservable, new CheckedElementsObservableCodeSupport(), "viewerObservable", "org.eclipse.core.databinding.observable.set.IObservableSet viewerObservable = org.eclipse.jface.databinding.viewers.ViewersObservables.observeCheckedElements(m_viewer, java.lang.String.class);", "org.eclipse.core.databinding.observable.set.IObservableSet viewerObserveCheckedElements = org.eclipse.jface.databinding.viewers.ViewersObservables.observeCheckedElements(m_viewer, java.lang.String.class);");
}
use of org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo in project windowbuilder by eclipse.
the class DetailPropertyCodeSupport method parseExpression.
// //////////////////////////////////////////////////////////////////////////
//
// Parser
//
// //////////////////////////////////////////////////////////////////////////
@Override
public AstObjectInfo parseExpression(AstEditor editor, String signature, MethodInvocation invocation, Expression[] arguments, IModelResolver resolver, IDatabindingsProvider provider) throws Exception {
Expression widgetExpression = null;
if (m_observeSignature.equals(signature)) {
widgetExpression = arguments[0];
} else if (m_observeRealmSignature.equals(signature)) {
widgetExpression = arguments[1];
} else {
return null;
}
//
WidgetsObserveTypeContainer container = (WidgetsObserveTypeContainer) DatabindingsProvider.cast(provider).getContainer(ObserveType.WIDGETS);
// prepare widget
WidgetBindableInfo bindableWidget = container.getBindableWidget(widgetExpression);
if (bindableWidget == null) {
AbstractParser.addError(editor, MessageFormat.format(Messages.DetailPropertyCodeSupport_widgetArgumentNotFound, widgetExpression), new Throwable());
return null;
}
// prepare property
WidgetPropertyBindableInfo bindableProperty = bindableWidget.resolvePropertyReference("observeSingleSelection");
Assert.isNotNull(bindableProperty);
//
m_masterObservable = new SingleSelectionObservableInfo(bindableWidget, bindableProperty);
m_masterObservable = (SingleSelectionObservableInfo) m_masterObservable.getMasterObservable();
Assert.isNotNull(m_masterObservable);
//
m_masterObservable.setCodeSupport(new ObservableCodeSupport() {
@Override
public void addSourceCode(ObservableInfo observable, List<String> lines, CodeGenerationSupport generationSupport) throws Exception {
}
});
//
m_detailObservable = createDetailObservable();
m_detailObservable.setCodeSupport(this);
return m_detailObservable;
}
use of org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo in project windowbuilder by eclipse.
the class ViewerPropertySingleSelectionCodeSupport method addSourceCode.
// //////////////////////////////////////////////////////////////////////////
//
// Code generation
//
// //////////////////////////////////////////////////////////////////////////
@Override
public void addSourceCode(ObservableInfo observable, List<String> lines, CodeGenerationSupport generationSupport) throws Exception {
super.addSourceCode(observable, lines, generationSupport);
String sourceCode = "org.eclipse.jface.databinding.viewers.ViewerProperties.singleSelection()";
if (getVariableIdentifier() != null) {
if (generationSupport.addModel(this)) {
lines.add("org.eclipse.jface.databinding.viewers.IViewerValueProperty " + getVariableIdentifier() + " = " + sourceCode + ";");
}
sourceCode = getVariableIdentifier();
}
SingleSelectionObservableInfo selectionObservable = (SingleSelectionObservableInfo) observable;
if (selectionObservable.getDelayValue() == 0) {
// no delay
lines.add("org.eclipse.core.databinding.observable.value.IObservableValue " + observable.getVariableIdentifier() + " = " + sourceCode + ".observe(" + observable.getBindableObject().getReference() + ");");
} else {
// with delay
lines.add("org.eclipse.core.databinding.observable.value.IObservableValue " + observable.getVariableIdentifier() + " = " + sourceCode + ".observeDelayed(" + Integer.toString(selectionObservable.getDelayValue()) + ", " + observable.getBindableObject().getReference() + ");");
}
}
Aggregations