コード例 #1
0
 private XModelObject validateLib(XModelObject object) {
   XModelObject lib = object.getChildByPath("lib"); // $NON-NLS-1$
   if (lib == null) {
     XModelObject wi = object.getChildByPath("WEB-INF"); // $NON-NLS-1$
     if (wi == null) return null;
     XModelObject lb = wi.getChildByPath("lib"); // $NON-NLS-1$
     if (lb == null) return null;
     lib = wi.getModel().createModelObject(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER, null);
     lib.setAttributeValue(XModelObjectConstants.ATTR_NAME, "lib"); // $NON-NLS-1$
     lib.setAttributeValue(
         XModelObjectConstants.ATTR_NAME_LOCATION,
         wi.getAttributeValue(XModelObjectConstants.ATTR_NAME_LOCATION) + "/lib"); // $NON-NLS-1$
     object.addChild(lib);
     object.setModified(true);
   }
   return lib;
 }
コード例 #2
0
 private static void _updateSrcs(XModelObject object) {
   IProject p = EclipseResourceUtil.getProject(object);
   if (p == null || !p.isAccessible()) return;
   String[] srcs = EclipseResourceUtil.getJavaProjectSrcLocations(p);
   Set<String> paths = new HashSet<String>();
   for (int i = 0; i < srcs.length; i++) {
     String path = EclipseResourceUtil.getRelativeLocation(object.getModel(), srcs[i]);
     if (path == null) continue;
     paths.add(path);
   }
   XModelObject[] cs = object.getChildren(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER);
   for (int i = 0; i < cs.length; i++) {
     if (cs[i]
         .getAttributeValue(XModelObjectConstants.ATTR_NAME)
         .startsWith("src")) { // $NON-NLS-1$
       String loc = cs[i].getAttributeValue(XModelObjectConstants.ATTR_NAME_LOCATION);
       if (!paths.contains(loc)) {
         object.removeChild(cs[i]);
       } else {
         paths.remove(loc);
       }
     }
   }
   for (String path : paths) {
     String n = getNextSrcName(object);
     Properties properties = new Properties();
     properties.setProperty(XModelObjectConstants.ATTR_NAME_LOCATION, path);
     properties.setProperty(XModelObjectConstants.ATTR_NAME, n);
     FileSystemImpl s =
         (FileSystemImpl)
             object
                 .getModel()
                 .createModelObject(XModelObjectConstants.ENT_FILE_SYSTEM_FOLDER, properties);
     object.addChild(s);
   }
 }