Ste*_*veT 12 java eclipse plugins
有没有人有一个"hello world"示例或教程来创建Eclipse插件片段?
我有一个工作主机插件,为了简单起见,就是这个......
public void start(BundleContext context) throws Exception {
System.out.println("Hello....");
super.start(context);
plugin = this;
}
public void stop(BundleContext context) throws Exception {
System.out.println("Goodbye...");
plugin = null;
super.stop(context);
}
Run Code Online (Sandbox Code Playgroud)
足够简单,有效.现在我想向该主机添加一个片段,这似乎不像创建一个插件主机那么简单.我只是没有看到如何创建一个片段项目并为其添加逻辑.假设我只是想做一些简单的事情并让片段打印出"Hello2" start()和"Goodbye2" stop().有人可以给我一个有效的例子吗?
Mic*_*ard 17
Eclipse - > File - > New ... - > Fragment project - >设置主机插件(在您的工作区或目标平台的插件中).
打开插件清单编辑器(你可以通过点击来实现build.properties,manifest.mf或者fragment.xml- 如果没有这样的文件,可以手动创建)
在选项卡Extentions中单击Add ..并添加org.eclipse.ui.startup并浏览实现org.eclipse.ui.IStartup类的类.
创建此类并实现它.您需要实现earlyStartup()作为片段入口点的方法.
注意:下面的行只是示例.我没有测试它,所以可能有错误......
您只需要这个(这是项目结构/目录结构):
META-INF/MANIFEST.MF内容:
Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: FragmentProject Bundle-SymbolicName: FragmentProject;singleton:=true Bundle-Version: 1.0.0 Bundle-ClassPath: src/,. Fragment-Host: *HostPluginProjectSymbolicName*;bundle-version="1.0.0" Bundle-RequiredExecutionEnvironment: J2SE-1.5 Require-Bundle:
build.properties内容:
source.. = src,\
output.. = bin/
bin.includes = META-INF/,
.,
fragment.xml
fragment.xml内容:
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.2"?>
<fragment>
<extension
point="org.eclipse.ui.startup">
<startup
class="FragmentStartClass">
</startup>
</extension>
</fragment>
FragmentStartClass.java内容:
import org.eclipse.ui.IStartup;
public class FragmentStartClass implements IStartup {
public void earlyStartup() {
System.out.println("Hello World From Fragment!");
}
}
| 归档时间: |
|
| 查看次数: |
14689 次 |
| 最近记录: |