我正在创建一个 RCP 应用程序。我需要用不同的数据打开同一个视图的多个实例。我通过为同一视图的不同实例设置辅助 id 来做到这一点。具体来说,我的问题如下: 请看一下
我有一个名为Views.GraphView
. openGraphView
我从一个名为显示不同图形的命令中打开了它的不同实例。命令如下:
page.showView("Views.GraphView", Integer.toString(instanceNum++), IWorkbenchPage.VIEW_ACTIVATE);
现在,我TreeLayout
在这个Views.GraphView
工具栏上调用了一个命令,它假设改变图形的布局,它将对视图的每个实例进行操作。但为此,我认为,我需要确定哪个视图实例处于活动状态。该TreeLayout
命令如下所示:
IViewPart findView = HandlerUtil.getActiveWorkbenchWindow(event).getActivePage(). findView( "Views.GraphView"); //I think in the findView I need to give the id of the view [but how can I put the secondary id?]
GraphView view = (GraphView) findView;
view.changeLayout(); //I wrote this method in the graph view to change the layout
//I just tried to print the secondary id, but it did not print anyting
System.out.println("From treelayout command:- " + view.getViewSite().getSecondaryId());
那么如何识别当前处于活动状态的视图实例并对其进行操作呢?