Search in sources :

Example 1 with SingleSelectionObservableInfo

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;
}
Also used : SingleSelectionObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo)

Example 2 with SingleSelectionObservableInfo

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;
}
Also used : SingleSelectionObservableCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.standard.SingleSelectionObservableCodeSupport) SingleSelectionObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo) FieldBeanBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.FieldBeanBindableInfo) BeanBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.BeanBindableInfo) MethodBeanBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.bindables.MethodBeanBindableInfo)

Example 3 with SingleSelectionObservableInfo

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);");
}
Also used : IObserveInfo(org.eclipse.wb.internal.core.databinding.model.IObserveInfo) MultiSelectionObservableCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.standard.MultiSelectionObservableCodeSupport) SingleSelectionObservableCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.standard.SingleSelectionObservableCodeSupport) SingleSelectionObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo) DatabindingsProvider(org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider) CheckedElementsObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.CheckedElementsObservableInfo) WidgetPropertyBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.bindables.WidgetPropertyBindableInfo) MultiSelectionObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.MultiSelectionObservableInfo) CompositeInfo(org.eclipse.wb.internal.swt.model.widgets.CompositeInfo) WidgetBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.bindables.WidgetBindableInfo) CheckedElementsObservableCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.standard.CheckedElementsObservableCodeSupport)

Example 4 with SingleSelectionObservableInfo

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;
}
Also used : ObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo) SingleSelectionObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo) DetailBeanObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailBeanObservableInfo) ObservableCodeSupport(org.eclipse.wb.internal.rcp.databinding.model.ObservableCodeSupport) WidgetPropertyBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.bindables.WidgetPropertyBindableInfo) CodeGenerationSupport(org.eclipse.wb.internal.core.databinding.model.CodeGenerationSupport) Expression(org.eclipse.jdt.core.dom.Expression) WidgetsObserveTypeContainer(org.eclipse.wb.internal.rcp.databinding.model.widgets.WidgetsObserveTypeContainer) SingleSelectionObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo) WidgetBindableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.bindables.WidgetBindableInfo)

Example 5 with SingleSelectionObservableInfo

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() + ");");
    }
}
Also used : SingleSelectionObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo)

Aggregations

SingleSelectionObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo)7 ObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo)3 WidgetBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.bindables.WidgetBindableInfo)3 WidgetPropertyBindableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.bindables.WidgetPropertyBindableInfo)3 CheckedElementsObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.CheckedElementsObservableInfo)2 MultiSelectionObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.MultiSelectionObservableInfo)2 SingleSelectionObservableCodeSupport (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.standard.SingleSelectionObservableCodeSupport)2 Expression (org.eclipse.jdt.core.dom.Expression)1 StyledText (org.eclipse.swt.custom.StyledText)1 Text (org.eclipse.swt.widgets.Text)1 CodeGenerationSupport (org.eclipse.wb.internal.core.databinding.model.CodeGenerationSupport)1 IObserveInfo (org.eclipse.wb.internal.core.databinding.model.IObserveInfo)1 DatabindingsProvider (org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider)1 EObjectBindableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EObjectBindableInfo)1 EPropertyBindableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.EPropertyBindableInfo)1 PropertiesSupport (org.eclipse.wb.internal.rcp.databinding.emf.model.bindables.PropertiesSupport)1 DetailEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailEmfObservableInfo)1 DetailListEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailListEmfObservableInfo)1 DetailValueEmfObservableInfo (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.DetailValueEmfObservableInfo)1 EmfObservableDetailListCodeSupport (org.eclipse.wb.internal.rcp.databinding.emf.model.observables.EmfObservableDetailListCodeSupport)1