Returns a list of the plugins in the plugins menu.
()
| 1137 | |
| 1138 | /** Returns a list of the plugins in the plugins menu. */ |
| 1139 | public static synchronized String[] getPlugins() { |
| 1140 | File f = pluginsPath!=null?new File(pluginsPath):null; |
| 1141 | if (f==null || (f!=null && !f.isDirectory())) |
| 1142 | return null; |
| 1143 | String[] list = f.list(); |
| 1144 | if (list==null) |
| 1145 | return null; |
| 1146 | Vector v = new Vector(); |
| 1147 | jarFiles = null; |
| 1148 | macroFiles = null; |
| 1149 | for (int i=0; i<list.length; i++) { |
| 1150 | String name = list[i]; |
| 1151 | boolean isClassFile = name.endsWith(".class"); |
| 1152 | boolean hasUnderscore = name.indexOf('_')>=0; |
| 1153 | if (hasUnderscore && isClassFile && name.indexOf('$')<0 ) { |
| 1154 | name = name.substring(0, name.length()-6); // remove ".class" |
| 1155 | v.addElement(name); |
| 1156 | } else if (hasUnderscore && (name.endsWith(".jar") || name.endsWith(".zip"))) { |
| 1157 | if (jarFiles==null) jarFiles = new Vector(); |
| 1158 | jarFiles.addElement(pluginsPath + name); |
| 1159 | } else if (validMacroName(name,hasUnderscore)) { |
| 1160 | if (macroFiles==null) macroFiles = new Vector(); |
| 1161 | macroFiles.addElement(name); |
| 1162 | } else { |
| 1163 | if (!isClassFile) |
| 1164 | checkSubdirectory(pluginsPath, name, v); |
| 1165 | } |
| 1166 | } |
| 1167 | list = new String[v.size()]; |
| 1168 | v.copyInto((String[])list); |
| 1169 | StringSorter.sort(list); |
| 1170 | return list; |
| 1171 | } |
| 1172 | |
| 1173 | /** Looks for plugins and jar files in a subdirectory of the plugins directory. */ |
| 1174 | private static void checkSubdirectory(String path, String dir, Vector v) { |
no test coverage detected