第13章 插件开发基础 《Eclipse从入门到精通》教学课件
Eclipse IDE开发环境使用教程说明书

iAbout the T utorialEclipse is an integrated development environment (IDE) for Java and other programming languages like C, C++, PHP, and Ruby etc. Development environment provided by Eclipse includes the Eclipse Java development tools (JDT) for Java, Eclipse CDT for C/C++, and Eclipse PDT for PHP, among others.This tutorial will teach you how to use Eclipse in your day-2-day life while developing any software project using Eclipse IDE. We will give special emphasis on Java project. AudienceThis tutorial has been prepared for beginners to help them understand basic functionality of Eclipse tool. After completing this tutorial, you will find yourself at a moderate level of expertise in using Eclipse IDE from where you can take yourself to next levels. PrerequisitesWe assume you are going to use Eclipse IDE to handle all levels of Java projects development. So it will be good if you have knowledge of software development using any programming language specially Java programming.Copyright & Disclaimer© Copyright 2015 by Tutorials Point (I) Pvt. Ltd.All the content and graphics published in this e-book are the property of Tutorials Point (I) Pvt. Ltd. The user of this e-book can retain a copy for future reference but commercial use of this data is not allowed. Distribution or republishing any content or a part of the content of this e-book in any manner is also not allowed without written consent of the publisher. We strive to update the contents of our website and tutorials as timely and as precisely as possible, however, the contents may contain inaccuracies or errors. Tutorials Point (I) Pvt. Ltd. provides no guarantee regarding the accuracy, timeliness or completeness of our website or its contents including this tutorial. If you discover any errors on our website or inthistutorial,******************************************iT able of ContentsAbout the Tutorial (i)Audience (i)Prerequisites (i)Copyright & Disclaimer (i)Table of Contents .................................................................................................................................... i i 1.OVERVIEW (1)What is Eclipse? (1)Licensing (1)Eclipse Releases (1)2.INSTALLATION (3)Downloading Eclipse (3)Installing Eclipse (3)Launching Eclipse (4)3.EXPLORE WINDOWS (5)Parts of an Eclipse Window (5)Using Multiple Windows (6)4.EXPLORE MENUS (7)Typical Eclipse Menus (7)Brief Description of Menus (8)Customizing Menus (8)5.EXPLORE VIEWS (9)About Views (9)Organizing Views (9)Moving Views (9)Creating View Folders (10)Opening a view (10)6.PERSPECTIVES (13)What is a Perspective? (13)Opening a Perspective (13)Switching between Perspectives (13)Closing a Perspective (14)Customizing a Perspective (14)7.WORKSPACES (16)About Eclipse Workspace (16)UI Elements for Managing the Workspace (16)8.CREATE JAVA PROJECT (18)Opening the New Java Project wizard (18)Using the New Java Project wizard (18)Viewing the Newly Created Project (20)9.CREATE JAVA PACKAGE (21)Opening the New Java Package wizard (21)Using the New Java Package Wizard (21)Viewing the Newly Created Package (22)10.CREATE JAVA CLASS (23)Opening the New Java Class Wizard (23)Using the New Java Class Wizard (23)Viewing the Newly Created Java class (24)11.CREATE JAVA INTERFACE (25)Opening the New Java Interface Wizard (25)Using the New Java Interface Wizard (25)Viewing the Newly Created Java Interface (26)12.CREATE XML FILE (27)Opening the New XML File wizard (27)Using the New XML File wizard (28)Viewing the Newly Created XML File (29)13.JAVA BUILD PATH (30)Setting the Java Build Path (30)14.RUN CONFIGURATION (31)Creating and Using a Run Configuration (31)15.RUNNING A PROGRAM (33)Running a Java Program (33)16.CREATE JAR FILES (35)Opening the Jar File wizard (35)Using the Jar File wizard (35)17.CLOSE PROJECT (37)Why Close a Project? (37)How to Close a Project? (37)Closed Project in Package Explorer (38)18.REOPEN PROJECT (39)Reopening a Closed Project (39)19.BUILD PROJECT (40)Building a Java Project (40)20.DEBUG CONFIGURATION (42)Creating and Using a Debug Configuration (42)21.DEBUGGING A PROGRAM (44)Debugging a Java Program (44)22.PREFERENCES (48)Setting Preferences (48)23.CONTENT ASSIST (50)Using Content Assist (50)24.QUICK FIX (52)Using Quix Fix (52)25.HOVER HELP (54)Using Hover Help (54)26.SEARCH MENU (56)Searching the Workspace (56)27.NAVIGATION (58)Navigating the Eclipse Workspace (58)Open Type (58)Open Type in Hierarchy (60)Open Resource (61)28.REFACTORING (63)Refactoring using Eclipse (63)29.ADD BOOKMARKS (64)About Bookmarks (64)Adding a Bookmark (64)Opening the Bookmarks View (64)Using the Bookmarks View (65)30.TASK MANAGEMENT (66)Managing Tasks (66)Opening the Tasks View (67)Using the Tasks View (67)31.INSTALL PLUGINS (69)Locating and Installing Plug-ins (69)32.CODE TEMPLATES (73)Using Code Templates (73)Modifying/Adding code templates (74)33.SHORTCUTS (75)About Shortcuts (75)34.RESTART OPTION (78)Restarting Eclipse (78)35.TIPS & TRICKS (79)36.WEB BROWSERS (81)Internal Web Browser (81)Eclipse 7What is Eclipse?In the context of computing, Eclipse is an integrated development environment (IDE) for developing applications using the Java programming language and other programming languages such as C/C++, Python, PERL, Ruby etc.The Eclipse platform which provides the foundation for the Eclipse IDE is composed of plug-ins and is designed to be extensible using additional plug-ins. Developed using Java, the Eclipse platform can be used to develop rich client applications, integrated development environments, and other tools. Eclipse can be used as an IDE for any programming language for which a plug-in is available.The Java Development Tools (JDT) project provides a plug-in that allows Eclipse to be used as a Java IDE, PyDev is a plugin that allows Eclipse to be used as a Python IDE, C/C++ Development Tools (CDT) is a plug-in that allows Eclipse to be used for developing application using C/C++, the Eclipse Scala plug-in allows Eclipse to be used an IDE to develop Scala applications and PHPeclipse is a plug-in to eclipse that provides complete development tool for PHP.LicensingEclipse platform and other plug-ins from the Eclipse foundation is released under the Eclipse Public License (EPL). EPL ensures that Eclipse is free to download and install. It also allows Eclipse to be modified and distributed.Eclipse ReleasesEvery year, since 2006, the Eclipse foundation releases the Eclipse Platform and a number of other plug-ins in June.1.Eclipse8Eclipse 9Downloading EclipseYou can download eclipse from /downloads/. The download page lists a number of flavors of eclipse.The capabilities of each packaging of eclipse are different. Java developers typically use Eclipse Classic or Eclipse IDE for developing Java applications.The drop down box in the right corner of the download page allows you to set the operating system on which eclipse is to be installed. You can choose between Windows, Linux and Mac. Eclipse is packaged as a zip file.Installing EclipseTo install on windows, you need a tool that can extract the contents of a zip file. For example you can use:∙7-zip ∙PeaZip ∙ IZArcUsing any one of these tools, extract the contents of the eclipse zip file to any folder of your choice.2.Launching EclipseOn the windows platform, if you extracted the contents of the zip file to c:\, then you can start eclipse by using c:\eclipse\eclipse.exeWhen eclipse starts up for the first time it prompts you for the location of the workspace folder. All your data will be stored in the workspace folder. You can accept the default or choose a new location.1011If you select "Use this as the default and do not ask again", this dialog box will not come up again. You can change this preference using the Workspaces Preference Page. See the Preference tutorialpage for more details.Eclipse 12Parts of an Eclipse WindowThe major visible parts of an eclipse window are:∙Views ∙Editors (all appear in one editor area) ∙Menu Bar ∙ ToolbarAn eclipse perspective is the name given to an initial collection and arrangement of views and an editor area. The default perspective is called java. An eclipse window can have multiple perspectives open in it but only one perspective can be active at any point of time. A user can switch between open perspectives or open a new perspective. A perspective controls what appears in some menus and tool bars.3.EclipseA perspective has only one editor area in which multiple editors can be open. The editor area is usually surrounded by multiple views. In general, editors are used to edit the project data and views are used to view the project metadata. For example, the package explorer shows the java files in the project and the java editor is used to edit a java file.The eclipse window can contain multiple editors and views but only one of them is active at any given point of time. The title bar of the active editor or view looks different from all the others.The UI elements on the menu bar and tool bar represent commands that can be triggered by an end user.Using Multiple WindowsMultiple Eclipse Windows can be open at the same time. To open a new window, click on the Windows menu and select the New Window menu item.Each window can have a different perspective open in them. For example you could open two Eclipse windows one in the Java perspective and the other in the Debug perspective. The window showing the Java perspective can be used for editing the java code and the window showing the debug perspective can be used for debugging the application being developed.13Eclipse 14T ypical Eclipse MenusThe typical menus available on the menu bar of an Eclipse window are:∙File menu ∙Edit menu ∙Navigate menu ∙Search menu ∙Project menu ∙Run menu ∙Window menu ∙ Help menu4.Plug-ins can add new menus and menu items. For example when the java editor is open, you will see the Source menu and when the XML editor is open, you will see the Design menu. Brief Description of Menus15Customizing MenusThe visible menu items on a menu depend on the installed plug-ins and customization done using the Customize Perspective dialog box.16Eclipse 17About ViewsEclipse views allow users to see a graphical representation of project metadata. For example the project navigator view presents a graphical representation of the folders and files associated with a project and properties view presents a graphical representation of an element selected in another view or editor.An eclipse perspective can show any number of views and editors. All editor instances appear in a single editor area, whereas views are placed inside view folders. A workbench window can display any number of view folders. Each view folder can display one or more views. Organizing ViewsThe following picture shows four views arranged in a view folder.The picture given below shows the same four views arranged in two view folders.5.Moving ViewsTo move a view from one view folder to another, just click on the view title and drag to the title bar area of another view folder. The green line shown below is a result of dragging the title bar of the Properties view from one view folder to the title bar area of another view folder. The Properties view can be moved to where the green line is by releasing the mouse button and sending out a drop event.Creating View FoldersView folders can be dynamically created by dragging the title bar of a view to anywhere outside the editor area and title bar of another view folder. As you drag the title bar around, green lines will indicate where exactly the new view folder will be created.Moving the drag icon to the bottom of a window allows you to create a view folder that spans the entire width of the window. Moving the drag icon to the left or right edge of window allows you to create a view folder that spans the entire height of the window.18Opening a viewTo open a view, click on the Window menu and select the Show View menu item.19Clicking on the Other menu item brings up the Show View dialog box that allows you to locate and activate a view.20The views are organized by category. To quickly locate a view, just type the name of a view into the filter text box. To open a view, select it and click on the OK button. The subsequent pages of this tutorial introduce you to a number of useful views.21End of ebook previewIf you liked what you saw…Buy it from our store @ https://22。
JAVA从入门到精通程序设计

float型,32位,IEEE 754规范
double型:64位,IEEE 754规范
–字符型变量是16位Unicode字符类型,可以直接表示包括中文在内的各国文字 变量名
–变量名需要满足的条件:
变量名必须以字符开头;
必须是一串连续的Unicode字符,不能有空格,也不能有减号(否则会与减法相混淆);
生
Java语言的特点
–结构中立的(Architecture Neutral)
Java编译器产生一种结构中立的目标文件格式,可以在多种处理器和操作系统中执行,
而不用考虑不同机器的差异
–可移植的(Portable)
Java的简单数据类型是不随操作系统变化的。Java程序库所定义的接口也是对所有的操
–Java虚拟机(JVM)
–Java应用程序界面(Java API) Java平台的组成结构
–Java虚拟机:解释并运行Java二进制码
–Java API:由许多软件包组成,这些软件包可以实现很多功能,包括图形界面功能
Java平台的组成结构
Java 历史与概述
–最底层是硬件层,表示Java系统运行的硬件和操作系统;
–“&”运算符对操作数op1和op2的每一位进行“与”操作 –例:10 & 13,计算过程如下:
Java二进制码能被迅速转换成机器码,Java二进制码的执行效率正在逐渐逼近其它编译
语言的执行效率
Java语言的特点
–多线程(Multi Threaded)
Java语言具有多线程的功能,这对于交互式程序以及实时响应程序是很有帮助的
–动态的(Dynamic)
Java比C或C++语言更具有动态性,更能适应时刻在变的环境,Java不会因程序库的更
第一讲 Eclipse简介

什么是EclipseEclipse是一个开放源代码的、与NetBeans、Sun ONE Studio和Borland Jbuilder类似的一种基于Java的整合型可扩展开发平台,也是目前最著名的开源项目之一,IBM在最近几年里也一直在大力支持该项目的发展,目标是将其做成用以替代IBM Visual Age for Java(简称IVJ)的下一代IDE开发环境,并于2001年11月宣布投入4千万美元资金到该项目的研发。
就其本身而言,它只是一个框架和一组服务,用于通过插件组件构建开发环境。
幸运的是,Eclips e 附带了一个标准的插件集,包括Java 开发工具(Java Development Tools,JDT)。
其未来的目标不仅仅是成为专门开发Java程序的IDE环境,根据Ecli pse的体系结构,通过开发插件,它能扩展到任何语言的开发,甚至能成为图片绘制的工具。
目前,Eclipse已经开始提供C语言开发的功能插件。
更难能可贵的是,Ec lipse是一个开放源代码的项目,任何人都可以下载Eclipse的源代码,并且在此基础上开发自己的功能插件。
也就是说未来只要有人需要,就会有建立在Eclip se之上的COBOL,Perl,Python等语言的开发插件出现。
同时可以通过开发新的插件扩展现有插件的功能,比如本系列文章为了进行手机应用程序的开发就是通过J2ME插件的扩展来加以实现的。
可以无限扩展,而且有着统一的外观,操作和系统资源管理,这也正是Eclipse的潜力所在。
Eclipse的主要组成Eclipse是一个开放源代码的软件开发项目,专注于为高度集成的工具开发提供一个全功能的、具有商业品质的工业平台。
它主要由Eclipse项目、Eclips e工具项目和Eclipse技术项目三个项目组成,具体包括四个部分组成--Eclipse Platform、JDT、CDT和PDE。
JDT支持Java开发、CDT支持C开发、PDE 用来支持插件开发,Eclipse Platform则是一个开放的可扩展IDE,提供了一个通用的开发平台。
Eclipse-plugin插件开发

使用PDE开发插件--步骤8
点击“完成”,完成插件项目的新建。 因为所创建的项目与“插件开发”透视 图相关联,因此将可自动转到“插件开 发”透视图。
使用PDE开发插件--步骤
插件项目生成之后,项目中将会包含一个按默 认方式生成的插HelloWorldPluginPlugin.java文 件。 因为该项目是一个插件项目,所以点击Eclipse 菜单栏中的“运行”按钮旁的下拉箭号,并选 择“运行为”->“运行时工作台”。运行后, 将生成一个和当前Eclipse几乎完全一致的平台, 惟一的差别是在新的Eclipse平台上增加了一个 “Hello,Eclipse world”插件(见下图中的工具 条上的第5个按钮)。
点击“下一步”,显示“插件代码生成 器”窗口 (如下图)。
在“插件代码生成器”窗口中,可以选择 “创建空白插件项目”生成一个空插件,也 可选择“使用代码生成向导创建插件项目”。 为了说明插件结构,本例使用代码生成向导 创建插件项目,并选择“Hello, World”代码 生成向导。
使用PDE开发插件--步骤6
\plugins\org.eclipse.core.runtime_2.1.1\runtime. jar \plugins\org.eclipse.swt.win32_2.1.0\ws\win32\s wt.jar \plugins\org.eclipse.ui.workbench_2.1.0\workbe nch.jar 注意,随着Eclipse的版本不同,以上文件的路径 名可能会有所不同。
requires标签
requires标签中所列出的是需要的插件, 需要用到Eclipse工作台和SWT API,因 此导入了org.eclipse.ui插件。
Java程序设计案例教程 全套课件

1.1.4 Java体系分类
3.微型版 Java微型版(Java Micro Edition,Java ME)是为机顶盒、移动电话和个人数字 助理(Personal Digital Assistant,PDA)之类的嵌入式消费电子设备提供的Java语言 平台,包括虚拟机和一系列标准化的Java API。所有的嵌入式装置大体上区分为两 种:一种是运算能力有限、电力供应也有限的嵌入式装置(如PDA、手机);另外 一种则是运算能力相对较强,并且在电力供应上相对充足的嵌入式装置(如冷风 机、电冰箱、机顶盒)。Java ME有自己的类库,还包括用户界面、安全模型、内 置的网络协议以及可以动态下载的联网和离线应用程序。
JRE是Java运行环境,负责运行Java程序。JRE只包含Java运行工具,不包含Java 编译工具。需要特别提到的是,JDK中自带了JRE工具。因此,我们只安装JDK即可, 不需要单独安装JRE,这样可以简化开发环境搭建步骤,方便使用。
《Java程序设计》
1.2.1 JDK的下载与安装
可以从Oracle官方网站下载JDK安装文件,根据自己计算机的操作系统合理选 取 JDK 版 本 。 各 种 版 本 的 JDK 的 安 装 和 配 置 步 骤 都 是 一 样 的 , 下 面 以 64 位 Windows 10操作系统和JDK 1.8为例,演示JDK的下载与安装步骤。
《Java程序设计》
1.2.1 JDK的下载与安装
1.下载JDK 下载适合自己计算机环境的JDK版本的安装文件,本案例选取的是JDK 1.8,安 装文件为“jdk-8u40-windows-x64.exe”。双击安装文件,进入JDK安装界面,如图 1-1所示。
图1-1 JDK安装界面
插件基础知识培训(电子)

可接受
特殊元件 引脚的电
气保护
不可接受
图示和说明
可接受: 保护套可 起到防止短路作用, 引脚上无保护套时, 引脚所跨过的导体 之间的距离 B≥0.5mm。
保护套损坏或 A>2.0mm时, 不能起 到防止短路作用或引 脚上无保护套时, 或 引脚所跨过的导体之 间距离B<0.5mm。
放映结束 感谢各位的批评指导!
插件基础知识培训
培训内容
一、插件作业前的确认 二、手工插件注意事项 三、插件工艺标准 四、插件检验标准
一、插件作业前的确认
1、分配的元器件型号和数量与插件作业指导、 BOM表上的是否一致; 2、元器件在PCB板的插入位置; 3、有极性元器件的数量、特点、位置及插入 方向; 4、插入顺序的合理性; 5、插件作业指导/BOM上是否有注意事项或 说明,若有应明白其含义。
元件脚与 线路间距
不可接受
卧式元件 本体斜度
标准
图示和说明
最佳: 元件本体与其在 基板上两插孔位组成的 连线或元件体在基板上 的边框线完全平行,无 斜度。
四、插件检验标准
4.1元器件插件检验标准
插件类型 接受等级
可接受
卧式元件 本体斜度
不可接受
图示和说明
可接受: 元件体与其在 基板上两插孔位组成 的连线或元件体在基 板上的边框线斜度 ≤1.0mm。
除要求作业者按照上述项目自检外,还应安排专 门检查人员,以保证插入质量,尽可能降低插入不良 率。
四、插件检验标准
4.1元器件插件检验标准
插件类型 接受等级
标准
卧式零件 插件的方 向与极性
可接受
图示和说明
四、插件检验标准
JAVA自学教程(完整版)PPT课件

而在Java语言中,Java自带的虚拟机很好地实现了跨平台 性。Java源程序代码经过编译后生成二进制的字节码是与平台 无关的,但是可被Java虚拟机识别的一种机器码指令。Java虚 拟机提供了一个字节码到底层硬件平台及操作系统的屏障,使 得Java语言具备跨平台性。
2. 面向对象
面向对象是指以对象为基本粒度,其下包含属性和方法。 对象的说明用属性表达,而通过使用方法来操作这个对象。面 向对象技术使得应用程序的开发变得简单易用,节省代码。 Java是一种面向对象的语言,也继承了面向对象的诸多好处, 如代码扩展、代码复用等。
图1.8 Applet显示“Hello World!”
习题
1. 简述Java的特点。 2. 简述Java的分类情况。 3. 进行Java环境的安装和配置。 4. 编写应用程序,屏幕上输出“欢迎来到Java世界!”。 5. 编写Applet,输出“欢迎来到Java世界!”。
第2章 Java基本语法
1.4 JDK包的下载与安装
Java Develop Kit简称为JDK,是Sun公司免费发行的软件包, 可以从Sun网站免费下载,也可以从其它国内 地址下载。JDK版本从1.02开始,目前版本发展到1.4,其中高 级版本对低级版本实现向下兼容。运用这个软件包,就可以对 Java源程序进行编译和运行。本书中下载使用的JDK包为j2sdk1_4_0_012-windows-i586.exe。 下载后双击图标,即可进行安装, 默认的安装目录为C:\j2sdk1.4.0_01。本书作者将安装目录改为 D:\j2sdk1.4.0_01。
图1.4 编辑lib变量
选中path变量,单击“编辑”按钮,弹出标题为“编辑用 户变量”的对话框,如图1.5所示。在变量值一栏的最后添加 “; D:\j2sdk1.4.0_01\bin”,“;”表示与前面的各项隔开,后面的 路径是JDK包的安装路径下的bin目录。图1.5为作者修改path变 量的情况,注意你的安装路径可能与作者的有所不同,同样要 以你的安装路径为基准进行修改。
java培训ppt课件全套课件ppt

Java中的异常处理机制包括捕获异常(Catch)、抛出异常(Throw)和声明异常(Throw)。
Java多线程编程
新建、就绪、运行、阻塞、终止。
线程具有5种状态
字符串编码
String类支持多种编码格式,如UTF-8、GBK等,可以方便地进行字符串的编码和解码。
ArrayList类是一个动态数组,可以根据需要自动增长和缩小。
动态数组
常用操作
线程安全
ArrayList类提供了添加、删除、查找等常用操作的方法。
ArrayList类不是线程安全的,如果需要在多线程环境下使用,可以考虑使用Vector类。
Java语言特点
Web开发、移动开发、大数据、游戏开发等。
Java应用领域
03
常用工具
Git、Maven、Gradle等在Java开发中的使用。
01
JDK安装与配置
下载和安装JDK,配置环境变量等。
02
集成开发环境(IDE)
Eclipse、IntelliJ IDEA等常用Java IDE的介绍和选择。
Java面向对象编程
面向对象编程(OOP)
一种编程范式,通过使用对象来设计和实现软件系统。
对象
现实世界中的事物在计算机中的表示,具有状态和行为。
类
对象的抽象,定义了对象的属性和方法。
实例
类的具体实例,具有类定义的属性和行为。
02
03
04
01
抽象
定义抽象类或抽象方法,用于规定接口和行为,但不实现具体实现细节。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
13.2.5 PDE透视图
向导完成后,会提示是否切换到“PDE透视图”。这里可 以根据个人习惯选择,因为PDE透视图和Java透视图差不多, 只是布局上有一些不同而已。
13.2.6 PDE项目的文件结构
PDE项目的文件结构和Java项目差不多。不同的是, 多了一个META-INF文件夹,以及MANIFEST.MF文件。还 有一个build.properties文件。
第一步:新建插件项目:插件项目也叫PDE项目。开 发插件的第一步就是在Eclipse中建立PDE项目。插件项目 需要由PDE工具来建立。另外PDE工具也提供了把普通 Java项目转换为PDE项目的向导。
第二步:建立Activator: 第三步:编辑manifest 第四步:编辑plugin.xml 第五步:实现扩展点 第六步:扩展Preference 第七步:扩展透视图 第八步:扩展视图 第九步:扩展ActionSet
13.2.7 PDE可视化编辑器
PDE最常用的功能就是使用PDE可视化编辑器。回头 看一下图13-7,在PDE透视图中,占据着编辑器区域的就是 PDE编辑器。PDE编辑器下方的标签也清晰地展示它的功能 。
Overview: Dependencies: Runtime: Extentions: Extention Points: Build: MANIFEST.MF: build.properties: plugin.xml:
13.3.3 使用扩展点向导添加扩展
CO2的功能很简单,只要扩展Java编辑器中的快捷菜 单就可以了。
13.3.3 设置快捷菜单的扩展
向导完成后,可以看到扩展列表中显示了新增的一个扩 展。选择扩展列表中的节点,右边的编辑器动态显示和节点 相关的编辑器。通过编辑器可以对相关的属性进行修改。
13.2.3 关于插件的唯一ID
每个插件都要有一个唯一ID,就好像是人的身份证号码 一样具有唯一性。不能和其他插件重复,ID不能随意变化, 变了就是另外一个插件。
现在Eclipse的插件成千上万,到底怎样命名ID,才能 避免与其他插件重复呢?习惯的做法就是用Java包的命名规 范。
13.2.4 新建插件项目向导
Hale Waihona Puke 3.3.1 编写Activator
Activator继承了抽象类AbstractUIPlugin。 AbstractUIPlugin继承了Plugin,Plugin实现的是 BundleActivator接口。
13.3.2 何时构造Activator?
编写Activator的时候,很自然会想到一个问题。 Activator到底什么时候构造?由谁来构造?按照IPlugin的 定义,Activator将会在插件第一次被调用之前被构造,然 后调用start()方法。这个构造过程由Eclipse平台来完成。 所以对于开发者来说,只要写好Activator就可以了,其他 就交由Eclipse去办了。
可视化的编辑工具: 对插件进行调试和测试的运行器。 插件项目的发布向导: RCP项目的发布向导:
13.2 新建插件项目
Eclipse插件的概念非常先进,也十分强大。但也不会 因为先进和强大而复杂。这种插件机制的宗旨就是简化开发 ,所以开发一个Eclipse插件其实是非常简单的事情。
13.2.1 开发插件项目的过程
13.3 编写插件代码
PDE的向导把一个插件最基本的东西已经准备好了, 接下来就是编写每个插件都必须的Activator。Activator实 现Plugin接口。Plugin是每个插件都必须的“启动器”,每 个插件都至少要有一个实现Plugin接口的启动器。按照向导 所提供的规范,实现自Plugin接口的启动器都命令为 Activator。
13.1.2 扩展点和插件
前两幅图中,有一个形象的比喻,插件和平台相连的连 线用了一个“插头”。正如现实中,各种插头是不能随便乱 插的,必须插在规格相符的插口上。同样,插件也要 “插” 在对应的“插口”上。在Eclipse中,这种“插口”叫“扩展 点Extention Point”。
13.1.3 Plug-in、Fragment和Feature
Eclipse中的插件还需要了解三个概念,Plug-in、 Fragment、Feature。Plug-in这个大家已经知道了,就是 插件,不再复述。
Fragment: Feature:
13.1.4 PDE提供的开发工具
PDE的全称是Plug-in Development Environment(插 件开发环境)。PDE提供了一系列的工具,可以用于建立、 开发、测试、调试、发布和Eclipse的插件。
13.2.2 插件功能设计
下面这个插件的例子是一个小工具,把源代码转换成为 带有语法提示格式的HTML代码。这个插件没有UI界面,只 是扩展了Eclipse的快捷菜单。当用户选择某个文件,或者 Java编辑器上某段代码后,按鼠标右键,在快捷菜单中显示 一个菜单命令。选择这个菜单命令后弹出一个对话框,让用 户选择转换的格式和文件夹,最后执行转换输出。把这个项 目命名为com.smartdio.co2,这个项目的名称也是插件的 唯一ID。
第13章 插件开发基础
经过前面的学习,相信对于Eclipse的使用已经十分熟 悉,应该也可以用Eclipse和SWT开发出一些独立运行的小 应用。但面对着强大、而且可以自由扩展的Eclipse,仅仅 用来作为一个开发工具来使用,有点浪费。
Eclipse的“野心”可不仅仅是希望作为一个开发工具 而已。Eclipse还可以被用来作为应用程序的基础平台。 Eclipse为大中型的应用程序提供了完善的组件管理机制, 提供了一个完整的界面框架。以这个平台作基础,不需要再 像前面的例子那样要自己开发一个界面框架、建立菜单、建 立工具栏…。利用Eclipse作为应用程序的基础,开发者不 需要在软件的界面上花太多的时间,只要集中精力开发插件 功能就可以了。