/** * The referenced model of this {@code ModelRefPropertyConnector} * changed. It will notify its {@code IModelChangeListener} s (i.e. the * child property connectors) of the change. * <p> * {@inheritDoc} */ @Override public void propertyChange(PropertyChangeEvent evt) { fireModelChange(evt.getOldValue(), evt.getNewValue()); super.propertyChange(evt); }
/** * Called when the underlying connectee value (the model property) changes. * This implementation notifies its {@code IValueChangeListener} s about * the change passing the new model property. * <p> * {@inheritDoc} */ @Override public void propertyChange(PropertyChangeEvent evt) { fireConnectorValueChange(); }
/** * Since model provider is usually the parent connector for this kind of * connector, this method is overloaded to call the * {@code modelProviderChanged} method. * <p> * {@inheritDoc} */ @Override public void setParentConnector(ICompositeValueConnector parentConnector) { IModelProvider oldModelProvider = getModelProvider(); super.setParentConnector(parentConnector); modelProviderChanged(oldModelProvider); }
recomputeAccessor(newModel); ICompositeValueConnector parentConnector = getParentConnector(); if (parentConnector != null && !(parentConnector instanceof ICollectionConnector)) { if (oldModel != null && oldModel instanceof IPropertyChangeCapable) { ((IPropertyChangeCapable) oldModel).removePropertyChangeListener( getId(), this); ((IPropertyChangeCapable) newModel).addPropertyChangeListener(getId(), this); if (getReadabilityGates() != null) { for (IGate gate : getReadabilityGates()) { if (gate instanceof IModelAware) { ((IModelAware) gate).setModel(newModel); if (getWritabilityGates() != null) { for (IGate gate : getWritabilityGates()) { if (gate instanceof IModelAware) { ((IModelAware) gate).setModel(newModel); writabilityChange(); readabilityChange(); fireConnectorValueChange();
private void recomputeAccessor(Object newModel) { if (isValueAccessedAsProperty() && getModelProvider() != null && accessorFactory != null && (accessor == null || !accessor.appliesTo(newModel))) { Class<?> modelType = null; try { if (newModel != null) { if (newModel instanceof IComponent) { modelType = ((IComponent) newModel).getComponentContract(); } else { modelType = newModel.getClass(); } } else { modelType = getModelProvider().getModelDescriptor().getModelType(); } accessor = accessorFactory.createPropertyAccessor(getId(), modelType); } catch (Exception ex) { LOG.error( "An error occurred when creating the accessor for the {} property on {} class.", getId(), modelType, ex); } if (accessor instanceof IModelDescriptorAware) { ((IModelDescriptorAware) accessor) .setModelDescriptor(getModelDescriptor()); } } }
oldModelProvider.removeModelChangeListener(this); if (getModelProvider() != null) { getModelProvider().addModelChangeListener(this); newModel = getModelProvider().getModel(); recomputeAccessor(newModel); modelChange(new ModelChangeEvent(getModelProvider(), oldModel, newModel));
/** * Accesses the underlying model property and sets its value. * <p> * {@inheritDoc} */ @Override protected void setConnecteeValue(Object aValue) { if (!ObjectUtils.equals(aValue, getConnecteeValue())) { try { accessor.setValue(getModelProvider().getModel(), aValue); } catch (IllegalAccessException | NoSuchMethodException ex) { throw new ConnectorBindingException(ex); } catch (InvocationTargetException ex) { if (ex.getCause() instanceof RuntimeException) { throw (RuntimeException) ex.getCause(); } throw new ConnectorBindingException(ex.getCause()); } } } }
/** * {@inheritDoc} */ @Override public ModelRefPropertyConnector clone(String newConnectorId) { ModelRefPropertyConnector clonedConnector = (ModelRefPropertyConnector) super .clone(newConnectorId); clonedConnector.modelChangeSupport = null; clonedConnector.childConnectors = null; clonedConnector.childConnectorKeys = null; return clonedConnector; }
/** * {@inheritDoc} */ @Override public boolean isWritable() { boolean writable = super.isWritable(); if (accessor != null) { writable = writable && accessor.isWritable(); } if (getModelProvider() != null) { writable = writable && getModelProvider().getModel() != null; } return writable; }
/** * Gets the modelProvider. * * @return the modelProvider. */ @Override public IModelProvider getModelProvider() { if (getParentConnector() instanceof IModelProvider) { return (IModelProvider) getParentConnector(); } return null; }
/** * Overridden to deal with polymorphism. * <p> * {@inheritDoc} */ @Override public IComponentDescriptorProvider<?> getModelDescriptor() { IComponentDescriptorProvider<?> registeredModelDescriptor = (IComponentDescriptorProvider<?>) super .getModelDescriptor(); if (getModel() instanceof IEntity && !(getModel() instanceof IQueryComponent)) { Class<? extends IEntity> entityContract = ((IEntity) getModel()) .getComponentContract(); if (!entityContract.equals(registeredModelDescriptor.getModelType())) { // we must take care of subclasses (polymorphism) return modelConnectorFactory.getDescriptorRegistry() .getComponentDescriptor(entityContract); } } return registeredModelDescriptor; }
/** * {@inheritDoc} */ @Override public ModelCollectionPropertyConnector clone(String newConnectorId) { ModelCollectionPropertyConnector clonedConnector = (ModelCollectionPropertyConnector) super .clone(newConnectorId); clonedConnector.childConnectors = null; clonedConnector.childConnectorKeys = null; clonedConnector.connectorTank = null; clonedConnector.selectionChangeSupport = null; return clonedConnector; }
/** * Accesses the underlying model property and gets its value. * <p> * {@inheritDoc} */ @Override protected Object getConnecteeValue() { try { return accessor.getValue(getModelProvider().getModel()); } catch (IllegalAccessException ex) { throw new ConnectorBindingException(ex); } catch (InvocationTargetException ex) { if (ex.getCause() instanceof RuntimeException) { throw (RuntimeException) ex.getCause(); } throw new ConnectorBindingException(ex.getCause()); } catch (NoSuchMethodException ex) { // this may be a normal behaviour in case of polymorphism. // don't throw any exception. // throw new ConnectorBindingException(ex); return null; } }
/** * Before invoking the super implementation which fires the * {@code ValueChangeEvent}, this implementation reconstructs the child * connectors based on the retrieved collection. * <p> * {@inheritDoc} */ @Override public void propertyChange(PropertyChangeEvent evt) { updateChildConnectors(); super.propertyChange(evt); }
((ModelPropertyConnector) collectionConnector).propertyChange(null);
((ModelPropertyConnector) collectionConnector).propertyChange(null);
((ModelPropertyConnector) collectionConnector).propertyChange(null);
((ModelPropertyConnector) collectionConnector).propertyChange(null);