java - How to add listener to Application Editor in the Eclipse? -
i writing eclipse rcp plug-in displaying properties of objects displayed in application editor. plug-in extends pagebookview. every time, select new object opened on applicationeditor(which canvas widget),i create new page & save old page.
applicationeditor extends editorpart. fires propertychange events when objects (on active editor changes). want add listener applicationeditor. when required event fires, have update page.
let me put in simmple way.
public class mypage implements ipage implements **which_listener** { public mypage(applicationeditor editor) { this.addpropertychangelistener(editor); } . . . . . . }
which listener should implement refresh page propertychange().?
ps: in advance precious advices. feel free question me further clarity in question! cannot change editor design or code, trying contribute open source project openvxml.
your approach of notifying ui-elements not optimal. ui-elements should register listeners objects changing. question listener implement editor depends on object editor listen to. in case pagebookview needs reference applicationeditor register itself, not good, because 1. pagebookview has unneccessary dependency editor , 2) editor not responsible propagating changes, object itself. following.
your editor:
public class myeditor extends editorpart implements propertychangelistener public void init(ieditorsite site, ieditorinput input) { // getting input , setting editor this.object = input.getobject(); // add propertychangelistener this.object.addpropertychangelistener(this) } public void propertychanged(propertychangeevents) { // element of model has changed. perform here ui things react on change. } }
the same thing needs done on pagebook.
public class mypropertyview extends pagebook implements propertychangelistener{ initmodel() { // have pass model editor depending pagebook. this.model = getmodelfromeditor() this.object.addpropertychangelistener(this) } public void propertychanged(propertychangeevents) { // element of model has changed. perform here ui things react on change. } }
as can see both ui elements reacting directly changes in model.
another way of displaying objects in editor use properyviews, further description see http://www.eclipse.org/articles/article-tabbed-properties/tabbed_properties_view.html
a time ago, i've written simple example notification stuff in eclipse see here.
hth tom
Comments
Post a Comment