2011-02-19 3 views
0

응용 프로그램 편집기에 표시된 객체의 특성을 표시하기 위해 Eclipse RCP 플러그인을 작성 중입니다. 내 플러그인은 PageBookView를 확장합니다. 매번 새로운 객체를 ApplicationEditor (Canvas 위젯)에서 열어서 새로운 페이지를 만듭니다. & 이전 페이지를 저장합니다.Eclipse의 Application Editor에 리스너를 추가하는 방법은 무엇입니까?

EditorEditor는 EditorPart를 확장합니다. 액티브 편집기에서 객체가 변경되면 propertyChange 이벤트가 발생합니다. 원하는 것은 applicationEditor에 리스너를 추가하는 것입니다. 필요한 이벤트가 발생하면 내 페이지를 업데이트해야합니다.

간단한 방식으로 알려 드리겠습니다. 리스너 난에 PropertyChange하여 페이지를 새로 구현해야

public Class MyPage implements IPage implements **WHICH_LISTENER** 
    { 

    public MyPage(ApplicationEditor editor) 
    { 

    this.addPropertyChangeListener(editor); 

    } 
    . . . . . . 

} 

().?

추신 : 귀하의 소중한 조언에 미리 감사드립니다. 질문에서 더 명확하게 저에게 질문하십시오! 나는 오픈 소스 프로젝트 OpenVXML에 기여하려고 노력하면서 편집자 디자인이나 코드를 변경할 수 없다.

답변

0

UI-Elements에 알리는 방법이 적절하지 않습니다. UI 요소는 변경중인 객체에 리스너를 등록해야합니다. 편집기에 구현할 청취자에 대한 질문은 편집기가 청취하는 객체에 따라 다릅니다. 귀하의 경우 PageBookView는 ApplicationEditor에 대한 참조가 필요합니다. 그 이유는 1. PageBookView에 에디터에 대한 불필요한 의존성이 있기 때문입니다. 그리고 2) 에디터가 변경 사항을 전파하는 일은 없으므로 객체 자체는 책임지지 않습니다. 나는 다음을 할 것이다.

편집기 :

public class MyEditor extends EditorPart implements PropertyChangeListener 

public void init(IEditorSite site, IEditorInput input) { 
// Getting the input and setting it to the editor 
this.object = input.getObject(); 
// add PropertyChangeListener 
this.object.addPropertyChangeListener(this) 
} 

public void propertyChanged(PropertyChangeEvents) { 
// some element of the model has changed. Perform here the UI things to react properly on the change. 
} 
} 

같은 일이 pageBook에서 수행 될 필요가있다.

public class MyPropertyView extends PageBook implements PropertyChangeListener{ 

initModel() { 
// you have to pass the model from the editor to the depending pageBook. 
this.model = getModelFromEditor() 
this.object.addPropertyChangeListener(this) 

} 
    public void propertyChanged(PropertyChangeEvents) { 
    // some element of the model has changed. Perform here the UI things to react properly on the change. 
    } 
} 

당신이 볼 수있는 두 UI 요소 모델의 변화에 ​​직접 반응하는 것처럼. 이클립스에서 모든 알림 물건 here를 참조하십시오

편집기에서 개체를 표시하는 또 다른 방법은 전 http://www.eclipse.org/articles/Article-Tabbed-Properties/tabbed_properties_view.html

참조 자세한 설명, ProperyViews을 사용하는 것입니다, 나는 간단한 예제를 작성했습니다.

HTH Tom

관련 문제