eclipse
eclipse workbench
gonGon
2010. 8. 17. 10:57
으례 보는 eclipse 화면에는 상단에 menu, toolbar가 있고 중앙에 editor와 view들이 있다.
이렇게 menu들과 editor, view들로 구성된 단위를 workbench라고 한다. view는 editor에 종속적이며, 한 단위로 움직인다. editor+view를 page라고 한다. 즉,
workbench = menubar + toolbar + page(=editor + view)
와 같이 구성된다.
workbench(와 editor, view)에는 part와 site가 있다.
part는 visual component, 즉 swt 객체와 관련된 부분이다. IWorkbenchpart interface로 정의되며, IViewpart와 IEditorPart가 이를 상속한다. workbench part가 생성되는 과정은 다음과 같다.
Lifecycle of workbench
* part extention is created
a. instantiate the part
b. create the part site
c. part.init(site)
* when visible in the workbench
a. part.createControl(parent)
b. fire partOpend event to all listeners
* when part is activated or gets focus
a. part.setFocus()
b. fire partActivated event to all listeners
* when part is closed
a. doSave or return cancel
b. deactive part
c. fire partClosed event to all listeners
d. controls are disposed on SWT widget tree
e. part.disclose()
workbench에서 part 객체를 생성하고, site를 만들어 part를 초기화한다.
part객체가 visible하게 되면 createPartControl(Compsite parent)를 호출한다.
createPartControl은 parent밑에 control을 만든 후 layout을 조정한다.
site 객체에 각종 global action, context menu과 selection provider를 등록한다.
workbench 객체로부터 site를 얻으면, 이를 통해 workbench에 등록되어 있는 page(editor, view), selection provider 등을 얻을 수 있다.
editor와 view에도 site가 있다. editorsite에서 contextmenu와 actionbar를, viewsite로부터 actionbar를 얻을 수 있다.
결국, site는 객체와 객체 외부의 인터페이스 역할을 한다.