prev 2014. 10 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 31
 
 

포인트 랭킹 Top 9

  • 1위. 김동영b
    23511점
  • 2위. 아름프로
    6846점
  • 3위. netfer
    1289점
  • 4위. 심플
    829점
  • 5위. 정의의소
    813점
  • 6위. 바이스
    627점
  • 7위. 달마다
    590점
  • 8위. 코디
    577점
  • 9위. 데로드
    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
조회 수 :
10539
등록일 :
2010.10.15
21:17:05 (*.148.64.111)
엮인글 :
http://jazzlab.net/jazz/clm_articles/13266/bf3/trackback
게시글 주소 :
http://jazzlab.net/jazz/13266

풍차

2010.11.23
19:23:38
(*.109.178.9)

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

fx-relationships.png

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

풍차

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/Download42]
process-config-source.png [File Size:10.9KB/Download8]
List of Articles
번호 제목 글쓴이 날짜 조회 수
372 CLM [CLM 설치] 커맨드를 이용한 CLM 설치 김동영b 2011-11-09 5893
371 CLM 커맨드를 이용한 CLM 설치 도움말 풍차 2011-11-08 6565
370 RTC JTS 백업 및 복원 도움말 김동영b 2011-11-08 16505
369 CLM 째즈 저장소 권한 종류 및 세부 권한 도움말 김동영b 2011-11-04 5263
368 RTC 어드민 - Considerations for Rational Team Concert 3.x backups 풍차 2011-11-04 5597
367 RTC 어드민 - Jazz Administration Guide (3.x) 풍차 2011-11-04 6841
366 RTC RTC Java API - 특정 상태를 이용한 쿼리 샘플 김동영b 2011-11-02 8526
365 RTC RTC Java API - 상태그룹 쿼리를 이용한 샘플 [1] 김동영b 2011-11-02 7594
364 RTC [RTC SCM] SCM content access logging 김동영b 2011-11-02 7052
363 CLM [CLM 설치] Manual DB2 테이블스페이스 생성 김동영b 2011-11-01 22936
362 CLM CLM Distributed Setup 시나리오 풍차 2011-10-31 8988
361 CLM CLM 3.0.1.1 설치 및 구성 테스트 (WAS/LDAP/SSO) [2] file 김동영b 2011-10-28 19852
360 RTC RTC REST API - 작업항목 상태변경 샘플 풍차 2011-10-27 7039
359 RTC RTC OSLC-CM용 워크플로우 상태 및 조치 정보 풍차 2011-10-27 5496
358 RTC RTC REST API에 필요한 HTTP Client 라이브러리 및 도움말 풍차 2011-10-27 5812
357 RTC RTC REST API - 작업항목 ID 검색 및 수정 샘플 (using JSON) file 풍차 2011-10-27 7725
356 RTC RTC REST API - 작업항목 ID 검색 및 수정 샘플 (using XML) file 풍차 2011-10-26 7017
355 RTC RTC REST API용 헬퍼클래스 ChangeRequest 샘플 [142] 풍차 2011-10-26 7530
354 RTC RTC REST API - 작업항목 ID 검색 샘플 [140] 풍차 2011-10-26 7649
353 RTC RTC REST API - 프로젝트 영역 리스트 샘플 풍차 2011-10-26 5542