Search in sources :

Example 46 with IBindingInfo

use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.

the class DatabindingsProvider method createObservable.

public ObservableInfo createObservable(IObservableFactory factory, BindableInfo bindable, BindableInfo property, Type type) throws Exception {
    boolean version_1_3 = Activator.getStore().getBoolean(IPreferenceConstants.GENERATE_CODE_FOR_VERSION_1_3);
    ObservableInfo newObservable = factory.createObservable(bindable, property, type, version_1_3);
    // 
    for (IBindingInfo ibinding : getBindings()) {
        if (ibinding instanceof BindingInfo) {
            BindingInfo binding = (BindingInfo) ibinding;
            // check target
            ObservableInfo targetObservable = binding.getTargetObservable();
            if (targetObservable.canShared() && binding.getTarget() == bindable && binding.getTargetProperty() == property && targetObservable.getClass() == newObservable.getClass()) {
                return targetObservable;
            }
            // check model
            ObservableInfo modelObservable = binding.getModelObservable();
            if (modelObservable.canShared() && binding.getModel() == bindable && binding.getModelProperty() == property && modelObservable.getClass() == newObservable.getClass()) {
                return modelObservable;
            }
        } else {
            AbstractViewerInputBindingInfo binding = (AbstractViewerInputBindingInfo) ibinding;
            // check viewer input
            ObservableInfo inputObservable = binding.getInputObservable();
            if (inputObservable.canShared() && binding.getModel() == bindable && binding.getModelProperty() == property && inputObservable.getClass() == newObservable.getClass()) {
                return inputObservable;
            }
        }
    }
    return newObservable;
}
Also used : AbstractViewerInputBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.AbstractViewerInputBindingInfo) ObservableInfo(org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) BindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo) ListBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.ListBindingInfo) AbstractViewerInputBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.widgets.input.AbstractViewerInputBindingInfo) SetBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.SetBindingInfo) ValueBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.context.ValueBindingInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) AbstractBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo)

Example 47 with IBindingInfo

use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.

the class DatabindingsProvider method createBinding.

// //////////////////////////////////////////////////////////////////////////
// 
// Creation/Editing
// 
// //////////////////////////////////////////////////////////////////////////
@Override
public IBindingInfo createBinding(IObserveInfo target, IObserveInfo targetProperty, IObserveInfo model, IObserveInfo modelProperty) throws Exception {
    // prepare target
    BindableInfo targetBindable = (BindableInfo) target;
    BindableInfo targetBindableProperty = (BindableInfo) targetProperty;
    IObservableFactory targetFactory = targetBindableProperty.getObservableFactory();
    // prepare model
    BindableInfo modelBindable = (BindableInfo) model;
    BindableInfo modelBindableProperty = (BindableInfo) modelProperty;
    IObservableFactory modelFactory = modelBindableProperty.getObservableFactory();
    // calculate type
    Type type = org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider.calculateObserveType(targetFactory, modelFactory);
    // handle input type
    if (type == Type.Input) {
        // XXX
        throw new UnsupportedOperationException();
    }
    // create binding
    BindingInfo binding = new BindingInfo(targetBindable, targetBindableProperty, modelBindable, modelBindableProperty);
    binding.setDocumentEditor(new AttributeDocumentEditor(binding));
    // 
    return binding;
}
Also used : ObserveType(org.eclipse.wb.internal.core.databinding.ui.ObserveType) Type(org.eclipse.wb.internal.rcp.databinding.model.IObservableFactory.Type) BindableInfo(org.eclipse.wb.internal.rcp.databinding.model.BindableInfo) WidgetBindableInfo(org.eclipse.wb.internal.rcp.databinding.xwt.model.widgets.WidgetBindableInfo) BindingInfo(org.eclipse.wb.internal.rcp.databinding.xwt.model.BindingInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) AbstractBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo) AttributeDocumentEditor(org.eclipse.wb.internal.rcp.databinding.xwt.model.AttributeDocumentEditor) IObservableFactory(org.eclipse.wb.internal.rcp.databinding.model.IObservableFactory)

Example 48 with IBindingInfo

use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.

the class DatabindingsProvider method getContentProviders.

// //////////////////////////////////////////////////////////////////////////
// 
// UI editing
// 
// //////////////////////////////////////////////////////////////////////////
@Override
public List<IUiContentProvider> getContentProviders(IBindingInfo ibinding, IPageListener listener) throws Exception {
    List<IUiContentProvider> providers = Lists.newArrayList();
    BindingInfo binding = (BindingInfo) ibinding;
    binding.createContentProviders(providers, listener, this);
    return providers;
}
Also used : BindingInfo(org.eclipse.wb.internal.rcp.databinding.xwt.model.BindingInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) AbstractBindingInfo(org.eclipse.wb.internal.rcp.databinding.model.AbstractBindingInfo) IUiContentProvider(org.eclipse.wb.internal.core.databinding.ui.editor.IUiContentProvider)

Example 49 with IBindingInfo

use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.

the class DatabindingsProvider method configureMoveUpDown.

private int configureMoveUpDown(IBindingInfo binding, int sourceIndex, int targetIndex) {
    if (!(binding instanceof ColumnBindingInfo)) {
        List<IBindingInfo> bindings = getBindings();
        IBindingInfo target = bindings.get(targetIndex);
        boolean up = sourceIndex > targetIndex;
        // configure target index
        if (target instanceof ColumnBindingInfo) {
            ColumnBindingInfo column = (ColumnBindingInfo) target;
            // calculate column index
            if (up) {
                targetIndex = bindings.indexOf(column.getJTableBinding());
            } else {
                // skip all columns
                targetIndex += column.getJTableBinding().getColumns().size();
                // 
                target = bindings.get(targetIndex);
                if (target instanceof JTableBindingInfo) {
                    // skip all columns
                    JTableBindingInfo tableBinding = (JTableBindingInfo) target;
                    targetIndex += tableBinding.getColumns().size();
                } else if (target instanceof JListBindingInfo) {
                    // skip detail binding
                    targetIndex++;
                }
            }
        } else if (target instanceof DetailBindingInfo) {
            if (up) {
                DetailBindingInfo detail = (DetailBindingInfo) target;
                targetIndex = bindings.indexOf(detail.getJListBinding());
            } else {
                // skip detail binding
                targetIndex++;
                // 
                target = bindings.get(targetIndex);
                if (target instanceof JTableBindingInfo) {
                    // skip all columns
                    JTableBindingInfo tableBinding = (JTableBindingInfo) target;
                    targetIndex += tableBinding.getColumns().size();
                } else if (target instanceof JListBindingInfo) {
                    // skip detail binding
                    targetIndex++;
                }
            }
        } else if (target instanceof JTableBindingInfo && !up) {
            // skip all columns
            JTableBindingInfo tableBinding = (JTableBindingInfo) target;
            targetIndex += tableBinding.getColumns().size();
        } else if (target instanceof JListBindingInfo && !up) {
            // skip detail binding
            targetIndex++;
        }
    }
    return targetIndex;
}
Also used : IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo) DetailBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.DetailBindingInfo) ColumnBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.ColumnBindingInfo) JTableBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.JTableBindingInfo) JListBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.JListBindingInfo)

Example 50 with IBindingInfo

use of org.eclipse.wb.internal.core.databinding.model.IBindingInfo in project windowbuilder by eclipse.

the class DatabindingsProvider method gotoDefinition.

public void gotoDefinition(IBindingInfo ibinding) {
    try {
        // calculate variable
        BindingInfo binding = (BindingInfo) ibinding;
        String variable = binding.getVariableIdentifier();
        if (variable != null) {
            if (variable.endsWith("()")) {
                variable = variable.substring(0, variable.length() - 2);
            }
            // calculate position
            int position = m_javaInfoRoot.getEditor().getEnclosingNode(variable).getStartPosition();
            // sets position
            IDesignPageSite site = IDesignPageSite.Helper.getSite(m_javaInfoRoot);
            site.openSourcePosition(position);
        }
    } catch (Throwable e) {
    }
}
Also used : IDesignPageSite(org.eclipse.wb.core.editor.IDesignPageSite) JTableBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.JTableBindingInfo) JComboBoxBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.JComboBoxBindingInfo) ColumnBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.ColumnBindingInfo) BindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.BindingInfo) JListBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.JListBindingInfo) DetailBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.DetailBindingInfo) AutoBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.AutoBindingInfo) VirtualBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.VirtualBindingInfo) IBindingInfo(org.eclipse.wb.internal.core.databinding.model.IBindingInfo)

Aggregations

IBindingInfo (org.eclipse.wb.internal.core.databinding.model.IBindingInfo)81 DatabindingsProvider (org.eclipse.wb.internal.rcp.databinding.DatabindingsProvider)51 CompositeInfo (org.eclipse.wb.internal.swt.model.widgets.CompositeInfo)48 BindingInfo (org.eclipse.wb.internal.rcp.databinding.model.context.BindingInfo)38 IObserveInfo (org.eclipse.wb.internal.core.databinding.model.IObserveInfo)18 TreeViewerInputBindingInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.TreeViewerInputBindingInfo)16 DetailListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailListBeanObservableInfo)14 DetailSetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.DetailSetBeanObservableInfo)14 ListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.ListBeanObservableInfo)14 SetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.SetBeanObservableInfo)14 WritableListBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableListBeanObservableInfo)14 WritableSetBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.WritableSetBeanObservableInfo)14 ObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.ObservableInfo)13 CheckedElementsObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.CheckedElementsObservableInfo)13 ViewerObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.ViewerObservableInfo)13 MapsBeanObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.beans.observables.MapsBeanObservableInfo)12 KnownElementsObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.KnownElementsObservableInfo)12 ViewerInputBindingInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.input.ViewerInputBindingInfo)12 MultiSelectionObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.MultiSelectionObservableInfo)12 SingleSelectionObservableInfo (org.eclipse.wb.internal.rcp.databinding.model.widgets.observables.SingleSelectionObservableInfo)12