转载于:https://my.oschina.net/zhenghuazhi/blog/816092
rcp 分离(detach)视图
最新推荐文章于 2018-12-30 11:51:59 发布
public
class
SampleView
extends
ViewPart {
public
static
final
String ID =
"test.detach.views.SampleView"
;
private
Button b;
public
void
createPartControl(Composite parent) {
parent.setLayout(
new
GridLayout());
b =
new
Button(parent, SWT.PUSH);
b.setText(
"Detach me"
);
b.addSelectionListener(
new
SelectionAdapter() {
@Override
public
void
widgetSelected(SelectionEvent e) {
EModelService s = (EModelService) getSite().getService(EModelService.
class
);
MPartSashContainerElement p = (MPart) getSite().getService(MPart.
class
);
if
(p.getCurSharedRef() !=
null
)
p = p.getCurSharedRef();
s.detach(p,
100
,
100
,
300
,
300
);
}
});
}
public
void
setFocus() {
b.setFocus();
}
}
((WorkbenchPage)getSite().getPage()).
getActivePerspective().getPresentation().detachPart(ref);
转载于:https://my.oschina.net/zhenghuazhi/blog/816092