/** * @param targetObservableList * @param modelObservableList * @return an update list strategy */ protected UpdateListStrategy createTargetToModelUpdateListStrategy( IObservableList targetObservableList, IObservableList modelObservableList) { return new UpdateListStrategy(); }
@Override protected void postInit() { if (modelToTarget.getUpdatePolicy() == UpdateListStrategy.POLICY_UPDATE) { updateModelToTarget(); } if (targetToModel.getUpdatePolicy() == UpdateListStrategy.POLICY_UPDATE) { validateTargetToModel(); } }
/** * Removes the element at the given index from the given observable list. * Clients may extend but must call the super implementation. * * @param observableList * @param index * @return a status */ protected IStatus doRemove(IObservableList<? super D> observableList, int index) { try { observableList.remove(index); } catch (Exception ex) { return logErrorWhileSettingValue(ex); } return Status.OK_STATUS; }
/** * * @param source * @param destination */ @SuppressWarnings("unchecked") protected void fillDefaults(IObservableList<? extends S> source, IObservableList<? super D> destination) { Object sourceType = source.getElementType(); Object destinationType = destination.getElementType(); if (provideDefaults && sourceType != null && destinationType != null) { if (converter == null) { setConverter((IConverter<S, D>) createConverter(sourceType, destinationType)); } } if (converter != null) { if (sourceType != null) { checkAssignable(converter.getFromType(), sourceType, "converter does not convert from type " + sourceType); //$NON-NLS-1$ } if (destinationType != null) { checkAssignable(destinationType, converter.getToType(), "converter does not convert to type " + destinationType); //$NON-NLS-1$ } } }
return super.createConverter(fromType, toType);
: createModelToTargetUpdateListStrategy(modelObservableList, targetObservableList); targetToModelStrategy.fillDefaults(targetObservableList, modelObservableList); modelToTargetStrategy.fillDefaults(modelObservableList, targetObservableList); ListBinding result = new ListBinding(targetObservableList,
/** * * @param source * @param destination */ protected void fillDefaults(IObservableList source, IObservableList destination) { Object sourceType = source.getElementType(); Object destinationType = destination.getElementType(); if (provideDefaults && sourceType != null && destinationType != null) { if (converter == null) { setConverter(createConverter(sourceType, destinationType)); } } if (converter != null) { if (sourceType != null) { checkAssignable(converter.getFromType(), sourceType, "converter does not convert from type " + sourceType); //$NON-NLS-1$ } if (destinationType != null) { checkAssignable(destinationType, converter.getToType(), "converter does not convert to type " + destinationType); //$NON-NLS-1$ } } }
return super.createConverter(fromType, toType);
UpdateListStrategy<? super M, ? extends T> modelToTargetStrategy = modelToTarget != null ? modelToTarget : createModelToTargetUpdateListStrategy(modelObservableList, targetObservableList); targetToModelStrategy.fillDefaults(targetObservableList, modelObservableList); modelToTargetStrategy.fillDefaults(modelObservableList, targetObservableList); ListBinding<M, T> result = new ListBinding<>(targetObservableList,
/** * * @param source * @param destination */ protected void fillDefaults(IObservableList source, IObservableList destination) { Object sourceType = source.getElementType(); Object destinationType = destination.getElementType(); if (provideDefaults && sourceType != null && destinationType != null) { if (converter == null) { setConverter(createConverter(sourceType, destinationType)); } } if (converter != null) { if (sourceType != null) { checkAssignable(converter.getFromType(), sourceType, "converter does not convert from type " + sourceType); //$NON-NLS-1$ } if (destinationType != null) { checkAssignable(destinationType, converter.getToType(), "converter does not convert to type " + destinationType); //$NON-NLS-1$ } } }
return super.createConverter(fromType, toType);
protected void postInit() { if (modelToTarget.getUpdatePolicy() == UpdateListStrategy.POLICY_UPDATE) { updateModelToTarget(); } if (targetToModel.getUpdatePolicy() == UpdateListStrategy.POLICY_UPDATE) { validateTargetToModel(); } }
/** * @param targetObservableList * @param modelObservableList * @return an update list strategy */ protected <T, M> UpdateListStrategy<T, M> createTargetToModelUpdateListStrategy( IObservableList<T> targetObservableList, IObservableList<M> modelObservableList) { return new UpdateListStrategy<>(); }
/** * Removes the element at the given index from the given observable list. * Clients may extend but must call the super implementation. * * @param observableList * @param index * @return a status */ protected IStatus doRemove(IObservableList observableList, int index) { try { observableList.remove(index); } catch (Exception ex) { return logErrorWhileSettingValue(ex); } return Status.OK_STATUS; }
: createModelToTargetUpdateListStrategy(modelObservableList, targetObservableList); targetToModelStrategy.fillDefaults(targetObservableList, modelObservableList); modelToTargetStrategy.fillDefaults(modelObservableList, targetObservableList); ListBinding result = new ListBinding(targetObservableList,
/** * @param target * @param model * @param modelToTargetStrategy * @param targetToModelStrategy */ public ListBinding(IObservableList target, IObservableList model, UpdateListStrategy targetToModelStrategy, UpdateListStrategy modelToTargetStrategy) { super(target, model); this.targetToModel = targetToModelStrategy; this.modelToTarget = modelToTargetStrategy; if ((targetToModel.getUpdatePolicy() & UpdateListStrategy.POLICY_UPDATE) != 0) { target.addListChangeListener(targetChangeListener); } else { targetChangeListener = null; } if ((modelToTarget.getUpdatePolicy() & UpdateListStrategy.POLICY_UPDATE) != 0) { model.addListChangeListener(modelChangeListener); } else { modelChangeListener = null; } }
/** * @param modelObservableList * @param targetObservableList * @return an update list strategy */ protected <M, T> UpdateListStrategy<M, T> createModelToTargetUpdateListStrategy( IObservableList<M> modelObservableList, IObservableList<T> targetObservableList) { return new UpdateListStrategy<>(); }
/** * Moves the element in the observable list located at the given old index * to the given new index. * * @param observableList * @param oldIndex * @param newIndex * @return a status * @since 1.2 */ protected IStatus doMove(IObservableList<? super D> observableList, int oldIndex, int newIndex) { try { observableList.move(oldIndex, newIndex); } catch (Exception ex) { return logErrorWhileSettingValue(ex); } return Status.OK_STATUS; }
/** * @param target * @param model * @param modelToTargetStrategy * @param targetToModelStrategy */ public ListBinding(IObservableList target, IObservableList model, UpdateListStrategy targetToModelStrategy, UpdateListStrategy modelToTargetStrategy) { super(target, model); this.targetToModel = targetToModelStrategy; this.modelToTarget = modelToTargetStrategy; if ((targetToModel.getUpdatePolicy() & UpdateListStrategy.POLICY_UPDATE) != 0) { target.addListChangeListener(targetChangeListener); } else { targetChangeListener = null; } if ((modelToTarget.getUpdatePolicy() & UpdateListStrategy.POLICY_UPDATE) != 0) { model.addListChangeListener(modelChangeListener); } else { modelChangeListener = null; } }
/** * @param modelObservableList * @param targetObservableList * @return an update list strategy */ protected UpdateListStrategy createModelToTargetUpdateListStrategy( IObservableList modelObservableList, IObservableList targetObservableList) { return new UpdateListStrategy(); }