SimpleModelChangeListenerAddon.java 文件源码

java
阅读 22 收藏 0 点赞 0 评论 0

项目:gemoc-studio-modeldebugging 作者:
public SimpleModelChangeListenerAddon(final IExecutionEngine engine) {
    this.engine = engine;
    changes = new HashMap<>();
    registeredAddons = new HashSet<>();
    adapter = new EContentAdapter() {

        @Override
        public void notifyChanged(Notification notification) {
            super.notifyChanged(notification);
            int eventType = notification.getEventType();
            Object notifier = notification.getNotifier();
            if (eventType < Notification.EVENT_TYPE_COUNT && notifier instanceof EObject && !notification.isTouch()) {
                switch (notification.getEventType()) {
                case Notification.ADD:
                case Notification.ADD_MANY:
                    addFeatureChange((EStructuralFeature) notification.getFeature(),
                            (EObject) notification.getNotifier(), notification.getNewValue(),
                            FieldChange.ChangeType.ADD);
                    break;
                case Notification.REMOVE:
                case Notification.REMOVE_MANY:
                    addFeatureChange((EStructuralFeature) notification.getFeature(),
                            (EObject) notification.getNotifier(), notification.getOldValue(),
                            FieldChange.ChangeType.REMOVE);
                    break;
                case Notification.MOVE:
                case Notification.SET:
                case Notification.UNSET:
                    addFeatureChange((EStructuralFeature) notification.getFeature(),
                            (EObject) notification.getNotifier(), notification.getNewValue(),
                            FieldChange.ChangeType.MODIFY);
                    break;
                }
            }
        }
    };
    Set<Resource> allResources = org.eclipse.gemoc.commons.eclipse.emf.EMFResource.getRelatedResources(this.engine
            .getExecutionContext().getResourceModel());
    allResources.stream().forEach(r -> {
        if (r != null) {
            r.eAdapters().add(adapter);
        }
    });
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号