Author: scabanovich
Date: 2007-08-08 10:51:47 -0400 (Wed, 08 Aug 2007)
New Revision: 2962
Removed:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/bean/AnnotatedBeans.java
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBeans.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java
Log:
JBIDE-672
Deleted:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/bean/AnnotatedBeans.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/bean/AnnotatedBeans.java 2007-08-08
14:04:13 UTC (rev 2961)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/bean/AnnotatedBeans.java 2007-08-08
14:51:47 UTC (rev 2962)
@@ -1,205 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
- * Distributed under license by Red Hat, Inc. All rights reserved.
- * This program is made available under the terms of the
- * Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at
http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
- ******************************************************************************/
-package org.jboss.tools.jsf.model.helpers.bean;
-
-import java.util.*;
-import org.eclipse.core.resources.*;
-import org.eclipse.jdt.core.*;
-import org.jboss.tools.common.model.*;
-import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.jsf.JSFModelPlugin;
-
-public class AnnotatedBeans {
-
- public static AnnotatedBeans getAnnotatedBeans(XModel model) {
- AnnotatedBeans bs = (AnnotatedBeans)model.getManager("AnnotatedBeans");
- if(bs == null) {
- bs = new AnnotatedBeans();
- bs.setModel(model);
- model.addManager("AnnotatedBeans", bs);
- }
- return bs;
- }
-
- XModel model;
- IProject project;
- Map<String,XModelObject> beans = new HashMap<String,XModelObject>();
-
-// String annotationType = "org.jboss.seam.annotations.Name";
-
- private AnnotatedBeans() {}
-
- public void setModel(XModel model) {
- this.model = model;
- try {
- update();
- } catch (Exception e) {
- JSFModelPlugin.getPluginLog().logError(e);
- }
- }
-
- public XModelObject[] getBeans() {
- return (XModelObject[])beans.values().toArray(new XModelObject[0]);
- }
-
- public XModelObject findBean(String name) {
- return (XModelObject)beans.get(name);
- }
-
- public void update() throws Exception {
- // TODO: this method is highly ineffective. We should do this in a builder
incrementally!
- project = EclipseResourceUtil.getProject(model.getRoot());
- IResource[] src = EclipseResourceUtil.getJavaSourceRoots(project);
- if(src == null) {
- return;
- }
-// IJavaProject javaProject = (IJavaProject)project.getNature(JavaCore.NATURE_ID);
-
-/**
- //This is how we can obtain annotated seam components.
- //However, it may be not needed now since we have separate Seam Components view
- //and separate code assist based on seam model.
- ISeamProject seamProject = SeamCorePlugin.getSeamProject(project, true);
-
- Set<ISeamComponent> cs = seamProject.getComponents();
-
- Set<String> set = new HashSet<String>();
- for (ISeamComponent c : cs) {
- String name = c.getName();
- String cls = c.getClassName();
- if(cls == null) cls = "";
- XModelObject o = beans.get(name);
- if(o == null) {
- o = model.createModelObject("JSFManagedBean", null);
- o.setAttributeValue("managed-bean-name", name);
- o.setAttributeValue("managed-bean-class", cls);
- beans.put(name, o);
- } else {
- o.setAttributeValue("managed-bean-class", cls);
- }
- set.add(name);
- }
- // TODO: why does the beans set have to double checkked for duplicates ?
- Iterator<String> it = beans.keySet().iterator();
- while(it.hasNext()) {
- if(!set.contains(it.next())) it.remove();
- }
-*/
- }
-
- void collectCompilationUnits(IParent parent, Set<ICompilationUnit> units) throws
Exception {
- if(parent instanceof IPackageFragmentRoot
- || parent instanceof IPackageFragment) {
- IJavaElement[] cs = parent.getChildren();
- for (int i = 0; i < cs.length; i++) {
- if(cs[i] instanceof ICompilationUnit) {
- units.add((ICompilationUnit)cs[i]);
- } else if(cs[i] instanceof IParent) {
- collectCompilationUnits((IParent)cs[i], units);
- }
- }
- }
- }
-
-// class ASTRequestorImpl extends ASTRequestor {
-// private ASTVisitorImpl visitor = new ASTVisitorImpl();
-// private Map<String, String> beans = new HashMap<String, String>();
-//
-// public Map<String, String> getBeans() {
-// return beans;
-// }
-//
-// public void acceptAST(ICompilationUnit source, CompilationUnit ast) {
-// visitor.name = null;
-//
-// try {
-// IType[] ts = source.getTypes();
-// if(ts != null && ts.length > 0) {
-// visitor.type = ts[0];
-// }
-// } catch (Exception e) {
-// //ignore
-// }
-// ast.accept(visitor);
-// if(visitor.name != null && visitor.type != null) {
-// String n = visitor.type.getElementName();
-// n = getResolvedType(visitor.type, n);
-// beans.put(visitor.name, n);
-// }
-// }
-// }
-
-// class ASTVisitorImpl extends ASTVisitor {
-// IType type;
-// String name = null;
-// public boolean visit(SingleMemberAnnotation node) {
-// if(!checkAnnotationType(node)) return false;
-// checkExpression(node.getValue());
-// return true;
-// }
-// public boolean visit(NormalAnnotation node) {
-// if(!checkAnnotationType(node)) return false;
-// List vs = node.values();
-// if(vs != null) for (int i = 0; i < vs.size(); i++) {
-// MemberValuePair p = (MemberValuePair)vs.get(i);
-// if("value".equals(p.getName().getIdentifier())) {
-// checkExpression(p.getValue());
-// }
-// }
-// return true;
-// }
-//
-// boolean checkAnnotationType(Annotation node) {
-// Name nm = node.getTypeName();
-// if(nm instanceof SimpleName) {
-// SimpleName sn = (SimpleName)nm;
-// String n = sn.getIdentifier();
-// if(type != null) {
-// n = getResolvedType(type, n);
-// }
-// if(!annotationType.equals(n)) return false;
-// } else if(nm instanceof QualifiedName) {
-// QualifiedName qn = (QualifiedName)nm;
-// if(!qn.getFullyQualifiedName().equals(annotationType)) return false;
-// //improve
-// } else {
-// return false;
-// }
-// return true;
-// }
-//
-// void checkExpression(Expression exp) {
-// if(exp instanceof StringLiteral) {
-// name = ((StringLiteral)exp).getLiteralValue();
-// }
-// }
-//
-// public boolean visit(Block node) {
-// return false;
-// }
-// public boolean visit(MethodDeclaration node) {
-// return false;
-// }
-// }
-
- String getResolvedType(IType type, String n) {
- try {
- String[][] rs = type.resolveType(n);
- if(rs != null && rs.length > 0) {
- return (rs[0][0].length() == 0) ? rs[0][1] : rs[0][0] + "." + rs[0][1];
- }
- } catch (Exception e) {
- //ignore
- }
- return n;
- }
-
-}
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBeans.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBeans.java 2007-08-08
14:04:13 UTC (rev 2961)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBeans.java 2007-08-08
14:51:47 UTC (rev 2962)
@@ -23,7 +23,6 @@
import org.jboss.tools.common.model.event.XModelTreeEvent;
import org.jboss.tools.common.model.impl.RegularObjectImpl;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
-import org.jboss.tools.jsf.model.helpers.bean.AnnotatedBeans;
import org.jboss.tools.jst.web.model.pv.WebProjectNode;
public class JSFProjectBeans extends RegularObjectImpl implements WebProjectNode {
@@ -55,9 +54,6 @@
process(fcs[i], BeanConstants.REFERENCED_BEAN_CONSTANTS, map, classes);
}
- AnnotatedBeans bs = AnnotatedBeans.getAnnotatedBeans(getModel());
- process(bs.getBeans(), BeanConstants.MANAGED_BEAN_CONSTANTS, map, classes);
-
Iterator<XModelObject> it = map.values().iterator();
while(it.hasNext()) {
it.next().removeFromParent();
@@ -162,11 +158,6 @@
valid = false;
Display.getDefault().asyncExec(new XJob.XRunnable() {
public void run() {
- try {
- AnnotatedBeans.getAnnotatedBeans(getModel()).update();
- } catch (Exception e) {
- //ignore
- }
fireStructureChanged(XModelTreeEvent.STRUCTURE_CHANGED, this);
}
public String getId() {
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java
===================================================================
---
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java 2007-08-08
14:04:13 UTC (rev 2961)
+++
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java 2007-08-08
14:51:47 UTC (rev 2962)
@@ -22,7 +22,6 @@
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
import org.jboss.tools.jsf.model.JSFConstants;
-import org.jboss.tools.jsf.model.helpers.bean.AnnotatedBeans;
import org.jboss.tools.jsf.model.helpers.converter.*;
import org.jboss.tools.jsf.model.helpers.pages.OpenCaseHelper;
import org.jboss.tools.jsf.model.helpers.pages.ResourceBundleHelper;
@@ -183,10 +182,6 @@
getBeans(os[i], BeanConstants.MANAGED_BEAN_CONSTANTS, list);
getBeans(os[i], BeanConstants.REFERENCED_BEAN_CONSTANTS, list);
}
- XModelObject[] bs = AnnotatedBeans.getAnnotatedBeans(model).getBeans();
- for (int i = 0; i < bs.length; i++) {
- list.add(bs[i].getAttributeValue(BeanConstants.MANAGED_BEAN_CONSTANTS.nameAttribute));
- }
return list;
}
@@ -211,9 +206,6 @@
WebProjectNode conf = (WebProjectNode)root.getChildByPath("Configuration");
if(n == null || conf == null) return EMPTY_LIST;
XModelObject bean = findBean(conf, beanName);
- if(bean == null) {
- bean = AnnotatedBeans.getAnnotatedBeans(model).findBean(beanName);
- }
if(bean == null) return EMPTY_LIST;
List<Object> list = new ArrayList<Object>();
XModelObject beanClass = findBeanClass(n, bean);
@@ -328,11 +320,6 @@
bean = os[i].getChildByPath("Referenced Beans/" + beanName);
if(bean != null) return bean;
}
- ////to be committed
- XModelObject[] bs = AnnotatedBeans.getAnnotatedBeans(conf.getModel()).getBeans();
- for (int i = 0; i < bs.length; i++) {
- if(beanName.equals(bs[i].getPathPart())) return bs[i];
- }
return null;
}