JBoss Tools SVN: r2362 - in trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core: scanner/java and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-07-09 12:37:13 -0400 (Mon, 09 Jul 2007)
New Revision: 2362
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentMethod.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java
Log:
EXIN-217 Java source scanner is being developed.
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java 2007-07-09 14:46:12 UTC (rev 2361)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/AbstractContextVariable.java 2007-07-09 16:37:13 UTC (rev 2362)
@@ -1,6 +1,8 @@
package org.jboss.tools.seam.internal.core;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -10,6 +12,7 @@
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.core.ScopeType;
import org.jboss.tools.seam.core.event.Change;
+import org.jboss.tools.seam.internal.core.scanner.java.ValueInfo;
public class AbstractContextVariable implements ISeamContextVariable, ISeamTextSourceReference {
/**
@@ -28,6 +31,8 @@
protected ScopeType scopeType;
protected String scope;
+ protected Map<String,ValueInfo> attributes = new HashMap<String, ValueInfo>();
+
public Object getId() {
return id;
}
@@ -63,6 +68,9 @@
public void setScopeAsString(String scope) {
try {
+ if(scope != null && scope.indexOf('.') > 0) {
+ scope = scope.substring(scope.lastIndexOf('.'));
+ }
this.scopeType = scope == null || scope.length() == 0 ? ScopeType.UNSPECIFIED : ScopeType.valueOf(scope.toUpperCase());
} catch (Exception e) {
//ignore
@@ -116,4 +124,14 @@
return s1 == null ? s2 == null : s1.equals(s2);
}
+ public void setName(ValueInfo value) {
+ attributes.put(ISeamXmlComponentDeclaration.NAME, value);
+ name = value == null ? null : value.getValue();
+ }
+
+ public void setScope(ValueInfo value) {
+ attributes.put(ISeamXmlComponentDeclaration.SCOPE, value);
+ setScopeAsString(value == null ? null : value.getValue());
+ }
+
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java 2007-07-09 14:46:12 UTC (rev 2361)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java 2007-07-09 16:37:13 UTC (rev 2362)
@@ -28,8 +28,6 @@
public class SeamAnnotatedFactory extends SeamJavaContextVariable implements ISeamAnnotatedFactory {
boolean autoCreate = false;
- protected Map<String,ValueInfo> attributes = new HashMap<String, ValueInfo>();
-
public IMethod getSourceMethod() {
return (IMethod)javaSource;
}
@@ -82,16 +80,6 @@
return reference;
}
- public void setName(ValueInfo value) {
- attributes.put(ISeamXmlComponentDeclaration.NAME, value);
- name = value == null ? null : value.getValue();
- }
-
- public void setScope(ValueInfo value) {
- attributes.put(ISeamXmlComponentDeclaration.SCOPE, value);
- setScopeAsString(value == null ? null : value.getValue());
- }
-
public void setAutoCreate(ValueInfo value) {
attributes.put(ISeamXmlComponentDeclaration.AUTO_CREATE, value);
setAutoCreate(value != null && "true".equals(value.getValue()));
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentMethod.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentMethod.java 2007-07-09 14:46:12 UTC (rev 2361)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentMethod.java 2007-07-09 16:37:13 UTC (rev 2362)
@@ -37,6 +37,10 @@
public IMember getSourceMember() {
return javaSource;
}
+
+ public void setSourceMember(IMember javaSource) {
+ this.javaSource = javaSource;
+ }
public int getLength() {
return 0;
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java 2007-07-09 14:46:12 UTC (rev 2361)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java 2007-07-09 16:37:13 UTC (rev 2362)
@@ -82,6 +82,10 @@
}
String resolveType(Annotation node) {
+ return resolveType(type, node);
+ }
+
+ static String resolveType(IType type, Annotation node) {
Name nm = node.getTypeName();
if(nm instanceof SimpleName) {
SimpleName sn = (SimpleName)nm;
@@ -96,7 +100,7 @@
return null;
}
- boolean isSeamAnnotationType(String n) {
+ static boolean isSeamAnnotationType(String n) {
return n != null && (n.startsWith(SEAM_ANNOTATION_TYPE_PREFIX)
|| n.equals(STATEFUL_ANNOTATION_TYPE));
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-09 14:46:12 UTC (rev 2361)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-09 16:37:13 UTC (rev 2362)
@@ -10,22 +10,28 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core.scanner.java;
-import java.util.HashSet;
-import java.util.Iterator;
+import java.util.ArrayList;
import java.util.List;
import java.util.Set;
import org.eclipse.jdt.core.IField;
-import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.Annotation;
+import org.eclipse.jdt.core.dom.ArrayInitializer;
import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.NormalAnnotation;
+import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
import org.eclipse.jdt.core.dom.VariableDeclaration;
+import org.jboss.tools.seam.core.BijectedAttributeType;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
+import org.jboss.tools.seam.internal.core.BijectedAttribute;
+import org.jboss.tools.seam.internal.core.Role;
import org.jboss.tools.seam.internal.core.SeamAnnotatedFactory;
+import org.jboss.tools.seam.internal.core.SeamComponentMethod;
import org.jboss.tools.seam.internal.core.SeamJavaComponentDeclaration;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
@@ -37,7 +43,7 @@
public class ComponentBuilder implements SeamAnnotations {
LoadedDeclarations ds = null;
- AnnotatedASTNode annotatedType = null;
+ AnnotatedASTNode<?> annotatedType = null;
Set<AnnotatedASTNode<FieldDeclaration>> annotatedFields = null;
Set<AnnotatedASTNode<MethodDeclaration>> annotatedMethods = null;
@@ -89,8 +95,8 @@
processFactories();
processBijections();
processComponentMethods();
+ processRoles();
- //TODO
}
void processFactories() {
@@ -105,7 +111,6 @@
factoryName.valueLength = m.getName().getLength();
factoryName.valueStartPosition = m.getName().getStartPosition();
}
- System.out.println("");
ValueInfo scope = ValueInfo.getValueInfo(a, ISeamXmlComponentDeclaration.SCOPE);
ValueInfo autoCreate = ValueInfo.getValueInfo(a, "autoCreate");
@@ -121,18 +126,86 @@
}
void processBijections() {
- //TODO
+ for (AnnotatedASTNode<MethodDeclaration> n: annotatedMethods) {
+ Annotation in = findAnnotation(n, IN_ANNOTATION_TYPE);
+ Annotation out = findAnnotation(n, OUT_ANNOTATION_TYPE);
+ if(in == null || out == null) continue;
+ MethodDeclaration m = n.getNode();
+
+ BijectedAttribute att = new BijectedAttribute();
+ component.getBijectedAttributes().add(att);
+
+ BijectedAttributeType[] types = (in == null) ? new BijectedAttributeType[]{BijectedAttributeType.OUT}
+ : (out == null) ? new BijectedAttributeType[]{BijectedAttributeType.IN}
+ : new BijectedAttributeType[]{BijectedAttributeType.IN, BijectedAttributeType.OUT};
+ att.setTypes(types);
+
+ Annotation a = in != null ? in : out;
+ ValueInfo name = ValueInfo.getValueInfo(a, null);
+ if(name == null) {
+ name = new ValueInfo();
+ name.value = m.getName().getIdentifier();
+ }
+
+ att.setName(name.getValue());
+
+ ValueInfo scope = ValueInfo.getValueInfo(a, "scope");
+ if(scope != null) att.setScopeAsString(scope.getValue());
+
+ att.setMember(findMethod(m));
+ }
}
void processComponentMethods() {
- //TODO
+ for (AnnotatedASTNode<MethodDeclaration> n: annotatedMethods) {
+ Annotation aCreate = findAnnotation(n, CREATE_ANNOTATION_TYPE);
+ Annotation aDestroy = findAnnotation(n, DESTROY_ANNOTATION_TYPE);
+ if(aCreate == null || aDestroy == null) continue;
+ MethodDeclaration m = n.getNode();
+
+ SeamComponentMethod cm = new SeamComponentMethod();
+ component.getMethods().add(cm);
+
+ if(aCreate != null) cm.setCreate(true);
+ if(aDestroy != null) cm.setDestroy(true);
+
+ cm.setSourceMember(findMethod(m));
+ }
}
void processRoles() {
- //TODO
+ Annotation roles = findAnnotation(annotatedType, ROLES_ANNOTATION_TYPE);
+ if(roles != null) {
+ RolesVisitor visitor = new RolesVisitor((IType)component.getSourceMember());
+ roles.accept(visitor);
+ List<Annotation> rs = visitor.annotations;
+ if(rs != null) for (Annotation role : rs) {
+ createRole(role);
+ }
+ }
+ ResolvedAnnotation[] as = annotatedType.getAnnotations();
+ for (int i = 0; i < as.length; i++) {
+ if(ROLE_ANNOTATION_TYPE.equals(as[i].getType())) {
+ createRole(as[i].getAnnotation());
+ }
+ }
}
+
+ void createRole(Annotation role) {
+ Role r = new Role();
+ r.setSourcePath(component.getSourcePath());
+ r.setId(component.getSourceMember());
+
+ ValueInfo name = ValueInfo.getValueInfo(role, "name");
+ if(name == null) return;
+
+ r.setName(name);
- private Annotation findAnnotation(AnnotatedASTNode n, String type) {
+ ValueInfo scope = ValueInfo.getValueInfo(role, "scope");
+ if(scope != null) r.setScope(scope);
+ }
+
+ private Annotation findAnnotation(AnnotatedASTNode<?> n, String type) {
ResolvedAnnotation[] as = n.getAnnotations();
for (int i = 0; i < as.length; i++) {
if(type.equals(as[i].getType())) return as[i].getAnnotation();
@@ -204,3 +277,38 @@
}
}
+
+class RolesVisitor extends ASTVisitor implements SeamAnnotations {
+ boolean arrayFound = false;
+ IType type;
+ List<Annotation> annotations = new ArrayList<Annotation>();
+
+ public RolesVisitor(IType type) {
+ this.type = type;
+ }
+
+ public boolean visit(SingleMemberAnnotation node) {
+ if(arrayFound) {
+ String typeName = ASTVisitorImpl.resolveType(type, node);
+ if(!ROLE_ANNOTATION_TYPE.equals(typeName)) return false;
+ annotations.add(node);
+ return false;
+ }
+ return true;
+ }
+
+ public boolean visit(NormalAnnotation node) {
+ if(arrayFound) {
+ String typeName = ASTVisitorImpl.resolveType(type, node);
+ if(!ROLE_ANNOTATION_TYPE.equals(typeName)) return false;
+ annotations.add(node);
+ }
+ return false;
+ }
+
+ public boolean visit(ArrayInitializer node) {
+ arrayFound = true;
+ return true;
+ }
+
+}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java 2007-07-09 14:46:12 UTC (rev 2361)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/SeamAnnotations.java 2007-07-09 16:37:13 UTC (rev 2362)
@@ -15,6 +15,8 @@
public static String FACTORY_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX + "Factory";
+ public static String ROLES_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX + "Roles";
+ public static String ROLE_ANNOTATION_TYPE = SEAM_ANNOTATION_TYPE_PREFIX + "Role";
public static String STATEFUL_ANNOTATION_TYPE = "javax.ejb.Stateful";
17 years, 5 months
JBoss Tools SVN: r2361 - in trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor: src/org/jboss/tools/hibernate/ui/veditor/editors/model and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: mdryakhlenkov
Date: 2007-07-09 10:46:12 -0400 (Mon, 09 Jul 2007)
New Revision: 2361
Modified:
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/.classpath
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmShape.java
trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialRootClass.java
Log:
EXIN-366 Adding elements on the diagram by double-click on fields of classes which have additional information in mapping files
Dislaying identifier class (inner class of RootClass) as separate element of diagram.
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/.classpath
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/.classpath 2007-07-09 14:35:19 UTC (rev 2360)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/.classpath 2007-07-09 14:46:12 UTC (rev 2361)
@@ -1,7 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
- <classpathentry kind="output" path="bin"/>
-</classpath>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2007-07-09 14:35:19 UTC (rev 2360)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmDiagram.java 2007-07-09 14:46:12 UTC (rev 2361)
@@ -188,16 +188,18 @@
if(!isConnectionExist(singleTableSubclassShape, shape))
new Connection(singleTableSubclassShape, shape);
}
-// if (persistentClass.getPersistentClassMapping() != null) {
-// Iterator iter =((IHibernateClassMapping)(persistentClass).getPersistentClassMapping()).getJoinIterator();
-// while ( iter.hasNext() ) {
-// IJoinMapping jm =(IJoinMapping)iter.next();
-// shape = (OrmShape)elements.get(jm.getTable().getName());
-// if(shape == null)
-// shape = getOrCreateDatabaseTable(jm.getTable());
-// createConnections(classShape, shape);
-// }
-// }
+
+ if (persistentClass.getIdentifier() instanceof Component) {
+ Component identifier = (Component)persistentClass.getIdentifier();
+ if (!identifier.getComponentClassName().equals(identifier.getOwner().getClassName())) {
+ OrmShape componentClassShape = elements.get(identifier.getComponentClassName());
+ if (componentClassShape == null && persistentClass instanceof RootClass) {
+ componentClassShape = getOrCreateComponentClass(((RootClass)persistentClass).getIdentifierProperty());
+ OrmShape tableShape = getOrCreateDatabaseTable(identifier.getTable());
+ createConnections(componentClassShape, tableShape);
+ }
+ }
+ }
}
return classShape;
}
@@ -223,14 +225,6 @@
// getOrCreatePersistentClass(singleTableSubclass, null);
}
}
-// IPersistentClassMapping persistentClassMappings[] = databaseTable.getPersistentClassMappings();
-// for (int j = 0; j < persistentClassMappings.length; j++) {
-// if(persistentClassMappings[j].getPersistentClass() != null ) {
-// OrmShape shape = (OrmShape)elements.get(persistentClassMappings[j].getPersistentClass().getName());
-// if(shape == null)
-// getOrCreatePersistentClass(persistentClassMappings[j].getPersistentClass(), null);
-// }
-// }
}
}
return tableShape;
@@ -372,20 +366,24 @@
}
}
- private OrmShape getOrCreateComponentClass(Property property) {
+ public OrmShape getOrCreateComponentClass(Property property) {
OrmShape classShape = null;
- Component component = (Component)((Collection)property.getValue()).getElement();
- if (component != null) {
+ if (property.getValue() instanceof Collection) {
+ Component component = (Component)((Collection)property.getValue()).getElement();
+ if (component != null) {
+ classShape = createShape(property);
+ OrmShape tableShape = (OrmShape)elements.get(component.getTable().getSchema() + "." + component.getTable().getName());
+ if (tableShape == null) tableShape = getOrCreateDatabaseTable(component.getTable());
+ createConnections(classShape, tableShape);
+ if(!isConnectionExist(classShape, tableShape))
+ new Connection(classShape, tableShape);
+ Shape parentShape = ((SpecialOrmShape)classShape).getParentShape();
+ OrmShape parentClassShape = (OrmShape)elements.get(((Property)parentShape.getOrmElement()).getPersistentClass().getClassName());
+ if(!isConnectionExist(parentShape, parentClassShape))
+ new Connection(parentShape, parentClassShape);
+ }
+ } else if (property.getValue() instanceof Component) {
classShape = createShape(property);
- OrmShape tableShape = (OrmShape)elements.get(component.getTable().getSchema() + "." + component.getTable().getName());
- if (tableShape == null) tableShape = getOrCreateDatabaseTable(component.getTable());
- createConnections(classShape, tableShape);
- if(!isConnectionExist(classShape, tableShape))
- new Connection(classShape, tableShape);
- Shape parentShape = ((SpecialOrmShape)classShape).getParentShape();
- OrmShape parentClassShape = (OrmShape)elements.get(((Property)parentShape.getOrmElement()).getPersistentClass().getClassName());
- if(!isConnectionExist(parentShape, parentClassShape))
- new Connection(parentShape, parentClassShape);
}
return classShape;
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmShape.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmShape.java 2007-07-09 14:35:19 UTC (rev 2360)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/OrmShape.java 2007-07-09 14:46:12 UTC (rev 2361)
@@ -47,10 +47,13 @@
KeyValue identifier = rootClass.getIdentifier();
if (identifier instanceof Component) {
- Iterator iterator = ((Component)identifier).getPropertyIterator();
- while (iterator.hasNext()) {
- Property property = (Property) iterator.next();
- getChildren().add(new Shape(property));
+ Component component = (Component)identifier;
+ if (component.isEmbedded()) {
+ Iterator iterator = ((Component)identifier).getPropertyIterator();
+ while (iterator.hasNext()) {
+ Property property = (Property) iterator.next();
+ getChildren().add(new Shape(property));
+ }
}
}
Modified: trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialRootClass.java
===================================================================
--- trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialRootClass.java 2007-07-09 14:35:19 UTC (rev 2360)
+++ trunk/hibernatetools/plugins/org.jboss.tools.hibernate.ui.veditor/src/org/jboss/tools/hibernate/ui/veditor/editors/model/SpecialRootClass.java 2007-07-09 14:46:12 UTC (rev 2361)
@@ -32,22 +32,29 @@
private void generate() {
if (property != null) {
- Collection collection = (Collection)property.getValue();
- Component component = (Component)collection.getElement();
- setClassName(component.getComponentClassName());
- PersistentClass ownerClass = collection.getOwner();
- if (component.getParentProperty() != null) {
- Property property = ownerClass.getProperty(component.getParentProperty());
- if (property == null && ownerClass.getIdentifierProperty().getName().equals(component.getParentProperty())) {
- property = ownerClass.getIdentifierProperty();
+ Component component = null;
+ if (property.getValue() instanceof Collection) {
+ Collection collection = (Collection)property.getValue();
+ component = (Component)collection.getElement();
+ } else if (property.getValue() instanceof Component) {
+ component = (Component)property.getValue();
+ }
+ if (component != null) {
+ setClassName(component.getComponentClassName());
+ PersistentClass ownerClass = component.getOwner();
+ if (component.getParentProperty() != null) {
+ Property property = ownerClass.getProperty(component.getParentProperty());
+ if (property == null && ownerClass.getIdentifierProperty().getName().equals(component.getParentProperty())) {
+ property = ownerClass.getIdentifierProperty();
+ }
+ if (property != null) parentProperty = ownerClass.getIdentifierProperty();
}
- if (property != null) parentProperty = ownerClass.getIdentifierProperty();
+ Iterator iterator = component.getPropertyIterator();
+ while (iterator.hasNext()) {
+ Property property = (Property)iterator.next();
+ if (property != null) addProperty(property);
+ }
}
- Iterator iterator = component.getPropertyIterator();
- while (iterator.hasNext()) {
- Property property = (Property)iterator.next();
- if (property != null) addProperty(property);
- }
}
}
17 years, 5 months
JBoss Tools SVN: r2360 - in trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core: validation and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: akazakov
Date: 2007-07-09 10:35:19 -0400 (Mon, 09 Jul 2007)
New Revision: 2360
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationContext.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaValidator.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java
Log:
http://jira.jboss.com/jira/browse/EXIN-327 Seam validation tools
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-09 14:22:33 UTC (rev 2359)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-09 14:35:19 UTC (rev 2360)
@@ -35,6 +35,7 @@
import org.jboss.tools.seam.core.event.SeamProjectChangeEvent;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
import org.jboss.tools.seam.internal.core.scanner.lib.ClassPath;
+import org.jboss.tools.seam.internal.core.validation.SeamValidationContext;
/**
* @author Viacheslav Kabanovich
@@ -49,6 +50,8 @@
List<ISeamProjectChangeListener> listeners = new ArrayList<ISeamProjectChangeListener>();
+ SeamValidationContext validationContext;
+
public SeamProject() {}
public void configure() throws CoreException {
@@ -85,6 +88,13 @@
protected void store() {
}
+ public SeamValidationContext getValidationContext() {
+ if(validationContext==null) {
+ validationContext = new SeamValidationContext();
+ }
+ return validationContext;
+ }
+
public ISeamComponent getComponentByName(String name) {
return allComponents.get(name);
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaValidator.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaValidator.java 2007-07-09 14:22:33 UTC (rev 2359)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaValidator.java 2007-07-09 14:35:19 UTC (rev 2360)
@@ -12,13 +12,13 @@
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Map;
import java.util.Set;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
@@ -31,6 +31,7 @@
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.ISeamTextSourceReference;
import org.jboss.tools.seam.internal.core.SeamComponentDeclaration;
+import org.jboss.tools.seam.internal.core.SeamProject;
/**
* Validator for Java files.
@@ -39,11 +40,11 @@
public class SeamJavaValidator extends SeamValidator {
private static final String NONUNIQUE_NAME_MESSAGE_GROUP = "nonuniqueName";
- private Map<String, Set<IResource>> markedNonuniqueNamedResources = new HashMap<String, Set<IResource>>();
- private Map<IResource, String> nonuniqueNames = new HashMap<IResource, String>();
public static final String NONUNIQUE_COMPONENT_NAME_MESSAGE_ID = "NONUNIQUE_COMPONENT_NAME_MESSAGE";
+ private SeamValidationContext validationContext;
+
public ISchedulingRule getSchedulingRule(IValidationContext helper) {
// TODO
return null;
@@ -54,61 +55,55 @@
SeamJavaHelper seamJavaHelper = (SeamJavaHelper)helper;
String[] uris = seamJavaHelper.getURIs();
ISeamProject project = seamJavaHelper.getSeamProject();
+ validationContext = ((SeamProject)project).getValidationContext();
if (uris.length > 0) {
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IFile currentFile = null;
- Set<IResource> checkedResource = new HashSet<IResource>();
- Set<ISeamComponent> checkedComponent = new HashSet<ISeamComponent>();
+ Set<IPath> checkedResources = new HashSet<IPath>();
+ Set<ISeamComponent> checkedComponents = new HashSet<ISeamComponent>();
for (int i = 0; i < uris.length && !reporter.isCancelled(); i++) {
currentFile = root.getFile(new Path(uris[i]));
+ // Don't validate one resource twice.
+ if(checkedResources.contains(currentFile)) {
+ continue;
+ }
if (currentFile != null && currentFile.exists()) {
- String oldComponentNameOfChangedFile = nonuniqueNames.get(currentFile);
+ String oldComponentNameOfChangedFile = validationContext.getNonuniqueNameOfComponent(currentFile.getLocation());
if(oldComponentNameOfChangedFile!=null) {
- Set<IResource> resources = new HashSet<IResource>(); // Resources which we have to validate.
+ Set<IPath> resources = new HashSet<IPath>(); // Resources which we have to validate.
// Check if component name was changed in java file
- String newComponentNameOfChangedFile = getComponentNameByResource(currentFile, project);
+ String newComponentNameOfChangedFile = getComponentNameByResource(currentFile.getLocation(), project);
if(newComponentNameOfChangedFile!=null && !oldComponentNameOfChangedFile.equals(newComponentNameOfChangedFile)) {
- // Name was changed. Remove markers from resources with new component name.
- Set<IResource> rs = markedNonuniqueNamedResources.get(newComponentNameOfChangedFile);
- if(rs!=null) {
- for (IResource resource : rs) {
- reporter.removeMessageSubset(this, resource, NONUNIQUE_NAME_MESSAGE_GROUP);
- resources.add(resource);
- }
+ // Name was changed.
+ // Collect resources with new component name.
+ Set<IPath> linkedResources = validationContext.getMarkedNonuniqueNamedResources(newComponentNameOfChangedFile);
+ if(linkedResources!=null) {
+ resources.addAll(linkedResources);
}
}
- Set<IResource> linkedResources = markedNonuniqueNamedResources.get(oldComponentNameOfChangedFile);
+ // Collect resources with old component name.
+ Set<IPath> linkedResources = validationContext.getMarkedNonuniqueNamedResources(oldComponentNameOfChangedFile);
if(linkedResources!=null) {
resources.addAll(linkedResources);
}
// Validate all collected linked resources.
- for (IResource linkedResource : resources) {
- if(checkedResource.contains(linkedResource)) {
+ for (IPath linkedResource : resources) {
+ // Don't validate one resource twice.
+ if(checkedResources.contains(linkedResource)) {
continue;
}
- reporter.removeMessageSubset(this, linkedResource, NONUNIQUE_NAME_MESSAGE_GROUP); // Remove markers from java file
- Set<ISeamComponent> components = project.getComponentsByResource(linkedResource);
- for (ISeamComponent component : components) {
- if(checkedComponent.contains(component)) {
- continue;
- }
- validateUniqueComponentName(project, component, helper, reporter);
- checkedComponent.add(component);
- }
- checkedResource.add(linkedResource);
+ // Remove markers from collected java file
+ reporter.removeMessageSubset(this, linkedResource, NONUNIQUE_NAME_MESSAGE_GROUP);
+ validateUniqueComponentName(project, linkedResource, checkedComponents, helper, reporter);
+ checkedResources.add(linkedResource);
}
} else {
// Validate new (unmarked) Java file.
- // TODO
+ validateUniqueComponentName(project, currentFile.getLocation(), checkedComponents, helper, reporter);
}
-// reporter.removeAllMessages(this, currentFile); // Remove all markers from java file
-// Set<ISeamComponent> components = project.getComponentsByResource(currentFile);
-// for (ISeamComponent component : components) {
-// validateUniqueComponentName(project, component, helper, reporter);
-// }
// TODO
}
}
@@ -119,9 +114,20 @@
return OK_STATUS;
}
- public String getComponentNameByResource(IResource resource, ISeamProject project) {
- Set<ISeamComponent> components = project.getComponentsByResource(resource);
+ private void validateUniqueComponentName(ISeamProject project, IPath sourceFilePath, Set<ISeamComponent> checkedComponents, IValidationContext helper, IReporter reporter) {
+ Set<ISeamComponent> components = project.getComponentsByPath(sourceFilePath);
for (ISeamComponent component : components) {
+ // Don't validate one component twice.
+ if(!checkedComponents.contains(component)) {
+ validateUniqueComponentName(project, component, helper, reporter);
+ checkedComponents.add(component);
+ }
+ }
+ }
+
+ public String getComponentNameByResource(IPath resourcePath, ISeamProject project) {
+ Set<ISeamComponent> components = project.getComponentsByPath(resourcePath);
+ for (ISeamComponent component : components) {
return component.getName();
}
return null;
@@ -166,11 +172,11 @@
ISeamTextSourceReference target = ((SeamComponentDeclaration)checkedDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, target, NONUNIQUE_NAME_MESSAGE_GROUP);
markedDeclarations.add(checkedDeclaration);
- addLinkedResource(checkedDeclaration.getName(), checkedDeclaration.getResource());
+ validationContext.addLinkedResource(checkedDeclaration.getName(), checkedDeclaration.getResource().getLocation());
}
// Mark next wrong declaration with that name
markedDeclarations.add(javaDeclaration);
- addLinkedResource(javaDeclaration.getName(), javaDeclaration.getResource());
+ validationContext.addLinkedResource(javaDeclaration.getName(), javaDeclaration.getResource().getLocation());
ISeamTextSourceReference target = ((SeamComponentDeclaration)javaDeclaration).getLocationFor(SeamComponentDeclaration.PATH_OF_NAME);
addError(NONUNIQUE_COMPONENT_NAME_MESSAGE_ID, target, NONUNIQUE_NAME_MESSAGE_GROUP);
}
@@ -179,22 +185,4 @@
}
}
- /*
- * Save linked resources of component name that we marked.
- * It's needed for incremental validation because we must save all linked resources of changed java file.
- */
- private void addLinkedResource(String componentName, IResource linkedResource) {
- Set<IResource> linkedResources = markedNonuniqueNamedResources.get(componentName);
- if(linkedResources==null) {
- // create set of linked resources with component name that we must mark.
- linkedResources = new HashSet<IResource>();
- markedNonuniqueNamedResources.put(componentName, linkedResources);
- }
- if(!linkedResources.contains(linkedResource)) {
- // save linked resources that we must mark.
- linkedResources.add(linkedResource);
- }
- // Save link between component name and marked resource. It's needed if component name changes in java file.
- nonuniqueNames.put(linkedResource, componentName);
- }
}
\ No newline at end of file
Added: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationContext.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationContext.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidationContext.java 2007-07-09 14:35:19 UTC (rev 2360)
@@ -0,0 +1,56 @@
+ /*******************************************************************************
+ * Copyright (c) 2007 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:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.internal.core.validation;
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.eclipse.core.runtime.IPath;
+
+/**
+ * Contains information for seam validators that must be saved between
+ * validation invoking.
+ * @author Alexey Kazakov
+ */
+public class SeamValidationContext {
+
+ private Map<String, Set<IPath>> markedNonuniqueNamedResources = new HashMap<String, Set<IPath>>();
+ private Map<IPath, String> nonuniqueNames = new HashMap<IPath, String>();
+
+ /**
+ * Save linked resources of component name that we marked.
+ * It's needed for incremental validation because we must save all linked resources of changed java file.
+ */
+ public void addLinkedResource(String componentName, IPath linkedResourcePath) {
+ Set<IPath> linkedResources = markedNonuniqueNamedResources.get(componentName);
+ if(linkedResources==null) {
+ // create set of linked resources with component name that we must mark.
+ linkedResources = new HashSet<IPath>();
+ markedNonuniqueNamedResources.put(componentName, linkedResources);
+ }
+ if(!linkedResources.contains(linkedResourcePath)) {
+ // save linked resources that we must mark.
+ linkedResources.add(linkedResourcePath);
+ }
+ // Save link between component name and marked resource. It's needed if component name changes in java file.
+ nonuniqueNames.put(linkedResourcePath, componentName);
+ }
+
+ public Set<IPath> getMarkedNonuniqueNamedResources(String componentName) {
+ return markedNonuniqueNamedResources.get(componentName);
+ }
+
+ public String getNonuniqueNameOfComponent(IPath sourcePath) {
+ return nonuniqueNames.get(sourcePath);
+ }
+}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java 2007-07-09 14:22:33 UTC (rev 2359)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamValidator.java 2007-07-09 14:35:19 UTC (rev 2360)
@@ -10,6 +10,9 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core.validation;
+import java.util.Set;
+
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.wst.validation.internal.core.Message;
import org.eclipse.wst.validation.internal.core.ValidationException;
@@ -28,6 +31,10 @@
private IValidationContext helper;
private IReporter reporter;
+ public SeamValidator() {
+ super();
+ }
+
public IStatus validateInJob(IValidationContext helper, IReporter reporter) throws ValidationException {
this.helper = helper;
this.reporter = reporter;
@@ -56,4 +63,10 @@
protected void addError(String messageId, ISeamTextSourceReference target, String messageGroup) {
addError(messageId, new String[0], target, messageGroup);
}
+
+ protected void removeMessagesFromResources(Set<IResource> resources, String messageGroup) {
+ for (IResource r : resources) {
+ reporter.removeMessageSubset(this, r, messageGroup);
+ }
+ }
}
\ No newline at end of file
17 years, 5 months
JBoss Tools SVN: r2359 - in trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam: internal/core and 1 other directories.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-07-09 10:22:33 -0400 (Mon, 09 Jul 2007)
New Revision: 2359
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/AnnotatedASTNode.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
Log:
EXIN-217 Java source scanner is being developed.
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java 2007-07-09 13:38:58 UTC (rev 2358)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java 2007-07-09 14:22:33 UTC (rev 2359)
@@ -14,6 +14,7 @@
import org.eclipse.core.resources.IProjectNature;
import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IPath;
import org.jboss.tools.seam.core.event.ISeamProjectChangeListener;
public interface ISeamProject extends IProjectNature {
@@ -37,10 +38,10 @@
public Set<ISeamComponent> getComponentsByScope(ScopeType type);
/**
- * @param resource of ISeamComponentDeclaration that belongs to component
- * @return Set of ISeamComponents by resource.
+ * @param resource path of ISeamComponentDeclaration that belongs to component
+ * @return Set of ISeamComponents by resource path.
*/
- public Set<ISeamComponent> getComponentsByResource(IResource resource);
+ public Set<ISeamComponent> getComponentsByPath(IPath path);
/**
* @param className
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-09 13:38:58 UTC (rev 2358)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-09 14:22:33 UTC (rev 2359)
@@ -452,15 +452,15 @@
listeners.remove(listener);
}
- /* (non-Javadoc)
+ /**
* @see org.jboss.tools.seam.core.ISeamProject#getComponentsByResource(org.eclipse.core.resources.IResource)
*/
- public Set<ISeamComponent> getComponentsByResource(IResource resource) {
+ public Set<ISeamComponent> getComponentsByPath(IPath path) {
Set<ISeamComponent> result = new HashSet<ISeamComponent>();
for (SeamComponent c: allComponents.values()) {
for (ISeamComponentDeclaration d: c.getAllDeclarations()) {
SeamComponentDeclaration di = (SeamComponentDeclaration)d;
- if(resource.equals(di.getResource())) {
+ if(path.equals(di.getSourcePath())) {
result.add(c);
break;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java 2007-07-09 13:38:58 UTC (rev 2358)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java 2007-07-09 14:22:33 UTC (rev 2359)
@@ -38,11 +38,13 @@
IType type;
- AnnotatedASTNode annotatedType = null;
- Set<AnnotatedASTNode> annotatedFields = new HashSet<AnnotatedASTNode>();
- Set<AnnotatedASTNode> annotatedMethods = new HashSet<AnnotatedASTNode>();
+ AnnotatedASTNode<TypeDeclaration> annotatedType = null;
+ Set<AnnotatedASTNode<FieldDeclaration>> annotatedFields = new HashSet<AnnotatedASTNode<FieldDeclaration>>();
+ Set<AnnotatedASTNode<MethodDeclaration>> annotatedMethods = new HashSet<AnnotatedASTNode<MethodDeclaration>>();
- AnnotatedASTNode currentAnnotatedNode = null;
+ AnnotatedASTNode<?> currentAnnotatedNode = null;
+ AnnotatedASTNode<FieldDeclaration> currentAnnotatedField = null;
+ AnnotatedASTNode<MethodDeclaration> currentAnnotatedMethod = null;
public boolean hasSeamComponent() {
if(annotatedFields.size() > 0 || annotatedMethods.size() > 0) return true;
@@ -103,9 +105,8 @@
return false;
}
-
public boolean visit(TypeDeclaration node) {
- annotatedType = new AnnotatedASTNode(node);
+ annotatedType = new AnnotatedASTNode<TypeDeclaration>(node);
currentAnnotatedNode = annotatedType;
return true;
}
@@ -115,7 +116,7 @@
}
public boolean visit(FieldDeclaration node) {
- currentAnnotatedNode = new AnnotatedASTNode(node);
+ currentAnnotatedField = new AnnotatedASTNode<FieldDeclaration>(node);
return true;
}
@@ -126,22 +127,24 @@
String name = vd.getName().getIdentifier();
System.out.println("-->" + name);
}
- if(currentAnnotatedNode != null && currentAnnotatedNode.getAnnotations() != null) {
- annotatedFields.add(currentAnnotatedNode);
+ if(currentAnnotatedField != null && currentAnnotatedField.getAnnotations() != null) {
+ annotatedFields.add(currentAnnotatedField);
}
- currentAnnotatedNode = null;
+ currentAnnotatedField = null;
+ currentAnnotatedNode = annotatedType;
}
public boolean visit(MethodDeclaration node) {
- currentAnnotatedNode = new AnnotatedASTNode(node);
+ currentAnnotatedMethod = new AnnotatedASTNode<MethodDeclaration>(node);
return true;
}
public void endVisit(MethodDeclaration node) {
- if(currentAnnotatedNode != null && currentAnnotatedNode.getAnnotations() != null) {
- annotatedMethods.add(currentAnnotatedNode);
+ if(currentAnnotatedMethod != null && currentAnnotatedMethod.getAnnotations() != null) {
+ annotatedMethods.add(currentAnnotatedMethod);
}
- currentAnnotatedNode = null;
+ currentAnnotatedMethod = null;
+ currentAnnotatedNode = annotatedType;
}
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/AnnotatedASTNode.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/AnnotatedASTNode.java 2007-07-09 13:38:58 UTC (rev 2358)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/AnnotatedASTNode.java 2007-07-09 14:22:33 UTC (rev 2359)
@@ -17,11 +17,11 @@
*
* @author Viacheslav Kabanovich
*/
-public class AnnotatedASTNode {
- ASTNode node;
+public class AnnotatedASTNode<T extends ASTNode> {
+ T node;
ResolvedAnnotation[] annotations = null;
- public AnnotatedASTNode(ASTNode node) {
+ public AnnotatedASTNode(T node) {
this.node = node;
}
@@ -36,7 +36,7 @@
}
}
- public ASTNode getNode() {
+ public T getNode() {
return node;
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-09 13:38:58 UTC (rev 2358)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-09 14:22:33 UTC (rev 2359)
@@ -12,13 +12,18 @@
import java.util.HashSet;
import java.util.Iterator;
+import java.util.List;
import java.util.Set;
+import org.eclipse.jdt.core.IField;
import org.eclipse.jdt.core.IJavaElement;
import org.eclipse.jdt.core.IMethod;
import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.JavaModelException;
import org.eclipse.jdt.core.dom.Annotation;
+import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.eclipse.jdt.core.dom.VariableDeclaration;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.internal.core.SeamAnnotatedFactory;
import org.jboss.tools.seam.internal.core.SeamJavaComponentDeclaration;
@@ -33,8 +38,8 @@
LoadedDeclarations ds = null;
AnnotatedASTNode annotatedType = null;
- Set<AnnotatedASTNode> annotatedFields = new HashSet<AnnotatedASTNode>();
- Set<AnnotatedASTNode> annotatedMethods = new HashSet<AnnotatedASTNode>();
+ Set<AnnotatedASTNode<FieldDeclaration>> annotatedFields = null;
+ Set<AnnotatedASTNode<MethodDeclaration>> annotatedMethods = null;
SeamJavaComponentDeclaration component = new SeamJavaComponentDeclaration();
@@ -89,10 +94,10 @@
}
void processFactories() {
- for (AnnotatedASTNode n: annotatedMethods) {
+ for (AnnotatedASTNode<MethodDeclaration> n: annotatedMethods) {
Annotation a = findAnnotation(n, FACTORY_ANNOTATION_TYPE);
if(a == null) continue;
- MethodDeclaration m = (MethodDeclaration)n.getNode();
+ MethodDeclaration m = n.getNode();
ValueInfo factoryName = ValueInfo.getValueInfo(a, null);
if(factoryName == null) {
factoryName = new ValueInfo();
@@ -136,10 +141,66 @@
}
private IMethod findMethod(MethodDeclaration m) {
-// IType type = (IType)component.getSourceMember();
- IJavaElement e = m.resolveBinding().getJavaElement();
- if(e instanceof IMethod) return (IMethod)e;
+ if(m == null || m.getName() == null) return null;
+ IType type = (IType)component.getSourceMember();
+ IMethod[] ms = null;
+ try {
+ ms = type.getMethods();
+ } catch (Exception e) {
+ //ignore
+ }
+ String name = m.getName().getIdentifier();
+ if(ms != null) for (int i = 0; i < ms.length; i++) {
+ if(!name.equals(ms[i].getElementName())) continue;
+ int s = m.getStartPosition() + m.getLength() / 2;
+ try {
+ int b = ms[i].getSourceRange().getOffset();
+ int e = b + ms[i].getSourceRange().getLength();
+ if(s >= b && s <= e) return ms[i];
+ } catch (JavaModelException e) {
+ return ms[i];
+ }
+ }
return null;
}
+ private IField findField(FieldDeclaration f) {
+ if(f == null || getFieldName(f) == null) return null;
+ IType type = (IType)component.getSourceMember();
+ IField[] fs = null;
+ try {
+ fs = type.getFields();
+ } catch (Exception e) {
+ //ignore
+ }
+ String name = getFieldName(f);
+ if(fs != null) for (int i = 0; i < fs.length; i++) {
+ if(!name.equals(fs[i].getElementName())) continue;
+ int s = f.getStartPosition() + f.getLength() / 2;
+ try {
+ int b = fs[i].getSourceRange().getOffset();
+ int e = b + fs[i].getSourceRange().getLength();
+ if(s >= b && s <= e) return fs[i];
+ } catch (JavaModelException e) {
+ return fs[i];
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns name of first field
+ * @param node
+ * @return
+ */
+ String getFieldName(FieldDeclaration node) {
+ List<?> fragments = node.fragments();
+ for (int i = 0; i < fragments.size(); i++) {
+ VariableDeclaration vd = (VariableDeclaration)fragments.get(i);
+ String name = vd.getName().getIdentifier();
+ return name;
+ }
+ return null;
+ }
+
}
17 years, 5 months
JBoss Tools SVN: r2358 - in trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core: scanner/java and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: scabanovich
Date: 2007-07-09 09:38:58 -0400 (Mon, 09 Jul 2007)
New Revision: 2358
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ValueInfo.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java
Log:
EXIN-217 Java source scanner is being developed.
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java 2007-07-09 08:09:04 UTC (rev 2357)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamAnnotatedFactory.java 2007-07-09 13:38:58 UTC (rev 2358)
@@ -10,12 +10,17 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import org.eclipse.core.resources.IResource;
import org.eclipse.jdt.core.IMethod;
import org.jboss.tools.seam.core.ISeamAnnotatedFactory;
+import org.jboss.tools.seam.core.ISeamTextSourceReference;
import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.core.event.Change;
+import org.jboss.tools.seam.internal.core.scanner.java.ValueInfo;
/**
* @author Viacheslav Kabanovich
@@ -23,6 +28,8 @@
public class SeamAnnotatedFactory extends SeamJavaContextVariable implements ISeamAnnotatedFactory {
boolean autoCreate = false;
+ protected Map<String,ValueInfo> attributes = new HashMap<String, ValueInfo>();
+
public IMethod getSourceMethod() {
return (IMethod)javaSource;
}
@@ -51,4 +58,43 @@
return changes;
}
+ /**
+ * @param path
+ * @return source reference for some member of declaration.
+ * e.g. if you need source reference for @Name you have to
+ * invoke getLocationFor("name");
+ */
+ public ISeamTextSourceReference getLocationFor(String path) {
+ final ValueInfo valueInfo = attributes.get(path);
+ ISeamTextSourceReference reference = new ISeamTextSourceReference() {
+ public int getLength() {
+ return valueInfo != null ? valueInfo.getLength() : 0;
+ }
+
+ public IResource getResource() {
+ return SeamAnnotatedFactory.this.getResource();
+ }
+
+ public int getStartPosition() {
+ return valueInfo != null ? valueInfo.getStartPosition() : 0;
+ }
+ };
+ return reference;
+ }
+
+ public void setName(ValueInfo value) {
+ attributes.put(ISeamXmlComponentDeclaration.NAME, value);
+ name = value == null ? null : value.getValue();
+ }
+
+ public void setScope(ValueInfo value) {
+ attributes.put(ISeamXmlComponentDeclaration.SCOPE, value);
+ setScopeAsString(value == null ? null : value.getValue());
+ }
+
+ public void setAutoCreate(ValueInfo value) {
+ attributes.put(ISeamXmlComponentDeclaration.AUTO_CREATE, value);
+ setAutoCreate(value != null && "true".equals(value.getValue()));
+ }
+
}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java 2007-07-09 08:09:04 UTC (rev 2357)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponentDeclaration.java 2007-07-09 13:38:58 UTC (rev 2358)
@@ -10,15 +10,18 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.seam.core.ISeamComponentDeclaration;
import org.jboss.tools.seam.core.ISeamTextSourceReference;
-import org.jboss.tools.seam.core.SeamCorePlugin;
+import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.core.event.Change;
+import org.jboss.tools.seam.internal.core.scanner.java.ValueInfo;
/**
* @author Viacheslav Kabanovich
@@ -44,6 +47,8 @@
*/
protected String name;
+ protected Map<String,ValueInfo> attributes = new HashMap<String, ValueInfo>();
+
public Object getId() {
return id;
}
@@ -106,6 +111,9 @@
}
if(id != d.id) id = d.id;
+ //be more specific
+ this.attributes = d.attributes;
+
return changes;
}
@@ -117,13 +125,13 @@
* @param path
* @return source reference for some member of declaration.
* e.g. if you need source reference for @Name you have to
- * invore getLocationFor("name");
+ * invoke getLocationFor("name");
*/
public ISeamTextSourceReference getLocationFor(String path) {
- // TODO
+ final ValueInfo valueInfo = attributes.get(path);
ISeamTextSourceReference reference = new ISeamTextSourceReference() {
public int getLength() {
- return 10;
+ return valueInfo != null ? valueInfo.getLength() : 0;
}
public IResource getResource() {
@@ -131,9 +139,15 @@
}
public int getStartPosition() {
- return 0;
+ return valueInfo != null ? valueInfo.getStartPosition() : 0;
}
};
return reference;
}
+
+ public void setName(ValueInfo value) {
+ attributes.put(ISeamXmlComponentDeclaration.NAME, value);
+ name = value == null ? null : value.getValue();
+ }
+
}
\ No newline at end of file
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-09 08:09:04 UTC (rev 2357)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamJavaComponentDeclaration.java 2007-07-09 13:38:58 UTC (rev 2358)
@@ -11,10 +11,12 @@
import org.jboss.tools.seam.core.IRole;
import org.jboss.tools.seam.core.ISeamComponentMethod;
import org.jboss.tools.seam.core.ISeamJavaComponentDeclaration;
+import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
import org.jboss.tools.seam.core.ScopeType;
import org.jboss.tools.seam.core.SeamComponentMethodType;
import org.jboss.tools.seam.core.SeamComponentPrecedenceType;
import org.jboss.tools.seam.core.event.Change;
+import org.jboss.tools.seam.internal.core.scanner.java.ValueInfo;
public class SeamJavaComponentDeclaration extends SeamComponentDeclaration
implements ISeamJavaComponentDeclaration {
@@ -202,4 +204,20 @@
public void setPrecedence(int precedence) {
this.precedence = precedence;
}
-}
\ No newline at end of file
+
+ public void setScope(ValueInfo value) {
+ attributes.put(ISeamXmlComponentDeclaration.SCOPE, value);
+ setScope(value == null ? null : value.getValue());
+ }
+
+ public void setPrecedence(ValueInfo value) {
+ attributes.put(ISeamXmlComponentDeclaration.PRECEDENCE, value);
+ try {
+ setPrecedence(value == null ? 0 : Integer.parseInt(value.getValue()));
+ } catch (NumberFormatException e) {
+ setPrecedence(-1); //error value
+ //ignore - exact value is stored in ValueInfo
+ }
+ }
+
+}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-09 08:09:04 UTC (rev 2357)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-07-09 13:38:58 UTC (rev 2358)
@@ -121,7 +121,7 @@
String name = loaded.getName();
- boolean nameChanged = current != null && !name.equals(current.getName());
+ boolean nameChanged = current != null && !stringsEqual(name, current.getName());
SeamComponent c = getComponent(name);
@@ -203,6 +203,10 @@
factoryDeclarationsRemoved(currentFactories);
}
+ boolean stringsEqual(String s1, String s2) {
+ return s1 == null ? s2 == null : s1.equals(s2);
+ }
+
/**
* Package local method called by builder.
* @param source
@@ -416,7 +420,7 @@
}
public SeamComponent getComponent(String name) {
- return allComponents.get(name);
+ return name == null ? null : allComponents.get(name);
}
SeamComponent newComponent(String name) {
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java 2007-07-09 08:09:04 UTC (rev 2357)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ASTVisitorImpl.java 2007-07-09 13:38:58 UTC (rev 2358)
@@ -18,43 +18,38 @@
import org.eclipse.jdt.core.dom.ASTVisitor;
import org.eclipse.jdt.core.dom.Annotation;
import org.eclipse.jdt.core.dom.Block;
-import org.eclipse.jdt.core.dom.Expression;
import org.eclipse.jdt.core.dom.FieldDeclaration;
import org.eclipse.jdt.core.dom.MarkerAnnotation;
-import org.eclipse.jdt.core.dom.MemberValuePair;
import org.eclipse.jdt.core.dom.MethodDeclaration;
import org.eclipse.jdt.core.dom.Name;
import org.eclipse.jdt.core.dom.NormalAnnotation;
import org.eclipse.jdt.core.dom.QualifiedName;
import org.eclipse.jdt.core.dom.SimpleName;
import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
-import org.eclipse.jdt.core.dom.StringLiteral;
import org.eclipse.jdt.core.dom.TypeDeclaration;
import org.eclipse.jdt.core.dom.VariableDeclaration;
/**
- * This object collects changes in target that should be fired to listeners.
+ * Processes AST tree to find annotated type, fields and methods.
*
* @author Viacheslav Kabanovich
*/
public class ASTVisitorImpl extends ASTVisitor implements SeamAnnotations {
- static int UNDEFINED_CONTEXT = -1;
- static int TYPE_CONTEXT = 0;
- static int FIELD_CONTEXT = 1;
- static int METHOD_CONTEXT = 2;
-
IType type;
- String name = null;
- String scope = null;
AnnotatedASTNode annotatedType = null;
- Set<Object> annotatedFields = new HashSet<Object>();
- Set<Object> annotatedMethods = new HashSet<Object>();
+ Set<AnnotatedASTNode> annotatedFields = new HashSet<AnnotatedASTNode>();
+ Set<AnnotatedASTNode> annotatedMethods = new HashSet<AnnotatedASTNode>();
AnnotatedASTNode currentAnnotatedNode = null;
- int context = UNDEFINED_CONTEXT;
+ public boolean hasSeamComponent() {
+ if(annotatedFields.size() > 0 || annotatedMethods.size() > 0) return true;
+ if(annotatedType != null && annotatedType.getAnnotations() != null) return true;
+ return false;
+ }
+
public boolean visit(SingleMemberAnnotation node) {
String type = resolveType(node);
if(isSeamAnnotationType(type) && currentAnnotatedNode != null) {
@@ -100,18 +95,10 @@
}
boolean isSeamAnnotationType(String n) {
- return n != null && n.startsWith(SEAM_ANNOTATION_TYPE_PREFIX);
+ return n != null && (n.startsWith(SEAM_ANNOTATION_TYPE_PREFIX)
+ || n.equals(STATEFUL_ANNOTATION_TYPE));
}
- String checkExpression(Expression exp) {
- if(exp instanceof StringLiteral) {
- return ((StringLiteral)exp).getLiteralValue();
- } else if(exp instanceof QualifiedName) {
- return exp.toString();
- }
- return null;
- }
-
public boolean visit(Block node) {
return false;
}
@@ -125,7 +112,6 @@
public void endVisit(TypeDeclaration node) {
currentAnnotatedNode = null;
- process();
}
public boolean visit(FieldDeclaration node) {
@@ -134,7 +120,7 @@
}
public void endVisit(FieldDeclaration node) {
- List fragments = node.fragments();
+ List<?> fragments = node.fragments();
for (int i = 0; i < fragments.size(); i++) {
VariableDeclaration vd = (VariableDeclaration)fragments.get(i);
String name = vd.getName().getIdentifier();
@@ -158,47 +144,4 @@
currentAnnotatedNode = null;
}
- void process() {
- if(annotatedType == null) return;
- ResolvedAnnotation[] as = annotatedType.getAnnotations();
- for (int i = 0; i < as.length; i++) {
- String type = as[i].getType();
- if(NAME_ANNOTATION_TYPE.equals(type)) {
- name = getValue(as[i].getAnnotation());
- } else if(SCOPE_ANNOTATION_TYPE.equals(type)) {
- scope = getValue(as[i].getAnnotation());
- if(scope != null) {
- int q = scope.lastIndexOf('.');
- if(q >= 0) scope = scope.substring(q + 1).toLowerCase();
- }
- }
- //TODO
- }
- //TODO
- }
-
- String getValue(Annotation node) {
- if(node instanceof SingleMemberAnnotation) {
- return getValue((SingleMemberAnnotation)node);
- } else if(node instanceof NormalAnnotation) {
- return getValue((NormalAnnotation)node);
- } else {
- return null;
- }
- }
-
- String getValue(SingleMemberAnnotation node) {
- return checkExpression(node.getValue());
- }
-
- String getValue(NormalAnnotation node) {
- 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())) {
- return checkExpression(p.getValue());
- }
- }
- return null;
- }
}
Added: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ComponentBuilder.java 2007-07-09 13:38:58 UTC (rev 2358)
@@ -0,0 +1,145 @@
+/*******************************************************************************
+ * 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.seam.internal.core.scanner.java;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.Set;
+
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IMethod;
+import org.eclipse.jdt.core.IType;
+import org.eclipse.jdt.core.dom.Annotation;
+import org.eclipse.jdt.core.dom.MethodDeclaration;
+import org.jboss.tools.seam.core.ISeamXmlComponentDeclaration;
+import org.jboss.tools.seam.internal.core.SeamAnnotatedFactory;
+import org.jboss.tools.seam.internal.core.SeamJavaComponentDeclaration;
+import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
+
+/**
+ * Builds component using results of ASTVisitorImpl
+ *
+ * @author Viacheslav Kabanovich
+ */
+public class ComponentBuilder implements SeamAnnotations {
+ LoadedDeclarations ds = null;
+
+ AnnotatedASTNode annotatedType = null;
+ Set<AnnotatedASTNode> annotatedFields = new HashSet<AnnotatedASTNode>();
+ Set<AnnotatedASTNode> annotatedMethods = new HashSet<AnnotatedASTNode>();
+
+ SeamJavaComponentDeclaration component = new SeamJavaComponentDeclaration();
+
+
+ public ComponentBuilder(LoadedDeclarations ds, ASTVisitorImpl visitor) {
+ annotatedType = visitor.annotatedType;
+ annotatedFields = visitor.annotatedFields;
+ annotatedMethods = visitor.annotatedMethods;
+
+ String n = visitor.type.getElementName();
+ n = JavaScanner.getResolvedType(visitor.type, n);
+
+ ds.getComponents().add(component);
+ component.setType(visitor.type);
+ component.setId(visitor.type);
+ component.setClassName(n);
+
+ process();
+ }
+
+ void process() {
+ if(annotatedType == null) return;
+ ResolvedAnnotation[] as = annotatedType.getAnnotations();
+ for (int i = 0; i < as.length; i++) {
+ String type = as[i].getType();
+ if(NAME_ANNOTATION_TYPE.equals(type)) {
+ component.setName(ValueInfo.getValueInfo(as[i].getAnnotation(), null));
+ } else if(SCOPE_ANNOTATION_TYPE.equals(type)) {
+ ValueInfo scope = ValueInfo.getValueInfo(as[i].getAnnotation(), null);
+ if(scope != null && scope.value != null) {
+ int q = scope.value.lastIndexOf('.');
+ if(q >= 0) scope.value = scope.value.substring(q + 1).toLowerCase();
+ }
+ component.setScope(scope);
+ } else if(INSTALL_ANNOTATION_TYPE.equals(type)) {
+ component.setPrecedence(ValueInfo.getValueInfo(as[i].getAnnotation(), "precedence"));
+ } else if(STATEFUL_ANNOTATION_TYPE.equals(type)) {
+ ValueInfo stateful = new ValueInfo();
+ stateful.value = "true";
+ stateful.valueStartPosition = as[i].getAnnotation().getStartPosition();
+ stateful.valueLength = as[i].getAnnotation().getLength();
+ component.setStateful(true);
+ }
+ //TODO entity
+ }
+
+ processFactories();
+ processBijections();
+ processComponentMethods();
+
+ //TODO
+ }
+
+ void processFactories() {
+ for (AnnotatedASTNode n: annotatedMethods) {
+ Annotation a = findAnnotation(n, FACTORY_ANNOTATION_TYPE);
+ if(a == null) continue;
+ MethodDeclaration m = (MethodDeclaration)n.getNode();
+ ValueInfo factoryName = ValueInfo.getValueInfo(a, null);
+ if(factoryName == null) {
+ factoryName = new ValueInfo();
+ factoryName.value = m.getName().getIdentifier();
+ factoryName.valueLength = m.getName().getLength();
+ factoryName.valueStartPosition = m.getName().getStartPosition();
+ }
+ System.out.println("");
+ ValueInfo scope = ValueInfo.getValueInfo(a, ISeamXmlComponentDeclaration.SCOPE);
+ ValueInfo autoCreate = ValueInfo.getValueInfo(a, "autoCreate");
+
+ SeamAnnotatedFactory factory = new SeamAnnotatedFactory();
+ factory.setMethod(findMethod(m));
+ factory.setName(factoryName);
+ if(autoCreate != null) factory.setAutoCreate(true);
+ if(scope != null) {
+ factory.setScope(scope);
+ }
+ ds.getFactories().add(factory);
+ }
+ }
+
+ void processBijections() {
+ //TODO
+ }
+
+ void processComponentMethods() {
+ //TODO
+ }
+
+ void processRoles() {
+ //TODO
+ }
+
+ private Annotation findAnnotation(AnnotatedASTNode n, String type) {
+ ResolvedAnnotation[] as = n.getAnnotations();
+ for (int i = 0; i < as.length; i++) {
+ if(type.equals(as[i].getType())) return as[i].getAnnotation();
+ }
+ return null;
+ }
+
+ private IMethod findMethod(MethodDeclaration m) {
+// IType type = (IType)component.getSourceMember();
+ IJavaElement e = m.resolveBinding().getJavaElement();
+ if(e instanceof IMethod) return (IMethod)e;
+ return null;
+ }
+
+}
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java 2007-07-09 08:09:04 UTC (rev 2357)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java 2007-07-09 13:38:58 UTC (rev 2358)
@@ -25,7 +25,6 @@
import org.eclipse.jdt.core.dom.CompilationUnit;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
import org.jboss.tools.common.util.FileUtil;
-import org.jboss.tools.seam.internal.core.SeamJavaComponentDeclaration;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
import org.jboss.tools.seam.internal.core.scanner.LoadedDeclarations;
@@ -114,7 +113,6 @@
}
public void acceptAST(ICompilationUnit source, CompilationUnit ast) {
- visitor.name = null;
try {
IType[] ts = source.getTypes();
@@ -125,24 +123,13 @@
//ignore
}
ast.accept(visitor);
- if(visitor.name != null && visitor.type != null) {
- String n = visitor.type.getElementName();
- n = getResolvedType(visitor.type, n);
- SeamJavaComponentDeclaration component = new SeamJavaComponentDeclaration();
-
- component.setId(visitor.type);
- component.setSourcePath(sourcePath);
- component.setResource(resource);
-
- ds.getComponents().add(component);
- component.setType(visitor.type);
- component.setId(visitor.type);
- component.setClassName(n);
- component.setName(visitor.name);
- if(visitor.scope != null) {
- component.setScope(visitor.scope);
- }
- }
+
+ if(!visitor.hasSeamComponent()) return;
+
+ ComponentBuilder b = new ComponentBuilder(ds, visitor);
+
+ b.component.setSourcePath(sourcePath);
+ b.component.setResource(resource);
}
}
Added: trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ValueInfo.java
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ValueInfo.java (rev 0)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/ValueInfo.java 2007-07-09 13:38:58 UTC (rev 2358)
@@ -0,0 +1,81 @@
+package org.jboss.tools.seam.internal.core.scanner.java;
+
+import java.util.List;
+
+import org.eclipse.jdt.core.dom.Annotation;
+import org.eclipse.jdt.core.dom.Expression;
+import org.eclipse.jdt.core.dom.MemberValuePair;
+import org.eclipse.jdt.core.dom.NormalAnnotation;
+import org.eclipse.jdt.core.dom.QualifiedName;
+import org.eclipse.jdt.core.dom.SingleMemberAnnotation;
+import org.eclipse.jdt.core.dom.StringLiteral;
+
+public class ValueInfo {
+ String value;
+ int valueStartPosition;
+ int valueLength;
+
+ /**
+ * Factory method.
+ * @param node
+ * @param name
+ * @return
+ */
+ public static ValueInfo getValueInfo(Annotation node, String name) {
+ if(name == null) name = "value";
+ if(node instanceof SingleMemberAnnotation) {
+ if(name == null || "value".equals(name)) {
+ SingleMemberAnnotation m = (SingleMemberAnnotation)node;
+ ValueInfo result = new ValueInfo();
+ Expression exp = m.getValue();
+ result.valueLength = exp.getLength();
+ result.valueStartPosition = exp.getStartPosition();
+ result.value = checkExpression(exp);
+ return result;
+ }
+ return null;
+ } else if(node instanceof NormalAnnotation) {
+ NormalAnnotation n = (NormalAnnotation)node;
+ List<?> vs = n.values();
+ if(vs != null) for (int i = 0; i < vs.size(); i++) {
+ MemberValuePair p = (MemberValuePair)vs.get(i);
+ String pname = p.getName().getIdentifier();
+ if(!name.equals(pname)) continue;
+ ValueInfo result = new ValueInfo();
+ Expression exp = p.getValue();
+ result.valueLength = exp.getLength();
+ result.valueStartPosition = exp.getStartPosition();
+ result.value = checkExpression(exp);
+ return result;
+ }
+ return null;
+ }
+ return null;
+ }
+
+ public ValueInfo() {
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public int getStartPosition() {
+ return valueStartPosition;
+ }
+
+ public int getLength() {
+ return valueLength;
+ }
+
+ static String checkExpression(Expression exp) {
+ if(exp == null) return null;
+ if(exp instanceof StringLiteral) {
+ return ((StringLiteral)exp).getLiteralValue();
+ } else if(exp instanceof QualifiedName) {
+ return exp.toString();
+ }
+ return exp.toString();
+ }
+
+}
17 years, 5 months
JBoss Tools SVN: r2357 - trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template.
by jbosstools-commits@lists.jboss.org
Author: svasilyev
Date: 2007-07-09 04:09:04 -0400 (Mon, 09 Jul 2007)
New Revision: 2357
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesToolBarTemplate.java
Log:
http://jira.jboss.org/jira/browse/EXIN-231
Little fix
Modified: trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesToolBarTemplate.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesToolBarTemplate.java 2007-07-09 07:43:01 UTC (rev 2356)
+++ trunk/jsf/plugins/org.jboss.tools.jsf.vpe.richfaces/src/org/jboss/tools/jsf/vpe/richfaces/template/RichFacesToolBarTemplate.java 2007-07-09 08:09:04 UTC (rev 2357)
@@ -429,7 +429,9 @@
this.leftToolBarItems = new LinkedList<SourceToolBarItem>();
this.rightToolBarItems = new LinkedList<SourceToolBarItem>();
this.itemSeparator = itemSeparator;
- this.itemSeparatorExists = itemSeparator != null && !ITEMSEPARATOR_ATTR_NAME.equals(itemSeparator);
+ this.itemSeparatorExists = !(itemSeparator == null
+ || itemSeparator.length() == 0
+ || ITEMSEPARATOR_ATTR_NAME.equals(itemSeparator));
init(sourceNode);
}
@@ -455,11 +457,11 @@
}
}
- if (!isLeftItemsExists()) {
+ if (isItemSeparatorExists() && !isLeftItemsExists()) {
rightToolBarItems.remove(0);
}
- if (!isRightItemsExists()) {
+ if (isItemSeparatorExists() && !isRightItemsExists()) {
leftToolBarItems.remove(leftToolBarItems.size()-1);
}
}
17 years, 5 months
JBoss Tools SVN: r2356 - trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting.
by jbosstools-commits@lists.jboss.org
Author: ayukhovich
Date: 2007-07-09 03:43:01 -0400 (Mon, 09 Jul 2007)
New Revision: 2356
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java
Log:
add some comments for functions
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java 2007-07-08 07:28:36 UTC (rev 2355)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java 2007-07-09 07:43:01 UTC (rev 2356)
@@ -86,13 +86,15 @@
setView(new ReportProblemWizardView());
}
-
}
-class ReportProblemWizardView extends AbstractQueryWizardView {
-
+/**
+ * @author yukhovich
+ *
+ */
+class ReportProblemWizardView extends AbstractQueryWizardView {
/** LOG_DATE_FORMAT */
- final private SimpleDateFormat LOG_DATE_FORMAT = new SimpleDateFormat(
+ final private static SimpleDateFormat LOG_DATE_FORMAT = new SimpleDateFormat(
"yyyyMMddHHmmss");
/** log file name */
@@ -101,6 +103,35 @@
/** Browse button */
private Button browseButton;
+ /** LINE_LIMIT */
+ final private static int LINE_LIMIT = 70;
+
+
+ int stackTracesCount;
+ Text problemDescription;
+ XAttributeSupport sendSupport;
+ XAttributeSupport infoSupport;
+
+ XModelObject reportOptions = PreferenceModelUtilities.getPreferenceModel()
+ .getByPath(ReportPreference.OPTIONS_REPORT_PROBLEM_PATH);
+
+ XModelObject exceptionsObject = PreferenceModelUtilities
+ .getPreferenceModel()
+ .createModelObject("ProblemBufferEditor", null);
+
+ XEntityData sendData = XEntityDataImpl.create(new String[][] {
+ { "SharableReportProblem" },
+ { ReportPreference.ATT_ATTACH_REDHAT_LOG, "no" },
+ // {ReportPreference.ATT_ATTACH_ECLIPSE_LOG, "no"}
+ });
+ XEntityData sendData2 = XEntityDataImpl
+ .create(new String[][] { { "SharableReportProblem" },
+ // {ReportPreference.ATT_ATTACH_ECLIPSE_LOG, "no"}
+ });
+ XEntityData infoData = XEntityDataImpl.create(new String[][] {
+ { "SharableReportProblem" }, { ReportPreference.ATT_E_MAIL, "no" },
+ { ReportPreference.ATT_OTHER, "no" } });
+
class PixelConverter {
private FontMetrics fFontMetrics;
@@ -127,29 +158,6 @@
}
}
- int stackTracesCount;
- Text problemDescription;
- XAttributeSupport sendSupport;
- XAttributeSupport infoSupport;
- XModelObject reportOptions = PreferenceModelUtilities.getPreferenceModel()
- .getByPath(ReportPreference.OPTIONS_REPORT_PROBLEM_PATH);
- XModelObject exceptionsObject = PreferenceModelUtilities
- .getPreferenceModel()
- .createModelObject("ProblemBufferEditor", null);
-
- XEntityData sendData = XEntityDataImpl.create(new String[][] {
- { "SharableReportProblem" },
- { ReportPreference.ATT_ATTACH_REDHAT_LOG, "no" },
- // {ReportPreference.ATT_ATTACH_ECLIPSE_LOG, "no"}
- });
- XEntityData sendData2 = XEntityDataImpl
- .create(new String[][] { { "SharableReportProblem" },
- // {ReportPreference.ATT_ATTACH_ECLIPSE_LOG, "no"}
- });
- XEntityData infoData = XEntityDataImpl.create(new String[][] {
- { "SharableReportProblem" }, { ReportPreference.ATT_E_MAIL, "no" },
- { ReportPreference.ATT_OTHER, "no" } });
-
public ReportProblemWizardView() {
//folderLogFileName = Platform.getLocation().toOSString() + SEPARATOR;
}
@@ -168,6 +176,44 @@
return composite;
}
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.common.model.ui.wizards.query.AbstractQueryWizardView#updateBar()
+ */
+ public void updateBar() {
+ getCommandBar().setEnabled("Ok", !isMessageEmpty());
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.common.model.ui.wizards.query.AbstractQueryWizardView#getPreferredSize()
+ */
+ public Point getPreferredSize() {
+ return new Point(400, 500);
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.common.model.ui.wizards.query.AbstractQueryWizardView#getCommands()
+ */
+ /* (non-Javadoc)
+ * @see org.jboss.tools.common.model.ui.wizards.query.AbstractQueryWizardView#getCommands()
+ */
+ public String[] getCommands() {
+ return new String[] { "Ok", CANCEL };
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.common.model.ui.wizards.query.AbstractQueryWizardView#action(java.lang.String)
+ */
+ public void action(String command) {
+ if (command.equals("Ok")) {
+ submitProblems();
+ super.action(OK);
+ } else {
+ super.action(command);
+ }
+ }
+
+
/**
*
*/
@@ -177,7 +223,7 @@
}
/**
- *
+ * @return
*/
private byte[] getEclipseLogContent() {
StringBuffer sb = new StringBuffer();
@@ -200,7 +246,7 @@
};
/**
- *
+ * @return
*/
private byte[] getUserCommentContent() {
StringBuffer sb = new StringBuffer();
@@ -215,78 +261,8 @@
return sb.toString().getBytes();
}
- private IConfigurationElement[] getSortedExtensions() {
- IConfigurationElement[] configElements = Platform
- .getExtensionRegistry().getConfigurationElementsFor(
- PlatformUI.PLUGIN_ID,
- IWorkbenchRegistryConstants.PL_SYSTEM_SUMMARY_SECTIONS);
-
- Arrays.sort(configElements, new Comparator() {
- Collator collator = Collator.getInstance(Locale.getDefault());
-
- public int compare(Object a, Object b) {
- IConfigurationElement element1 = (IConfigurationElement) a;
- IConfigurationElement element2 = (IConfigurationElement) b;
-
- String id1 = element1.getAttribute("id"); //$NON-NLS-1$
- String id2 = element2.getAttribute("id"); //$NON-NLS-1$
-
- if (id1 != null && id2 != null && !id1.equals(id2)) {
- return collator.compare(id1, id2);
- }
-
- String title1 = element1.getAttribute("sectionTitle"); //$NON-NLS-1$
- String title2 = element2.getAttribute("sectionTitle"); //$NON-NLS-1$
-
- if (title1 == null) {
- title1 = ""; //$NON-NLS-1$
- }
- if (title2 == null) {
- title2 = ""; //$NON-NLS-1$
- }
-
- return collator.compare(title1, title2);
- }
- });
-
- return configElements;
- }
-
- /*
- * Appends the contents of all extensions to the configurationLogSections
- * extension point.
- */
- private void appendExtensions(PrintWriter writer) {
- IConfigurationElement[] configElements = getSortedExtensions();
- for (int i = 0; i < configElements.length; ++i) {
- IConfigurationElement element = configElements[i];
-
- Object obj = null;
- try {
- obj = WorkbenchPlugin.createExtension(element,
- IWorkbenchConstants.TAG_CLASS);
- } catch (CoreException e) {
- WorkbenchPlugin.log(
- "could not create class attribute for extension", //$NON-NLS-1$
- e.getStatus());
- }
-
- writer.println();
- writer.println(NLS.bind(
- WorkbenchMessages.SystemSummary_sectionTitle, element
- .getAttribute("sectionTitle"))); //$NON-NLS-1$
-
- if (obj instanceof ISystemSummarySection) {
- ISystemSummarySection logSection = (ISystemSummarySection) obj;
- logSection.write(writer);
- } else {
- writer.println(WorkbenchMessages.SystemSummary_sectionError);
- }
- }
- }
-
/**
- *
+ * @return
*/
private byte[] getEclipsePropertiesContent() {
StringWriter out = new StringWriter();
@@ -318,12 +294,15 @@
} finally {
zout.close();
}
-
- //
- // return byteBuffer.toString();
- //
}
+ /**
+ * Add bytes form tempBuffer in zipOutputStream with name from fileName
+ * @param tempBuffer tempolary-buffer
+ * @param fileName
+ * @param zout
+ * @throws IOException
+ */
private void addFileToZip(byte[] tempBuffer, String fileName,
ZipOutputStream zout) throws IOException {
@@ -346,7 +325,7 @@
currentDate = LOG_DATE_FORMAT.format(today);
return "jbosstools-diagnostics-" + currentDate.toString() + ".zip";
}
-
+
private void createStackTracesControl(Composite parent) {
stackTracesCount = ProblemReportingHelper.buffer.getSize();
exceptionsObject.setAttributeValue("exceptions",
@@ -379,104 +358,10 @@
}
}
- /**
- * Creates a new label widget
- *
- * @param parent
- * the parent composite to add this label widget to
- * @param text
- * the text for the label
- * @param hspan
- * the horizontal span to take up in the parent composite
- * @return the new label
- */
- public static Label createLabel(Composite parent, String text, int hspan) {
- Label l = new Label(parent, SWT.NONE);
- l.setFont(parent.getFont());
- l.setText(text);
- GridData gd = new GridData();
- gd.horizontalSpan = hspan;
- l.setLayoutData(gd);
- return l;
- }
/**
- * Creates a new text widget
*
* @param parent
- * the parent composite to add this text widget to
- * @param hspan
- * the horizontal span to take up on the parent composite
- * @return the new text widget
- */
- public static Text createSingleText(Composite parent, int hspan) {
- Text t = new Text(parent, SWT.SINGLE | SWT.BORDER);
- t.setFont(parent.getFont());
- GridData gd = new GridData(GridData.FILL_HORIZONTAL);
- gd.horizontalSpan = hspan;
- gd.widthHint = 100;
- t.setLayoutData(gd);
- return t;
- }
-
- /**
- * Returns a width hint for a button control.
- */
- public int getButtonWidthHint(Button button) {
- button.setFont(JFaceResources.getDialogFont());
- PixelConverter converter = new PixelConverter(button);
- int widthHint = converter
- .convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
- return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT,
- true).x);
- }
-
- /**
- * Sets width and height hint for the button control. <b>Note:</b> This is
- * a NOP if the button's layout data is not an instance of
- * <code>GridData</code>.
- *
- * @param the
- * button for which to set the dimension hint
- */
- public void setButtonDimensionHint(Button button) {
- Object gd = button.getLayoutData();
- if (gd instanceof GridData) {
- ((GridData) gd).widthHint = getButtonWidthHint(button);
- ((GridData) gd).horizontalAlignment = GridData.FILL;
- }
- }
-
- /**
- * Creates and returns a new push button with the given label and/or image.
- *
- * @param parent
- * parent control
- * @param label
- * button label or <code>null</code>
- * @param image
- * image or <code>null</code>
- *
- * @return a new push button
- */
- public Button createPushButton(Composite parent, String label, Image image) {
- Button button = new Button(parent, SWT.PUSH);
- button.setFont(parent.getFont());
- if (image != null) {
- button.setImage(image);
- }
- if (label != null) {
- button.setText(label);
- }
- GridData gd = new GridData();
- button.setLayoutData(gd);
- setButtonDimensionHint(button);
- return button;
- }
-
- /**
- *
- * @param parent
* a parent Composite object
*/
private void createFilenameLogControl(final Composite parent) {
@@ -572,32 +457,6 @@
});
}
- public Point getPreferredSize() {
- return new Point(400, 500);
- }
-
- protected GridLayout getDefaultSupportLayout() {
- GridLayout gridLayout = new GridLayout(2, false);
- gridLayout.marginHeight = 0;
- gridLayout.marginWidth = 0;
- gridLayout.horizontalSpacing = 0;
- gridLayout.verticalSpacing = 5;
- return gridLayout;
- }
-
- public String[] getCommands() {
- return new String[] { "Ok", CANCEL };
- }
-
- public void action(String command) {
- if (command.equals("Ok")) {
- submitProblems();
- super.action(OK);
- } else {
- super.action(command);
- }
- }
-
private void submitProblems() {
if (sendSupport != null)
sendSupport.store();
@@ -638,7 +497,6 @@
}
}
- static int LINE_LIMIT = 70;
private String formatContent(String content) {
StringBuffer sb = new StringBuffer();
@@ -662,11 +520,12 @@
return sb.toString();
}
- public void updateBar() {
- getCommandBar().setEnabled("Ok", !isMessageEmpty());
- }
- boolean isMessageEmpty() {
+ /**
+ *
+ * @return
+ */
+ private boolean isMessageEmpty() {
if (sendSupport != null) {
IModelPropertyEditorAdapter a = sendSupport
.getPropertyEditorAdapterByName(ReportPreference.ATT_ATTACH_REDHAT_LOG);
@@ -683,4 +542,179 @@
return false;
}
+
+ /**
+ * Creates a new label widget
+ *
+ * @param parent
+ * the parent composite to add this label widget to
+ * @param text
+ * the text for the label
+ * @param hspan
+ * the horizontal span to take up in the parent composite
+ * @return the new label
+ */
+ private Label createLabel(Composite parent, String text, int hspan) {
+ Label l = new Label(parent, SWT.NONE);
+ l.setFont(parent.getFont());
+ l.setText(text);
+ GridData gd = new GridData();
+ gd.horizontalSpan = hspan;
+ l.setLayoutData(gd);
+ return l;
+ }
+
+ /**
+ * Creates a new text widget
+ *
+ * @param parent
+ * the parent composite to add this text widget to
+ * @param hspan
+ * the horizontal span to take up on the parent composite
+ * @return the new text widget
+ */
+ private Text createSingleText(Composite parent, int hspan) {
+ Text t = new Text(parent, SWT.SINGLE | SWT.BORDER);
+ t.setFont(parent.getFont());
+ GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+ gd.horizontalSpan = hspan;
+ gd.widthHint = 100;
+ t.setLayoutData(gd);
+ return t;
+ }
+
+ /**
+ * Returns a width hint for a button control.
+ */
+ private int getButtonWidthHint(Button button) {
+ button.setFont(JFaceResources.getDialogFont());
+ PixelConverter converter = new PixelConverter(button);
+ int widthHint = converter
+ .convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH);
+ return Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT,
+ true).x);
+ }
+
+ /**
+ * Sets width and height hint for the button control. <b>Note:</b> This is
+ * a NOP if the button's layout data is not an instance of
+ * <code>GridData</code>.
+ *
+ * @param the
+ * button for which to set the dimension hint
+ */
+ private void setButtonDimensionHint(Button button) {
+ Object gd = button.getLayoutData();
+ if (gd instanceof GridData) {
+ ((GridData) gd).widthHint = getButtonWidthHint(button);
+ ((GridData) gd).horizontalAlignment = GridData.FILL;
+ }
+ }
+
+ /**
+ * Creates and returns a new push button with the given label and/or image.
+ *
+ * @param parent
+ * parent control
+ * @param label
+ * button label or <code>null</code>
+ * @param image
+ * image or <code>null</code>
+ *
+ * @return a new push button
+ */
+ private Button createPushButton(Composite parent, String label, Image image) {
+ Button button = new Button(parent, SWT.PUSH);
+ button.setFont(parent.getFont());
+ if (image != null) {
+ button.setImage(image);
+ }
+ if (label != null) {
+ button.setText(label);
+ }
+ GridData gd = new GridData();
+ button.setLayoutData(gd);
+ setButtonDimensionHint(button);
+ return button;
+ }
+
+ private IConfigurationElement[] getSortedExtensions() {
+ IConfigurationElement[] configElements = Platform
+ .getExtensionRegistry().getConfigurationElementsFor(
+ PlatformUI.PLUGIN_ID,
+ IWorkbenchRegistryConstants.PL_SYSTEM_SUMMARY_SECTIONS);
+
+ Arrays.sort(configElements, new Comparator() {
+ Collator collator = Collator.getInstance(Locale.getDefault());
+
+ public int compare(Object a, Object b) {
+ IConfigurationElement element1 = (IConfigurationElement) a;
+ IConfigurationElement element2 = (IConfigurationElement) b;
+
+ String id1 = element1.getAttribute("id"); //$NON-NLS-1$
+ String id2 = element2.getAttribute("id"); //$NON-NLS-1$
+
+ if (id1 != null && id2 != null && !id1.equals(id2)) {
+ return collator.compare(id1, id2);
+ }
+
+ String title1 = element1.getAttribute("sectionTitle"); //$NON-NLS-1$
+ String title2 = element2.getAttribute("sectionTitle"); //$NON-NLS-1$
+
+ if (title1 == null) {
+ title1 = ""; //$NON-NLS-1$
+ }
+ if (title2 == null) {
+ title2 = ""; //$NON-NLS-1$
+ }
+
+ return collator.compare(title1, title2);
+ }
+ });
+
+ return configElements;
+ }
+
+ /*
+ * Appends the contents of all extensions to the configurationLogSections
+ * extension point.
+ */
+ private void appendExtensions(PrintWriter writer) {
+ IConfigurationElement[] configElements = getSortedExtensions();
+ for (int i = 0; i < configElements.length; ++i) {
+ IConfigurationElement element = configElements[i];
+
+ Object obj = null;
+ try {
+ obj = WorkbenchPlugin.createExtension(element,
+ IWorkbenchConstants.TAG_CLASS);
+ } catch (CoreException e) {
+ WorkbenchPlugin.log(
+ "could not create class attribute for extension", //$NON-NLS-1$
+ e.getStatus());
+ }
+
+ writer.println();
+ writer.println(NLS.bind(
+ WorkbenchMessages.SystemSummary_sectionTitle, element
+ .getAttribute("sectionTitle"))); //$NON-NLS-1$
+
+ if (obj instanceof ISystemSummarySection) {
+ ISystemSummarySection logSection = (ISystemSummarySection) obj;
+ logSection.write(writer);
+ } else {
+ writer.println(WorkbenchMessages.SystemSummary_sectionError);
+ }
+ }
+ }
+
+ protected GridLayout getDefaultSupportLayout() {
+ GridLayout gridLayout = new GridLayout(2, false);
+ gridLayout.marginHeight = 0;
+ gridLayout.marginWidth = 0;
+ gridLayout.horizontalSpacing = 0;
+ gridLayout.verticalSpacing = 5;
+ return gridLayout;
+ }
+
}
17 years, 5 months
JBoss Tools SVN: r2355 - in trunk/common/plugins: org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting and 1 other directory.
by jbosstools-commits@lists.jboss.org
Author: max.andersen(a)jboss.com
Date: 2007-07-08 03:28:36 -0400 (Sun, 08 Jul 2007)
New Revision: 2355
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java
trunk/common/plugins/org.jboss.tools.common.model/resources/help/keys-model.properties
Log:
EXIN-240 fixed title and date pattern
Modified: trunk/common/plugins/org.jboss.tools.common.model/resources/help/keys-model.properties
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model/resources/help/keys-model.properties 2007-07-07 12:04:08 UTC (rev 2354)
+++ trunk/common/plugins/org.jboss.tools.common.model/resources/help/keys-model.properties 2007-07-08 07:28:36 UTC (rev 2355)
@@ -636,7 +636,7 @@
SharableVPEEditor.show_comments=Show Comments in Visual Editor
-ReportProblemWizard.WindowTitle=Report Problemsssss
+ReportProblemWizard.WindowTitle=Report Problems
ReportProblemWizard.Title=Red Hat Developer Studio
ReportProblemWizard.Message=Creates a zip file with information useful when reporting and debugging issues
Modified: trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java
===================================================================
--- trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java 2007-07-07 12:04:08 UTC (rev 2354)
+++ trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/reporting/ReportProblemWizard.java 2007-07-08 07:28:36 UTC (rev 2355)
@@ -93,7 +93,7 @@
/** LOG_DATE_FORMAT */
final private SimpleDateFormat LOG_DATE_FORMAT = new SimpleDateFormat(
- "dd_MMM_yyyy__HH_mm_ss_SSS");
+ "yyyyMMddHHmmss");
/** log file name */
private Text logFileName;
17 years, 5 months
JBoss Tools SVN: r2353 - trunk/documentation/GettingStartedGuide/docs/userguide/en/modules.
by jbosstools-commits@lists.jboss.org
Author: afedosik
Date: 2007-07-07 08:00:19 -0400 (Sat, 07 Jul 2007)
New Revision: 2353
Modified:
trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GettingStartedStrutsValidationExamples.xml
Log:
bug fixed
Modified: trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GettingStartedStrutsValidationExamples.xml
===================================================================
--- trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GettingStartedStrutsValidationExamples.xml 2007-07-07 11:38:20 UTC (rev 2352)
+++ trunk/documentation/GettingStartedGuide/docs/userguide/en/modules/GettingStartedStrutsValidationExamples.xml 2007-07-07 12:00:19 UTC (rev 2353)
@@ -74,7 +74,7 @@
<para>you don't actually have to do any of the script coding. The Validation Framework handles this.</para>
<para>To see how this works in our application, you'll just need to make a couple of modifications to one of the JSP files.</para>
<itemizedlist continuation="continues">
-<listitem><para>Double-click inputname.jsp under <emphasis>StrutsHello/WEB-ROOT(WebContent)/pages to open it for editing.</para></listitem>
+<listitem><para>Double-click inputname.jsp under <emphasis>StrutsHello/WEB-ROOT(WebContent)/pages</emphasis> to open it for editing.</para></listitem>
<listitem><para>Find the tag near the top and hit Return to make a new line under it.</para></listitem>
<listitem><para>In the Red Hat Palette view to the right, open the HTML folder and click on the javascript tag.</para></listitem>
<listitem><para>Back in the editor, just in front of the closing slash for this inserted tag, hit Ctrl+Space and select formName from the prompting menu.</para></listitem>
17 years, 5 months