/** * The property is a simple value list. If property is a list property, the method will check to * see if the current element has the local list value, if it has, the method returns, otherwise, * a copy of the list value inherited from container or parent will be set locally on the element * itself. * * <p>This method is supposed to be used when we need to change the value of a composite property( * a simple list property ). These kind of property is inherited as a whole, so when the value * changed from a child element. This method will be called to ensure that a local copy will be * made, so change to the child won't affect the original value in the parent. * * @param ref a reference to a list property or member. */ private DesignElement makeLocalCompositeValue( DesignElement topElement, ElementPropertyDefn prop, DesignElement content) { // Top level property is a list. Object localValue = topElement.getLocalProperty(module, prop); if (localValue != null) return content; // Make a local copy of the inherited list value. Object inherited = topElement.getProperty(module, prop); // if the action is add, the inherited can be null. if (inherited == null) return null; int index = -1; if (content != null && inherited instanceof List) index = ((List) inherited).indexOf(content); Object newValue = ModelUtil.copyValue(prop, inherited); ActivityStack activityStack = module.getActivityStack(); ContainerContext context = new ContainerContext(topElement, prop.getName()); if (newValue instanceof List) { List list = new ArrayList(); PropertyRecord propRecord = new PropertyRecord(topElement, prop, list); activityStack.execute(propRecord); list = (List) newValue; for (int i = 0; i < list.size(); i++) { DesignElement tmpContent = (DesignElement) list.get(i); ContentRecord addRecord = new ContentRecord(module, context, tmpContent, i); activityStack.execute(addRecord); } } else { PropertyRecord propRecord = new PropertyRecord(topElement, prop, newValue); activityStack.execute(propRecord); } if (index != -1) return (DesignElement) ((List) newValue).get(index); return content; }
private void insertLevelHandle(LevelHandle levelHandle, int pos) throws SemanticException { CrosstabReportItemHandle reportHandle = viewHandle.getCrosstab(); // int viewCount = viewHandle.getLevelCount( ); DataItemHandle dataHandle = CrosstabAdaptUtil.createColumnBindingAndDataItem( (ExtendedItemHandle) reportHandle.getModelHandle(), levelHandle); LevelViewHandle levelViewHandle = viewHandle.insertLevel(levelHandle, pos); CrosstabCellHandle cellHandle = levelViewHandle.getCell(); cellHandle.addContent(dataHandle); ActionHandle actionHandle = levelHandle.getActionHandle(); if (actionHandle != null) { List source = new ArrayList(); source.add(actionHandle.getStructure()); List newAction = ModelUtil.cloneStructList(source); dataHandle.setAction((Action) newAction.get(0)); } CrosstabUtil.addLabelToHeader(levelViewHandle); }