Automotive/EclipseRCP

Eclipse RCP (Rich Client Platform) - 5.다른 plug-ins으로 부터 application model 확장하기

TimeSave 2022. 1. 21. 21:24

 

5. Extending the application model from other plug-ins

: 다른 plug-ins으로 부터 application model 확장하기

 

5.1. Contributions

 

모든 plugin-ins 는 '다음'을 통해 application model에 contribute 할 수 있습니다. :

- Static contribution : text file을 통한 기여입니다.; 이 확장(extension)은 fragment 혹은 model fragment로 불립니다.

- Dynamic contribution : Java class들을 통한 기여입니다; 이 확장(extension)은 processor 혹은 model processor로 불립니다.

 

이 model contribution 들은 org.eclipse.e4.workbench.model의 extension point로 등록되어야 합니다.model contribution들은 startup 동안 read 되고, application model runtime의 build에 사용됩니다.

 

이 runtime application model은 당신의 현재의 application을 반영합니다.

application의 runtime 동안, application 안의 변경은 model에 다시 write 됩니다. 그 예로, user가 part를 다른 stack에 drag&drop을 통해 위치시키는 것을 말할 수 있습니다.

 

만약 Eclipse application이 닫히면, 이 변경은 workbench.xmi 파일에 record 되고, 저장됩니다. 이 파일은 .metadata/.plugins/org.eclipse.e4.workbench폴더에 있습니다. 만약 어떤 model element가 shutdown 동안 유지 되어선 안된다면, 당신은 model element의 persistedState에 constant "persistState"를 추가하면 됩니다. "persistState"는 IWorkbench.PERSIST_STATE를 통해 정의되어 있습니다.

 

당신은 application을 model element 변경을 이용한 당신의 code를 통해 변경 할 수있습니다. Eclipse platform은 수많은 model의 parts에 등록된listener를 가지고 있고, 당신이 model을 변경한다면 application을 update합니다.

 

아이디어: application model의 persisted state는 application의 시작시에 삭제될 수 있습니다. 이것은 launch parameter의 clearPersistedState parameter를 통해서 가능합니다. applicaton을 export하는 것과 개발에만 사용하는 대부분의 경우에서, 이것은 바람직하지 않은 행동입니다.

 

정보 : Eclipse 3.x와 비교

Eclipse 3.x의 programming model은 우선적으로 extension points를 application의 contribution을 define하는데 사용합니다. 이 extension들은 새로운 parts, menu, 기타등등을 정의합니다. 최신의 Eclipse RCP application에서 당신은 fragment와 processor를 사용합니다.

 

 

5.2. Model fragments

model fragment는 보통 .e4xmi의 확장자를 가진 file입니다.

이것은 추가적인 model elements와 model element가 확장하는 것을 특정합니다. 예를 들어, fragment는 몇개의 새로운 menu entry를 application의 main menu에 포함하는~ 새로운 menu를 contribute할 수 있습니다.

fragment 안의 the Featurename은 당신이 확장을 원하는 model element에 대한 link입니다. 다음의 표에는 Featurename 값과 용도가 나열되어 있습니다.

 

Table 3. Contribution, Featurename and Element id

You want to contribute to a
Featurename
Element Id
Command to the application
commands
ID of your application
Handler to the application
handlers
ID of your application
New MenuItem / HandledMenuItem to existing menu
children
ID of the menu
New menu to the main menu of the window
children
ID of your main menu
New Part to existing PartStack
children
ID of your PartStack
 
5.2.1. Defining the model element which gets extended

: extend 되는 model element의 정의

 

specify the ID of the element to which you are contributing

use an XPath expression to describe the model element which should get extended

The following table gives several examples how you can use XPath expressions to define the model element you want to extend.

 

만약, 당신이 application model의 element에 기여하고 싶다면, 당신은 다음의 것을 할 수 있습니다:

- 기여하고 싶은 element의 ID를 특정하기

- XPath 표현을 사용하기; extend 되어지는 model element를 표현하는데.

 

아래의 표에는 extend하고 싶은 model element를 정의하는 데, 어떻게 XPath를 사용하면 되는지, 예시가 나와있습니다.

 

Table 4. Sample XPaths for the Application Model

XPath
Element in Application Model
xpath:/
The slash (/) always addresses the root element of an XML file, which always is the MApplication element.
xpath://mainMenu
Contribute to the main menu.
xpath://mainMenu/children
Contribute to all children of the main menu, e.g. to every menu in it.
xpath://mainMenu/*[1]
Contribute to the first child of the main menu. In most applications this would be the menu:File menu.
xpath://mainMenu/[@[local-name()='type' and .='menu:Menu']]
Contribute to the first Menu of the main menu. This xpath is more detailed than the one above since it also requires that the main menu child is of type menu:Menu. In most application this would be the menu:File menu.
xpath://trimBars[@side="Bottom"]
Contribute to the bottom trimbar.
xpath://trimBars[not(@side)]
Contribute to the top trimbar. When the MTrimBar is on top the side attribute is omitted, therefore not(@side) is used.
xpath://children[@*[local-name()='type' and .='basic:Part']]
Contribute to a MPart.
xpath://children[@*[local-name()='type' and .='basic:Part']][./tags = 'Editor']
Contribute to a MPart which is tagged with the Editor tag.

 

Xpath를 evaluate 하는데 좋은 도구는, Eclipse XPath evaluation plug-in입니다.

 

5.2.2. Position of new model elements

fragments는 새 model element의 요구되는 position을 정의할 수 있습니다.

이것은 List attribute의 Postion을 통해서 가능합니다. 다음 표의 값들이 허용됩니다.

 

 

Table 5. Position in list

Value
Description
first
Positions the element on the beginning of the list.
index:theIndex
Places the new model elements at position theIndex. Example: index:0
before:theOtherElementsId
Places the new model elements before the model element with the ID theOtherElementsId.
after:theotherelementsid
Places the new model elements after the model element with the ID theotherelementsid.

 

독립 plug-ins의 Fragment는 MANIFEST.MF 파일의 dependencies 순서대로 실행됩니다. 그러므로, 맨 앞 혹은 index는 아마 항상 원하는 결과가 나오지 않을 수 있습니다.

 

5.3. Model processors

이것은 program code를 통한 기여를 허용하는 processor입니다. 이것은application의 start 동안 model elements의 동적인(dynamic) 생성을 허용합니다.

 

5.4. Examples of model fragment and model processors

: model fragment와 model processor에 대한 예시

 

model fragment와 model processor의 나중에 다음 주소에서 설명합니다.( https://learn.vogella.com/courses/rich-client-platform)

나중이라 하면, 당신이 menu, command, handler, Eclipse service에 대해 배운 이후를 말합니다.