In the Eclipse rcp program starts, open the way to custom EditorPart

In the Eclipse rcp startup, for the system default start Perspective, by increasing the variety of viewpart, at boot time, open the custom view. However, in createInitialLayout (ILayout layout) method, using a custom layout can not be transferred editorpart, replace the system default "org.eclipse.ui.editorss" editor, so how to open a custom editorpart has become a problem.

Open the custom in the analysis method editorpart call: PlatformUI.getWrokbench (). GetActiveWorkbenchWindow (). GetActivePage (). OpenEditor (, EditorInput, EditorID, true), the key issue is to obtain IWorkBenchPage object. In order to obtain active of the page, through the Eclipse UI structure analysis, we can see when workbenchWindow opens, you may or may activepage, therefore, can be overloaded ApplicationWorkbenchWindowAdivor the postWidowOpen method, in which the open editorpart, you can, my code is as follows:

public void postWindowOpen () (
/ / TODO Auto-generated method stub
super.postWindowOpen ();

IWorkbench bench = PlatformUI.getWorkbench ();
String defaultPerspectiveID = bench.getPerspectiveRegistry ()
. getDefaultPerspective ();

if (defaultPerspectiveID.equals (MyPerspective.PERSPECTIVE_ID)) (
File file = new File ("");
String path = file.getAbsolutePath ();

if (path! = null) (
IEditorInput input = new DiagramEditorInput (new Path (path));
IWorkbenchPage page = PlatformUI.getWorkbench ()
. getActiveWorkbenchWindow (). getActivePage ();
try (
page.openEditor (input, DiagramEditor.ID, true);
) Catch (PartInitException e) (
/ / TODO Auto-generated catch block
e.printStackTrace ();
)
)
)

)

分类:Java 时间:2010-03-29 人气:393
分享到:
blog comments powered by Disqus

相关文章

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

Copyright (C) codeweblog.com, All Rights Reserved.

CodeWeblog.com 版权所有 黔ICP备15002463号-1

processed in 0.385 (s). 12 q(s)