예제 #1
0
  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;
  }
 protected void setOtherProperties(XModelObject object, Properties p) {
   String fvi = p.getProperty("from-view-id"); // $NON-NLS-1$
   XModelObject parent = object.getParent();
   while (parent != null && !(parent instanceof JSFNavigationModel)) {
     parent = parent.getParent();
   }
   if (parent != null) {
     JSFNavigationModel m = (JSFNavigationModel) parent;
     int i = m.getRuleCount(fvi);
     p.setProperty("index", "" + i); // $NON-NLS-1$ //$NON-NLS-2$
   }
 }
  public VResult[] check(VObject object) {
    XModelObject o = ((VObjectImpl) object).getModelObject();
    String paramName = o.getAttributeValue("param-name");
    if (paramName == null) return null;
    XModelObject parent = o.getParent();
    if (parent == null || !"WebAppServlet".equals(parent.getModelEntity().getName())) {
      return null;
    }
    if (!paramName.equals("config") && !paramName.startsWith("config/")) return null;

    String value = o.getAttributeValue("param-value");
    if (value == null || value.length() == 0) return null;
    XModel model = getXModel(object);
    XModelObject webRoot = model == null ? null : model.getByPath("FileSystems/WEB-ROOT");
    if (webRoot == null) return null;
    StringTokenizer st = new StringTokenizer(value, ",");
    while (st.hasMoreTokens()) {
      String path = st.nextToken().trim();
      if (path.length() == 0) continue;
      XModelObject fc = XModelImpl.getByRelativePath(model, path);
      if (fc == null) {
        return fire(object, "config.exists", "param-value", path);
      }
      String path2 = path.startsWith("/") ? path.substring(1) : path;
      XModelObject fc2 = webRoot.getChildByPath(path2);
      if (fc2 == null) {
        return fire(object, "config.exists", "param-value", path);
      }
      if (!fc2.getModelEntity().getName().startsWith("StrutsConfig")) {
        return fire(object, "config.valid", "param-value", path);
      }
    }
    return null;
  }
예제 #4
0
 public void update() {
   if (!object.isActive()) {
     if (file == null) return;
     else file = null;
   } else if (file == null) {
     XModelObject f = object;
     while (f != null && f.getFileType() != XModelObject.FILE) f = f.getParent();
     if (f instanceof FileAnyImpl) file = (FileAnyImpl) f;
   }
   if (file == null) {
     fileTimeStamp = -1;
     start = -1;
     end = -1;
     line = -1;
     return;
   }
   long ts = (file == null) ? -1 : file.getTimeStamp();
   if (ts == fileTimeStamp) return;
   fileTimeStamp = ts;
   String text = file.getAsText();
   PositionSearcher searcher = new PositionSearcher();
   searcher.init(text, object, attribute);
   searcher.execute();
   start = searcher.getStartPosition();
   end = searcher.getEndPosition();
   line = computeLine(text, start);
 }
 public static IModelObjectEditorInput createInstance(XModelObject object) {
   object = getMainObject(object);
   IFile f = getFileByObject(object);
   if (f == null && object instanceof FileAnyImpl) {
     XModelObject p = object.getParent();
     if (p instanceof FolderImpl) {
       String path = ((FileAnyImpl) object).getAbsolutePath();
       if (path != null) {
         return new ModelObjectLocationEditorInput(object, new Path(path));
       }
     }
     return new ModelObjectStorageEditorInput(object);
   }
   return (f == null) ? null : new XModelObjectEditorInput(object);
 }