/** * {@inheritDoc} */ public String getRenderedProperty() { if (renderedProperty == null) { return ((ICollectionDescriptorProvider<?>) getModelDescriptor()) .getCollectionDescriptor().getElementDescriptor() .getToStringProperty(); } return renderedProperty; }
/** * Gets the entity descriptor to execute the LOV action for from the context. * It allows sub classes to override in order to define the descriptor at * runtime. * * @param context * the action context. * @return the entity descriptor to execute the LOV action for. */ @SuppressWarnings("UnusedParameters") protected IComponentDescriptor<? extends IComponent> getEntityDescriptor(Map<String, Object> context) { if (entityDescriptor == null) { IModelDescriptor modelDescriptor = getModelDescriptor(context); if (modelDescriptor instanceof ICollectionDescriptorProvider<?>) { ICollectionDescriptor<?> collectionDescriptor = ((ICollectionDescriptorProvider<?>) modelDescriptor) .getCollectionDescriptor(); if (collectionDescriptor != null) { return (IComponentDescriptor<? extends IComponent>) collectionDescriptor.getElementDescriptor(); } } } return entityDescriptor; }
/** * This implementation returns a {@code ModelConnector} instance. * <p> * {@inheritDoc} */ @Override public IValueConnector createChildConnector(String connectorId) { if (connectorTank != null && !connectorTank.isEmpty()) { return connectorTank.remove(0); } IComponentDescriptor<?> componentDescriptor; componentDescriptor = ((ICollectionDescriptorProvider<?>) getModelDescriptor()) .getCollectionDescriptor().getElementDescriptor(); IValueConnector elementConnector = modelConnectorFactory .createModelConnector(connectorId, componentDescriptor, getSecurityHandler()); return elementConnector; }
private SecurityContextBuilder append(IModelDescriptor modelDescriptor) { if (modelDescriptor != null) { if (modelDescriptor instanceof IPropertyDescriptor) { currentSecurityContext.put(SecurityContextConstants.PROPERTY, ((IPropertyDescriptor) modelDescriptor).getPermId()); } if (modelDescriptor instanceof IComponentDescriptorProvider<?> && ((IComponentDescriptorProvider<?>) modelDescriptor) .getComponentDescriptor() != null) { if (!(currentSecurityContext.get(LAST_PUSHED_VIEW) instanceof IPropertyViewDescriptor)) { // only dig the model if we are not on a reference property view (LOV // field). see bug #560. currentSecurityContext.put(SecurityContextConstants.MODEL, ((IComponentDescriptorProvider<?>) modelDescriptor) .getComponentDescriptor().getPermId()); } } else if (modelDescriptor instanceof ICollectionDescriptorProvider<?>) { currentSecurityContext.put(SecurityContextConstants.MODEL, ((ICollectionDescriptorProvider<?>) modelDescriptor) .getCollectionDescriptor().getElementDescriptor().getPermId()); } } return this; }
/** * Retrieves the bean component descriptor to create the child bean module. * * @param parentModule * the parent module to add the child bean module to. * @param context * the action context. * @return the bean module component descriptor. */ @SuppressWarnings("UnusedParameters") protected IComponentDescriptor<?> getBeanComponentDescriptor( Module parentModule, Map<String, Object> context) { IModelDescriptor modelDescriptor = getModelDescriptor(context); IComponentDescriptor<?> childComponentDescriptor; if (modelDescriptor instanceof ICollectionDescriptorProvider<?>) { childComponentDescriptor = ((ICollectionDescriptorProvider<?>) modelDescriptor) .getCollectionDescriptor().getElementDescriptor(); } else { childComponentDescriptor = ((IComponentDescriptorProvider<?>) modelDescriptor) .getComponentDescriptor(); } return childComponentDescriptor; }
/** * Gets the elementComponentDescriptor. * * @return the elementComponentDescriptor. */ public IComponentDescriptor<?> getElementComponentDescriptor() { if (elementComponentDescriptor == null) { IViewDescriptor projectedViewDescriptor = getProjectedViewDescriptor(); if (projectedViewDescriptor instanceof ICollectionViewDescriptor && projectedViewDescriptor.getModelDescriptor() != null) { return ((ICollectionDescriptorProvider<?>) projectedViewDescriptor.getModelDescriptor()) .getCollectionDescriptor().getElementDescriptor(); } } return elementComponentDescriptor; }
/** * {@inheritDoc} */ @Override public String getIconImageURL() { String iconImageURL = super.getIconImageURL(); if (iconImageURL == null) { iconImageURL = ((ICollectionDescriptorProvider<?>) getModelDescriptor()) .getCollectionDescriptor().getElementDescriptor().getIconImageURL(); setIconImageURL(iconImageURL); } return iconImageURL; } }
.getCollectionDescriptor().getCollectionInterface())) { return false;
/** * Creates a new entity to add to the projected object collection. * * @param actionHandler * the action handler (generally the controller). * @param context * the action context. * @return the created entity. */ @SuppressWarnings({"unchecked", "UnusedParameters"}) protected Object createNewModuleObject(IActionHandler actionHandler, Map<String, Object> context) { IComponentDescriptor<? extends IEntity> projectedDesc = ((ICollectionDescriptorProvider<IEntity>) getModelDescriptor(context)) .getCollectionDescriptor().getElementDescriptor(); Class<? extends IEntity> componentContract = projectedDesc.getComponentContract(); return getEntityFactory(context).createEntityInstance( componentContract); } }
/** * Creates a new entity to add to the projected object collection. * * @param actionHandler * the action handler (generally the controller). * @param context * the action context. * @return the created entity. */ @SuppressWarnings("unchecked") protected Object createNewModuleObject(IActionHandler actionHandler, Map<String, Object> context) { IComponentDescriptor projectedComponentDescriptor = ((ICollectionDescriptorProvider<?>) getModelDescriptor(context)) .getCollectionDescriptor().getElementDescriptor(); return getEntityFactory(context).createEntityInstance( (Class<? extends IEntity>) projectedComponentDescriptor .getComponentContract()); } }
if (transferStructure != null && transferStructure.getContent() != null) { List<Object> componentsToTransfer; if (((Class<?>) getModelDescriptor(context).getCollectionDescriptor() .getElementDescriptor().getComponentContract()) .isAssignableFrom(transferStructure.getComponentDescriptor()
/** * {@inheritDoc} */ public List<ISubViewDescriptor> getColumnViewDescriptors() { if (columnViewDescriptors == null) { ICollectionDescriptorProvider<?> modelDescriptor = ((ICollectionDescriptorProvider<?>) getModelDescriptor()); IComponentDescriptor<?> rowModelDescriptor = modelDescriptor .getCollectionDescriptor().getElementDescriptor(); List<String> modelRenderedProperties = rowModelDescriptor .getRenderedProperties(); if (modelDescriptor instanceof ICollectionPropertyDescriptor && ((ICollectionPropertyDescriptor<?>) modelDescriptor) .getReverseRelationEnd() != null) { modelRenderedProperties .remove(((ICollectionPropertyDescriptor<?>) modelDescriptor) .getReverseRelationEnd().getName()); } List<ISubViewDescriptor> defaultColumnViewDescriptors = new ArrayList<ISubViewDescriptor>(); for (String renderedProperty : modelRenderedProperties) { BasicSubviewDescriptor columnDescriptor = new BasicSubviewDescriptor(); columnDescriptor.setName(renderedProperty); columnDescriptor.setGrantedRoles(rowModelDescriptor .getPropertyDescriptor(renderedProperty).getGrantedRoles()); defaultColumnViewDescriptors.add(columnDescriptor); } return defaultColumnViewDescriptors; } return columnViewDescriptors; }
/** * Sets the columnViewDescriptors. * * @param columnViewDescriptors * the columnViewDescriptors to set. */ public void setColumnViewDescriptors( List<ISubViewDescriptor> columnViewDescriptors) { this.columnViewDescriptors = columnViewDescriptors; if (columnViewDescriptors != null) { ICollectionDescriptorProvider<?> modelDescriptor = ((ICollectionDescriptorProvider<?>) getModelDescriptor()); if (modelDescriptor != null) { IComponentDescriptor<?> rowModelDescriptor = modelDescriptor .getCollectionDescriptor().getElementDescriptor(); for (ISubViewDescriptor columnViewDescriptor : columnViewDescriptors) { columnViewDescriptor.setGrantedRoles(rowModelDescriptor .getPropertyDescriptor(columnViewDescriptor.getName()) .getGrantedRoles()); } } } }
/** * Retrieves the managed collection from the model connector then registers * the selected elements. * <p> * {@inheritDoc} */ @SuppressWarnings("unchecked") @Override public boolean execute(IActionHandler actionHandler, Map<String, Object> context) { int[] selectedIndices = getSelectedIndices(context); ICollectionConnector collectionConnector = getModelConnector(context); if (selectedIndices == null || selectedIndices.length == 0 || collectionConnector == null) { return false; } List<Object> transferedComponents = new ArrayList<Object>(); for (int i = 0; i < selectedIndices.length; i++) { transferedComponents.add(collectionConnector.getChildConnector( selectedIndices[i]).getConnectorValue()); } getController(context).storeComponents( new ComponentTransferStructure(getModelDescriptor(context) .getCollectionDescriptor().getElementDescriptor(), transferedComponents, transferMode)); return super.execute(actionHandler, context); }
/** * Gets the new map component to add. * * @param context * the action context. * @return the map to add to the collection. */ @Override @SuppressWarnings("unchecked") protected List<?> getAddedComponents(Map<String, Object> context) { IComponentDescriptor componentDescriptor = getModelDescriptor(context) .getCollectionDescriptor().getElementDescriptor(); Map<String, Object> newMap = new ObjectEqualityMap<String, Object>(); if (componentDescriptor.getLifecycleInterceptors() != null) { List<ILifecycleInterceptor> interceptors = componentDescriptor .getLifecycleInterceptors(); if (interceptors != null) { for (ILifecycleInterceptor<Map<String, Object>> interceptor : interceptors) { interceptor.onCreate(newMap, getEntityFactory(context), getApplicationSession(context).getPrincipal(), getApplicationSession(context)); } } } return Collections.singletonList(newMap); }
protected List<?> getAddedComponents(Map<String, Object> context) { IComponentDescriptor<?> componentDescriptor = getModelDescriptor(context) .getCollectionDescriptor().getElementDescriptor(); Map<String, Object> newMap = new ObjectEqualityMap<>(); for (IPropertyDescriptor propertyDescriptor : componentDescriptor
private IView<JComponent> createListView(IListViewDescriptor viewDescriptor, @SuppressWarnings("unused") IActionHandler actionHandler, @SuppressWarnings("unused") Locale locale) { ICollectionDescriptorProvider<?> modelDescriptor = ((ICollectionDescriptorProvider<?>) viewDescriptor .getModelDescriptor()); ICompositeValueConnector rowConnectorPrototype = connectorFactory .createCompositeValueConnector(modelDescriptor.getName() + "Element", viewDescriptor.getRenderedProperty()); ICollectionConnector connector = connectorFactory .createCollectionConnector(modelDescriptor.getName(), mvcBinder, rowConnectorPrototype); JList viewComponent = createJList(); JScrollPane scrollPane = createJScrollPane(); scrollPane.setViewportView(viewComponent); IView<JComponent> view = constructView(scrollPane, viewDescriptor, connector); if (viewDescriptor.getRenderedProperty() != null) { IValueConnector cellConnector = createColumnConnector(viewDescriptor .getRenderedProperty(), modelDescriptor.getCollectionDescriptor() .getElementDescriptor()); rowConnectorPrototype.addChildConnector(cellConnector); } viewComponent.setCellRenderer(new EvenOddListCellRenderer()); viewComponent.setModel(new CollectionConnectorListModel(connector)); listSelectionModelBinder.bindSelectionModel(connector, viewComponent .getSelectionModel(), null); return view; }
process(((IComponentDescriptorProvider<?>) viewDescriptor.getModelDescriptor()).getComponentDescriptor()); } else if (viewDescriptor.getModelDescriptor() instanceof ICollectionDescriptorProvider<?>) { process(((ICollectionDescriptorProvider<?>) viewDescriptor.getModelDescriptor()).getCollectionDescriptor() .getElementDescriptor()); } else if (viewDescriptor.getModelDescriptor() instanceof IPropertyDescriptor) {
private IView<SComponent> createListView(IListViewDescriptor viewDescriptor, @SuppressWarnings("unused") IActionHandler actionHandler, @SuppressWarnings("unused") Locale locale) { ICollectionDescriptorProvider<?> modelDescriptor = ((ICollectionDescriptorProvider<?>) viewDescriptor .getModelDescriptor()); ICompositeValueConnector rowConnectorPrototype = connectorFactory .createCompositeValueConnector(modelDescriptor.getName() + "Element", viewDescriptor.getRenderedProperty()); ICollectionConnector connector = connectorFactory .createCollectionConnector(modelDescriptor.getName(), mvcBinder, rowConnectorPrototype); SList viewComponent = createSList(); SScrollPane scrollPane = createSScrollPane(); scrollPane.setViewportView(viewComponent); IView<SComponent> view = constructView(scrollPane, viewDescriptor, connector); if (viewDescriptor.getRenderedProperty() != null) { IValueConnector cellConnector = createColumnConnector(viewDescriptor .getRenderedProperty(), modelDescriptor.getCollectionDescriptor() .getElementDescriptor()); rowConnectorPrototype.addChildConnector(cellConnector); } viewComponent.setCellRenderer(new EvenOddListCellRenderer()); viewComponent.setModel(new CollectionConnectorListModel(connector)); listSelectionModelBinder.bindSelectionModel(connector, viewComponent .getSelectionModel(), null); return view; }
.getRenderedProperty(), modelDescriptor.getCollectionDescriptor() .getElementDescriptor()); rowConnectorPrototype.addChildConnector(cellConnector);