AOS 自动生成代码支持其它操作系统

来源:互联网 发布:卡迪夫城市大学 知乎 编辑:程序博客网 时间:2024/05/18 18:21

原生AOS 在自动生成代码时只支持win,其它操作系统会提示  

  AOS.tip('选中节点不合法,请重新选择。');

由于在程序中 CoderService.java 中写了   StringUtils.contains(subPath,"java\\")  这是win 的写法,而其它 操作系统需要  StringUtils.contains(subPath,"java/")

所以改进以下程序:  CoderService.java   的 listProjectView 方法


public List<TreeNode> listProjectView(Dto queryDto) {List<TreeNode> fileList = Lists.newArrayList();String path = queryDto.getString("path");if (StringUtils.equalsIgnoreCase("aosroot_", path)) {// 根节点String coder_project_rootpath_ = WebCxt.getCfgOfDB("coder_project_rootpath_");if (StringUtils.equals(coder_project_rootpath_, "0")) {path = System.getProperty("user.dir");} else {path = coder_project_rootpath_;}}<span style="color:#ff0000;">String os = System.getProperty("os.name");  </span>File file = new File(path);if (file.exists()) {File[] subFiles = file.listFiles();for (File subFile : subFiles) {TreeNode treeNode = new TreeNode();String subPath = subFile.getAbsolutePath();treeNode.setId(subPath);String filename = subFile.getName();if (StringUtils.startsWith(filename, "."))continue;if (filename.equalsIgnoreCase("classes"))continue;if (filename.equalsIgnoreCase("icon"))continue;if (filename.equalsIgnoreCase("image"))continue;if (filename.equalsIgnoreCase("data") || filename.equalsIgnoreCase("report")|| filename.equalsIgnoreCase("tld") || filename.equalsIgnoreCase("lib")|| filename.equalsIgnoreCase("db"))continue;treeNode.setText(filename);if (subFile.isDirectory()) {// 目录treeNode.setA("1");<span style="color:#ff0000;">if (StringUtils.contains(subPath, "java\\")||StringUtils.contains(subPath, "java/"))</span> {// java packagetreeNode.setIcon("icon34.gif");// 目录类型:java源文件包treeNode.setB("1");String pkgpath = StringUtils.substringAfter(subPath, "java\\");pkgpath = AOSUtils.isEmpty(pkgpath)?StringUtils.substringAfter(subPath, "java/"):pkgpath;<span style="color:#ff0000;">if(os.toLowerCase().startsWith("win")){</span>pkgpath = pkgpath.replace("\\", ".");}else{pkgpath = pkgpath.replace("/", ".");}treeNode.setC(pkgpath);} else if (StringUtils.contains(subPath, "webapp\\")) {treeNode.setIcon("icon42.gif");} else {treeNode.setIcon("icon35.gif");}if (filename.equalsIgnoreCase("webapp")) {treeNode.setIcon("icon42.gif");}treeNode.setLeaf(false);} else {// 文件treeNode.setA("2");treeNode.setLeaf(true);if (StringUtils.endsWith(filename, "java")) {treeNode.setIcon("icon36.gif");} else if (StringUtils.endsWith(filename, "xml")) {treeNode.setIcon("icon39.gif");} else if (StringUtils.endsWith(filename, "js")) {treeNode.setIcon("icon37.gif");} else if (StringUtils.endsWith(filename, "jsp")) {treeNode.setIcon("icon26.gif");} else {treeNode.setIcon("icon38.gif");}}if (StringUtils.equalsIgnoreCase("webapp", treeNode.getText())|| StringUtils.equalsIgnoreCase("WEB-INF", treeNode.getText())|| StringUtils.equalsIgnoreCase("src", treeNode.getText())) {treeNode.setExpanded(true);}fileList.add(treeNode);}}// 重排序,树枝节点排在前面String jqlText = "SELECT * FROM :AOSList ORDER BY toNumber(a) ASC";fileList = AOSListUtils.select(fileList, TreeNode.class, jqlText, null);return fileList;}


0 0