(一)安装Spket-1.6.18
1. 在CMD 中执行 java -jar spket-1.6.18.jar, 点"Next"
2. 选择eclipse plugin
3. 选择MyEclipse8.5的安装目录的common文件夹, 点"Next"!
4. 选择Spket 的安装目录(不要和MyEclipse的目录在一起),点"Next", 然后开始安装
5. 编译CreatePluginsConfig.java并运行(代码在最后面,运行之前需要将main方法中的值改为第4步中Spket安装目录下的plugins),将控制台输出的信息追加到MyEclipse 8.5安装目录下的\configuration\org.eclipse.equinox.simpleconfigurator\bundles.info文件后面
6. 重启MyEclipse 8.5完成Spket-1.6.18的安装,在MyEclipse 8.5中的菜单Window -> Preferences 中将出现 Spket项目
(二)配置Spket-1.6.8
1. Window → Preferences → Spket → JavaScript Profiles → New
2. 输入Ext, 点"OK"
3. 选择ExtJS, 点"Add Library", 在弹出窗口中选择"ExtJS"
4. 选择ExtJS, 点"Add File", 选择ext-3.4.0下的ext.jsb2,全部勾选
5. 选择Ext, 点"Default"
6. Window → Preferences → General → Editors → File Associations,选择js,将Spket JavaScript Editor设置为默认,OK啦!
(三)CreatePluginsConfig.java
import java.io.File;
import java.util.ArrayList;
import java.util.List;
public class CreatePluginsConfig {
private String path;
public CreatePluginsConfig(String path) {
this.path = path;
}
public void print() {
List list = getFileList(path);
if (list == null) {
return;
}
int length = list.size();
for (int i = 0; i < length; i++) {
String result = "";
String thePath = getFormatPath(getString(list.get(i)));
File file = new File(thePath);
if (file.isDirectory()) {
String fileName = file.getName();
if (fileName.indexOf("_") < 0) {
continue;
}
String[] filenames = fileName.split("_");
String filename1 = filenames[0];
String filename2 = filenames[1];
result = filename1 + "," + filename2 + ",file:/" + path + "/"
+ fileName + "/,4,false";
System.out.println(result);
} else if (file.isFile()) {
String fileName = file.getName();
if (fileName.indexOf("_") < 0) {
continue;
}
int last = fileName.lastIndexOf("_");//
String filename1 = fileName.substring(0, last);
String filename2 = fileName.substring(last + 1, fileName
.length() - 4);
result = filename1 + "," + filename2 + ",file:/" + path + "/"
+ fileName + ",4,false";
System.out.println(result);
}
}
}
public List getFileList(String path) {
path = getFormatPath(path);
path = path + "/";
File filePath = new File(path);
if (!filePath.isDirectory()) {
return null;
}
String[] filelist = filePath.list();
List filelistFilter = new ArrayList();
for (int i = 0; i < filelist.length; i++) {
String tempfilename = getFormatPath(path + filelist[i]);
filelistFilter.add(tempfilename);
}
return filelistFilter;
}
public String getString(Object object) {
if (object == null) {
return "";
}
return String.valueOf(object);
}
public String getFormatPath(String path) {
path = path.replaceAll("\\\\", "/");
path = path.replaceAll("//", "/");
return path;
}
public static void main(String[] args) {
String dir = "D:/Program Files/spket/eclipse/plugins"; // spket安装目录下的plugins文件夹
new CreatePluginsConfig(dir).print();
}
}