Getting full state of a custom attribute
Hi,
I am extending com.ibm.team.workitem.ide.ui.internal.editor.presentations.AttributePart Everything is fine when I am working on the attribute part I extend. But now, I'd like to write to another existing custom attribute. In creation I can get Item handle of the custom attribute but after saving and reopenning the work item, I cannot get full state. Here is the part that I am getting full state of the custom attribute successfully: @Override This code works in creation. But when I save and re-open the workitem, itemhandle is null. Can you please tell me a way to get item handle after saving the workitem? Thanks, |
3 answers
Hi, The problem is this line: IItemHandle itemHandle = attrHandle.getFullState(); There are two problems here: a) If you want the full state of the item, getFullState() only works if the handle is actually an item already (items inherit from item handles). You have to resolve the item handle either using the ItemManager or our IAuditableClient library: IAuditableClient auditableClient= (IAuditableClient) getTeamRepository().getClientLibrary(IAuditableClient.class); b) If you need only an IItemHandle, as your assignment suggests, a simple assignment would be enough (IAttributeHandle inherits from IItemHandle) |
Hi Patrick,
Thanks for your answer, I need some more clearifications in both a and b. In a) you provided a code: IAuditableClient auditableClient= (IAuditableClient) getTeamRepository().getClientLibrary(IAuditableClient.class); here, since I am extending com.ibm.team.workitem.ide.ui.internal.editor.presentations.AttributePart; I do not have getTeamRepository() method. whose method is this? And can you define attrHandle and monitor? In b) I replaced IItemHandle with IAttributeHandle and I am still having null itemhandle:
to be more spesific: here is what I do when I get the itemhandle: if( itemHandle != null){ |
Hi,
IAuditableClient has a getClientLibrary() method. The monitor is a org.eclipse.core.runtime.ProgressMonitor. Please read the Java doc. There are lots of examples in the RTC source code. The monitor is necessary because resolveAuditable is a long running operation that talks to a server. You can find the attrHandle for a custom attribute with a given ID through IAttribute IWorkItemCommon.findAttribute(..., String identifier, ...). A IWorkItemCommon can be obtained through the getClientLibrary() method. hth, --andre Andre Weinand Work Item Team |
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.