Eclipse RCP应用程序-用于多个监视器的多窗口设计 [英] Eclipse RCP application - multi-window design for multiple monitors

查看:141
本文介绍了Eclipse RCP应用程序-用于多个监视器的多窗口设计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有关Eclipse RCP和整个透视图/视图/编辑器设计的问题-创建在多个监视器上显示多个窗口的应用程序的最佳方法是什么?我见过的教程和书总是将RCP/SWT设计整合到单个应用程序窗口内的透视图中.

Question about Eclipse RCP and whole perspective/view/editor design - what is the best way to create application which will display multiple windows on multiple monitors? Tutorials and book I've seen always pack RCP/SWT design into views inside perspective within single application window.

一个窗口应该统治所有其他窗口,还是所有窗口都相等(关闭最后一个退出应用程序)?如何处理观点和观点?还有其他我们应该知道的事情吗?

Should one window rule all others or they all should be equal (closing last one exits application)? How deal with the perspectives and views? Are there any other things we should know?

环境:Eclipse Ganymede,Windows XP.

Environment: Eclipse Ganymede, Windows XP.

推荐答案

单个Eclipse工作台可以创建多个窗口.每个窗口都使用透视图进行布局,因此可以将不同的窗口设置为不同的透视图或相同的透视图,并且可以独立于其他窗口在每个窗口中切换透视图.

A single Eclipse workbench can create multiple windows. Each window is laid out using a perspective, so different windows could be set to different perspectives, or the same perspective, and you can switch perspectives in each window independently of the other windows.

您还可以为每个窗口设置输入.如果每个窗口正在处理不同的数据(例如,每个窗口可以连接到不同的服务器,或者可能显示来自具有相同模式但不同数据的不同数据库的数据),则此功能很有用.

You can also set input for each window. This is useful if each window is working on different data (for example, each window could be connected to a different server or could be showing data from different databases that all have the same schema but different data).

可能是您仅使用Windows,因此您可以在不同的显示器上看到同一数据的不同视角.在这种情况下,您无需以编程方式创建窗口,而只需添加工作台提供的操作.这可以通过修改ActionBarAdvisor类来完成:

It may be that you are using windows only so that you can see different perspectives of the same data on different monitors. In that case you do not need to programatically create the windows but need only add the action supplied by the workbench. This can be done by modifying your ActionBarAdvisor class:

添加到字段声明中:

private IWorkbenchAction newWindowAction;

添加到执行操作的代码中(通常是一个名为makeActions的方法):

add to the code where you make the actions (typically a method called makeActions):

    newWindowAction = ActionFactory.OPEN_NEW_WINDOW.create(window);
    register(newWindowAction);

添加到创建菜单的代码中:

add to the code where you create the menus:

    menu.add(newWindowAction);

其中菜单通常是窗口"菜单.如果您的应用程序中还没有Window菜单,并且想创建一个Window菜单,那么以下行将起作用:

where menu is typically the Window menu. If you don't have a Window menu already in your application and would like to create one, the following line will work:

    MenuManager menu = new MenuManager(
      "&Window", 
      IWorkbenchActionConstants.M_WINDOW);

这将为您提供一个菜单项,该菜单项将以与Eclipse IDE中的Window-> New Window菜单项相同的方式创建一个新窗口.

This will give you a menu item that will create a new window in the same way as the Window->New Window menu item in the Eclipse IDE.

另一方面,如果您希望每个窗口显示不同的数据,则需要以编程方式打开新窗口.这使您可以为每个窗口设置不同的输入.您将需要以下代码行:

If, on the other hand, you want each window to show different data then you will need to open the new windows programatically. This allows you to set different input for each window. You will need a line of code something like:

IWorkbenchPage newPage = window.openPage(inputObject);

其中,inputObject包含标识窗口中显示的数据的信息.如果要设置初始透视图,可以通过在页面上调用setPerspective来完成.

where inputObject contains information that identifies the data shown in the window. If you want to set the initial perspective this can be done by calling setPerspective on the page.

您将要在每个窗口中设置标题:

You will want to set the title in each window:

newPage.getWorkbenchWindow().getShell().setText(windowTitle);

其中windowTitle是描述窗口输入的字符串.

where windowTitle is a string describing the input to the window.

您可以按以下方式获取窗口的输入:

You can fetch the input for a window as follows:

window.getActivePage().getInput()

然后可以将其强制转换为您用作窗口输入的任何类.

You can then cast this to whatever class you are using as your window input.

这篇关于Eclipse RCP应用程序-用于多个监视器的多窗口设计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆