Author: dgolovin
Date: 2007-09-10 14:54:43 -0400 (Mon, 10 Sep 2007)
New Revision: 3512
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.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/project/facet/SeamFacetInstallDelegete.java
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/WtpUtils.java
trunk/seam/plugins/org.jboss.tools.seam.core/templates/ear/.settings/org.eclipse.wst.common.component
trunk/seam/plugins/org.jboss.tools.seam.core/templates/ear/EarContent/META-INF/application.xml
trunk/seam/plugins/org.jboss.tools.seam.core/templates/ejb/.classpath
Log:
fixes for :
http://jira.jboss.org/jira/browse/JBIDE-759
http://jira.jboss.org/jira/browse/JBIDE-351
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2007-09-10
18:54:35 UTC (rev 3511)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/core/project/facet/SeamRuntimeManager.java 2007-09-10
18:54:43 UTC (rev 3512)
@@ -10,7 +10,6 @@
******************************************************************************/
package org.jboss.tools.seam.core.project.facet;
-import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
@@ -18,10 +17,8 @@
import java.util.Map;
import org.eclipse.core.resources.IProject;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.jboss.tools.seam.core.ISeamProject;
import org.jboss.tools.seam.core.SeamCorePlugin;
-import org.jboss.tools.seam.internal.core.SeamPreferenceInitializer;
import org.jboss.tools.seam.internal.core.project.facet.SeamFacetPreferenceInitializer;
/**
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-09-10
18:54:35 UTC (rev 3511)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/SeamProject.java 2007-09-10
18:54:43 UTC (rev 3512)
@@ -63,18 +63,23 @@
* @author Viacheslav Kabanovich
*/
public class SeamProject extends SeamObject implements ISeamProject, IProjectNature {
+
IProject project;
+
ClassPath classPath = new ClassPath(this);
SeamRuntime runtime = null;
Set<IPath> sourcePaths = new HashSet<IPath>();
+
private boolean isStorageResolved = false;
SeamScope[] scopes = new SeamScope[ScopeType.values().length];
+
Map<ScopeType, SeamScope> scopesMap = new HashMap<ScopeType, SeamScope>();
Set<SeamProject> dependsOn = new HashSet<SeamProject>();
+
Set<SeamProject> usedBy = new HashSet<SeamProject>();
{
@@ -86,8 +91,11 @@
}
Map<String, SeamComponent> allComponents = new HashMap<String,
SeamComponent>();
+
protected Set<ISeamFactory> allFactories = new HashSet<ISeamFactory>();
+
Set<ISeamContextVariable> allVariables = new
HashSet<ISeamContextVariable>();
+
Map<String, SeamJavaComponentDeclaration> javaDeclarations = new
HashMap<String, SeamJavaComponentDeclaration>();
Map<String, ISeamPackage> packages = new HashMap<String, ISeamPackage>();
@@ -96,20 +104,35 @@
SeamValidationContext validationContext;
+ /**
+ *
+ */
public SeamProject() {}
+ /**
+ *
+ */
public void configure() throws CoreException {
addToBuildSpec(SeamCoreBuilder.BUILDER_ID);
}
+ /**
+ *
+ */
public void deconfigure() throws CoreException {
removeFromBuildSpec(SeamCoreBuilder.BUILDER_ID);
}
+ /**
+ *
+ */
public IProject getProject() {
return project;
}
+ /**
+ *
+ */
public SeamRuntime getRuntime() {
return runtime;
}
@@ -137,25 +160,40 @@
return scopesMap.get(scopeType);
}
+ /**
+ *
+ */
public Collection<ISeamPackage> getPackages() {
return packages.values();
}
+ /**
+ *
+ */
public Collection<ISeamPackage> getAllPackages() {
List<ISeamPackage> list = new ArrayList<ISeamPackage>();
SeamPackageUtil.collectAllPackages(packages, list);
return list;
}
+ /**
+ *
+ */
public ISeamPackage getPackage(ISeamComponent c) {
String pkg = SeamPackageUtil.getPackageName(c);
return SeamPackageUtil.findPackage(this, packages, pkg);
}
+ /**
+ *
+ */
public ISeamProject getSeamProject() {
return this;
}
+ /**
+ *
+ */
public void setProject(IProject project) {
this.project = project;
setSourcePath(project.getFullPath());
@@ -165,6 +203,9 @@
// load();
}
+ /**
+ *
+ */
void loadRuntime() {
IEclipsePreferences prefs = getSeamPreferences();
if(prefs == null) return;
@@ -177,11 +218,19 @@
}
}
+ /**
+ *
+ * @return
+ */
public IEclipsePreferences getSeamPreferences() {
IScopeContext projectScope = new ProjectScope(project);
return projectScope.getNode(SeamCorePlugin.PLUGIN_ID);
}
+ /**
+ *
+ * @param p
+ */
public void addSeamProject(SeamProject p) {
if(dependsOn.contains(p)) return;
dependsOn.add(p);
@@ -202,14 +251,26 @@
}
}
+ /**
+ *
+ * @return
+ */
public Set<SeamProject> getSeamProjects() {
return dependsOn;
}
+ /**
+ *
+ * @param p
+ */
public void addDependentSeamProject(SeamProject p) {
usedBy.add(p);
}
+ /**
+ *
+ * @param p
+ */
public void removeSeamProject(SeamProject p) {
if(!dependsOn.contains(p)) return;
p.usedBy.remove(this);
@@ -223,10 +284,18 @@
}
}
+ /**
+ *
+ * @return
+ */
public ClassPath getClassPath() {
return classPath;
}
+ /**
+ *
+ * @param load
+ */
public void resolveStorage(boolean load) {
if(isStorageResolved) return;
if(load) {
@@ -236,6 +305,9 @@
}
}
+ /**
+ *
+ */
public void resolve() {
resolveStorage(true);
}
@@ -285,6 +357,9 @@
XMLUtilities.serialize(root, file.getAbsolutePath());
}
+ /**
+ *
+ */
void storeRuntime() {
IEclipsePreferences prefs = getSeamPreferences();
String runtimeName = prefs.get(RUNTIME_NAME, null);
@@ -305,6 +380,9 @@
}
}
+ /*
+ *
+ */
private void storeSourcePaths(Element root) {
Element sourcePathsElement = XMLUtilities.createElement(root,
"source-paths");
for (IPath path : sourcePaths) {
@@ -313,6 +391,9 @@
}
}
+ /*
+ *
+ */
private void storeProjectDependencies(Element root) {
Element dependsOnElement = XMLUtilities.createElement(root,
"depends-on-projects");
for (ISeamProject p : dependsOn) {
@@ -328,6 +409,9 @@
}
}
+ /*
+ *
+ */
private void loadSourcePaths(Element root) {
Element sourcePathsElement = XMLUtilities.getUniqueChild(root,
"source-paths");
if(sourcePathsElement == null) return;
@@ -344,6 +428,9 @@
}
}
+ /*
+ *
+ */
private void loadProjectDependencies(Element root) {
Element dependsOnElement = XMLUtilities.getUniqueChild(root,
"depends-on-projects");
if(dependsOnElement != null) {
@@ -376,12 +463,19 @@
}
+ /*
+ *
+ */
private File getStorageFile() {
IPath path = SeamCorePlugin.getDefault().getStateLocation();
File file = new File(path.toFile(), "projects/" + project.getName());
return file;
}
+ /**
+ *
+ * @return
+ */
public SeamValidationContext getValidationContext() {
if(validationContext==null) {
validationContext = new SeamValidationContext();
@@ -389,10 +483,18 @@
return validationContext;
}
+ /**
+ *
+ * @param name
+ * @return
+ */
public ISeamComponent getComponentByName(String name) {
return allComponents.get(name);
}
+ /**
+ *
+ */
public Set<ISeamComponent> getComponents() {
Set<ISeamComponent> result = new HashSet<ISeamComponent>();
result.addAll(allComponents.values());
@@ -525,6 +627,12 @@
}
}
+ /**
+ *
+ * @param ds
+ * @param source
+ * @throws CloneNotSupportedException
+ */
public void registerComponentsInDependentProjects(LoadedDeclarations ds, IPath source)
throws CloneNotSupportedException {
if(usedBy.size() == 0) return;
if(source.toString().endsWith(".jar")) return;
@@ -542,16 +650,31 @@
}
}
+ /**
+ *
+ * @param s1
+ * @param s2
+ * @return
+ */
boolean stringsEqual(String s1, String s2) {
return s1 == null ? s2 == null : s1.equals(s2);
}
+ /*
+ *
+ * @param oldClassName
+ * @param newClassName
+ * @return
+ */
private boolean isClassNameChanged(String oldClassName, String newClassName) {
if(oldClassName == null || oldClassName.length() == 0) return false;
if(newClassName == null || newClassName.length() == 0) return false;
return !oldClassName.equals(newClassName);
}
+ /*
+ *
+ */
private void onXMLLoadedDeclaration(SeamComponent c, String oldClassName,
ISeamXmlComponentDeclaration xml) {
String className = xml.getClassName();
List<Change> changes = null;
@@ -619,6 +742,11 @@
}
}
+ /**
+ *
+ * @param source
+ * @return
+ */
public Map<Object,ISeamComponentDeclaration> findComponentDeclarations(IPath
source) {
Map<Object,ISeamComponentDeclaration> map = new HashMap<Object,
ISeamComponentDeclaration>();
for (SeamComponent c: allComponents.values()) {
@@ -630,6 +758,10 @@
return map;
}
+ /**
+ *
+ * @param removed
+ */
void componentDeclarationsRemoved(Map<Object,ISeamComponentDeclaration> removed)
{
Collection<ISeamComponentDeclaration> declarations = removed.values();
for (ISeamComponentDeclaration declaration: declarations) {
@@ -662,6 +794,9 @@
}
}
+ /*
+ *
+ */
private List<Change> removeEmptyComponent(SeamComponent c) {
List<Change> changes = null;
ISeamElement p = c.getParent();
@@ -674,6 +809,9 @@
return changes;
}
+ /*
+ *
+ */
private boolean isComponentEmpty(SeamComponent c) {
if(c.getAllDeclarations().size() == 0) return true;
for (ISeamComponentDeclaration d: c.getAllDeclarations()) {
@@ -682,6 +820,11 @@
return true;
}
+ /**
+ *
+ * @param source
+ * @return
+ */
public Map<Object,ISeamFactory> findFactoryDeclarations(IPath source) {
Map<Object,ISeamFactory> map = new HashMap<Object, ISeamFactory>();
for (ISeamFactory c: allFactories) {
@@ -691,6 +834,10 @@
return map;
}
+ /**
+ *
+ * @param removed
+ */
void factoryDeclarationsRemoved(Map<Object,ISeamFactory> removed) {
Iterator<ISeamFactory> iterator = allFactories.iterator();
List<Change> changes = null;
@@ -725,6 +872,9 @@
return getComponentsByScope(type, false);
}
+ /**
+ *
+ */
public Set<ISeamComponent> getComponentsByScope(ScopeType type, boolean
addVisibleScopes) {
Set<ISeamComponent> result = new HashSet<ISeamComponent>();
for(SeamComponent component: allComponents.values()) {
@@ -776,6 +926,9 @@
return getVariablesByScope(scope, false);
}
+ /**
+ *
+ */
public Set<ISeamContextVariable> getVariablesByScope(ScopeType scope, boolean
addVisibleScopes) {
Set<ISeamContextVariable> result = new HashSet<ISeamContextVariable>();
for (ISeamContextVariable v: allVariables) {
@@ -786,6 +939,13 @@
return result;
}
+ /**
+ *
+ * @param v
+ * @param scope
+ * @param addVisibleScopes
+ * @return
+ */
private boolean isVisibleInScope(ISeamContextVariable v, ScopeType scope, boolean
addVisibleScopes) {
if(scope == v.getScope()) {
return true;
@@ -797,14 +957,23 @@
return false;
}
+ /**
+ *
+ */
public void addFactory(ISeamFactory factory) {
allFactories.add(factory);
}
+ /**
+ *
+ */
public Set<ISeamFactory> getFactories() {
return allFactories;
}
+ /**
+ *
+ */
public Set<ISeamFactory> getFactories(String name, ScopeType scope) {
Set<ISeamFactory> result = new HashSet<ISeamFactory>();
for (ISeamFactory f: allFactories) {
@@ -813,6 +982,9 @@
return result;
}
+ /**
+ *
+ */
public Set<ISeamFactory> getFactoriesByName(String name) {
Set<ISeamFactory> result = new HashSet<ISeamFactory>();
for (ISeamFactory f: allFactories) {
@@ -821,10 +993,16 @@
return result;
}
+ /**
+ *
+ */
public Set<ISeamFactory> getFactoriesByScope(ScopeType scope) {
return getFactoriesByScope(scope, false);
}
+ /**
+ *
+ */
public Set<ISeamFactory> getFactoriesByScope(ScopeType scope, boolean
addVisibleScopes) {
Set<ISeamFactory> result = new HashSet<ISeamFactory>();
for (ISeamFactory f: allFactories) {
@@ -835,7 +1013,7 @@
return result;
}
- /* (non-Javadoc)
+ /**
* @see
org.jboss.tools.seam.core.ISeamProject#getFactoriesByPath(org.eclipse.core.runtime.IPath)
*/
public Set<ISeamFactory> getFactoriesByPath(IPath path) {
@@ -848,6 +1026,9 @@
return result;
}
+ /**
+ *
+ */
public void removeFactory(ISeamFactory factory) {
allFactories.remove(factory);
allVariables.remove(factory);
@@ -877,10 +1058,19 @@
return set;
}
+ /**
+ *
+ */
public SeamComponent getComponent(String name) {
return name == null ? null : allComponents.get(name);
}
+ /**
+ *
+ * @param name
+ * @param scopeType
+ * @return
+ */
SeamComponent newComponent(String name, ScopeType scopeType) {
SeamComponent c = new SeamComponent();
c.setName(name);
@@ -890,6 +1080,10 @@
return c;
}
+ /**
+ *
+ * @param changes
+ */
void fireChanges(List<Change> changes) {
if(changes == null || changes.size() == 0) return;
SeamProjectChangeEvent event = new SeamProjectChangeEvent(this, changes);
@@ -904,11 +1098,17 @@
}
}
+ /**
+ *
+ */
public synchronized void addSeamProjectListener(ISeamProjectChangeListener listener) {
if(listeners.contains(listener)) return;
listeners.add(listener);
}
+ /**
+ *
+ */
public synchronized void removeSeamProjectListener(ISeamProjectChangeListener listener)
{
listeners.remove(listener);
}
@@ -956,14 +1156,23 @@
return result;
}
+ /**
+ *
+ */
int revalidateLock = 0;
+ /**
+ *
+ */
void revalidate() {
if(revalidateLock > 0) return;
revalidateScopes();
revalidatePackages();
}
+ /**
+ *
+ */
void revalidateScopes() {
List<Change> changes = null;
for(SeamComponent c : allComponents.values()) {
@@ -984,11 +1193,19 @@
fireChanges(changes);
}
+ /**
+ *
+ */
void revalidatePackages() {
List<Change> changes = SeamPackageUtil.revalidatePackages(this, allComponents,
getComponents(), packages);
fireChanges(changes);
}
+ /**
+ *
+ * @return
+ * @throws CloneNotSupportedException
+ */
Map<IPath, LoadedDeclarations> getAllDeclarations() throws
CloneNotSupportedException {
Map<IPath, LoadedDeclarations> map = new HashMap<IPath,
LoadedDeclarations>();
for (ISeamComponent c : allComponents.values()) {
@@ -1016,6 +1233,11 @@
return map;
}
+ /**
+ *
+ * @param builderID
+ * @throws CoreException
+ */
protected void addToBuildSpec(String builderID) throws CoreException {
IProjectDescription description = getProject().getDescription();
ICommand command = null;
@@ -1036,9 +1258,21 @@
}
}
+ /**
+ *
+ */
static String EXTERNAL_TOOL_BUILDER =
"org.eclipse.ui.externaltools.ExternalToolBuilder";
+
+ /**
+ *
+ */
static final String LAUNCH_CONFIG_HANDLE = "LaunchConfigHandle";
+ /**
+ *
+ * @param builderID
+ * @throws CoreException
+ */
protected void removeFromBuildSpec(String builderID) throws CoreException {
IProjectDescription description = getProject().getDescription();
ICommand[] commands = description.getBuildSpec();
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java 2007-09-10
18:54:35 UTC (rev 3511)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/SeamFacetInstallDelegete.java 2007-09-10
18:54:43 UTC (rev 3512)
@@ -291,6 +291,9 @@
//
********************************************************************************************
AntCopyUtils.copyFileToFolder(new File(seamGenResFolder,"seam.properties"),
srcFolder, true);
+ WtpUtils.createSourceFolder(project, new Path("src/test"),new
Path("src"));
+ WtpUtils.createSourceFolder(project, new Path("src/action"),new
Path("src"));
+ WtpUtils.createSourceFolder(project, new Path("src/model"),new
Path("src"));
// Copy sources to src
AntCopyUtils.copyFileToFile(
new File(seamGenHomeFolder,"src/Authenticator.java"),
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/WtpUtils.java
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/WtpUtils.java 2007-09-10
18:54:35 UTC (rev 3511)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/src/org/jboss/tools/seam/internal/core/project/facet/WtpUtils.java 2007-09-10
18:54:43 UTC (rev 3512)
@@ -129,7 +129,7 @@
return "";
}
- public static IResource createSourceFolder (IProject project, IPath path) {
+ public static IResource createSourceFolder (IProject project, IPath path, IPath exclude)
{
IJavaProject javaProject;
IClasspathEntry[] javaProjectEntries;
IPath outputLocation;
@@ -152,30 +152,8 @@
IPath projPath= javaProject.getProject().getFullPath();
IPath newSourceFolderPath = projPath.append(path);
+ IPath excludeSourceFolderPath = projPath.append(exclude);
- IStatus validate=
workspaceRoot.getWorkspace().validatePath(newSourceFolderPath.toString(),
IResource.FOLDER);
- if (validate.matches(IStatus.ERROR))
- return null;
-
- IResource res= workspaceRoot.findMember(newSourceFolderPath);
- if (res != null) {
- if (res.getType() != IResource.FOLDER) {
- return null;
- }
- } else {
- URI projLocation= javaProject.getProject().getLocationURI();
- if (projLocation != null) {
- try {
- IFileStore store= EFS.getStore(projLocation).getChild(path.toString());
- if (store.fetchInfo().exists()) {
- return null;
- }
- } catch (CoreException e) {
- // Ignore if we cannot check that the file exists.
- // Assume that it doesn't
- }
- }
- }
ArrayList newEntries= new ArrayList(javaProjectEntries.length + 1);
int projectEntryIndex= -1;
@@ -187,7 +165,10 @@
}
if (projPath.equals(curr.getPath())) {
projectEntryIndex= i;
- }
+ }
+ if (excludeSourceFolderPath.equals(curr.getPath())) {
+ continue;
+ }
}
newEntries.add(curr);
}
@@ -216,9 +197,9 @@
}
}
- IFolder newSourceFolder= javaProject.getProject().getFolder(newSourceFolderPath);
+ IFolder newSourceFolder= javaProject.getProject().getFolder(path);
if (!newSourceFolder.exists()) {
- CoreUtility.createFolder(newSourceFolder, true, true, null);
+ CoreUtility.createFolder(newSourceFolder, true, true, new NullProgressMonitor());
}
javaProject.setRawClasspath(newClasspathEntries, newOutputLocation, new
NullProgressMonitor());
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/templates/ear/.settings/org.eclipse.wst.common.component
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/templates/ear/.settings/org.eclipse.wst.common.component 2007-09-10
18:54:35 UTC (rev 3511)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/templates/ear/.settings/org.eclipse.wst.common.component 2007-09-10
18:54:43 UTC (rev 3512)
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project-modules id="moduleCoreId" project-version="1.5.0">
-<wb-module deploy-name="@projectName@">
+<wb-module deploy-name="@projectName@-ear">
<wb-resource deploy-path="/" source-path="/EarContent"/>
<dependent-module deploy-path="/"
handle="module:/resource/@projectName@-ejb/@projectName@-ejb">
<dependency-type>uses</dependency-type>
Modified:
trunk/seam/plugins/org.jboss.tools.seam.core/templates/ear/EarContent/META-INF/application.xml
===================================================================
---
trunk/seam/plugins/org.jboss.tools.seam.core/templates/ear/EarContent/META-INF/application.xml 2007-09-10
18:54:35 UTC (rev 3511)
+++
trunk/seam/plugins/org.jboss.tools.seam.core/templates/ear/EarContent/META-INF/application.xml 2007-09-10
18:54:43 UTC (rev 3512)
@@ -4,7 +4,7 @@
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/application_5.xsd"
version="5">
- <display-name>t2</display-name>
+ <display-name>@projectName@-ear</display-name>
<module>
<web>
Modified: trunk/seam/plugins/org.jboss.tools.seam.core/templates/ejb/.classpath
===================================================================
--- trunk/seam/plugins/org.jboss.tools.seam.core/templates/ejb/.classpath 2007-09-10
18:54:35 UTC (rev 3511)
+++ trunk/seam/plugins/org.jboss.tools.seam.core/templates/ejb/.classpath 2007-09-10
18:54:43 UTC (rev 3512)
@@ -2,7 +2,6 @@
<classpath>
<classpathentry kind="src" path="ejbModule"/>
<classpathentry kind="con"
path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
- <classpathentry kind="con"
path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.generic.runtimeTarget/@runtimeName@"/>
- <classpathentry exported="true" kind="con"
path="org.eclipse.jst.j2ee.internal.module.container"/>
+ <classpathentry kind="con"
path="org.jboss.ide.eclipse.as.classpath.core.runtime.ProjectRuntimeInitializer/@runtimeName@"/>
<classpathentry kind="output" path="build/classes"/>
</classpath>