Esempio n. 1
0
  private void parseTLD(XModelObject o, IPath source, LoadedDeclarations ds) {
    TLDLibrary library = new TLDLibrary();
    library.setId(o);
    library.setURI(new XMLValueInfo(o, AbstractTagLib.URI));
    library.setDisplayName(new XMLValueInfo(o, TLDLibrary.DISPLAY_NAME));
    library.setShortName(new XMLValueInfo(o, ATTR_SHORTNAME));
    String version = o.getAttributeValue(TLDLibrary.VERSION);
    if (version == null) {
      if ("FileTLD_1_2".equals(o.getModelEntity().getName())) { // $NON-NLS-1$
        version = "1.2"; // $NON-NLS-1$
      } else {
        version = "1.1"; // $NON-NLS-1$
      }
      library.setVersion(version);
    } else {
      library.setVersion(new XMLValueInfo(o, TLDLibrary.VERSION));
    }

    ds.getLibraries().add(library);

    XModelObject[] ts = o.getChildren();
    for (XModelObject t : ts) {
      if (t.getModelEntity().getName().startsWith("TLDTag")) { // $NON-NLS-1$
        AbstractComponent tag = new TLDTag();
        tag.setId(t);

        tag.setName(new XMLValueInfo(t, XMLStoreConstants.ATTR_NAME));
        tag.setDescription(new XMLValueInfo(t, AbstractComponent.DESCRIPTION));
        tag.setComponentClass(new XMLValueInfo(t, ATTR_TAGCLASS));
        tag.setCanHaveBody(new XMLValueInfo(t, ATTR_BODY_CONTENT));

        XModelObject[] as = t.getChildren();
        for (XModelObject a : as) {
          if (a.getModelEntity().getName().startsWith("TLDAttribute")) { // $NON-NLS-1$
            AbstractAttribute attr = new TLDAttribute();
            attr.setId(a);
            attr.setName(new XMLValueInfo(a, XMLStoreConstants.ATTR_NAME));
            attr.setDescription(new XMLValueInfo(a, AbstractComponent.DESCRIPTION));
            attr.setRequired(new XMLValueInfo(a, AbstractAttribute.REQUIRED));

            tag.addAttribute(attr);
          }
        }

        library.addComponent(tag);
      }
    }
    XModelObject functions = o.getChildByPath("Functions"); // $NON-NLS-1$
    if (functions != null) {
      ts = functions.getChildren();
      for (XModelObject t : ts) {
        ELFunction f = new ELFunction();
        f.setId(t);
        f.setName(new XMLValueInfo(t, XModelObjectConstants.ATTR_NAME));
        f.setSignature(new XMLValueInfo(t, ATTR_FUNC_SIGN));
        f.setFunctionClass(new XMLValueInfo(t, ELFunction.FUNCTION_CLASS));
        library.addFunction(f);
      }
    }
  }
  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);
  }
Esempio n. 3
0
  private void parseFaceletTaglib(XModelObject o, IPath source, LoadedDeclarations ds) {
    FaceletTagLibrary library = new FaceletTagLibrary();
    library.setId(o);
    library.setURI(new XMLValueInfo(o, AbstractTagLib.URI));

    ds.getLibraries().add(library);

    XModelObject[] os = o.getChildren();
    for (XModelObject t : os) {
      String entity = t.getModelEntity().getName();
      if (entity.startsWith("FaceletTaglibTag")) { // $NON-NLS-1$
        FaceletTag tag = new FaceletTag();
        tag.setId(t);
        tag.setName(new XMLValueInfo(t, ATTR_TAG_NAME));
        tag.setDescription(new XMLValueInfo(t, AbstractComponent.DESCRIPTION));
        XModelObject d = t.getChildByPath("declaration"); // $NON-NLS-1$
        if (d != null
            && d.getModelEntity().getName().startsWith("FaceletTaglibComponent")) { // $NON-NLS-1$
          String componentType = d.getAttributeValue(ATTR_COMPONENT_TYPE); // $NON-NLS-1$
          if (componentType != null && componentType.length() > 0) {
            tag.setComponentType(new XMLValueInfo(d, ATTR_COMPONENT_TYPE)); // $NON-NLS-1$
          }
        }
        XModelObject[] as = t.getChildren();
        for (XModelObject a : as) {
          String entity2 = a.getModelEntity().getName();
          if (entity2.startsWith("FaceletTaglibAttribute")) { // $NON-NLS-1$
            FaceletAttribute attr = new FaceletAttribute();
            attr.setId(a);
            attr.setName(new XMLValueInfo(a, XMLStoreConstants.ATTR_NAME));
            attr.setDescription(new XMLValueInfo(a, AbstractComponent.DESCRIPTION));
            attr.setRequired(new XMLValueInfo(a, AbstractAttribute.REQUIRED));

            tag.addAttribute(attr);
          }
        }
        library.addComponent(tag);
      } else if (entity.startsWith("FaceletTaglibFunction")) { // $NON-NLS-1$
        ELFunction f = new ELFunction();
        f.setId(t);
        f.setName(new XMLValueInfo(t, ATTR_FUNC_NAME));
        f.setSignature(new XMLValueInfo(t, ATTR_FUNC_SIGN));
        f.setFunctionClass(new XMLValueInfo(t, ELFunction.FUNCTION_CLASS));
        library.addFunction(f);
      }
    }
  }
 public String[] getSelectedProperties() {
   support.store();
   XModelObject[] cs = propertyListObject.getChildren();
   String[] s = new String[cs.length];
   for (int i = 0; i < cs.length; i++) {
     s[i] = cs[i].getAttributeValue("name"); // $NON-NLS-1$
   }
   return s;
 }
 void printPaths(XModelObject o) {
   if (o == null) {
     System.out.println("null");
     return;
   }
   System.out.println(o.getPath());
   XModelObject[] cs = o.getChildren();
   for (int i = 0; i < cs.length; i++) printPaths(cs[i]);
 }
 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);
     }
   }
 }
Esempio n. 7
0
  private void parseFacesConfig(XModelObject o, IPath source, LoadedDeclarations ds) {
    FacesConfigTagLibrary library = new FacesConfigTagLibrary();
    library.setId(o);
    library.setURI("TODO"); // TODO what is the URI? //$NON-NLS-1$

    ds.getLibraries().add(library);

    XModelObject componentFolder = o.getChildByPath("Components"); // $NON-NLS-1$
    if (componentFolder == null) return;
    XModelObject[] os = componentFolder.getChildren();
    for (XModelObject c : os) {
      FacesConfigComponent component = new FacesConfigComponent();
      component.setId(c);
      // what else can we take for the name? only attribute 'component-type' is available
      component.setName(new XMLValueInfo(c, AbstractComponent.COMPONENT_TYPE));

      component.setComponentClass(new XMLValueInfo(c, AbstractComponent.COMPONENT_CLASS));
      component.setComponentType(new XMLValueInfo(c, AbstractComponent.COMPONENT_TYPE));
      component.setDescription(new XMLValueInfo(c, AbstractComponent.DESCRIPTION));

      XModelObject[] as = c.getChildren();
      for (XModelObject child : as) {
        String entity = child.getModelEntity().getName();
        if (entity.startsWith("JSFAttribute")) { // $NON-NLS-1$
          FacesConfigAttribute attr = new FacesConfigAttribute();
          attr.setId(child);
          attr.setName(new XMLValueInfo(child, ATTR_ATTRIBUTE_NAME));
          component.addAttribute(attr);
        } else if (entity.startsWith("JSFFacet")) { // $NON-NLS-1$
          Facet f = new Facet();
          f.setId(child);
          f.setName(new XMLValueInfo(child, ATTR_FACET_NAME));
          f.setDescription(new XMLValueInfo(child, AbstractComponent.DESCRIPTION));
          component.addFacet(f);
        }
      }
      library.addComponent(component);
    }
  }
 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();
 }
 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);
   }
 }