我在我的RCP应用程序中包含了一个来自ActionFactory的HELP_CONTENTS操作,但是当我在应用程序中调用它而不是普通的xml文件时,我想打开一个PDF文件。那可能吗?我没有在网上找到任何例子。
答案 0 :(得分:0)
如果您使用HelpContentsAction
,那么您将获得Eclipse帮助。如果要显示自己的文件,请创建自己的操作(如果需要,可以重复使用图标和文本)。
使用IWorkbenchPage
。openEditor(IEditorInput input, String editorId)
方法打开PDF文件:
org.eclipse.core.resources.IFile workspaceFile;
java.io.File externalFile;
//PDF in workspace
IEditorInput input = new FileEditorInput(workspaceFile);
//or external
IFileSystem fs = org.eclipse.core.filesystem.EFS.getLocalFileSystem();
IFileStore fileStore = fs.fromLocalFile(externalFile);
input = new FileStoreEditorInput(fileStore);
IWorkbenchPage page =
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
page.openEditor(input, IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID);