public void load(XModelObject object) {
    if (EclipseResourceUtil.isProjectFragment(object.getModel())) return;

    IAutoLoad auto = (IAutoLoad) object.getModel().getProperties().get(XModelConstants.AUTOLOAD);
    if (auto != null) {
      auto.load(object.getModel());
      updateLibs(object);
      _updateSrcs(object);
      ((FileSystemsImpl) object).updateOverlapped();
      return;
    }

    String f = getEclipseFileName(object, true);
    if (f == null) super.load(object);
    else util().load(new File(f), object);

    XModelObject[] os = object.getChildren();
    for (int i = 0; i < os.length; i++) {
      String s = os[i].getAttributeValue(XModelObjectConstants.ATTR_NAME_LOCATION);
      if (s == null || !s.startsWith(XModelConstants.WORKSPACE_OLD_REF)) continue;
      s = XModelConstants.WORKSPACE_REF + s.substring(XModelConstants.WORKSPACE_OLD_REF.length());
      os[i].setAttributeValue(XModelObjectConstants.ATTR_NAME_LOCATION, s);
    }

    removeMissingJarSystems(object);
  }
 void removeMissingJarSystems(XModelObject object) {
   XModelObject[] os = object.getChildren("FileSystemJar"); // $NON-NLS-1$
   for (int i = 0; i < os.length; i++) {
     JarSystemImpl jar = (JarSystemImpl) os[i];
     String location = jar.getLocation();
     if (location != null && !new File(location).isFile()) {
       jar.removeFromParent();
       object.setModified(true);
     }
   }
 }
 public void saveTo(File f, XModelObject object) {
   XModelObject o = object.copy(1);
   XModelObject[] cs = o.getChildren();
   for (XModelObject c : cs) {
     if (c.getModelEntity().getName().equals("FileSystemJar")) { // $NON-NLS-1$
       o.removeChild(c);
     }
     if (!c.getAttributeValue(XModelObjectConstants.ATTR_NAME_LOCATION)
         .startsWith("%")) { // $NON-NLS-1$
       o.removeChild(c);
     }
   }
   util().save(f, o);
 }
  public boolean update(XModelObject object) throws XModelException {
    boolean b = true;

    IAutoLoad auto = (IAutoLoad) object.getModel().getProperties().get(XModelConstants.AUTOLOAD);
    if (auto != null) {
      auto.update(object.getModel());
    }

    XModelObject[] cs = object.getChildren();
    for (int i = 0; i < cs.length; i++) {
      XObjectLoader loader = XModelObjectLoaderUtil.getObjectLoader(cs[i]);
      if (loader != null) b &= loader.update(cs[i]);
    }
    updateClassPath(object);
    ((FileSystemsImpl) object).updateOverlapped();
    return b;
  }
  public boolean save(XModelObject object) {
    if (!fsutil.isModified(object)) return true;

    if (object.getModel().getProperties().get(XModelConstants.AUTOLOAD) != null) {
      return true;
    }

    String s = getEclipseFileName(object, false);
    boolean b = (s == null) ? super.save(object.copy(1)) : saveEclipse(object.copy(1));
    if (((FileSystemsImpl) object).requestSave()) return true;
    XModelObject[] cs = object.getChildren();
    for (int i = 0; i < cs.length; i++) {
      XObjectLoader loader = XModelObjectLoaderUtil.getObjectLoader(cs[i]);
      if (loader != null) b &= loader.save(cs[i]);
    }
    return b;
  }
 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);
   }
 }