How do I add a WorkItemListener to WorkItemEditor?
Hi,
What is the right way to add an IWorkItemListener to a WorkItem that is currently opened in a WorkItemEditor? I have tried to cach the currently opened WorkItemEditor and do the following: currentEditor = (WorkItemEditor) part; IEditorInput input = currentEditor.getEditorInput(); if (input instanceof WorkItemEditorInput) { WorkItemWorkingCopy workingCopy= ((WorkItemEditorInput) input).getWorkingCopy(); WorkItemUIWorkingCopy uiCopy= (WorkItemUIWorkingCopy) workingCopy.getAdapter(IWorkItemUIWorkingCopy.class); uiCopy.getUIWorkItemListener().addListener(this); } However, this causes some strange behaviors. After I make changes to the WorkItem, the '*' sign doesn't appear on the editor tab as before and I can't directly save the changes. Only when I try to close the editor tab that there is a popup saying that there is another editor still opened and asking me if I want to save the changes. Can anyone help me out on this, please? Thanks, Petcharat |
2 answers
Thanks, Christof. I used IWorkItemWorkingCopyManager#addWorkItemListener(..) and things work properly now. :)
|
Hi Petcharat,
WorkItemEditorInput.getWorkingCopy() could cause some unexpected behavior if called before the input was fully resolved (you could check that with WorkItemEditorInput.isResolved()). Depending on what you want to do you could also register a listener with IWorkItemWorkingCopyManager.addWorkItemListener(...) which would then be notified independently of the kind of editor used to change the work item. HTH, Christof Jazz Work Item team petcharatv wrote: Hi, |
Your answer
Dashboards and work items are no longer publicly available, so some links may be invalid. We now provide similar information through other means. Learn more here.