如何关闭一个view

来源:互联网 发布:手机号收集软件 编辑:程序博客网 时间:2024/06/05 17:27

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

原创粉丝点击