這一篇將怎么在spket內置js文件,而不用用戶自己去添加。
1. 在開發的Eclipse的 運行配置將下面幾個插件勾選上。


2. 在org.eclipse.ui.startup拓展里執行(只需執行一次):
JSPlugin.getDefault().getPreferenceStore().setValue("js.profile", "BingoTouch");
PS:記得引入com.spket.js的包
3. 生成profiles.xml


這個profiles.xml里面就是:

這份配置其實能在界面操作生成,簡單就是調插件代碼也就可以生成。但我實在是沒耐心去看源碼,更何況是沒有源碼(這個插件不是開源的),於是我直接自己生成這樣一個文件:
String comSpketJs = JSPlugin.getDefault().getStateLocation().toString(); //com.spket.js目錄地址 File file = new File(comSpketJs); if(!file.exists()) file.mkdir(); FileUtil.createSpketProfilesXml(comSpketJs + File.separator + "profiles.xml"); public static void createSpketProfilesXml(String path) { String jstipFolder = eclipseRootPath + "/resource/config/jstip"; File file = new File(jstipFolder); PrintWriter pw; try { pw = new PrintWriter(new FileWriter(path)); pw.write("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"); pw.print("<profiles>\n"); pw.print("<profile id=\"BingoTouch\" name=\"BingoTouch\">use namespace jQuery;\n"); File[] fs = file.listFiles(); for(File f : fs){ pw.print("include '" + f.getAbsolutePath().replaceAll("\\\\", "\\\\\\\\") + "';\n"); } pw.print("</profile>\n"); pw.print("</profiles>"); pw.close(); } catch (IOException e) { // TODO 自動生成的 catch 塊 e.printStackTrace(); } }
代碼還是比較簡單的,看看就明白,之后第一次打開Eclipse就有:
