@Override public void initializeWatchedModel(DataAssociationEditorModel watchedModel, DataAssociationBean modelToBind) { // 1 - load assignments if(modelToBind.getAssignements()!=null && !modelToBind.getAssignements().isEmpty()) { IAssignmentBean a = modelToBind.getAssignements().get(0); if(a.getFrom()!=null) { watchedModel.setFrom(a.getFrom().getContent()); } if(a.getTo()!=null) { watchedModel.setTo(a.getTo().getContent()); } } // 2 - load source or target item if(modelToBind.getSourceItem()!=null) { watchedModel.setItemDef(modelToBind.getSourceItem()); } else if (modelToBind.getTargetItem()!=null) { watchedModel.setItemDef(modelToBind.getTargetItem()); } }
@Override public void bind(DataAssociationEditorModel watchedModel, DataAssociationBean modelToBind) { // 1 - binding of 'to' and 'from' fields of the editor model //add an assignment with the 'to' and 'from' expressions modelToBind.getAssignements().clear(); IAssignmentBean a = new AssignmentBean(); modelToBind.addAssignement(a); IExpressionBean from = new ExpressionBean(); from.setContent(watchedModel.getFrom()); a.setFrom(from); IExpressionBean to = new ExpressionBean(); to.setContent(watchedModel.getTo()); a.setTo(to); // 2 - binding of 'itemDef' property of the editor model //set targetItem and sourceItem to the editor model value // the builder will use one of them depending if the data association // is a datainputassociation or a dataoutputassociation modelToBind.setTargetItem(watchedModel.getItemDef()); modelToBind.setSourceItem(watchedModel.getItemDef()); }