ste*_*ros 6 java eclipse plugins save
我想为Eclipse创建一个Google Closure Compiler插件.我已经有一个弹出菜单项,可以将JavaScript文件编译为其缩小版本.但是,如果每次保存*.js缩小版本都会自动生成,那将非常有用.我读/听过自然和建设者,延伸点和IResourceChangeListener.但我没有设法弄清楚我应该使用什么,特别是如何使它工作.
是否有一个插件的工作示例执行"相同类型的事情"所以我可以从那个或教程编写这样的?
在下面的答案中,我搜索了使用该项目的项目,IResourceChangeListener并提出了以下代码:
清单:http://codepaste.net/3yahwe
plugin.xml:http://codepaste.net/qek3rw
激活者:http://codepaste.net/s7xowm
DummyStartup:http://codepaste.net/rkub82
MinifiedJavascriptUpdater:http://codepaste.net/koweuh
有在MinifiedJavascriptUpdater.java保存用于该代码IResourceChangeListener的resourceChanged()功能从未达到.
从这里回答http://www.eclipse.org/forums/index.php/t/362425/
解决方案是将代码放入激活器并摆脱MinifiedJavascriptUpdater:
package closure_compiler_save;
import org.eclipse.ui.plugin.AbstractUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
public class Activator extends AbstractUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "closure-compiler-save"; //$NON-NLS-1$
// The shared instance
private static Activator plugin;
/**
* The constructor
*/
public Activator() {
} //gets here
@Override
public void start(BundleContext context) throws Exception {
super.start(context);
Activator.plugin = this;
ResourcesPlugin.getWorkspace().addResourceChangeListener(new IResourceChangeListener() {
public void resourceChanged(IResourceChangeEvent event) {
System.out.println("Something changed!");
}
});
}
@Override
public void stop(BundleContext context) throws Exception {
Activator.plugin = null;
super.stop(context);
}
/**
* Returns the shared instance
*
* @return the shared instance
*/
public static Activator getDefault() {
return plugin;
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2901 次 |
| 最近记录: |