[jbosstools-commits] JBoss Tools SVN: r42901 - branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model.
jbosstools-commits at lists.jboss.org
jbosstools-commits at lists.jboss.org
Wed Aug 8 01:22:53 EDT 2012
Author: rob.stryker at jboss.com
Date: 2012-08-08 01:22:53 -0400 (Wed, 08 Aug 2012)
New Revision: 42901
Modified:
branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
Log:
JBIDE-12361 archives portion to maintenance
Modified: branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java
===================================================================
--- branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java 2012-08-08 05:22:30 UTC (rev 42900)
+++ branches/jbosstools-3.3.x/archives/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java 2012-08-08 05:22:53 UTC (rev 42901)
@@ -84,6 +84,9 @@
protected ScannableFileSet fs;
protected ArrayList<FileWrapper> matches;
protected HashMap<String, ArrayList<FileWrapper>> matchesMap;
+
+ /* Folders that are required to be created due to a descendent, but are not fully included */
+ protected HashMap<String, ArrayList<FileWrapper>> requiredFolders;
public DirectoryScannerExtension(ScannableFileSet fs) {
this.fs = fs;
String includes = fs.includes == null ? "" : fs.includes; //$NON-NLS-1$
@@ -95,6 +98,7 @@
workspaceRelative = fs.inWorkspace;
matches = new ArrayList<FileWrapper>();
matchesMap = new HashMap<String, ArrayList<FileWrapper>>();
+ requiredFolders = new HashMap<String, ArrayList<FileWrapper>>();
setBasedir2(fs.rawPath);
}
@@ -139,8 +143,10 @@
.getVFS().getWorkspaceChildren(workspaceRelative);
IPath[] childrenAbsolute = globalize(childrenWorkspace);
File[] files = new File[childrenAbsolute.length];
+ IPath parentRootFSRelative = ((FileWrapper)file).getRootArchiveRelative();
for( int i = 0; i < files.length; i++ ) {
- files[i] = new FileWrapper(childrenAbsolute[i].toFile(), childrenWorkspace[i], fs.rootArchiveRelativePath);
+ files[i] = new FileWrapper(childrenAbsolute[i].toFile(), childrenWorkspace[i],
+ parentRootFSRelative.append(childrenWorkspace[i].lastSegment()));
}
return files;
}
@@ -171,15 +177,29 @@
f2.setFilesetRelative(relative);
if( f.isFile() ) {
matches.add(f2);
- ArrayList<FileWrapper> l = matchesMap.get(f2);
- if( l == null ) {
- l = new ArrayList<FileWrapper>();
- matchesMap.put(((FileWrapper)f).getAbsolutePath(), l);
- }
- l.add(f2);
+ addMatchToMap(f2, matchesMap);
+ if( fs.inWorkspace )
+ ensureRequiredFoldersIncluded(f2);
}
}
}
+ protected void addMatchToMap(FileWrapper f2, HashMap<String, ArrayList<FileWrapper>> map) {
+ ArrayList<FileWrapper> l = map.get(f2);
+ if( l == null ) {
+ l = new ArrayList<FileWrapper>();
+ map.put(f2.getAbsolutePath(), l);
+ }
+ l.add(f2);
+ }
+ protected void ensureRequiredFoldersIncluded(FileWrapper includedFile) {
+ FileWrapper tmpParentWrapper = includedFile.getParentFile();
+ while(tmpParentWrapper != null ) {
+ includedFile = tmpParentWrapper;
+ if( requiredFolders.get(includedFile.getAbsolutePath()) != null )
+ return; // all done
+ addMatchToMap(includedFile, requiredFolders);
+ }
+ }
protected boolean isSelected(String name, File file) {
return super.isSelected(name, file) && file.isFile();
@@ -195,6 +215,10 @@
return matchesMap;
}
+ public HashMap<String, ArrayList<FileWrapper>> getRequiredFolderMap() {
+ return requiredFolders;
+ }
+
public static class FileWrapper extends File {
// The actual source file
File f;
@@ -232,8 +256,11 @@
}
public IPath getRootArchiveRelative() {
- if( rootArchiveRelativePath != null )
+ if( rootArchiveRelativePath != null ) {
+ if( fsRelative == null )
+ return rootArchiveRelativePath;
return rootArchiveRelativePath.append(fsRelative);
+ }
return null;
}
@@ -244,6 +271,23 @@
}
return false;
}
+ @Override
+ public FileWrapper getParentFile() {
+ if( f.getParentFile() == null )
+ return null;
+ if( path.segmentCount() == 0 )
+ return null;
+ if( rootArchiveRelativePath.segmentCount() == 0 )
+ return null;
+ IPath p = new Path(fsRelative);
+ if( p.segmentCount() == 0 )
+ return null;
+
+ FileWrapper ret = new FileWrapper(f.getParentFile(),
+ path.removeLastSegments(1), rootArchiveRelativePath.removeLastSegments(1));
+ ret.setFilesetRelative(p.removeLastSegments(1).toString());
+ return ret;
+ }
}
public boolean couldBeIncluded(String path, boolean inWorkspace) {
More information about the jbosstools-commits
mailing list