Search in sources :

Example 1 with JListBindingInfo

use of org.eclipse.wb.internal.swing.databinding.model.bindings.JListBindingInfo in project windowbuilder by eclipse.

the class DatabindingsProvider method createSwingBinding.

private IBindingInfo createSwingBinding(ObserveInfo component, ObserveInfo componentProperty, ObserveInfo model, ObserveInfo modelProperty) throws Exception {
    // check swing binding type
    if (componentProperty.getCreationType() != ObserveCreationType.SelfProperty) {
        return null;
    }
    if (modelProperty.getCreationType() != ObserveCreationType.ListSelfProperty && modelProperty.getCreationType() != ObserveCreationType.ListProperty) {
        return null;
    }
    // create strategy
    UpdateStrategyInfo strategy = new UpdateStrategyInfo(UpdateStrategyInfo.Value.READ);
    // create properties
    PropertyInfo componentAstProperty = createProperty(component, componentProperty);
    PropertyInfo modelAstProperty = createProperty(model, modelProperty);
    // create binding
    switch(component.getCreationType()) {
        case JListBinding:
            return new JListBindingInfo(strategy, component, componentProperty, componentAstProperty, model, modelProperty, modelAstProperty);
        case JTableBinding:
            return new JTableBindingInfo(strategy, component, componentProperty, componentAstProperty, model, modelProperty, modelAstProperty);
        case JComboBoxBinding:
            return new JComboBoxBindingInfo(strategy, component, componentProperty, componentAstProperty, model, modelProperty, modelAstProperty);
    }
    // 
    return null;
}
Also used : UpdateStrategyInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.UpdateStrategyInfo) JComboBoxBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.JComboBoxBindingInfo) PropertyInfo(org.eclipse.wb.internal.swing.databinding.model.properties.PropertyInfo) JTableBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.JTableBindingInfo) JListBindingInfo(org.eclipse.wb.internal.swing.databinding.model.bindings.JListBindingInfo)

Example 2 with JListBindingInfo

use of org.eclipse.wb.internal.swing.databinding.model.bindings.JListBindingInfo 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)

Aggregations

JListBindingInfo (org.eclipse.wb.internal.swing.databinding.model.bindings.JListBindingInfo)2 JTableBindingInfo (org.eclipse.wb.internal.swing.databinding.model.bindings.JTableBindingInfo)2 IBindingInfo (org.eclipse.wb.internal.core.databinding.model.IBindingInfo)1 ColumnBindingInfo (org.eclipse.wb.internal.swing.databinding.model.bindings.ColumnBindingInfo)1 DetailBindingInfo (org.eclipse.wb.internal.swing.databinding.model.bindings.DetailBindingInfo)1 JComboBoxBindingInfo (org.eclipse.wb.internal.swing.databinding.model.bindings.JComboBoxBindingInfo)1 UpdateStrategyInfo (org.eclipse.wb.internal.swing.databinding.model.bindings.UpdateStrategyInfo)1 PropertyInfo (org.eclipse.wb.internal.swing.databinding.model.properties.PropertyInfo)1