[Plug-in development] - 1 Eclipse plug-in development guide blind

  After contact with the real eclipse plugin development A month later, the development process and technical requirements for the plug, there is a degree of understanding. Way back before the same as without a head rattling chaos science, really I think a lot of wasted time. Here summarize the main process of learning as well as information required.

  Eclipse as a strong development IDE, itself as an open-source software, available to the user a strong expansion capability. We can develop a plug-in themselves, as long as the plug into the directory, you can use.

  Here is the content of this blog post describes, hoping to help the novice have a certain understanding of plug-in development.

 

1 learning materials

  Learning materials is the introduction of several mind mapping above. As the domestic engage in this direction it is indeed less, that is, some large companies or specially designed tools to develop some of the company will be used. Therefore, it is no longer published books are mostly printed, electronic version can be downloaded from the Internet or from Taobao to buy the scarcity of paper books.

  About books, recommend the following few. Recommended books have Baidu cloud disk link to download.

  " The Eclipse plug-in development study notes "

  This book relative novice, pretty good. Because the Internet can easily find the source. The shining read, easier to understand. Books on the style biased teaching novice.

  " The Eclipse plug-in development ." 

  This book is almost like an API tutorial, English original should be said that the Eclipse development Bible Translation but nothing special feeling, but could not find the source code. Interspersed with, familiar API for good.

  " GEF Redbook "

  This English electronic version of the book, from the GEF's official website can be downloaded. Recommended study GEF we'll see.

 

  Forum, in fact, there is no good, after all, few developers.

  Or look at IBM's Eclipse developer's official website or better.

  IBM Develper : http://www.ibm.com/developerworks/cn/java/os-ecplug/

  Eclipse Corner : https://wiki.eclipse.org/Eclipse_Corner

 

  博客

  这个可以说是国内开发人员最好的学习地方了。

  首轮最佳推荐,【八进制】的博客,我学习GEF基本就是总看他的博客,可惜他已经不研究这个了,要不然可以作为领路人了。

  http://www.cnblogs.com/bjzhanghao/category/36197.html

  其他人的写的也不多,也就不做多说了。

 

  源码

  关于Eclipse插件的源码,阅读起来真心不是一般的累。因为为了迎合官方的开发模式,我们自己开发的插件,往往也十分庞大。一个简单的编辑器功能,基本上都要几千行甚至上万的代码。如果没有一定的理论基础,看代码是十分痛苦的。这里推荐几个学习的源码:

  【org.eclipse.draw2d.examples】,这里面有很多独立启动的小应用。可以学习很多插件相关的知识,比如属性开发,界面等等。

  【读书笔记附带源码】, 结合书籍阅读,简直是开发必备。

  【GEF源码】,官网都有下载,这里是3.6版本。这个插件安装到eclipse后,会在新建工程的导航菜单里面,看到Examples文件夹,打开就可以看到有几个文件。这几个都是GEF的样例代码,比如logic,可以给开发者进行学习和参考。

 

  另外呢,sourceForge以及github上面都有不少的开源插件,但是大多比较庞大,大家可以针对某一些领域专门查找学习。

 

2 插件的安装

  

  Eclipse插件通常以jar包形式存在,这个jar包需要先进行解压缩。

  【方法1】:解压缩后直接放在Eclipse开发工具文件目录的Plugins下。

  【方法2】:在dropins里面创建XXX.link文件,然后以相对路径的方式放置插件。

  比如我们在这个目录下新建一个文件夹my_plugins。那么link的内容应该是:path=my_plugins\\XXX

 

  另外有一个小技巧:如果你想查看eclipse的版本,可以用记事本打开.eclipseproduct文件,里面可以看到eclipse的版本:

name=Eclipse Platform
id=org.eclipse.platform
version=4.4.0

  如果你想修改jvm或者绑定jdk的路径,可以修改eclipse.ini

-startup
plugins/org.eclipse.equinox.launcher_1.3.0.v20140415-2008.jar
--launcher.library
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.1.200.v20140603-1326
-product
org.eclipse.epp.package.jee.product
--launcher.defaultAction
openFile
--launcher.XXMaxPermSize
256M
-showsplash
org.eclipse.platform
--launcher.XXMaxPermSize
256m
--launcher.defaultAction
openFile
--launcher.appendVmargs
-vmargs
-Dosgi.requiredJavaVersion=1.6
-Xms40m
-Xmx512m

 

3 插件的调试以及创建

 

  之前整理过一篇图片贴,是关于 如何创建一个插件开发工程 ,那么这里就不再对创建工程做过多的描述了。

  一般插件都是以Eclipse Application方式启动调试,如果是Debug模式,当你插入断电后,运行到此处会进入debug调试模式。与正常的JAVA项目相同。

  当然也有许多是在Java Application,也即是main函数里面创建的,比如org.eclipse.draw2d.examples里面的示例。

 

4 学习路线

  基本的路线就是要有一定的JAVA基础,要不然学习起来很吃力的。

  swt,主要是一些界面的布局开发。

  GEF,是开发编辑器的一种常用技术。

  EMF,是开发复杂模型的框架。

  GMF,是GEF与EMF的整合,但是包含的插件包很多,因此不推荐学习。如果使用的话,自己整合GEF和EMF也是可以的。红皮书里面有整合的内容。

 

  关于设计模式,不得不说,Eclipse插件开发里面涉及到了大量的设计模式。下面就简单的介绍下插件开发中设计模式的典型应用场景。

  

  【工厂方法】

  比如在GEF中的Control模块,就是使用这种设计模式匹配Model与view之间的关系。

  【单例模式】

  As the eclipse for the entire development cycle, and therefore must be efficient use of resources. When necessary, long life cycle of objects using Singleton pattern is necessary, such as Plugin object.

  [Adapter] mode

  For different classes, the editor provides a different approach. In the Editor class, we need to be adapted to different classes.

  Command mode

  Editor inside, a lot of command operations are to be recorded. For example, we deleted a model node, it needs to be restored by undo. Then the data should be stored in the command object, and recorded in CommonStack inside, if necessary conduct Undo, Redo operation.

  [Policy] mode

  For complex scenarios, there are many treatment methods. To facilitate the expansion process of a model approach, the strategy pattern is the classic approach.

  

  Design patterns to learn, can refer to before finishing Bowen: Design Patterns Overview  to learn.

5 development prospects

  Speaking of this, if not a certain development value, and maybe we did not learn of the power.

  Many UML design software on the market are developed using the Eclipse plug-ins, and the Eclipse RCP rich client development, application is very extensive.

  Said a popular mind mapping software XMind, is the use of Eclipse RCP technology development, there are some good features, are required to pay the trial, so the "money scene" is great.

  

  I hope in this direction, to inject more new people!

  Follow-up will continue to update, plug-in development and the use of tips, etc., thank you support.

Reproduced in: https: //my.oschina.net/u/204616/blog/545355

Guess you like

Origin blog.csdn.net/weixin_34402090/article/details/91990126