Author: rob.stryker(a)jboss.com
Date: 2008-08-26 20:41:46 -0400 (Tue, 26 Aug 2008)
New Revision: 9914
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFileSet.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java
Log:
JBIDE-2693
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java 2008-08-26
21:39:17 UTC (rev 9913)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/eclipse/org/jboss/ide/eclipse/archives/core/project/ArchivesBuilder.java 2008-08-27
00:41:46 UTC (rev 9914)
@@ -77,7 +77,7 @@
ArchiveBuildDelegate delegate = new ArchiveBuildDelegate();
if (kind == IncrementalProjectBuilder.INCREMENTAL_BUILD || kind ==
IncrementalProjectBuilder.AUTO_BUILD) {
fillDeltas(interestingProjects, addedChanged, removed);
- delegate.projectIncrementalBuild(addedChanged, removed);
+ delegate.incrementalBuild(null,addedChanged, removed,true);
} else if (kind == IncrementalProjectBuilder.FULL_BUILD){
// build each package fully
@@ -126,9 +126,9 @@
// ignore the packages project. that will it's own build call,
// or will handle the change in some other way
if(
!delta.getResource().equals(proj.findMember(IArchiveModel.DEFAULT_PACKAGES_FILE)))
- addedChanged.add(delta.getResource().getLocation());
+ addedChanged.add(delta.getResource().getFullPath());
} else if( (delta.getKind() & IResourceDelta.REMOVED ) > 0 ) {
- removed.add(delta.getResource().getLocation());
+ removed.add(delta.getResource().getFullPath());
}
}
return true;
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java 2008-08-26
21:39:17 UTC (rev 9913)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java 2008-08-27
00:41:46 UTC (rev 9914)
@@ -151,22 +151,7 @@
EventManager.finishedCollectingFileSet(fileset);
}
-
-
-
/**
- * Incremental Build!!
- * Parameters are instances of changed IPath objects.
- * Will search the entire model for matching filesets.
- *
- * @param addedChanged Set of changed / added resources
- * @param setRemoved Set of removed resources
- */
- public void projectIncrementalBuild(Set<IPath> addedChanged, Set<IPath>
removed) {
- incrementalBuild(null, addedChanged, removed);
- }
-
- /**
* Incremental build.
* Parameters are instance sof changed IPath objects
* Will search only the given node for matching descendent filesets
@@ -174,34 +159,58 @@
* @param addedChanged A list of added or changed resource paths
* @param removed A list of removed resource paths
*/
- public void incrementalBuild(IArchive archive, Set<IPath> addedChanged,
Set<IPath> removed) {
+ public void incrementalBuild(IArchive archive, Set<IPath> addedChanged,
+ Set<IPath> removed, boolean workspaceRelative) {
// find any and all filesets that match each file
- Iterator<IPath> i = addedChanged.iterator();
- IPath path;
+ Iterator<IPath> i;
+ IPath path, globalPath;
IArchiveFileSet[] matchingFilesets;
ArrayList<IArchive> topPackagesChanged = new ArrayList<IArchive>();
+ ArrayList<IArchiveFileSet> seen = new ArrayList<IArchiveFileSet>();
+
+ // Handle the removed files first. Hopefully the fileset hasn't been reset yet
+ // or it could make this block of code fail.
+ i = removed.iterator();
while(i.hasNext()) {
- path = i.next();
- matchingFilesets = ModelUtil.getMatchingFilesets(archive, path);
+ path = ((IPath)i.next());
+ globalPath = !workspaceRelative ? path :
+ ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(path);
+
+ matchingFilesets = ModelUtil.getMatchingFilesets(archive, path, workspaceRelative);
localFireAffectedTopLevelPackages(topPackagesChanged, matchingFilesets);
for( int j = 0; j < matchingFilesets.length; j++ ) {
- ModelTruezipBridge.copyFiles(matchingFilesets[j],
matchingFilesets[j].getMatches(path));
+ ModelTruezipBridge.deleteFiles(matchingFilesets[j],
matchingFilesets[j].getMatches(globalPath));
+ if( !seen.contains(matchingFilesets[j])) {
+ seen.add(matchingFilesets[j]);
+ }
}
- EventManager.fileUpdated(path, matchingFilesets);
+ EventManager.fileRemoved(path, matchingFilesets);
}
+
+ // reset all of the filesets that have already matched
+ Iterator<IArchiveFileSet> fit = seen.iterator();
+ while(fit.hasNext())
+ fit.next().resetScanner();
- i = removed.iterator();
+ i = addedChanged.iterator();
while(i.hasNext()) {
- path = ((IPath)i.next());
- matchingFilesets = ModelUtil.getMatchingFilesets(archive, path);
+ path = i.next();
+ globalPath = !workspaceRelative ? path :
+ ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(path);
+ matchingFilesets = ModelUtil.getMatchingFilesets(archive, path, workspaceRelative);
localFireAffectedTopLevelPackages(topPackagesChanged, matchingFilesets);
for( int j = 0; j < matchingFilesets.length; j++ ) {
- ModelTruezipBridge.deleteFiles(matchingFilesets[j],
matchingFilesets[j].getMatches(path));
+ if( !seen.contains(matchingFilesets[j])) {
+ seen.add(matchingFilesets[j]);
+ matchingFilesets[j].resetScanner();
+ }
+ ModelTruezipBridge.copyFiles(matchingFilesets[j],
matchingFilesets[j].getMatches(globalPath));
}
- EventManager.fileRemoved(path, matchingFilesets);
+ EventManager.fileUpdated(path, matchingFilesets);
}
+
TrueZipUtil.sync();
Iterator<IArchive> i2 = topPackagesChanged.iterator();
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java 2008-08-26
21:39:17 UTC (rev 9913)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java 2008-08-27
00:41:46 UTC (rev 9914)
@@ -222,5 +222,9 @@
return false;
}
}
+
+ public boolean couldBeIncluded(String name, boolean inWorkspace) {
+ return super.isIncluded(name) && !super.isExcluded(name);
+ }
}
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFileSet.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFileSet.java 2008-08-26
21:39:17 UTC (rev 9913)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFileSet.java 2008-08-27
00:41:46 UTC (rev 9914)
@@ -41,8 +41,6 @@
public static final String FLATTENED_ATTRIBUTE = ATTRIBUTE_PREFIX +
"flattened";
public static final String SOURCE_PATH_ATTRIBUTE = ATTRIBUTE_PREFIX +
"sourcePath";
-
-
/**
* @return Whether or not this fileset's basedir is inside the workspace
*/
@@ -74,35 +72,6 @@
public String getExcludesPattern();
/**
- * @return An array of matching IPath's in the filesystem (for external filesystem
filesets)
- */
- public FileWrapper[] findMatchingPaths();
-
- /**
- * Get the FileWrapper objects that match this path
- * @param path
- * @return
- */
- public FileWrapper[] getMatches(IPath path);
-
- /**
- * @param path The absolute path on the filesystem to check
- * @return Whether or not this fileset matches the passed-in path
- */
- public boolean matchesPath(IPath path);
-
- /**
- * Does this global path file match this fileset
- * at the specific fileset-relative location?
- *
- * If fsRelative is null, just match the path
- * @param globalPath
- * @param fsRelative
- * @return
- */
- public boolean matchesPath(IPath globalPath, String fsRelative);
-
- /**
* Sets the "root" or "source" of this fileset (file-system or
workspace relative)
* @param path The absolute path that is the source of this fileset
*/
@@ -132,4 +101,35 @@
*/
public void setFlattened(boolean flattened);
+
+ /**
+ * @return An array of matching IPath's in the filesystem (for external filesystem
filesets)
+ */
+ public FileWrapper[] findMatchingPaths();
+
+ /**
+ * Get the FileWrapper objects that match this path
+ * @param path
+ * @return
+ */
+ public FileWrapper[] getMatches(IPath path);
+
+ /**
+ * This method returns whether the global path passed in matches this fileset.
+ * It must give an accurate answer regardless of whether the path is cached or not.
+ *
+ * @param path The absolute path on the filesystem to check.
+ * @return Whether or not this fileset matches the passed-in path
+ */
+ public boolean matchesPath(IPath path);
+
+ /**
+ * This method returns whether the path passed in matches this fileset.
+ * It must give an accurate answer regardless of whether the path is cached or not.
+ *
+ * @param path The absolute path on the filesystem to check.
+ * @param inWorkspace Whether this is a workspace path or a global path
+ * @return Whether or not this fileset matches the passed-in path
+ */
+ public boolean matchesPath(IPath path, boolean inWorkspace);
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java 2008-08-26
21:39:17 UTC (rev 9913)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java 2008-08-27
00:41:46 UTC (rev 9914)
@@ -96,27 +96,24 @@
/*
* @see IArchiveFileSet#matchesPath(IPath)
*/
- public boolean matchesPath(IPath path) {
- return matchesPath(path, null);
+ public boolean matchesPath(IPath globalPath) {
+ return matchesPath(globalPath, false);
}
- public boolean matchesPath(IPath globalPath, String fsRelative) {
+ public boolean matchesPath(IPath path, boolean inWorkspace) {
getScanner();
+ IPath globalPath = path;
+ if( inWorkspace )
+ globalPath = ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(path);
+
ArrayList<FileWrapper> result =
matchingMap.get(globalPath.toFile().getAbsolutePath());
- if( result != null ) {
- if( result.size() > 0 && fsRelative == null )
+ if( result != null )
+ if( result.size() > 0 )
return true;
-
- FileWrapper tmp;
- for( int i = 0; i < result.size(); i++ ) {
- tmp = result.get(i);
- if( tmp.getFilesetRelative().equals(fsRelative))
- return true;
- }
- }
- return false;
+
+ return getScanner().couldBeIncluded(path.toString(), inWorkspace);
}
-
+
public FileWrapper[] getMatches(IPath path) {
getScanner();
ArrayList<FileWrapper> l = matchingMap.get(path.toFile().getAbsolutePath());
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java 2008-08-26
21:39:17 UTC (rev 9913)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java 2008-08-27
00:41:46 UTC (rev 9914)
@@ -27,7 +27,6 @@
import java.util.Iterator;
import java.util.List;
-import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
@@ -61,17 +60,8 @@
*
*/
public class ModelUtil {
-
+
/**
- * Get any declared fileset that matches this path and are registered with the model
- * @param path
- * @return
- */
- public static IArchiveFileSet[] getMatchingFilesets(final IPath path) {
- return getMatchingFilesets(null, path);
- }
-
- /**
* Get any declared filesets that match this path and are
* a child of the given node
* @param node
@@ -79,11 +69,15 @@
* @return
*/
public static IArchiveFileSet[] getMatchingFilesets(IArchiveNode node, final IPath path)
{
+ return getMatchingFilesets(node, path, false);
+ }
+
+ public static IArchiveFileSet[] getMatchingFilesets(IArchiveNode node, final IPath path,
final boolean inWorkspace) {
final ArrayList<IArchiveFileSet> rets = new ArrayList<IArchiveFileSet>();
IArchiveNodeVisitor visitor = new IArchiveNodeVisitor() {
public boolean visit(IArchiveNode node) {
if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET &&
- ((IArchiveFileSet)node).matchesPath(path)) {
+ ((IArchiveFileSet)node).matchesPath(path, inWorkspace)) {
rets.add((IArchiveFileSet)node);
}
return true;
@@ -178,14 +172,7 @@
* @return
*/
public static IPath getBaseDestinationFile(IArchiveNode node) {
- ArrayList<IArchiveNode> list = new ArrayList<IArchiveNode>();
- while( node != null && !(node instanceof ArchiveModelNode)) {
- list.add(node);
- node = node.getParent();
- }
- Collections.reverse(list);
- IArchiveNode[] nodes = list.toArray(new IArchiveNode[list.size()]);
-
+ IArchiveNode[] nodes = getReverseNodeTree(node);
IPath lastConcrete = null;
for( int i = 0; i < nodes.length; i++ ) {
if( nodes[i] instanceof IArchive) {
@@ -205,10 +192,29 @@
public static IPath getBaseDestinationFile(IArchiveFileSet node, IPath fsRelative) {
IPath last = getBaseDestinationFile(node);
- if( fsRelative != null )
- last = last.append(fsRelative);
+ if( fsRelative != null ) {
+ IArchiveNode[] nodes = getReverseNodeTree(node);
+ boolean anyZipped = false;
+ for( int i = 0; !anyZipped && i < nodes.length; i++ )
+ if( nodes[i] instanceof IArchive && !((IArchive)nodes[i]).isExploded())
+ anyZipped = true;
+
+ if(!anyZipped) // none are zipped, we can append this path
+ last = last.append(fsRelative);
+ }
return last;
}
+
+ private static IArchiveNode[] getReverseNodeTree(IArchiveNode node) {
+ ArrayList<IArchiveNode> list = new ArrayList<IArchiveNode>();
+ while( node != null && !(node instanceof ArchiveModelNode)) {
+ list.add(node);
+ node = node.getParent();
+ }
+ Collections.reverse(list);
+ IArchiveNode[] nodes = list.toArray(new IArchiveNode[list.size()]);
+ return nodes;
+ }
public static void fillArchiveModel( XbPackages node, IArchiveModelRootNode modelNode)
throws ArchivesModelException {
for (Iterator iter = node.getAllChildren().iterator(); iter.hasNext(); ) {