private String tranCH2En(String[] urls, IARESProject project) throws Exception { StringBuffer sb = new StringBuffer(); IARESModuleRoot root = project.getModuleRoot(getModuleRootByCHName(urls[0], project)); if (root != null) { for (int i = 1; i < urls.length; i++) { for (IARESModule module : root.getModules()) { IARESResource property = module.getARESResource(IARESModule.MODULE_PROPERTY_FILE); if (property != null && property.exists()) { try { ModuleProperty info = property.getInfo(ModuleProperty.class); if (info != null) { Object obj = info.getValue(ICommonModel.CNAME); if (obj != null) { if (StringUtils.equals(urls[i], obj.toString())) { sb.append("/"); sb.append(module.getShortName()); break; } } } } catch (Exception e) { e.printStackTrace(); } } } } for (String enname : urls) { root.getModule(enname); } } return sb.toString(); }
/* (non-Javadoc) * @see com.hundsun.ares.studio.core.IARESModule#getParentModule() */ public IARESModule getParentModule() { // 默认模块或第一级模块视为没有父模块 if (isDefaultModule() || getElementName().indexOf('.') == -1) return null; IARESModuleRoot root = getRoot(); String name = getElementName(); String parentModuleName = StringUtils.substringBeforeLast(name, "."); return root.getModule(parentModuleName); }
/* (non-Javadoc) * @see com.hundsun.ares.studio.core.IARESElement#getResource() */ public IResource getResource() { IARESModuleRoot root = (IARESModuleRoot) getParent(); int length = this.names.length; if (length == 0) { return root.getResource(); } else { IPath path = new Path(this.names[0]); for (int i = 1; i < length; i++) path = path.append(this.names[i]); return ((IContainer) root.getResource()).getFolder(path); } }
/* (non-Javadoc) * @see com.hundsun.ares.devtool.common.core.ICommonModule#getSubModules() */ public IARESModule[] getSubModules() throws ARESModelException { // default module if (isDefaultModule()) { return new IARESModule[0]; } IARESModuleRoot root = getRoot(); IARESModule[] all = root.getModules(); List<IARESModule> modules = new ArrayList<IARESModule>(); for (IARESModule module : all) { if (module.getElementName().startsWith(getElementName() + ".")) modules.add(module); } return modules.toArray(new IARESModule[0]); }