티스토리 뷰

Editing domain이 무엇인지에대한 설명은 블로그의 다른글 'Command를 이용하여 EMF model 수정하기'를 참조하기 바랍니다.

다음은 기본적으로 editing domain을 생성하는 코드이다. 

// Create an adapter factory that yields item providers.
adapterFactory = new ComposedAdapterFactory(ComposedAdapterFactory.Descriptor.Registry.INSTANCE);

// Create the command stack that will notify this editor as commands are executed.
BasicCommandStack commandStack = new BasicCommandStack();


// Add a listener to set the most recent command's affected objects to be the selection of the viewer with focus.
commandStack.addCommandStackListener(new CommandStackListener() {
    public void commandStackChanged(final EventObject event) {
        getContainer().getDisplay().asyncExec(new Runnable() {
            public void run() {
            firePropertyChange(IEditorPart.PROP_DIRTY);
            Command mostRecentCommand = ((CommandStack) event.getSource()).getMostRecentCommand();
            }
        });
    }
});

// Create the editing domain with a special command stack.
EditingDomain editingDomain = new AdapterFactoryEditingDomain(adapterFactory,  commandStack, new HashMap<Resource, Boolean>());

위의 code는 EMF model generator에 의해서 자동으로 생성된 code의 일부이다. 
editing domain을 만들기 위해서는 adapterFactory, commandStack, hashMap이 필요하다. adapterFactory가 하는 역할에 대해서는 다른 문서를 참조하기 바란다.(솔직히 필자도 EMF model만을 사용하는 방법을 사용하기 때문에 EMF.edit가 제공하는 adapter및 item provider에 대한 이해가 부족하다. 혹시 이것에 대해서 잘아는 다른 분이 본다면 내용을 추가해주시기 바랍니다.) 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/05   »
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31