[jbosstools-commits] JBoss Tools SVN: r43813 - in trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf: jsf2/bean/model and 3 other directories.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Tue Sep 18 20:31:42 EDT 2012
Author: scabanovich
Date: 2012-09-18 20:31:41 -0400 (Tue, 18 Sep 2012)
New Revision: 43813
Modified:
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/bean/build/JSF2ProjectBuilder.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/bean/model/IJSF2Project.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/bean/model/impl/DefinitionContext.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/bean/model/impl/JSF2Project.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/JSFProcessHelper.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBean.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBeans.java
trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java
Log:
JBIDE-12636
https://issues.jboss.org/browse/JBIDE-12636
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/bean/build/JSF2ProjectBuilder.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/bean/build/JSF2ProjectBuilder.java 2012-09-19 00:26:08 UTC (rev 43812)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/bean/build/JSF2ProjectBuilder.java 2012-09-19 00:31:41 UTC (rev 43813)
@@ -29,6 +29,7 @@
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.eclipse.jdt.core.IClassFile;
import org.eclipse.jdt.core.IClasspathEntry;
@@ -57,15 +58,32 @@
public class JSF2ProjectBuilder extends IncrementalProjectBuilder implements IIncrementalProjectBuilderExtension {
JSF2ResourceVisitor resourceVisitor = null;
+
+ /**
+ * Set only for instance created to initially load jsf2 model.
+ */
+ JSF2Project jsf;
public JSF2ProjectBuilder() {}
+ public JSF2ProjectBuilder(JSF2Project jsf) throws CoreException {
+ this.jsf = jsf;
+ build(IncrementalProjectBuilder.FULL_BUILD, null, new NullProgressMonitor());
+ }
+
protected JSF2Project getJSF2Project() {
+ if(jsf != null) {
+ return jsf;
+ }
IProject p = getProject();
if(p == null) return null;
return (JSF2Project)JSF2ProjectFactory.getJSF2Project(p, false);
}
+ IProject getCurrentProject() {
+ return jsf != null ? jsf.getProject() : getProject();
+ }
+
JSF2ResourceVisitor getResourceVisitor() {
if(resourceVisitor == null) {
resourceVisitor = new JSF2ResourceVisitor();
@@ -91,17 +109,19 @@
try {
n.resolveStorage(kind != FULL_BUILD);
+
+ if(kind == FULL_BUILD) n.getClassPath().reset();
//1. Check class path.
boolean isClassPathUpdated = n.getClassPath().update();
Map<String, XModelObject> newJars = new HashMap<String, XModelObject>();
- if(isClassPathUpdated) {
+ if(isClassPathUpdated || kind == FULL_BUILD) {
//2. Update class path. Removed paths will be cached to be applied to working copy of context.
n.getClassPath().setSrcs(getResourceVisitor().srcs);
newJars = n.getClassPath().process();
- }
+ }int i = 0;
//4. Create working copy of context.
n.getDefinitions().newWorkingCopy(kind == FULL_BUILD);
@@ -126,7 +146,7 @@
if (kind == FULL_BUILD) {
fullBuild(monitor);
} else {
- IResourceDelta delta = getDelta(getProject());
+ IResourceDelta delta = getDelta(getCurrentProject());
if (delta == null) {
fullBuild(monitor);
} else {
@@ -154,7 +174,7 @@
try {
JSF2ResourceVisitor rv = getResourceVisitor();
rv.incremental = false;
- getProject().accept(rv);
+ getCurrentProject().accept(rv);
FileSet fs = rv.fileSet;
build(fs, getJSF2Project());
@@ -263,8 +283,8 @@
Set<IPath> visited = new HashSet<IPath>();
public JSF2ResourceVisitor() {
- getJavaSourceRoots(getProject());
- webinfs = WebUtils.getWebInfPaths(getProject());
+ getJavaSourceRoots(getCurrentProject());
+ webinfs = WebUtils.getWebInfPaths(getCurrentProject());
}
void getJavaSourceRoots(IProject project) {
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/bean/model/IJSF2Project.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/bean/model/IJSF2Project.java 2012-09-19 00:26:08 UTC (rev 43812)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/bean/model/IJSF2Project.java 2012-09-19 00:31:41 UTC (rev 43813)
@@ -91,6 +91,6 @@
/**
* Updates model by loaded definitions.
*/
- public void update();
+ public void update(boolean updateDependent);
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/bean/model/impl/DefinitionContext.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/bean/model/impl/DefinitionContext.java 2012-09-19 00:26:08 UTC (rev 43812)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/bean/model/impl/DefinitionContext.java 2012-09-19 00:31:41 UTC (rev 43813)
@@ -243,7 +243,7 @@
typeDefinitions = workingCopy.typeDefinitions;
facesConfig = workingCopy.facesConfig;
- project.update();
+ project.update(true);
workingCopy = null;
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/bean/model/impl/JSF2Project.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/bean/model/impl/JSF2Project.java 2012-09-19 00:26:08 UTC (rev 43812)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/jsf2/bean/model/impl/JSF2Project.java 2012-09-19 00:31:41 UTC (rev 43813)
@@ -13,6 +13,7 @@
import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -35,6 +36,7 @@
import org.jboss.tools.common.util.FileUtil;
import org.jboss.tools.common.xml.XMLUtilities;
import org.jboss.tools.jsf.JSFModelPlugin;
+import org.jboss.tools.jsf.jsf2.bean.build.JSF2ProjectBuilder;
import org.jboss.tools.jsf.jsf2.bean.model.IJSF2ManagedBean;
import org.jboss.tools.jsf.jsf2.bean.model.IJSF2Project;
import org.jboss.tools.jsf.jsf2.bean.model.JSF2ProjectFactory;
@@ -166,7 +168,7 @@
XJob.addRunnableWithPriority(new XRunnable() {
public void run() {
project.resolve();
- project.update();
+ project.update(true);
}
public String getId() {
return "Build JSF2 Project " + project.getProject().getName();
@@ -254,7 +256,7 @@
if(isStorageResolved) return;
isStorageResolved = true;
try {
- getProject().build(IncrementalProjectBuilder.FULL_BUILD, KbBuilder.BUILDER_ID, new HashMap<String,String>(), new NullProgressMonitor());
+ new JSF2ProjectBuilder(this);
} catch (CoreException e) {
JSFModelPlugin.getDefault().logError(e);
}
@@ -281,7 +283,7 @@
fireChanges();
}
- public void update() {
+ public void update(boolean updateDependent) {
FacesConfigDefinition fc = definitions.getFacesConfig();
isMetadataComplete = fc != null && fc.isMetadataComplete();
@@ -309,6 +311,13 @@
}
}
+ if(updateDependent) {
+ Collection<JSF2Project> dependent = new ArrayList<JSF2Project>(usedBy);
+ for (JSF2Project p: dependent) {
+ p.update(false);
+ }
+ }
+
}
public void addBean(IJSF2ManagedBean bean) {
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/JSFProcessHelper.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/JSFProcessHelper.java 2012-09-19 00:26:08 UTC (rev 43812)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/helpers/JSFProcessHelper.java 2012-09-19 00:31:41 UTC (rev 43813)
@@ -93,8 +93,7 @@
targets.put(ppt, getTemplate());
}
}
- Iterator it = groups.keySet().iterator();
- while(it.hasNext()) targets.remove(it.next());
+ for(String s: groups.keySet()) targets.remove(s);
removeObsoleteGroups();
createPageGroups();
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBean.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBean.java 2012-09-19 00:26:08 UTC (rev 43812)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBean.java 2012-09-19 00:31:41 UTC (rev 43813)
@@ -237,9 +237,8 @@
}
}
}
- Iterator<XModelObject> it = map.values().iterator();
- while(it.hasNext()) {
- it.next().removeFromParent();
+ for(XModelObject o: map.values()) {
+ o.removeFromParent();
}
}
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBeans.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBeans.java 2012-09-19 00:26:08 UTC (rev 43812)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFProjectBeans.java 2012-09-19 00:31:41 UTC (rev 43813)
@@ -55,9 +55,8 @@
process(fcs[i], BeanConstants.REFERENCED_BEAN_CONSTANTS, map, classes);
}
- Iterator<XModelObject> it = map.values().iterator();
- while(it.hasNext()) {
- it.next().removeFromParent();
+ for(XModelObject o: map.values()) {
+ o.removeFromParent();
}
} finally {
isLoading = false;
Modified: trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java
===================================================================
--- trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java 2012-09-19 00:26:08 UTC (rev 43812)
+++ trunk/jsf/plugins/org.jboss.tools.jsf/src/org/jboss/tools/jsf/model/pv/JSFPromptingProvider.java 2012-09-19 00:31:41 UTC (rev 43813)
@@ -32,6 +32,7 @@
import org.jboss.tools.jsf.project.JSFNature;
import org.jboss.tools.jsf.web.JSFWebProject;
import org.jboss.tools.jsf.web.pattern.JSFUrlPattern;
+import org.jboss.tools.jst.web.model.helpers.WebAppHelper;
import org.jboss.tools.jst.web.model.pv.WebProjectNode;
import org.jboss.tools.jst.web.project.WebProject;
import org.jboss.tools.jst.web.project.list.IWebPromptingProvider;
@@ -158,7 +159,14 @@
if(url != null && url.length() > 0) list.add(url);
return list;
} else if(JSF_CONVERT_URL_TO_PATH.equals(id)) {
- if(!EclipseResourceUtil.hasNature(model, JSFNature.NATURE_ID)) return EMPTY_LIST;
+ if(!EclipseResourceUtil.hasNature(model, JSFNature.NATURE_ID)) {
+ XModelObject webxml = WebAppHelper.getWebApp(model);
+ if(webxml != null) {
+ JSFWebProject.getInstance(model).getPatternLoader().revalidate(webxml);
+ } else {
+ return EMPTY_LIST;
+ }
+ }
ArrayList<Object> list = new ArrayList<Object>();
List<String> paths = JSFWebProject.getInstance(model).getUrlPattern().getJSFPaths(prefix);
if(!paths.isEmpty()) {
More information about the jbosstools-commits
mailing list