如何关闭一个view

Thiago

If you are as new to RCP as a newborn butt I advise you to take it slowly but with firm step.


RCP is very powerful, you can achieve very good apps but it is very complicated.

So, if you are really decided to learn RCP you should do a small investment and by some books.

I firmly recommend:

1. Designing Coding and Packaging Java Applications by Jeff McAffer - Jean Michel Lemieux.

This book teaches you a lot of stuff and gets you going on.

2. If you are new to SWT and JFace, this book is as a bible:

The Definitive Guide to SWT and JFace by Rob Warner - Robert Harris.

Now, comming back to your question, there are several situations and ways for closing a view:

1. Just use the 'X' in the vies tab.
2. Closing it from inside the view:

  getViewSite().getPage().hideView(MyView.this);

where MyView is your views class name.

3. From outside the view.

3.1 If your view does not allow multiple instances:

IWorkbenchPage wbp = PlatformUI.getWorkbench()
getActiveWorkbenchWindow().getActivePage();
   
wbp.hideView(wbp.findView("myViewId"));

where myViewId is the id you assigned to the view.

3.2 If your view allows multiple instances:

IWorkbenchPage wbp = PlatformUI.getWorkbench()
getActiveWorkbenchWindow().getActivePage();

wbp.hideView(wbp.findViewReference("myViewId", "mySecondaryViewId"));

where myViewId is the id you assigned to the view and mySecondaryViewId is the secondary id assigned to the view when opened.

I hope this helps you.

AG

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值