prev 2014. 04 next
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
 
 

포인트 랭킹 Top 9

  • 1위. [레벨:15]김동영b
    22613점
  • 2위. [레벨:8]아름프로
    6801점
  • 3위. [레벨:3]netfer
    1284점
  • 4위. [레벨:3]심플
    829점
  • 5위. [레벨:3]정의의소
    813점
  • 6위. [레벨:2]바이스
    627점
  • 7위. [레벨:2]달마다
    590점
  • 8위. [레벨:2]코디
    573점
  • 9위. [레벨:2]데로드
    448점

counter
 
 
 
   
  
 
출처 : https://jazz.net/wiki/bin/view/Main/ContributingAttributePresentations

Introduction

This document describes how the work item component can be extended to display an attribute with a custom presentation. Our example implements an alternative presentation for a boolean attribute. Instead of a check box, our custom presentations will show a starred image. When true, the star is filled in and when false the star is outlined.

star_enabled_and_disabled.png

For more information about configuring presentations and defining custom attributes, please see Work Item Editor Presentations.

There is an additional example on how to develop a custom attribute presentation that handles calculated attributes and attribute dependencies in CalculatedAttributePresentation.

Contributing to the Work Item Editor

Contributing a new presentation to the work item editors consists of two steps for each editor:

  1. Implement the presentation
  2. Bind the abstract presentation ID to the concrete implementation class

The kind for a presentation can be determined in two ways: either a kind is declared in the Process Configuration directly (blue), or a kind can be retrieved from the Attribute type registry (orange) where the type of an attribute is bound to a default presentation. The Eclipse UI instantiates the bound java class and displays it in the editor.

We assume that our new presentation has an ID of com.example.star. This presentation ID can be chosen arbitrarily but should be prefixed with the implementing component's namespace. Any boolean attribute can then be associated with our new presentation ID and will be shown using the respective control both in the web and in the rich client. Let's start with the Eclipse UI implementation:

Editor Presentations

Editor presentations for the work item editor in the eclipse ui are registered to the com.ibm.team.workitem.ide.ui.editorPresentations extension point. An extension has to specify whether it is intended to work on an attribute or not and has then to subclass either PresentationPart or AttributePart.

The com.ibm.team.workitem.common.attributeTypePresentationIdBinding extension point allows to bind a presentation id to an attribute type. Presentations configured with an attribute but without a kind will use the presentation specified in this extension point. As our example is an additional presentation, we will not register it to be default for boolean.

The presentation shows the attribute name on the left side and a toggle button with the star icon on the right side. Let's have a look at some parts of the code:

Presentation Updater:
private IPresentationUpdater fPresentationUpdater= new AbstractPresentationUpdater() {
@Override
public void setVisible(boolean visible) {
List<Control> changedControls= new ArrayList<Control>();
if (fAttributeName != null && !fAttributeName.isDisposed()) {
TeamFormUtil.setVisible(fAttributeName.getLayoutControl(), visible);
changedControls.add(fAttributeName.getLayoutControl());
}
if (fStar != null && !fStar.isDisposed()) {
TeamFormUtil.setVisible(fStar, visible);
changedControls.add(fStar);
}
Util.updateFormLayout(changedControls.toArray(new Control[changedControls.size()]));
};
@Override
public void setRequired(boolean required) {
if (fAttributeName != null && !fAttributeName.isDisposed()) {
fAttributeName.setRequired(required);
}
}
@Override
public void attributeChanged(WorkItemChangeEvent event) {
handleValueChanged();
};
};
This is the presentation updater that handles events from the presentation handler infrastructure. Such changes include visibility, attribute changes, required property annotation, dependency changes (not implemented in this example) and status reporting (not implemented in this example). The updater is registered and de-registered when the input of the work item editor changes or the editor is closed.

Button:
@Override
public void createContent(ITeamFormLayout formLayout) {
final WorkItemEditorToolkit toolkit= (WorkItemEditorToolkit) getSite().getToolkit();
Composite parent= formLayout.getContainer();
if (isLabelVisible()) {
fAttributeName= new RequiredPropertyLabel(parent, toolkit, getBackgroundStyle());
formLayout.add(fAttributeName.getLayoutControl(), ITeamFormConfiguration.LABEL_GUIDE);
}
fResourceManager= new LocalResourceManager(JFaceResources.getResources(), parent);
fStar= toolkit.createButton(parent, "", SWT.TOGGLE | SWT.FLAT, getBackgroundStyle()); //$NON-NLS-1$
TeamFormLayouts.setLayoutData(fStar, ITeamFormData.BUTTON);
formLayout.add(fStar, ITeamFormConfiguration.CONTENT_GUIDE);
if (isReadOnly()) {
fStar.setEnabled(false);
} else {
fStar.addSelectionListener(new SelectionListener() {
public void widgetDefaultSelected(SelectionEvent e) {
}
public void widgetSelected(SelectionEvent e) {
if (fWorkingCopy != null) {
// Change the value on the work item
fWorkingCopy.getWorkItem().setValue(getAttribute(), fStar.getSelection());
}
}
});
}
}
This createContent method uses the TeamFormLayout infrastructure to align the label and the button on the respective guides. The work item editor has two guides in a section. For small sections LABEL_GUIDE and CONTENT_GUIDE, for wide sections LABEL_GUIDE and WIDE_CONTENT_GUIDE. The example also shows how to correctly respect the labelVisible and readOnly properties. When the button is clicked, the value is written to the work item.

Get Value
// Get the value from the resolved work item
private boolean getNonNullValue() {
Boolean value= null;
if (fWorkingCopy != null && getAttribute() != null && fWorkingCopy.getWorkItem().hasAttribute(getAttribute())) {
WorkItemUIWorkingCopy uiCopy= (WorkItemUIWorkingCopy) fWorkingCopy.getAdapter(IWorkItemUIWorkingCopy.class);
ResolvedWorkItem workItem= uiCopy.getResolvedWorkItem();
value= (Boolean)workItem.getValue(getAttribute());
}
if (value == null) {
value= Boolean.FALSE;
}
return value.booleanValue();
}
This method is used to get the value in a safe way from the work item. It demonstrates the use of the resolved work item which allows to get a resolved value directly (this is not a problem for boolean, but for example for an IContributor where the work item would return an IContributorHandle instead).

Update UI
// The value has changed, update the UI
private void handleValueChanged() {
if (!fStar.isDisposed()) {
boolean value= getNonNullValue();
if (fStar.getSelection() != value) {
fStar.setSelection(value);
}
if (value) {
fStar.setImage(JazzResources.getImageWithDefault(fResourceManager, ImagePool.STAR_ICON_ENABLED));
} else {
fStar.setImage(JazzResources.getImageWithDefault(fResourceManager, ImagePool.STAR_ICON_DISABLED));
}
}
}
Update the UI when the value has changed. This is the case when the user clicks the button, or a different (or the initial) input is set to the editor.

Set Input
@Override
public void setInput(Object input) {
removeListeners();
if (input instanceof WorkItemEditorInput && ((WorkItemEditorInput) input).isResolved() && getAttribute() != null) {
WorkItemEditorInput workItemEditorInput= (WorkItemEditorInput) input;
fWorkingCopy= workItemEditorInput.getWorkingCopy();
addListeners();
if (fAttributeName != null && fStar != null && !fAttributeName.isDisposed()) {
fAttributeName.setText(NLS.bind(ATTRNAME_COLON, getAttribute().getDisplayName()));
}
if (fStar != null && !fStar.isDisposed()) {
handleValueChanged();
}
} else if (input instanceof WorkItemEditorInputFuture) {
fWorkingCopy= null;
}
}
When the editor gets the input, remove the old presentation updater (if necessary), add the new updater, set the attribute name and update the star button.

Add Presentation Updater
private void addListeners() {
PresentationHandlerManager mgr= (PresentationHandlerManager) getSite().getAdapter(PresentationHandlerManager.class);
if (mgr != null) {
mgr.addPresentationUpdater(fPresentationUpdater, getDescriptor());
}
}
The presentation updater is registered to the handler infrastructure. Removing the updater is very similar.

Presentation Binding

The presentation created above is bound to a Kind ID in the plugin.xml. I needs an attribute and can handle attributes of type boolean.
<extension point="com.ibm.team.workitem.ide.ui.editorPresentations">
<editorPresentation
id="com.example.star"
displayName="Star"
class="com.example.presentations.StarAttributePart"
needsAttribute="true" >
<attributeType id="boolean" />
</editorPresentation>
</extension>

Resources

Conclusion

With the implementations and bindings in place, we are now ready to define a new custom attribute and to configure the work item editors to use the new presentation for it: We define a boolean attribute named 'Has Star' and add it to the Details section using the 'Star' presentation:

star-configuration.png

The attribute is then editable using our new control:


Attachement

StarAttributePart.java : Star implementation for the eclipse ui work item editor

분류 :
RTC
조회 수 :
7976
등록일 :
2010.10.15
21:17:05 (*.148.64.111)
엮인글 :
http://jazzlab.net/jazz/13266/f6c/trackback
게시글 주소 :
http://jazzlab.net/jazz/13266

[레벨:15]풍차

2010.11.23
19:23:38
(*.109.178.9)

위 함수들간의 관계는 아래 처럼 해석해 봅니다.

fx-relationships.png

첨부 :
fx-relationships.png [File Size:14.7KB/Download8]

[레벨:15]풍차

2010.11.24
17:23:49
(*.109.178.9)

boolean 이외의 attributeType에 지정할 땐, process source를 보고, attribute type id를 설정해주면 된다고 합니다.

process-config-source.png

presentation-extensions.png

첨부 :
presentation-extensions.png [File Size:10.8KB/Download34]
process-config-source.png [File Size:10.9KB/Download8]
List of Articles
번호 제목 글쓴이 날짜 조회 수
359 RTC RTC OSLC-CM용 워크플로우 상태 및 조치 정보 [레벨:15]풍차 2011-10-27 4270
358 RTC RTC REST API에 필요한 HTTP Client 라이브러리 및 도움말 [레벨:15]풍차 2011-10-27 4405
357 RTC RTC REST API - 작업항목 ID 검색 및 수정 샘플 (using JSON) file [레벨:15]풍차 2011-10-27 5693
356 RTC RTC REST API - 작업항목 ID 검색 및 수정 샘플 (using XML) file [레벨:15]풍차 2011-10-26 5194
355 RTC RTC REST API용 헬퍼클래스 ChangeRequest 샘플 [142] [레벨:15]풍차 2011-10-26 5840
354 RTC RTC REST API - 작업항목 ID 검색 샘플 [139] [레벨:15]풍차 2011-10-26 6004
353 RTC RTC REST API - 프로젝트 영역 리스트 샘플 [레벨:15]풍차 2011-10-26 3920
352 RTC RTC REST API - 로그인 샘플 [레벨:15]풍차 2011-10-26 7886
351 RTC RTC Java API - 특정 프로젝트 영역에 멤버와 역할을 추가하는 샘플 [레벨:15]김동영b 2011-10-25 4332
350 RTC RTC Java API - 작업항목 ID 검색 및 열거형 값 수정 샘플 [레벨:15]김동영b 2011-10-25 4218
349 RTC RTC Java API - 작업항목 ID 검색 및 열거형 값 출력 샘플 [레벨:15]김동영b 2011-10-25 4070
348 RTC RTC Java API - 속성 목록 및 열거형 리터럴 목록 출력 샘플 [레벨:15]김동영b 2011-10-25 4615
347 RTC [RTC 작업항목] 스크립트 기반 값세트 샘플 - 외부 데이터소스 file [레벨:15]김동영b 2011-10-24 5507
346 RTC [RTC 작업항목] 외부 데이터소스 값세트 샘플 (중급예제) [레벨:15]김동영b 2011-10-24 3367
345 RTC RTC Java API - 작업항목 첨부문서를 디스크 저장하기 [1] [레벨:15]김동영b 2011-10-20 5431
344 RTC RTC Java API - 작업항목에 문서 첨부하기 [레벨:15]김동영b 2011-10-20 3606
343 RTC RTC Java API - 작업항목 삭제하기 [레벨:15]김동영b 2011-10-20 3717
342 RTC RTC Java API - 작업항목 생성하기 [레벨:15]김동영b 2011-10-20 3354
341 RTC RTC Java API - 작업항목 수정하기 [레벨:15]김동영b 2011-10-20 4400
340 RTC RTC Java API - 작업항목 중복 수정시의 유의점 [레벨:15]김동영b 2011-10-20 4064