[英]How to create a custom 'new class wizard' for Eclipse?
I would like to create a functionality ( for myself ), wherein on clicking a button ( or say firing any event or anything that can trigger my program ), a popup will be displayed which will ask the name of the Class, objects it have and few more thing. 我想创建一个功能(对我自己),其中点击一个按钮(或者说任何事件或任何可以触发我的程序的事件),将显示一个弹出窗口,它将询问类的名称,它拥有的对象和更多的事情。 Then on pressing OK, it will create a java file with skeleton of predefined methods, inherit known interface and ...
然后按OK,它将创建一个带有预定义方法骨架的java文件,继承已知的接口和...
So, basically how to do that? 那么,基本上该怎么做? Do i need to create a plugin for eclipse or there is something else in eclipse for it.
我是否需要为eclipse创建一个插件,或者在eclipse中还有其他东西。
PS Please change the title. PS请更改标题。 I am unable to think of any better one.
我无法想到更好的一个。
As others said, you want to create a wizard, then you want to augment the New Class Wizard, which is doing something similar to what you want (but the default wizard don't allow you to to add fields and custom methods). 正如其他人所说,你想创建一个向导,然后你想要扩充New Class Wizard,它正在做你想要的类似的事情(但是默认向导不允许你添加字段和自定义方法)。
To create a wizard, you can use the "New File Wizard" extension template: Create a plug-in, then, go to the extensions tab, select Add..., and select the "Extension Wizards" tab. 要创建向导,可以使用“新建文件向导”扩展模板:创建插件,然后转到扩展选项卡,选择添加...,然后选择“扩展向导”选项卡。 That will get you started on Eclipse wizards.
这将使您开始使用Eclipse向导。
Once you've learned the basics of creating Wizards and pages, then, include the org.eclipse.jdt.ui and org.eclipse.jdt.core in your plug-in dependencies. 一旦学习了创建向导和页面的基础知识,就可以在插件依赖项中包含org.eclipse.jdt.ui和org.eclipse.jdt.core。 Open the following type (Ctrl-Shift-T): "NewClassWizardPage".
打开以下类型(Ctrl-Shift-T):“NewClassWizardPage”。 This is the page that is displayed when you select New > Class in the Package Explorer.
这是在Package Explorer中选择New> Class时显示的页面。
You can probably either copy this page and the parent pages to help you get started or just extend it (in my experience, internal Eclipse wizards such as this one are difficult to extend because they have lots of fields and methods that are package/private, so I usually end up copying the code as a starting point... don't forget to keep the license though!). 您可以复制此页面和父页面以帮助您入门或仅扩展它(根据我的经验,内部Eclipse向导很难扩展,因为它们有很多字段和方法是包/私有的,所以我通常最终将代码复制为起点......不要忘记保留许可证!)。
You more or less want to add your own wizzard to the 'new class' dialog .. right? 您或多或少想要将自己的wizzard添加到“新类”对话框中..对吗?
This was the first site I found when typing "creating your own new wizzard eclipse" in Google: http://www.eclipse.org/articles/article.php?file=Article-JFaceWizards/index.html 这是我在Google上输入“创建你自己的新wizzard eclipse”时找到的第一个网站: http : //www.eclipse.org/articles/article.php? file = Article-JFaceWizards/ index.html
I may be mis-understanding the question, but it sounds like you are re-implementing the New Class Wizard that exists already. 我可能误解了这个问题,但听起来你正在重新实现已经存在的新类向导。
It lets you name the class, the containing package. 它允许您命名类,包含的包。 Can assign a superclass and/or interface and can also choose if you want to include the contructors for the superclass.
可以分配超类和/或接口,也可以选择是否要包含超类的构造函数。
A new .java file is created with all known methods from declared interfaces and also any abstract methods from the superclass. 使用声明的接口中的所有已知方法以及来自超类的任何抽象方法创建新的.java文件。
Edt: Title was changed whilst I was writing this reply to "How to creat a customer 'new class wizard; for Eclipse". Edt:当我写这篇回复“如何创建客户的新类向导;对于Eclipse”时,标题被更改了。 It makes my answer slightly redundant but I'm not seeing any new functionality being added in the question.
它使我的回答略显多余,但我没有看到问题中添加任何新功能。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.