Jazz Forum Welcome to the Jazz Community Forum Connect and collaborate with IBM Engineering experts and users

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

0 votes



2 answers

Permanent link
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,

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

0 votes


Permanent link
Thanks, Christof. I used IWorkItemWorkingCopyManager#addWorkItemListener(..) and things work properly now. :)

0 votes

Your answer

Register or log in to post 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.

Search context
Follow this question

By Email: 

Once you sign in you will be able to subscribe for any updates here.

By RSS:

Answers
Answers and Comments
Question details
× 10,941

Question asked: Jul 06 '08, 12:09 a.m.

Question was seen: 6,531 times

Last updated: Jul 06 '08, 12:09 a.m.

Confirmation Cancel Confirm