Source:
private Object getSelection(IStructuredSelection selection) { Object treeSelected = selection != null ? selection.getFirstElement() : null; if (getViewModelContext().getContextValue("enableMultiEdit") == Boolean.TRUE && treeSelected instanceof EObject && selection.size() > 1) { boolean allOfSameType = true; final EObject dummy = EcoreUtil.create(((EObject) treeSelected).eClass()); final Iterator iterator = selection.iterator(); final Set<EObject> selectedEObjects = new LinkedHashSet<EObject>(); while (iterator.hasNext()) { final EObject eObject = (EObject) iterator.next(); allOfSameType &= eObject.eClass() == dummy.eClass(); if (allOfSameType) { for (final EAttribute attribute : dummy.eClass().getEAllAttributes()) { if (eObject == treeSelected) { dummy.eSet(attribute, eObject.eGet(attribute)); } else if (dummy.eGet(attribute) != null && !dummy.eGet(attribute).equals(eObject.eGet(attribute))) { dummy.eUnset(attribute); } } selectedEObjects.add(eObject); } else { break; } } if (allOfSameType) { treeSelected = dummy; dummy.eAdapters().add(new AdapterImpl() { @Override public void notifyChanged(Notification notification) { final EditingDomain editingDomain = AdapterFactoryEditingDomain .getEditingDomainFor(getViewModelContext().getDomainModel()); if (dummy.eClass().getEAllAttributes().contains(notification.getFeature())) { final CompoundCommand cc = new CompoundCommand(); for (final EObject selected : selectedEObjects) { final Command setCommand = SetCommand.create(editingDomain, selected, notification.getFeature(), notification.getNewValue()); cc.append(setCommand); } editingDomain.getCommandStack().execute(cc); } } }); } } return treeSelected; }

Target:
private Object getSelection(IStructuredSelection selection) { Object treeSelected = selection != null ? selection.getFirstElement() : null; if (getViewModelContext().getContextValue("enableMultiEdit") == Boolean.TRUE && treeSelected instanceof EObject && selection.size() > 1) { boolean allOfSameType = true; final EObject dummy = EcoreUtil.create(((EObject) treeSelected).eClass()); final Iterator iterator = selection.iterator(); final Set<EObject> selectedEObjects = new LinkedHashSet<EObject>(); while (iterator.hasNext()) { final EObject eObject = (EObject) iterator.next(); allOfSameType &= eObject.eClass() == dummy.eClass(); if (allOfSameType) { for (final EAttribute attribute : dummy.eClass().getEAllAttributes()) { if (eObject == treeSelected) { dummy.eSet(attribute, eObject.eGet(attribute)); } else if (dummy.eGet(attribute) != null && !dummy.eGet(attribute).equals(eObject.eGet(attribute))) { dummy.eUnset(attribute); } } selectedEObjects.add(eObject); } else { break; } } if (allOfSameType) { treeSelected = dummy; dummy.eAdapters().add(new AdapterImpl() { @Override public void notifyChanged(Notification notification) { final EditingDomain editingDomain = AdapterFactoryEditingDomain .getEditingDomainFor(getViewModelContext().getDomainModel()); if (dummy.eClass().getEAllAttributes().contains(notification.getFeature())) { final CompoundCommand cc = new CompoundCommand(); for (final EObject selected : selectedEObjects) { Command command = null; switch (notification.getEventType()) { case Notification.SET: command = SetCommand.create(editingDomain, selected, notification.getFeature(), notification.getNewValue()); break; case Notification.UNSET: command = SetCommand.create(editingDomain, selected, notification.getFeature(), SetCommand.UNSET_VALUE); break; default: continue; } cc.append(command); } editingDomain.getCommandStack().execute(cc); } } }); } } return treeSelected; }