2015-01-20 15 views
0

Sample Ecore editor (org.eclipse.emf.ecore* plugins)을 기반으로 사용자 정의 Ecore 편집기를 만들고 목록의 변경 사항이 모델 변경 알림에 나타나지 않는다는 것을 알았습니다. 예를 들어, EAnnotation.references 목록을 변경해도 모델 변경 알림이 나타나지 않지만 EAnnotation.setSource() 메서드는 알림을 생성합니다. 이것은 EAnnotationItemProvider의 기본값 getText() 메서드가 source 필드 만 사용하는 이유 중 하나입니다.EAnnotation 참조 목록 알림 변경

references 필드의 값을 사용하여 EAnnotation의 UI 프리젠 테이션을 생성하므로 올바른 작동을 위해이 필드의 변경 사항을 확인해야합니다.

이러한 변경 사항을 관찰하고 refresh()을 모델보기에서 실행하는 표준 방법이 있습니까?

답변

0

알림이 생성되었음을 알았지 만 notifyChanged() 메서드는 처음에이를 무시했습니다. 이것이 나를 위해 일한 것입니다 :

@Override 
public void notifyChanged(Notification notification) { 
    updateChildren(notification); 

    switch (notification.getFeatureID(EAnnotation.class)) { 
     case EcorePackage.EANNOTATION__SOURCE: 
     case EcorePackage.EANNOTATION__REFERENCES: /*ADDED*/ 
      fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), false, true)); 
      return; 
     case EcorePackage.EANNOTATION__CONTENTS: 
      fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, false)); 
      return; 
     case EcorePackage.EANNOTATION__DETAILS: /*MODIFIED TO UPDATE VIEW*/ 
      fireNotifyChanged(new ViewerNotification(notification, notification.getNotifier(), true, true)); 
      return; 
    } 
    super.notifyChanged(notification); 
}