private void recurseSetFromComponent(Component com, boolean onlyUnmapped) { if (com == null) { return; } List<StereotypeMetaData> metas = com.getMetaData(); for (StereotypeMetaData meta : metas) { if (!onlyUnmapped || !isMapped(meta, com)) { setValue(meta, com, meta.getComponentValue(com)); } } if (com.getSlots() != null) { for (Slot slot : com.getSlots()) { List<StereotypeMetaData> slotMetas = slot.getMetaData(); for (StereotypeMetaData meta : slotMetas) { if (!onlyUnmapped || !isMapped(meta, slot)) { setValue(meta, slot, meta.getComponentValue(slot)); } } if (slot.getContent() != null) { for (Component slotCom : slot.getContent()) { recurseSetFromComponent(slotCom, onlyUnmapped); } } } } }
private void setValueNoCheck( final StereotypeMetaData meta, final HasMetaData instance, Object object) { if (!data.containsKey(instance.getUuid())) { data.put(instance.getUuid(), new HashMap<String, Object>()); } Map<String, Object> comMap = data.get(instance.getUuid()); comMap.put(meta.getPropertyName(), object); if (stereotype.getCurrentPreviewState() == null) { meta.setComponentValue(instance, object); } }
protected void checkInitialised(final HasMetaData instance) { if (getClass().equals(DefaultPreviewState.class)) { if (!data.containsKey(instance.getUuid())) { // if uuid is not initialised, this is a new component, so init all metas List<StereotypeMetaData> metas = instance.getMetaData(); for (StereotypeMetaData cur : metas) { Object o = cur.getComponentValue(instance); setValueNoCheck(cur, instance, o); } } } else { stereotype.getDefaultState().checkInitialised(instance); } }
private void recurseSetOnComponent(Component com) { if (com == null) { return; } checkInitialised(com); List<StereotypeMetaData> metas = com.getMetaData(); for (StereotypeMetaData meta : metas) { meta.setComponentValue(com, getValue(meta, com)); } if (com.getSlots() != null) { for (Slot slot : com.getSlots()) { List<StereotypeMetaData> slotMetas = slot.getMetaData(); for (StereotypeMetaData meta : slotMetas) { meta.setComponentValue(slot, getValue(meta, slot)); } if (slot.getContent() != null) { for (Component slotCom : slot.getContent()) { recurseSetOnComponent(slotCom); } } } } }
private boolean isMapped(final StereotypeMetaData meta, final HasMetaData instance) { return (data.containsKey(instance.getUuid()) && data.get(instance.getUuid()).containsKey(meta.getPropertyName())); }
public Object getValue(final StereotypeMetaData meta, final HasMetaData instance) { checkInitialised(instance); Map<String, Object> comMap = data.get(instance.getUuid()); return comMap.get(meta.getPropertyName()); }