Author: akazakov
Date: 2007-06-27 13:51:15 -0400 (Wed, 27 Jun 2007)
New Revision: 2197
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BijectedAttributeType.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/IBijectedAttribute.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamModelObject.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamXmlElement.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ScopeType.java
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponent.java
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/ISeamProperty.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCorePlugin.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.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/SeamProperty.java
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/xml/XMLScanner.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaHelper.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaValidator.java
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java
Log:
Seam Tools Model
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BijectedAttributeType.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BijectedAttributeType.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/BijectedAttributeType.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -0,0 +1,20 @@
+ /*******************************************************************************
+ * 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.core;
+
+/**
+ * @author igels
+ *
+ */
+public enum BijectedAttributeType {
+ IN,
+ OUT
+}
\ No newline at end of file
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/IBijectedAttribute.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/IBijectedAttribute.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/IBijectedAttribute.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -0,0 +1,34 @@
+ /*******************************************************************************
+ * 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.core;
+
+import org.eclipse.jdt.core.IMember;
+
+/**
+ * @author igels
+ */
+public interface IBijectedAttribute {
+
+ /**
+ * @return name
+ */
+ public String getName();
+
+ /**
+ * @return type
+ */
+ public BijectedAttributeType getType();
+
+ /**
+ * @return java source element
+ */
+ public IMember getJavaElement();
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponent.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponent.java 2007-06-27
16:59:56 UTC (rev 2196)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamComponent.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -10,36 +10,86 @@
******************************************************************************/
package org.jboss.tools.seam.core;
-public interface ISeamComponent {
-
- //Common to all components attributes
- public static String NAME = "name";
- public static String CLASS = "class";
- public static String SCOPE = "scope";
- public static String PRECEDENCE = "precedence";
- public static String INSTALLED = "installed";
- public static String AUTO_CREATE = "auto-create";
- public static String JNDI_NAME = "jndi-name";
-
- //If property has default value but it cannot be resolved yet,
- //then set property value to this constant.
- //TODO specify string value
- public String DEFAULT = "";
+import java.util.List;
+import java.util.Set;
- public ISeamProperty<? extends Object> getProperty(String propertyName);
- public void addProperty(ISeamProperty<? extends Object> property);
+import org.eclipse.jdt.core.IType;
+public interface ISeamComponent extends ISeamModelObject {
+
/**
- * Convenient access methods to properties common for all components
- * Implementation has to create and access ISeamProperty instances for
- * these properties, to allow storing attribute location in source.
+ * @return Name
*/
public String getName();
+
+ /**
+ * @return qualified Class name of component
+ */
public String getClassName();
- public String getScope();
- public String getPrecedence();
- public boolean isInstalled();
- public boolean isAutoCreate();
- public String getJndiName();
-}
+ /**
+ * @return scope type
+ */
+ public ScopeType getScope();
+
+ /**
+ * @return bijected attributes
+ */
+ public Set<IBijectedAttribute> getBijectedAttributes();
+
+ /**
+ * Adds bijected attribute
+ */
+ public void addBijectedAttribute(IBijectedAttribute attribute);
+
+ /**
+ * Returns bijected attributes by name
+ * @param name
+ * @return
+ */
+ public Set<IBijectedAttribute> getBijectedAttributesByName(String name);
+
+ /**
+ * Returns bijected attributes by type
+ * @param type
+ * @return
+ */
+ public Set<IBijectedAttribute> getBijectedAttributesByType(BijectedAttributeType
type);
+
+ /**
+ * Returns all properties from component.xml for that component.
+ * @param propertyName
+ * @return
+ */
+ public List<ISeamProperty<? extends Object>> getProperties(String
propertyName);
+
+ /**
+ * Returns properties by name from component.xml.
+ * @param propertyName
+ * @return
+ */
+ public Set<ISeamProperty<? extends Object>> getProperties();
+
+ /**
+ * Adds property to component.
+ * @param property
+ */
+ public void addProperty(ISeamProperty<? extends Object> property);
+
+ /**
+ * @return Set of Java source classes
+ */
+ public Set<IType> getJavaSourceClasses();
+
+ /**
+ * @param sourceClass
+ */
+ public void addJavaSourceClass(IType sourceClass);
+
+ /**
+ * @return Set of source xml elements
+ */
+ public Set<ISeamXmlElement> getXmlSourceElements();
+
+ // TODO add @Rules @Factory ...
+}
\ No newline at end of file
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamModelObject.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamModelObject.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamModelObject.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -0,0 +1,19 @@
+/*******************************************************************************
+ * 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.core;
+
+public interface ISeamModelObject {
+
+ /**
+ * @return ID of Model Object
+ */
+ public String getId();
+}
\ No newline at end of file
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-06-27
16:59:56 UTC (rev 2196)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProject.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -11,12 +11,39 @@
package org.jboss.tools.seam.core;
import java.util.Set;
+
import org.eclipse.core.resources.IProjectNature;
public interface ISeamProject extends IProjectNature {
+
public static String NATURE_ID = "org.jboss.tools.seam.core.seam";
-
- public ISeamComponent getComponent(String name);
+
+ /**
+ * @param name of component.
+ * @return Set of ISeamComponents by name.
+ */
+ public Set<ISeamComponent> getComponentsByName(String name);
+
+ /**
+ * @param type of scope.
+ * @return Set of ISeamComponents by Scope Type.
+ */
+ public Set<ISeamComponent> getComponentsByScope(ScopeType type);
+
+ /**
+ * @param className
+ * @return Set of ISeamComponents by class name.
+ */
+ public Set<ISeamComponent> getComponentsByClass(String className);
+
+ /**
+ * @param id of component.
+ * @return ISeamComponent by model object ID.
+ */
+ public ISeamComponent getComponent(String modelObjectId);
+
+ /**
+ * @return Set of ISeamComponents
+ */
public Set<ISeamComponent> getComponents();
-
-}
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProperty.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProperty.java 2007-06-27
16:59:56 UTC (rev 2196)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamProperty.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -10,16 +10,18 @@
******************************************************************************/
package org.jboss.tools.seam.core;
-public interface ISeamProperty<T extends Object> {
-
+import org.eclipse.core.resources.IFile;
+
+/**
+ * Seam Property defined in Component.xml
+ * @param <T>
+ */
+public interface ISeamProperty<T extends Object> extends ISeamXmlElement {
+
public String getName();
- public int getStartPosition();
- public int getLength();
-
public T getValue();
public String getStringValue();
-
+
public void setObject(Object value);
-
-}
+}
\ No newline at end of file
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamXmlElement.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamXmlElement.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ISeamXmlElement.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -0,0 +1,24 @@
+ /*******************************************************************************
+ * 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
+ *
+ * Contributor:
+ * Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+package org.jboss.tools.seam.core;
+
+import org.eclipse.core.resources.IFile;
+
+/**
+ * @author igels
+ * TODO should we use WTP's stuff instead?
+ */
+public interface ISeamXmlElement {
+
+ public IFile getSourceFile();
+ public int getStartPosition();
+ public int getLength();
+}
\ No newline at end of file
Added:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ScopeType.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ScopeType.java
(rev 0)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/ScopeType.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * 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.core;
+
+/**
+ * Types of Seam Scopes.
+ * @author igels
+ */
+public enum ScopeType {
+ STATELESS,
+ METHOD,
+ EVENT,
+ PAGE,
+ CONVERSATION,
+ SESSION,
+ APPLICATION,
+ BUSINESS_PROCESS,
+ UNSPECIFIED;
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2007-06-27
16:59:56 UTC (rev 2196)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCoreBuilder.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -89,7 +89,7 @@
try {
c = scanner.parse(f);
} catch (Exception e) {
- SeamCorePlugin.log(e);
+ SeamCorePlugin.getDefault().logError(e);
}
if(c != null) componentsLoaded(c, f);
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCorePlugin.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCorePlugin.java 2007-06-27
16:59:56 UTC (rev 2196)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/SeamCorePlugin.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -10,15 +10,14 @@
******************************************************************************/
package org.jboss.tools.seam.core;
-import org.eclipse.core.runtime.Status;
import org.eclipse.jface.resource.ImageDescriptor;
-import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.jboss.tools.common.log.BaseUIPlugin;
import org.osgi.framework.BundleContext;
/**
* The activator class controls the plug-in life cycle
*/
-public class SeamCorePlugin extends AbstractUIPlugin {
+public class SeamCorePlugin extends BaseUIPlugin {
// The plug-in ID
public static final String PLUGIN_ID = "org.jboss.tools.seam.core";
@@ -69,9 +68,4 @@
public static ImageDescriptor getImageDescriptor(String path) {
return imageDescriptorFromPlugin(PLUGIN_ID, path);
}
-
- static public void log(Exception ex) {
- getDefault().getLog().log(new Status(Status.ERROR, PLUGIN_ID, Status.OK, "No
message", ex));
- }
-
-}
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java 2007-06-27
16:59:56 UTC (rev 2196)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamComponent.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -11,31 +11,26 @@
package org.jboss.tools.seam.internal.core;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IType;
+import org.jboss.tools.seam.core.BijectedAttributeType;
+import org.jboss.tools.seam.core.IBijectedAttribute;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamProperty;
+import org.jboss.tools.seam.core.ISeamXmlElement;
+import org.jboss.tools.seam.core.ScopeType;
public class SeamComponent implements ISeamComponent {
protected Map<String,ISeamProperty<? extends Object>> properties = new
HashMap<String, ISeamProperty<? extends Object>>();
protected IPath source;
-
+
public SeamComponent () {
- properties.put(NAME, new SeamProperty<String>(NAME));
- properties.put(CLASS, new SeamProperty<String>(CLASS));
- properties.put(SCOPE, new SeamProperty<String>(SCOPE, DEFAULT));
}
- public String getName() {
- return getStringProperty(NAME);
- }
-
- public void setName(String name) {
- setStringProperty(NAME, name);
- }
-
public Set<String> getPropertyNames() {
return properties.keySet();
}
@@ -53,11 +48,11 @@
Object value = o.getValue();
return value == null ? null : value.toString();
}
-
+
public ISeamProperty<? extends Object> getProperty(String propertyName) {
return properties.get(propertyName);
}
-
+
public void addProperty(ISeamProperty<? extends Object> property) {
properties.put(property.getName(), property);
}
@@ -71,63 +66,125 @@
}
properties.put(propertyName, p);
}
-
+
public void setSource(IPath path) {
source = path;
}
- public String getClassName() {
- return getStringProperty(CLASS);
+ /**
+ * @return ID of Seam Component. It's unique within Project.
+ */
+ public String getId() {
+ return getClassName() + ":" + getName();
}
-
- public void setClassName(String className) {
- setStringProperty(CLASS, className);
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.core.ISeamComponent#addBijectedAttribute(org.jboss.tools.seam.core.IBijectedAttribute)
+ */
+ public void addBijectedAttribute(IBijectedAttribute attribute) {
+ // TODO Auto-generated method stub
+
}
-
- public String getScope() {
- return getStringProperty(SCOPE);
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.core.ISeamComponent#addJavaSourceClass(org.eclipse.jdt.core.IType)
+ */
+ public void addJavaSourceClass(IType sourceClass) {
+ // TODO Auto-generated method stub
+
}
- public void setScope(String scope) {
- setStringProperty(SCOPE, scope);
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.core.ISeamComponent#getBijectedAttributes()
+ */
+ public Set<IBijectedAttribute> getBijectedAttributes() {
+ // TODO Auto-generated method stub
+ return null;
}
-
- public String getJndiName() {
- return getStringProperty(JNDI_NAME);
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.core.ISeamComponent#getBijectedAttributesByName(java.lang.String)
+ */
+ public Set<IBijectedAttribute> getBijectedAttributesByName(String name) {
+ // TODO Auto-generated method stub
+ return null;
}
- public void setJndiName(String jndiName) {
- setStringProperty(JNDI_NAME, jndiName);
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.core.ISeamComponent#getBijectedAttributesByType(org.jboss.tools.seam.core.BijectedAttributeType)
+ */
+ public Set<IBijectedAttribute> getBijectedAttributesByType(
+ BijectedAttributeType type) {
+ // TODO Auto-generated method stub
+ return null;
}
-
- public String getPrecedence() {
- return getStringProperty(PRECEDENCE);
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.core.ISeamComponent#getClassName()
+ */
+ public String getClassName() {
+ // TODO Auto-generated method stub
+ return null;
}
- public void setPrecedence(String precedence) {
- setStringProperty(PRECEDENCE, precedence);
+ public void setClassName(String name) {
+ // TODO Auto-generated method stub
}
-
- public boolean isAutoCreate() {
- return getBooleanProperty(AUTO_CREATE);
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.core.ISeamComponent#getJavaSourceClasses()
+ */
+ public Set<IType> getJavaSourceClasses() {
+ // TODO Auto-generated method stub
+ return null;
}
- public void setAutoCreate(String autoCreate) {
- if(DEFAULT.equals(autoCreate) || autoCreate == null || autoCreate.length() == 0) {
- setStringProperty(AUTO_CREATE, DEFAULT);
- }
- addProperty(new SeamProperty<Boolean>(AUTO_CREATE,
Boolean.parseBoolean(autoCreate)));
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.core.ISeamComponent#getName()
+ */
+ public String getName() {
+ // TODO Auto-generated method stub
+ return null;
}
-
- public boolean isInstalled() {
- return getBooleanProperty(INSTALLED);
- }
- public void setInstalled(String installed) {
- if(DEFAULT.equals(installed) || installed == null || installed.length() == 0) {
- setStringProperty(INSTALLED, DEFAULT);
- }
- addProperty(new SeamProperty<Boolean>(INSTALLED,
Boolean.parseBoolean(installed)));
+ public void setName(String name) {
+ // TODO Auto-generated method stub
}
-
-}
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.core.ISeamComponent#getProperties(java.lang.String)
+ */
+ public List<ISeamProperty<? extends Object>> getProperties(
+ String propertyName) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.core.ISeamComponent#getProperties()
+ */
+ public Set<ISeamProperty<? extends Object>> getProperties() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.core.ISeamComponent#getScope()
+ */
+ public ScopeType getScope() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public void setScope(ScopeType scope) {
+ // TODO Auto-generated method stub
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.core.ISeamComponent#getXmlSourceElements()
+ */
+ public Set<ISeamXmlElement> getXmlSourceElements() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
\ No newline at end of file
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-06-27
16:59:56 UTC (rev 2196)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -21,6 +21,7 @@
import org.eclipse.core.runtime.IPath;
import org.jboss.tools.seam.core.ISeamComponent;
import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.ScopeType;
/**
*
@@ -29,9 +30,9 @@
public class SeamProject implements ISeamProject {
IProject project;
Map<String,SeamComponent> components = new HashMap<String,
SeamComponent>();
-
- public SeamProject() {}
+ public SeamProject() {}
+
public void configure() throws CoreException {
}
@@ -46,26 +47,24 @@
this.project = project;
load();
}
-
+
/**
* Loads results of last build, which are considered
* actual until next build.
*/
protected void load() {
-
}
-
+
/**
* Stores results of last build, so that on exit/enter Eclipse
* load them without rebuilding project
*/
protected void store() {
-
}
- public ISeamComponent getComponent(String name) {
- return components.get(name);
- }
+// public ISeamComponent getComponentByName(String name) {
+// return components.get(name);
+// }
public Set<ISeamComponent> getComponents() {
//TODO store cash
@@ -73,7 +72,7 @@
set.addAll(components.values());
return set;
}
-
+
/**
* Package local method called by builder.
* @param component
@@ -87,7 +86,7 @@
components.put(list[i].getName(), list[i]);
}
}
-
+
/**
* Package local method called by builder.
* @param source
@@ -102,4 +101,35 @@
}
}
-}
+ public ISeamComponent getComponent(String modelObjectId) {
+ return components.get(modelObjectId);
+ }
+
+ public Set<ISeamComponent> getComponentsByName(String name) {
+ Set<ISeamComponent> result = new HashSet<ISeamComponent>();
+ Iterator<SeamComponent> iterator = components.values().iterator();
+ while(iterator.hasNext()) {
+ SeamComponent component = iterator.next();
+ if(name.equals(component.getName())) {
+ result.add(component);
+ }
+ }
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.core.ISeamProject#getComponentsByClass(java.lang.String)
+ */
+ public Set<ISeamComponent> getComponentsByClass(String className) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ /* (non-Javadoc)
+ * @see
org.jboss.tools.seam.core.ISeamProject#getComponentsByScope(org.jboss.tools.seam.core.ScopeType)
+ */
+ public Set<ISeamComponent> getComponentsByScope(ScopeType type) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
\ No newline at end of file
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProperty.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProperty.java 2007-06-27
16:59:56 UTC (rev 2196)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProperty.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -10,6 +10,7 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core;
+import org.eclipse.core.resources.IFile;
import org.jboss.tools.seam.core.ISeamProperty;
public class SeamProperty<T extends Object> implements ISeamProperty<T> {
@@ -66,4 +67,11 @@
this.value = (T)value;
}
-}
+ /* (non-Javadoc)
+ * @see org.jboss.tools.seam.core.ISeamXmlElement#getSourceFile()
+ */
+ public IFile getSourceFile() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+}
\ No newline at end of file
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-06-27
16:59:56 UTC (rev 2196)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/java/JavaScanner.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -137,7 +137,8 @@
component.setClassName(n);
component.setName(visitor.name);
if(visitor.scope != null) {
- component.setScope(visitor.scope);
+ //TODO
+ //component.setScope(visitor.scope);
}
}
}
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-06-27
16:59:56 UTC (rev 2196)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/scanner/xml/XMLScanner.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -73,13 +73,14 @@
static Set<String> COMMON_ATTRIBUTES = new HashSet<String>();
static {
- COMMON_ATTRIBUTES.add(ISeamComponent.NAME);
- COMMON_ATTRIBUTES.add(ISeamComponent.CLASS);
- COMMON_ATTRIBUTES.add(ISeamComponent.SCOPE);
- COMMON_ATTRIBUTES.add(ISeamComponent.PRECEDENCE);
- COMMON_ATTRIBUTES.add(ISeamComponent.INSTALLED);
- COMMON_ATTRIBUTES.add(ISeamComponent.AUTO_CREATE);
- COMMON_ATTRIBUTES.add(ISeamComponent.JNDI_NAME);
+ //TODO
+// COMMON_ATTRIBUTES.add(ISeamComponent.NAME);
+// COMMON_ATTRIBUTES.add(ISeamComponent.CLASS);
+// COMMON_ATTRIBUTES.add(ISeamComponent.SCOPE);
+// COMMON_ATTRIBUTES.add(ISeamComponent.PRECEDENCE);
+// COMMON_ATTRIBUTES.add(ISeamComponent.INSTALLED);
+// COMMON_ATTRIBUTES.add(ISeamComponent.AUTO_CREATE);
+// COMMON_ATTRIBUTES.add(ISeamComponent.JNDI_NAME);
}
public SeamComponent[] parse(XModelObject o) {
@@ -91,13 +92,14 @@
if(componentEntity.getAttribute("class") != null) {
//This is a component model object
SeamComponent component = new SeamComponent();
- component.setName(os[i].getAttributeValue(ISeamComponent.NAME));
- component.setClassName(os[i].getAttributeValue(ISeamComponent.CLASS));
- component.setScope(os[i].getAttributeValue(ISeamComponent.SCOPE));
- component.setPrecedence(os[i].getAttributeValue(ISeamComponent.PRECEDENCE));
- component.setInstalled(os[i].getAttributeValue(ISeamComponent.INSTALLED));
- component.setAutoCreate(os[i].getAttributeValue(ISeamComponent.AUTO_CREATE));
- component.setJndiName(os[i].getAttributeValue(ISeamComponent.JNDI_NAME));
+ //TODO
+// component.setName(os[i].getAttributeValue(ISeamComponent.NAME));
+// component.setClassName(os[i].getAttributeValue(ISeamComponent.CLASS));
+// component.setScope(os[i].getAttributeValue(ISeamComponent.SCOPE));
+// component.setPrecedence(os[i].getAttributeValue(ISeamComponent.PRECEDENCE));
+// component.setInstalled(os[i].getAttributeValue(ISeamComponent.INSTALLED));
+// component.setAutoCreate(os[i].getAttributeValue(ISeamComponent.AUTO_CREATE));
+// component.setJndiName(os[i].getAttributeValue(ISeamComponent.JNDI_NAME));
XAttribute[] attributes = componentEntity.getAttributes();
for (int ia = 0; ia < attributes.length; ia++) {
@@ -145,8 +147,9 @@
} else if(os[i].getModelEntity().getName().startsWith("SeamFactory")) {
//TODO what is the best way for factory?
SeamComponent component = new SeamComponent();
- component.setName(os[i].getAttributeValue(ISeamComponent.NAME));
- component.setScope(os[i].getAttributeValue(ISeamComponent.SCOPE));
+ //TODO
+// component.setName(os[i].getAttributeValue(ISeamComponent.NAME));
+// component.setScope(os[i].getAttributeValue(ISeamComponent.SCOPE));
String value = os[i].getAttributeValue("value");
//TODO how should we resolve value?
if(value != null) component.setStringProperty("value", value);
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaHelper.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaHelper.java 2007-06-27
16:59:56 UTC (rev 2196)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaHelper.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -10,8 +10,20 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core.validation;
+import org.eclipse.core.runtime.CoreException;
import org.eclipse.wst.validation.internal.operations.WorkbenchContext;
+import org.jboss.tools.seam.core.ISeamProject;
+import org.jboss.tools.seam.core.SeamCorePlugin;
public class SeamJavaHelper extends WorkbenchContext {
+ public ISeamProject getSeamProject() {
+ ISeamProject project = null;
+ try {
+ project = (ISeamProject)getProject().getNature(ISeamProject.NATURE_ID);
+ } catch (CoreException e) {
+ SeamCorePlugin.getDefault().logError("Can't get Seam Project", e);
+ }
+ return project;
+ }
}
\ No newline at end of file
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-06-27
16:59:56 UTC (rev 2196)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/validation/SeamJavaValidator.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -10,12 +10,20 @@
******************************************************************************/
package org.jboss.tools.seam.internal.core.validation;
+import java.util.Set;
+
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.jobs.ISchedulingRule;
import org.eclipse.wst.validation.internal.core.ValidationException;
import org.eclipse.wst.validation.internal.provisional.core.IReporter;
import org.eclipse.wst.validation.internal.provisional.core.IValidationContext;
import org.eclipse.wst.validation.internal.provisional.core.IValidatorJob;
+import org.jboss.tools.seam.core.ISeamComponent;
+import org.jboss.tools.seam.core.ISeamProject;
public class SeamJavaValidator implements IValidatorJob {
@@ -26,7 +34,23 @@
public IStatus validateInJob(IValidationContext helper, IReporter reporter) throws
ValidationException {
SeamJavaHelper seamJavaHelper = (SeamJavaHelper)helper;
- System.out.println("Validate");
+ ISeamProject project = seamJavaHelper.getSeamProject();
+ Set<ISeamComponent> components = project.getComponents();
+ for (ISeamComponent seamComponent : components) {
+// seamComponent.
+ }
+ String[] uris = seamJavaHelper.getURIs();
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ if (uris.length > 0) {
+ IFile currentFile = null;
+ for (int i = 0; i < uris.length && !reporter.isCancelled(); i++) {
+ currentFile = root.getFile(new Path(uris[i]));
+ if (currentFile != null && currentFile.exists()) {
+ System.out.println(currentFile);
+ }
+ }
+ }
+
return OK_STATUS;
}
Modified:
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java
===================================================================
---
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java 2007-06-27
16:59:56 UTC (rev 2196)
+++
trunk/seam/tests/org.jboss.tools.seam.core.test/src/org/jboss/tools/seam/core/test/ScannerTest.java 2007-06-27
17:51:15 UTC (rev 2197)
@@ -10,8 +10,12 @@
******************************************************************************/
package org.jboss.tools.seam.core.test;
+import java.util.Iterator;
import java.util.List;
+import java.util.Set;
+import junit.framework.TestCase;
+
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IResource;
@@ -26,8 +30,6 @@
import org.jboss.tools.seam.internal.core.SeamProject;
import org.jboss.tools.seam.internal.core.scanner.IFileScanner;
-import junit.framework.TestCase;
-
public class ScannerTest extends TestCase {
TestProjectProvider provider = null;
IProject project = null;
@@ -80,18 +82,21 @@
//After having tested details of xml scanner now let us check
// that it succeeded in build.
- ISeamComponent c = seamProject.getComponent("myComponent");
-
- assertTrue("Seam builder must put myComponent to project.", c != null);
-
- //We have list property in this component
- ISeamProperty<?> property = c.getProperty("myList");
- Object o = property.getValue();
- assertTrue("Property myList in myComponent must be instanceof
java.util.List.", o instanceof List);
- List<?> oList = (List<?>)o;
- assertTrue("Property myList misses value 'value1.",
"value1".equals(oList.get(0)));
-
-
+ Set<ISeamComponent> components =
seamProject.getComponentsByName("myComponent");
+
+ assertTrue("Seam builder must put myComponent to project.", components.size()
== 1);
+
+ for (Iterator iterator = components.iterator(); iterator.hasNext();) {
+ ISeamComponent c = (ISeamComponent) iterator.next();
+ //We have list property in this component
+ List<ISeamProperty<?>> prs = c.getProperties("myList");
+ assertTrue("Property myList is not found in components.xml", prs.size() ==
1);
+ ISeamProperty<?> property = prs.get(0);
+ Object o = property.getValue();
+ assertTrue("Property myList in myComponent must be instanceof
java.util.List.", o instanceof List);
+ List<?> oList = (List<?>)o;
+ assertTrue("Property myList misses value 'value1.",
"value1".equals(oList.get(0)));
+ }
}
public void testJavaScanner() {
@@ -128,9 +133,9 @@
//After having tested details of java scanner now let us check
//that it succeeded in build.
- ISeamComponent c = seamProject.getComponent("myUser");
+ Set<ISeamComponent> components =
seamProject.getComponentsByName("myUser");
- assertTrue("Seam builder must put myUser to project.", c != null);
+ assertTrue("Seam builder must put myUser to project.", components.size() ==
1);
}
@@ -183,10 +188,8 @@
* After having tested details of library scanner now let us check
* that it succeeded in build.
*/
- ISeamComponent c = seamProject.getComponent("actor");
-
- assertTrue("Seam builder must put actor to project.", c != null);
+ Set<ISeamComponent> components =
seamProject.getComponentsByName("actor");
+ assertTrue("Seam builder must put actor to project.",
components.size()==1);
}
-
-}
+}
\ No newline at end of file