コード例 #1
0
  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);
  }
コード例 #2
0
 public void updateSrcs(XModelObject object) {
   IAutoLoad auto = (IAutoLoad) object.getModel().getProperties().get(XModelConstants.AUTOLOAD);
   if (auto == null && WatcherLoader.isLocked(object.getModel())) {
     return;
   }
   _updateSrcs(object);
 }
コード例 #3
0
ファイル: XMLScanner.java プロジェクト: grdryn/jbosstools-jst
  public LoadedDeclarations parse(XModelObject o, IPath source, IKbProject sp) {
    if (o == null) return null;

    if (o.getParent() instanceof FolderImpl) {
      IFile f = ResourcesPlugin.getWorkspace().getRoot().getFile(source);
      if (f != null && f.exists()) {
        try {
          ((FolderImpl) o.getParent()).updateChildFile(o, f.getLocation().toFile());
        } catch (XModelException e) {
          ModelPlugin.getPluginLog().logError(e);
        }
        if (o.getParent() == null) {
          boolean b = isLikelyComponentSource(f);
          if (!b) return null;
          o = EclipseResourceUtil.getObjectByResource(o.getModel(), f);
          if (o == null) return null;
        }
      }
    }

    LoadedDeclarations ds = new LoadedDeclarations();
    if (LibraryScanner.isTLDFile(o)) {
      parseTLD(o, source, ds);
    } else if (LibraryScanner.isFaceletTaglibFile(o)) {
      parseFaceletTaglib(o, source, ds);
    } else if (LibraryScanner.isFacesConfigFile(o)) {
      parseFacesConfig(o, source, ds);
    }
    return ds;
  }
コード例 #4
0
 private String getEclipseFileName(XModelObject object, boolean load) {
   String project = object.getModel().getProperties().getProperty(IModelNature.ECLIPSE_PROJECT);
   if (project == null) return null;
   String fn = project + XModelObjectConstants.SEPARATOR + IModelNature.PROJECT_FILE;
   if (!load || new File(fn).exists()) return fn;
   return null;
 }
コード例 #5
0
 public static XModelObject getJarEntryObject(IProject p, String jarFile, String entry) {
   if (p == null) {
     IFile f = EclipseResourceUtil.getFile(jarFile);
     if (f == null) return null;
     p = f.getProject();
   }
   if (p == null) return null;
   IModelNature n = EclipseResourceUtil.getModelNature(p);
   XModel model = null;
   if (n != null) {
     model = n.getModel();
   } else {
     XModelObject o = EclipseResourceUtil.createObjectForResource(p);
     if (o != null) model = o.getModel();
   }
   if (model == null) return null;
   XModelObject[] fs = FileSystemsHelper.getFileSystems(model).getChildren();
   for (XModelObject s : fs) {
     String loc =
         Paths.expand(s.get(XModelObjectConstants.ATTR_NAME_LOCATION), model.getProperties());
     if (new File(loc).equals(new File(jarFile))) {
       XModelObject result = s.getChildByPath(entry);
       if (result == null && entry != null) {
         int q = entry.indexOf('/');
         int d = entry.indexOf('.');
         if (q > d && d >= 0) {
           String entry1 = entry.substring(0, q).replace('.', '/') + entry.substring(q);
           result = s.getChildByPath(entry1);
         }
       }
       if (result != null) return result;
     }
   }
   return (n == null) ? null : n.getModel().getByPath("/" + entry); // $NON-NLS-1$
 }
コード例 #6
0
  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;
  }
コード例 #7
0
 public static XModel getXModel(IFile file) {
   if (file == null) return null;
   XModelObject fs = EclipseResourceUtil.getObjectByResource(file);
   if (fs != null) return fs.getModel();
   IProject project = file.getProject();
   IModelNature nature = EclipseResourceUtil.getModelNature(project);
   return (nature == null) ? null : nature.getModel();
 }
コード例 #8
0
 private void saveWorkspaceHomeAttr(Element element, XModelObject o) {
   Properties p = o.getModel().getProperties();
   String project = p.getProperty(IModelNature.ECLIPSE_PROJECT);
   String workspace = p.getProperty(XModelConstants.WORKSPACE);
   if (project == null) return;
   String relative =
       workspace.startsWith(project + XModelObjectConstants.SEPARATOR)
           ? "." + workspace.substring(project.length())
           : workspace; //$NON-NLS-1$
   element.setAttribute("workspace-home", relative); // $NON-NLS-1$
 }
コード例 #9
0
 private void setSelectedProperties(String[] s) {
   XModelObject[] cs = propertyListObject.getChildren();
   for (int i = 0; i < cs.length; i++) cs[i].removeFromParent();
   for (int i = 0; i < s.length; i++) {
     XModelObject c =
         propertyListObject
             .getModel()
             .createModelObject("JSFDataTableProperty", null); // $NON-NLS-1$
     c.setAttributeValue("name", s[i]); // $NON-NLS-1$
     propertyListObject.addChild(c);
   }
   propertyListEditor.update();
 }
コード例 #10
0
  private void updateLibs(XModelObject object) {
    if (WatcherLoader.isLocked(object.getModel())) {
      return;
    }
    IProject project = EclipseResourceUtil.getProject(object);
    if (project == null) return;
    XModelObject lib = validateLib(object);
    //    	if(lib == null) {
    //    		return;
    //    	}

    Libs libs = FileSystemsHelper.getLibs(object);
    if (libs != null) libs.update();
  }
コード例 #11
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);
   }
 }
コード例 #12
0
  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;
  }
コード例 #13
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;
 }
コード例 #14
0
  private String[] getAvailableProperties(String value) {
    if (value == null || value.length() == 0) {
      return new String[0];
    }
    JSFPromptingProvider provider = new JSFPromptingProvider();

    XModel xModel = getXModel();
    if (xModel == null) {
      // lets create fake model, which can build properties for the value.
      IFile file = (IFile) properties.get("file"); // $NON-NLS-1$
      if (file != null) {
        XModelObject f = EclipseResourceUtil.createObjectForResource(file);
        if (f != null) {
          xModel = f.getModel();
        }
      }
    }
    if (xModel == null) {
      return new String[0];
    }

    return (String[]) provider.buildBeanProperties(xModel, value, null).toArray(new String[0]);
  }
コード例 #15
0
 private XModelObject getWeb(XModelObject object) {
   return object.getModel().getByPath("Web"); // $NON-NLS-1$
 }
コード例 #16
0
 public String fileroot(XModelObject object) {
   return XModelConstants.getWorkspace(object.getModel()) + XModelObjectConstants.SEPARATOR;
 }