---------------------------------------------------------------------------------------------------
学习: http://www.blogjava.net/youxia/archive/2006/11/28/84013.html
---------------------------------------------------------------------------------------------------
1. 新建 OleView:
package hellorcp.ole;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.ole.win32.OleFrame;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;
public class OleView extends ViewPart {
public OleFrame frame;
public static final String ID = "hellorcp.view.OleView"; //$NON-NLS-1$
/**
* Create contents of the view part
*
* @param parent
*/
@Override
public void createPartControl(Composite parent) {
// 创建OleFrame对象
frame = new OleFrame(parent, SWT.NONE);
//
createActions();
initializeToolBar();
initializeMenu();
}
/**
* Create the actions
*/
private void createActions() {
// Create the actions
}
/**
* Initialize the toolbar
*/
private void initializeToolBar() {
IToolBarManager toolbarManager = getViewSite().getActionBars()
.getToolBarManager();
}
/**
* Initialize the menu
*/
private void initializeMenu() {
IMenuManager menuManager = getViewSite().getActionBars()
.getMenuManager();
}
@Override
public void setFocus() {
// Set the focus
}
}
2. 新建 OpenFileAction:
package hellorcp.ole;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.ole.win32.OLE;
import org.eclipse.swt.ole.win32.OleAutomation;
import org.eclipse.swt.ole.win32.OleClientSite;
import org.eclipse.swt.ole.win32.Variant;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IViewReference;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
public class OpenFileAction implements IWorkbenchWindowActionDelegate {
IWorkbenchWindow window;
public void dispose() {
// TODO 自动生成方法存根
}
public void init(IWorkbenchWindow window) {
this.window = window;
}
public void run(IAction action) {
IViewReference[] vfs = window.getActivePage().getViewReferences();
IViewPart vw;
for (int i = 0; i < vfs.length; i++) {
vw = vfs[i].getView(false);
if (vw.getTitle().equals("使用Active X控件")) {
OleClientSite client = new OleClientSite(((OleView) vw).frame,
SWT.NONE, "Shell.Explorer.2");
client.doVerb(OLE.OLEIVERB_SHOW);
OleAutomation oa = new OleAutomation(client);
Variant str = new Variant("http://www.iteye.com/");
oa.invoke(104, new Variant[] { str });
}
}
}
public void selectionChanged(IAction action, ISelection selection) {
// TODO 自动生成方法存根
}
}
3. 修改 Perspective.java, 修改后:
package hellorcp;
import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;
public class Perspective implements IPerspectiveFactory {
public void createInitialLayout(IPageLayout layout) {
// FirstView
String editorArea = layout.getEditorArea();
// layout.addView("hellorcp.view.FirstView", IPageLayout.RIGHT, 0.2f,
// editorArea);
// SecondView
// layout.setEditorAreaVisible(false);
// layout.addView("hellorcp.view.SecondView", IPageLayout.RIGHT, 0.5f,
// editorArea);
// OleView
layout.addView("hellorcp.ole.OleView", IPageLayout.RIGHT, 0.5f,
editorArea);
}
}
4. 配置 plugin.xml:
1) action 配置片段:
<action
class ="hellorcp.ole.OpenFileAction"
icon ="icons/alt_window_16.gif"
id ="hellorcp.ole.OpenFileAction"
label ="Ole菜单项"
menubarPath ="hellorcp.firstmenu/additions"
style ="push"
toolbarPath ="additions"
tooltip ="Ole菜单项" />
2) view 配置片段:
<view
class="hellorcp.ole.OleView"
id="hellorcp.ole.OleView"
name="使用Active X控件" />
5. 保存,运行(点击工具类第1个图标),效果如下:
- 大小: 68.6 KB
分享到:
相关推荐
eclipse rcp 插件开发学习笔记.pdf 15-24章
eclipse rcp 插件开发学习笔记.pdf 1-14章
ECLIPSE RCP应用系统开发方法与实战.pdf ECLIPSE RCP应用系统开发方法与实战.pdf
Eclipse RCP 允许开发者使用 eclipse结构风格设计弹性的可扩展的应用程序,可重用Eclipse中 已存在的方法和编码模式。俗话说,万事开头难。Eclipse RCP 入手可能会比较困难、费时。接下 来我们将主要讲述如何让RCP ...
最近抽些时间,更新到eclipse3.6上来,既作为为广大Eclipser入门plugin/RCP开发的一个方便之门,也是对自己近年来学习的一个总结吧。 每一章都会单独提取出来,并尽可能的独立于其他章节,更新中的源代码工程也会...
Eclipse RCP允许开发者使用eclipse结构风格设计弹性的可扩展的应用程序,可重用Eclipse中已存在的方法和编码模式。俗话说,万事开头难。Eclipse RCP入手可能会比较困难、费时。接下来我们将主要讲述如何让RCP工作. ...
Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT Eclipse RCP开发教程,RCP入门教程,教你如何使用SWT
Eclipse RCP 开发资料打包下载 目录如下: RCP程序设计.pdf(推荐) Addison.Wesley.Eclipse.Rich.Client.Platform.Designing.Coding.and.Packaging.Java.Applications.Oct.2005.chm Eclipse+RCP入门.pdf example_...
一个 Eclipse RCP 的入门教程
eclipse RCP Plug-in开发自学教程 , 只要java基础好,自学没问题的。。。
网络中最全面最合适学习或开发的相关资料全面都有; 包含eclipse rcp开发入门教程; eclipse rcp基础教程;eclipse rcp开发自学教程; eclipse rcp开发培训教程及ppt等相关资料;教程中包含一步步操作实例,包含对...
rcp org.eclipse.ui.newWizards扩展点例子,模仿新建java项目
通过例子学习EclipseRCP开发通过例子学习EclipseRCP开发
Eclipse RCP入门,初级的RCP开发介绍。
[基于Eclipse.RCP的复合应用开发].扈晓炜等.pdf .
EclipseRCP系统开发与实战(书).rar,pdf格式,下了不后悔
eclipse rcp应用系统开发方法与实战源代码.zip
2.4.6 在Eclipse中使用其他计算机程序..... 55 2.4.7 性能..... 60 2.5 练习概述...... 61 2.6 本章小结...... 61 2.7 参考文献...... 62 第3章 使用Java开发工具 63 3.1 JDT入门...... 64 3.1.1 JDT用户界面概述.....
[Eclipse.RCP深入浅出].Jeff.McAffer等.扫描版.pdf 还有其他两本在我的资源分享页面.
[基于Eclipse.RCP的复合应用开发].扈晓炜等.扫描版