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 人气:446
分享到:
blog comments powered by Disqus

相关文章

  • Eclipse plug-ins work area access to the folder path 2010-04-21

    String projectRoot = Platform.getInstanceLocation (). GetURL (). GetPath (); IFile file = (IFile) PlatformUI.getWorkbench () . GetActiveWorkbenchWindow (). GetActivePage () . GetActiveEditor (). GetEditorInput (). GetAdapter (IFile.class); IProject p

  • Display the file name contains the string: grep-lr string path 2011-05-29

    Display the file name contains the string: grep -l -r String path

  • Displays the file name containing the string: grep-lr string path 2011-05-29

    Displays the file name containing the string: grep -l -r String path

  • public void testStatementAddBatch () public void testConnCommit () 2011-09-01

    public void testStatementAddBatch() { Connection conn = null; Statement stmt = null; try { conn = getDBConnectionMsSqlBySuperAdmin(); stmt = conn.createStatement(); for(int i = 0; i < 100; i++) { String sql = " sql " + i; stmt.addBatch(sql);

  • PHP get current file path run before, name, server path 2011-01-07

    <? Php var $ a = "test string"; echo 'values obtained through the global variable'. $ GLOBALS ['a']; echo '<br/>'; echo '<br/>'; echo 'The current implementation of the document's file name'. $ _SERVER ['PHP_SELF']; echo '<br/&

  • android remote download desktop background pattern - URLConnection and setWallpaper () with 2010-04-28

    Main class code: package com.EX08; import java.net.URL; import java.net.URLConnection; import android.app.Activity; import android.app.AlertDialog; import android.content.DialogInterface; import android.graphics.Bitmap; import android.graphics.Bitmap

  • access control implementation interceptor struts2 2010-12-11

    Struts2 framework development in the use of an office when the OA system, you need to access control In addition to determining whether the landing but also to access implementation of each action of the access control, because if the user login is s

  • Failed to convert path to a short DOS path: c:\... 2012-12-10

    今天郁闷的出来了这个问题"Failed to convert path to a short DOS path: c:\windows\system32\java.exe 如果哪位兄弟看到这个问题 估计跟我一样也要烦恼了 经过google 百度找解决办法,反复尝试终于解决了 解决方法如下: 在android-sdk-windows\tools\lib这个目录下找到这个批处理find_java.bat 然后用编辑器把它打开 找到这个 for /f %%a in (""%~dps

  • HTML相对路径(Relative Path)和绝对路径(Absolute Path) 2013-02-27

    HTML相对路径(Relative Path) 同一个目录的文件引用 如果源文件和引用文件在同一个目录里,直接写引用文件名即可. 我们现在建一个源文件info.html,在info.html里要引用index.html文件作为超链接. 假设info.html路径是:c:\Inetpub\wwwroot\sites\blabla\info.html 假设index.html路径是:c:\Inetpub\wwwroot\sites\blabla\index.html 在info.html加入inde

  • 安卓问题总结( android.os.NetworkOnMainThreadException异常) 2015-01-30

    问题描述: android.os.NetworkOnMainThreadException异常(不要在主线程访问网络资源) 问题分析: 造成这种异常的原因是安卓版本问题(仔细研究错误原因是代码不符合Android规范),网上搜索发现:android3.0版本开始(具体是不是从这个版本开始的,就不深究咯)就强制程序不能在主线程中访问网络,要把访问网络放在独立的线程中. 解决方式: 1.想要忽略这些强制策略问题的话,可以在onCreate()方法里面加上 StrictMode.setThreadPo

iOS 开发

Android 开发

Python 开发

JAVA 开发

开发语言

PHP 开发

Ruby 开发

搜索

前端开发

数据库

开发工具

开放平台

Javascript 开发

.NET 开发

云计算

服务器

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

CodeWeblog.com 版权所有 闽ICP备15018612号

processed in 0.035 (s). 13 q(s)