如何向我的 eclipse rcp 应用程序添加快速 View ?
最佳答案
可以添加右键,如this thread :
that can be done by adding a button to fast view bar and by opening a standard view in button event
按钮按钮 = new Button ((Composite)((WorkbenchWindow) window).getFastViewBar ().getControl (), SWT.PUSH);
to avoid overlapping in button event first create folder layout for this view with reference to initial view and then call the action to add view.
IFolderLayout ViewLayout1 = layout.createFolder ( "ViewLayout1",
IPageLayout.BOTTOM,
0.50f, initalView.ID);
OpenViewAction ov = new OpenViewAction (window, "label", secondview.ID);
ov.run ();
以编程方式显示和最小化快速 View 应该通过带有参数“org.eclipse.ui.views.showView”的命令“
”。org.eclipse.ui.views.showView
”来完成。 makeFast
参见 Eclipse RCP: open a view via standard command org.eclipse.ui.handlers.ShowViewHandler
:
Eclipse provides the standard command
org.eclipse.ui.views.showView
to open an arbitrary view.
The default handler isorg.eclipse.ui.handlers.ShowViewHandler
. This handler is a nice example how you could add your own command with arguments. It takes two parameters:
- The first has the
ID
org.eclipse.ui.views.showView.viewId
and identifies the view ID which should be opened,- the next one has the
ID
org.eclipse.ui.views.showView.makeFast
and determines if the view should be open as a fast view.Without parameters the command will let the user choose which view to open.
参见 Parameter for commands 一些例子
Lets see the real world example: "Show View" command. The command is generic and can show any view. The view id is given to the command as a parameter:
<command
name="%command.showView.name"
description="%command.showView.description"
categoryId="org.eclipse.ui.category.views"
id="org.eclipse.ui.views.showView"
defaultHandler="org.eclipse.ui.handlers.ShowViewHandler">
<commandParameter
id="org.eclipse.ui.views.showView.viewId"
name="%command.showView.viewIdParameter"
values="org.eclipse.ui.internal.registry.ViewParameterValues" />
<commandParameter
id="org.eclipse.ui.views.showView.makeFast"
name="%command.showView.makeFastParameter"
optional="true"/>
</command>
The list of all possible values of the parameter is given by the class
ViewParameterValues
. The class would iterate through the view registry and return it.
注意:理论上只是为了完整(this thread)
RCP apps can disable fast views by calling
WorkbenchWindowConfigurer.setShowFastViewBar(false)
from theirWorkbenchAdvisor
'spreWindowOpen()
method.
This not only hides the fast view bar, but also hides the Fast View menu item on views.
关于eclipse - eclipse rcp 应用程序中的快速 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2743256/