RCP中对视图的状态控制(最大化,最小化,还原)

最近一个项目中,有两种数据来源:A和B,如果是A的话 所有视图都需要,如果是B的话 有一两个视图没有用处,但又占着好多的版面,于是去看workbenchpage的源码 发现了这么几个方法。

1.视图的最小化最大化和还原操作
WorkbenchPage:
/**
* Sets the state of the given part.
*
* @param ref part whose state should be modified (not null)
* @param newState one of the IStackPresentationSite.STATE_* constants
*/
public void setState(IWorkbenchPartReference ref, int newState) ;

这个可以方便的让我们的视图改变当前的状态 (最大化,最小化,还原等),相应的状态为:
WorkbenchPage.STATE_RESTORED : 还原

WorkbenchPage.STATE_MINIMIZED : 最小化


WorkbenchPage.STATE_MAXIMIZED : 最大化


2.视图的隐藏和显示
IWorkbenchPage 接口中提供了 视图的隐藏和显示方法

/**
* Shows the view identified by the given view id in this page and gives it
* focus. If there is a view identified by the given view id (and with no
* secondary id) already open in this page, it is given focus.
*
* @param viewId
* the id of the view extension to use
* @return the shown view
* @exception PartInitException
* if the view could not be initialized
*/
public IViewPart showView(String viewId) throws PartInitException;

/**
* Shows a view in this page with the given id and secondary id. The
* behaviour of this method varies based on the supplied mode. If
* <code>VIEW_ACTIVATE</code> is supplied, the view is given focus. If
* <code>VIEW_VISIBLE</code> is supplied, then it is made visible but not
* given focus. Finally, if <code>VIEW_CREATE</code> is supplied the view is
* created and will only be made visible if it is not created in a folder
* that already contains visible views.
*
* This allows multiple instances of a particular view to be created. They
* are disambiguated using the secondary id. If a secondary id is given, the
* view must allow multiple instances by having specified
* allowMultiple="true" in its extension.
*

*
* @param viewId
* the id of the view extension to use
* @param secondaryId
* the secondary id to use, or <code>null</code> for no secondary
* id
* @param mode
* the activation mode. Must be {@link #VIEW_ACTIVATE},
* {@link #VIEW_VISIBLE} or {@link #VIEW_CREATE}
* @return a view
* @exception PartInitException
* if the view could not be initialized
* @exception IllegalArgumentException
* if the supplied mode is not valid
* @since 3.0
*/
public IViewPart showView(String viewId, String secondaryId, int mode)
throws PartInitException;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值