Author: rob.stryker(a)jboss.com
Date: 2008-06-27 01:26:45 -0400 (Fri, 27 Jun 2008)
New Revision: 8977
Removed:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/GenerateArchivesTask.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/IsolatedTruezipExecution.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/asf/DirectoryScanner.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/build/ModelChangeListener.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/EventManager.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
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/FilesetInfoWizardPage.java
Log:
This is a big commit regarding a huge flaw with the model for dealing with an eclipse VFS.
Specifically, multiple eclipse file links can in fact point to the same absolute file, so
using the absolute file as a key to map backwards to an eclipse-based path is unacceptable
and can yield more than one answer.
This commit will cause archives unit test regressions, which I will work on fixing.
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java 2008-06-27
05:21:09 UTC (rev 8976)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/modules/PackageModuleFactory.java 2008-06-27
05:26:45 UTC (rev 8977)
@@ -33,26 +33,25 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Status;
-import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
import org.eclipse.wst.server.core.IModule;
import org.eclipse.wst.server.core.internal.ModuleFactory;
-import org.eclipse.wst.server.core.internal.ModuleFile;
import org.eclipse.wst.server.core.internal.ServerPlugin;
import org.eclipse.wst.server.core.model.IModuleFile;
import org.eclipse.wst.server.core.model.IModuleFolder;
import org.eclipse.wst.server.core.model.IModuleResource;
import org.eclipse.wst.server.core.model.ModuleDelegate;
import org.eclipse.wst.server.core.model.ModuleFactoryDelegate;
+import org.eclipse.wst.server.core.util.ModuleFile;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor;
+import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
import org.jboss.ide.eclipse.as.core.JBossServerCorePlugin;
-import org.osgi.service.prefs.BackingStoreException;
/**
*
@@ -182,7 +181,9 @@
public static interface IExtendedModuleResource extends IModuleResource {
public IPath getSourcePath();
public IArchiveNode getNode();
+ // deep destination is the full path this resource represents, even if it's inside
a jar
public IPath getDeepDestination();
+ // the concrete file this resource is part of... so the top most zipped jar or, if all
is exploded, the file itself
public IPath getConcreteDestFile();
}
@@ -234,20 +235,20 @@
public static class ArchiveContainerResource implements IModuleFolder,
IExtendedModuleResource {
protected IPath moduleRelativePath;
+ protected IPath fsRelative;
protected IArchiveNode node;
protected String name;
private HashMap<IPath, IModuleResource> members;
-
+
// represents source folder on disk. only used if node is fileset
- private IPath folderGlobalPath = null;
+// private IPath folderGlobalPath = null;
public ArchiveContainerResource(String name,IArchiveNode node,IPath moduleRelativePath
) {
this.name = name;
this.node = node;
this.moduleRelativePath = moduleRelativePath;
members = new HashMap<IPath, IModuleResource>();
- if( node instanceof IArchiveFileSet) {
- IPath tmp =
moduleRelativePath.removeFirstSegments(node.getParent().getRootArchiveRelativePath().segmentCount());
- folderGlobalPath = ((IArchiveFileSet)node).getGlobalSourcePath().append(tmp);
+ if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET ) {
+ fsRelative =
moduleRelativePath.removeFirstSegments(node.getParent().getRootArchiveRelativePath().segmentCount());
}
}
@@ -275,30 +276,28 @@
}
public void addFilesetAsChild(IArchiveFileSet fs) {
- IPath[] paths = fs.findMatchingPaths(); // file-system based source paths
- IPath globalSource = fs.getGlobalSourcePath();
- for( int i = 0; i < paths.length; i++ ) {
- addFilesetPathAsChild(fs, globalSource, paths[i]);
+ FileWrapper[] files = fs.findMatchingPaths(); // file-system based source paths
+ for( int i = 0; i < files.length; i++ ) {
+ addFilesetPathAsChild(fs, files[i]);
}
}
- public void addFilesetPathAsChild(IArchiveFileSet fs, IPath globalSource, IPath path)
{
- IPath archiveRelative = fs.getRootArchiveRelativePath(path);
- IPath fsRelative = path.removeFirstSegments(globalSource.segmentCount());
- ArchiveContainerResource parent = find(fs, globalSource,
fsRelative.removeLastSegments(1), true);
- ExtendedModuleFile emf = new ExtendedModuleFile(archiveRelative.lastSegment(),
archiveRelative, path.toFile().lastModified(), path, fs);
+ public void addFilesetPathAsChild(IArchiveFileSet fs, FileWrapper file) {
+ IPath fsRelative = new Path(file.getFilesetRelative());
+ ArchiveContainerResource parent = find(fs, fsRelative.removeLastSegments(1), true);
+ ExtendedModuleFile emf = new ExtendedModuleFile(file, fs);
parent.addChild(emf);
}
public void removeFilesetPathAsChild(IArchiveFileSet fs, IPath path) {
IPath globalSource = fs.getGlobalSourcePath();
IPath fsRelative = path.removeFirstSegments(globalSource.segmentCount());
- ArchiveContainerResource parent = find(fs, globalSource,
fsRelative.removeLastSegments(1), false);
+ ArchiveContainerResource parent = find(fs, fsRelative.removeLastSegments(1), false);
if( parent != null )
parent.removeFilesetPathAsChild(fs, path);
}
- protected ArchiveContainerResource find(IArchiveFileSet fs, IPath globalSource, IPath
fsRelative, boolean create) {
+ protected ArchiveContainerResource find(IArchiveFileSet fs, IPath fsRelative, boolean
create) {
ArchiveContainerResource resource = this;
ArchiveContainerResource tmpResource;
IPath tmpPath = fs.getRootArchiveRelativePath();
@@ -335,12 +334,16 @@
}
public IPath getDeepDestination() {
- IPath tmp = node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET ?
- ((IArchiveFileSet)node).getRootArchiveRelativePath(folderGlobalPath) :
node.getRootArchiveRelativePath();
+ IPath tmp = node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET
+ ? moduleRelativePath : node.getRootArchiveRelativePath();
return node.getRootArchive().getGlobalDestinationPath().append(tmp);
}
+
public IPath getConcreteDestFile() {
- return ModelUtil.getBaseDestinationFile(node,folderGlobalPath);
+ if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FILESET )
+ return ModelUtil.getBaseDestinationFile((IArchiveFileSet)node,fsRelative);
+ else
+ return ModelUtil.getBaseDestinationFile((IArchiveFileSet)node);
}
public IArchiveNode getNode() {
return node;
@@ -353,29 +356,27 @@
}
public static class ExtendedModuleFile extends ModuleFile implements
IExtendedModuleResource {
- private IPath srcPath;
+ private FileWrapper wrapper;
private IArchiveFileSet node;
- public ExtendedModuleFile(String name, IPath relativePath, long stamp,
- IPath srcPath, IArchiveFileSet fs) {
- super(name, relativePath, stamp);
- this.srcPath = srcPath;
+ public ExtendedModuleFile(FileWrapper wrapper, IArchiveFileSet fs) {
+ super(wrapper.getOutputName(), wrapper.getRootArchiveRelative(),
wrapper.lastModified());
this.node = fs;
}
public int hashCode() {
return getName().hashCode() * 37 + getPath().hashCode();
}
- public IPath getPath() { return srcPath; }
+ public IPath getPath() { return new Path(wrapper.getAbsolutePath()); }
public IArchiveNode getNode() { return node; }
public IPath getDeepDestination() {
- return
node.getRootArchive().getGlobalDestinationPath().append(node.getRootArchiveRelativePath(getModuleRelativePath()));
+ return
node.getRootArchive().getGlobalDestinationPath().append(wrapper.getRootArchiveRelative());
}
public IPath getSourcePath() {
- return this.srcPath;
+ return new Path(this.wrapper.getAbsolutePath());
}
public IPath getConcreteDestFile() {
- return ModelUtil.getBaseDestinationFile(node, srcPath);
+ return ModelUtil.getBaseDestinationFile(node, new
Path(this.wrapper.getFilesetRelative()));
}
public boolean equals(Object other) {
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java 2008-06-27
05:21:09 UTC (rev 8976)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.core/jbosscore/org/jboss/ide/eclipse/as/core/publishers/PackagesPublisher.java 2008-06-27
05:26:45 UTC (rev 8977)
@@ -162,8 +162,11 @@
protected void countConcreteFiles(IModuleResource mr, ArrayList list) {
if( mr instanceof IExtendedModuleResource) {
IExtendedModuleResource emr = ((IExtendedModuleResource)mr);
- IPath p = emr.getConcreteDestFile();
- if( mr instanceof IModuleFile && !list.contains(p)) list.add(p);
+ if( mr instanceof IModuleFile ) {
+ IPath p = emr.getConcreteDestFile();
+ if( !list.contains(p))
+ list.add(p);
+ }
if( mr instanceof IModuleFolder) {
IModuleResource[] children = ((IModuleFolder)mr).members();
for( int i = 0; i < children.length; i++ )
Modified:
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java
===================================================================
---
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java 2008-06-27
05:21:09 UTC (rev 8976)
+++
trunk/as/plugins/org.jboss.ide.eclipse.as.ui/jbossui/org/jboss/ide/eclipse/as/ui/views/server/providers/FilesetViewProvider.java 2008-06-27
05:26:45 UTC (rev 8977)
@@ -81,7 +81,8 @@
import org.eclipse.ui.ide.FileStoreEditorInput;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.wst.server.core.IServer;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelCore;
+import org.jboss.ide.eclipse.archives.core.asf.DirectoryScanner;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
import org.jboss.ide.eclipse.archives.ui.util.composites.FilesetPreviewComposite;
import org.jboss.ide.eclipse.as.core.server.IDeployableServer;
import org.jboss.ide.eclipse.as.core.server.internal.ServerAttributeHelper;
@@ -302,8 +303,9 @@
Fileset fs = (Fileset)parentElement;
IPath[] paths = null;
try {
- paths = ArchivesModelCore.findMatchingPaths(
- new Path(fs.getFolder()), fs.getIncludesPattern(), fs.getExcludesPattern());
+ paths = findPaths(fs.getFolder(),
+ fs.getIncludesPattern(),
+ fs.getExcludesPattern());
} catch( BuildException be ) {
return new Object[]{};
}
@@ -588,6 +590,24 @@
return null;
}
+ private IPath[] findPaths(String dir, String includes, String excludes) {
+ IPath[] paths = new IPath[0];
+ try {
+ if( dir != null ) {
+ DirectoryScanner scanner =
+ DirectoryScannerFactory.createDirectoryScanner(new Path(dir), includes, excludes,
true);
+ if( scanner != null ) {
+ String[] files = scanner.getIncludedFiles();
+ paths = new IPath[files.length];
+ for( int i = 0; i < files.length; i++ ) {
+ paths[i] = new Path(files[i]);
+ }
+ }
+ }
+ } catch( IllegalStateException ise ) {}
+ return paths;
+ }
+
protected class FilesetDialog extends TitleAreaDialog {
protected Fileset fileset;
private String name, dir, includes, excludes;
@@ -721,10 +741,9 @@
}
private void updatePreview() {
- IPath files[] = ArchivesModelCore.findMatchingPaths(new Path(dir),
includesText.getText(), excludesText.getText());
- preview.setInput(files);
+ preview.setInput(findPaths(dir, includes, excludes));
}
-
+
public String getDir() {
return dir;
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/GenerateArchivesTask.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/GenerateArchivesTask.java 2008-06-27
05:21:09 UTC (rev 8976)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/GenerateArchivesTask.java 2008-06-27
05:26:45 UTC (rev 8977)
@@ -30,8 +30,8 @@
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelCore;
/**
* @author rob.stryker <rob.stryker(a)redhat.com>
@@ -66,7 +66,7 @@
Thread.currentThread().setContextClassLoader(myCL);
ArchivesModel.instance().registerProject(projectPath, monitor);
- ArchivesModelCore.buildProject(projectPath, monitor);
+ new ArchiveBuildDelegate().fullProjectBuild(projectPath);
} catch(RuntimeException e ) {
e.printStackTrace();
throw e;
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/IsolatedTruezipExecution.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/IsolatedTruezipExecution.java 2008-06-27
05:21:09 UTC (rev 8976)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/ant/IsolatedTruezipExecution.java 2008-06-27
05:26:45 UTC (rev 8977)
@@ -8,8 +8,8 @@
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelCore;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
import org.jboss.ide.eclipse.archives.core.model.IArchive;
import org.jboss.ide.eclipse.archives.core.model.IArchiveBuildListener;
@@ -40,7 +40,7 @@
IPath path = ArchivesCore.getInstance().getVFS().workspacePathToAbsolutePath(new
Path(task.getEclipseProject()));
if( verifyBuildPrereqs(path) ) {
task.log("Building archives for project project: " + path,
Project.MSG_VERBOSE);
- ArchivesModelCore.buildProject(path, null);
+ new ArchiveBuildDelegate().fullProjectBuild(path);
} else {
throw new BuildException("Eclipse-relative paths missing absolute path
mappings.");
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/asf/DirectoryScanner.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/asf/DirectoryScanner.java 2008-06-27
05:21:09 UTC (rev 8976)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/asf/DirectoryScanner.java 2008-06-27
05:26:45 UTC (rev 8977)
@@ -1162,15 +1162,24 @@
boolean included = false;
if (isExcluded(name)) {
exc.add(name);
+ postExclude(file, name);
} else if (isSelected(name, file)) {
included = true;
inc.add(name);
+ postInclude(file, name);
} else {
des.add(name);
}
everythingIncluded &= included;
}
+ protected void postInclude(File f, String name) {
+ // do nothing
+ }
+
+ protected void postExclude(File f, String name) {
+ // do nothing
+ }
/**
* Test whether or not a name matches against at least one include
* pattern.
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-06-27
05:21:09 UTC (rev 8976)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ArchiveBuildDelegate.java 2008-06-27
05:26:45 UTC (rev 8977)
@@ -36,6 +36,7 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
import org.jboss.ide.eclipse.archives.core.model.IArchiveModelRootNode;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
import org.jboss.ide.eclipse.archives.core.util.internal.ModelTruezipBridge;
import org.jboss.ide.eclipse.archives.core.util.internal.TrueZipUtil;
@@ -141,7 +142,7 @@
// reset the scanner. It *is* a full build afterall
fileset.resetScanner();
- IPath[] paths = fileset.findMatchingPaths();
+ FileWrapper[] paths = fileset.findMatchingPaths();
ModelTruezipBridge.fullFilesetBuild(fileset);
EventManager.filesUpdated(topLevel, fileset, paths);
@@ -182,7 +183,9 @@
path = i.next();
matchingFilesets = ModelUtil.getMatchingFilesets(archive, path);
localFireAffectedTopLevelPackages(topPackagesChanged, matchingFilesets);
- ModelTruezipBridge.copyFiles(matchingFilesets, new IPath[] { path }, false);
+ for( int j = 0; j < matchingFilesets.length; j++ ) {
+ ModelTruezipBridge.copyFiles(matchingFilesets[j],
matchingFilesets[j].getMatches(path));
+ }
EventManager.fileUpdated(path, matchingFilesets);
}
@@ -191,7 +194,9 @@
path = ((IPath)i.next());
matchingFilesets = ModelUtil.getMatchingFilesets(archive, path);
localFireAffectedTopLevelPackages(topPackagesChanged, matchingFilesets);
- ModelTruezipBridge.deleteFiles(matchingFilesets, new IPath[] { path }, false);
+ for( int j = 0; j < matchingFilesets.length; j++ ) {
+ ModelTruezipBridge.deleteFiles(matchingFilesets[j],
matchingFilesets[j].getMatches(path));
+ }
EventManager.fileRemoved(path, matchingFilesets);
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java 2008-06-27
05:21:09 UTC (rev 8976)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/build/ModelChangeListener.java 2008-06-27
05:26:45 UTC (rev 8977)
@@ -33,6 +33,7 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeDelta;
import org.jboss.ide.eclipse.archives.core.model.IArchivesLogger;
+import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
import org.jboss.ide.eclipse.archives.core.util.internal.ModelTruezipBridge;
@@ -183,8 +184,8 @@
IArchiveFileSet[] filesets = ModelUtil.findAllDescendentFilesets(added);
for( int i = 0; i < filesets.length; i++ ) {
ModelTruezipBridge.fullFilesetBuild(filesets[i]);
- IPath[] paths = filesets[i].findMatchingPaths();
- EventManager.filesUpdated(filesets[i].getRootArchive(), filesets[i], paths);
+ FileWrapper[] files = filesets[i].findMatchingPaths();
+ EventManager.filesUpdated(filesets[i].getRootArchive(), filesets[i], files);
}
postChange(added);
}
Deleted:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java 2008-06-27
05:21:09 UTC (rev 8976)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/ArchivesModelCore.java 2008-06-27
05:26:45 UTC (rev 8977)
@@ -1,88 +0,0 @@
-/*
- * JBoss, a division of Red Hat
- * Copyright 2006, Red Hat Middleware, LLC, and individual contributors as indicated
- * by the @authors tag. See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- *
- * This is free software; you can redistribute it and/or modify it
- * under the terms of the GNU Lesser General Public License as
- * published by the Free Software Foundation; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
- */
-package org.jboss.ide.eclipse.archives.core.model;
-
-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.jboss.ide.eclipse.archives.core.asf.DirectoryScanner;
-import org.jboss.ide.eclipse.archives.core.build.ArchiveBuildDelegate;
-
-/**
- * Utility methods and entry points for model-related APIs
- * @author Rob Stryker (rob.stryker(a)redhat.com)
- *
- */
-public class ArchivesModelCore {
-
- /**
- * Builds all of a project's packages. Note that this does not call any builders
before or after the package builder (i.e. the JDT builder).
- * If you are looking to run all the builders on a project use project.build()
- * @param project The project to build
- * @param buildType FULL_BUILD, INCREMENTAL_BUILD, CLEAN_BUILD, etc
- * @param monitor A progress monitor
- */
- public static void buildProject (IPath project, IProgressMonitor monitor) {
- if (monitor == null) monitor = new NullProgressMonitor();
- new ArchiveBuildDelegate().fullProjectBuild(project);
- }
-
- /**
- * Build the passed-in package.
- * @param pkg The package to build
- */
- public static void buildArchive (IArchive pkg, IProgressMonitor monitor) {
- if (monitor == null) monitor = new NullProgressMonitor();
- new ArchiveBuildDelegate().fullArchiveBuild(pkg);
- }
-
- public static boolean packageFileExists (IPath project) {
- return project.append(IArchiveModel.DEFAULT_PACKAGES_FILE).toFile().exists();
- }
-
- public static boolean projectRegistered(IPath project) {
- return ArchivesModel.instance().getRoot(project) == null ? false : true;
- }
-
- public static IPath[] findMatchingPaths(IPath root, String includes, String excludes) {
- try {
- if(root==null) return new IPath[0];
-
- DirectoryScanner scanner =
- DirectoryScannerFactory.createDirectoryScanner(root, includes, excludes, true);
-
- if( scanner == null )
- return new IPath[] {};
-
- String[] files = scanner.getIncludedFiles();
- IPath[] paths = new IPath[files.length];
- for( int i = 0; i < files.length; i++ ) {
- paths[i] = new Path(files[i]);
- }
- return paths;
- } catch( IllegalStateException ise ) {
- return new IPath[]{};
- }
- }
-
-}
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-06-27
05:21:09 UTC (rev 8976)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/DirectoryScannerFactory.java 2008-06-27
05:26:45 UTC (rev 8977)
@@ -22,6 +22,7 @@
package org.jboss.ide.eclipse.archives.core.model;
import java.io.File;
+import java.util.ArrayList;
import java.util.HashMap;
import org.eclipse.core.runtime.IPath;
@@ -34,39 +35,38 @@
* @author rob.stryker(a)jboss.com
*/
public class DirectoryScannerFactory {
+ private static class ScannableFileSet {
+ public IPath rawPath;
+ public IPath rootArchiveRelativePath;
+ public String includes;
+ public String excludes;
+ public boolean inWorkspace;
+ };
- public static DirectoryScannerExtension createDirectoryScanner (IPath filesystemFolder,
String includes, String excludes, boolean scan) {
- if (includes == null) includes = "";
- if (excludes == null) excludes = "";
- if( filesystemFolder == null )
- return null;
-
- DirectoryScannerExtension scanner = new DirectoryScannerExtension(false);
- String excludesList[] = excludes.split(" ?, ?");
- String includesList[] = includes.split(" ?, ?");
-
- scanner.setBasedir2(filesystemFolder);
- scanner.setExcludes(excludesList);
- scanner.setIncludes(includesList);
- if (scan) {
- scanner.scan();
- }
-
- return scanner;
+ public static DirectoryScannerExtension createDirectoryScanner(IArchiveFileSet fs,
boolean scan) {
+ return createDirectoryScanner(fs.getSourcePath(), fs.getRootArchiveRelativePath(),
fs.getIncludesPattern(), fs.getExcludesPattern(), fs.isInWorkspace(), scan);
}
- public static DirectoryScannerExtension createDirectoryScanner(IArchiveFileSet fs,
boolean scan) {
- if( !fs.isInWorkspace()) {
- return createDirectoryScanner(fs.getGlobalSourcePath(), fs.getIncludesPattern(),
fs.getExcludesPattern(), scan);
- }
-
- // in workspace
+ // THIS SHOULD NOT BE USED ;) just here for now
+ // eradicate all uses!
+ public static DirectoryScannerExtension createDirectoryScanner (IPath rawPath, String
includes, String excludes, boolean scan) {
+ return createDirectoryScanner(rawPath, null, includes, excludes, false, scan);
+ }
+
+ public static DirectoryScannerExtension createDirectoryScanner (IPath rawPath, IPath
rootArchiveRelativePath, String includes, String excludes, boolean inWorkspace, boolean
scan) {
+ ScannableFileSet fs = new ScannableFileSet();
+ fs.rawPath = rawPath;
+ fs.rootArchiveRelativePath = rootArchiveRelativePath;
+ fs.includes = includes;
+ fs.excludes = excludes;
+ fs.inWorkspace = inWorkspace;
DirectoryScannerExtension scanner = new DirectoryScannerExtension(fs);
if (scan) {
scanner.scan();
}
return scanner;
}
+
/**
* Exposes the isIncluded method so that entire scans do not need to occur
@@ -76,54 +76,52 @@
*/
public static class DirectoryScannerExtension extends DirectoryScanner {
protected boolean workspaceRelative;
- // maps a File to it's workspace path
- protected HashMap<File, IPath> absoluteToWorkspace;
- protected IArchiveFileSet fs;
-
- public DirectoryScannerExtension(boolean relative) {
- workspaceRelative = relative;
- absoluteToWorkspace = new HashMap<File, IPath>();
- }
-
- public DirectoryScannerExtension(IArchiveFileSet fs) {
+ protected ScannableFileSet fs;
+ protected ArrayList<FileWrapper> matches;
+ protected HashMap<String, ArrayList<FileWrapper>> matchesMap;
+ public DirectoryScannerExtension(ScannableFileSet fs) {
this.fs = fs;
- String includes = fs.getIncludesPattern() == null ? "" :
fs.getIncludesPattern();
- String excludes = fs.getExcludesPattern() == null ? "" :
fs.getExcludesPattern();
+ String includes = fs.includes == null ? "" : fs.includes;
+ String excludes = fs.excludes == null ? "" : fs.excludes;
String includesList[] = includes.split(" ?, ?");
String excludesList[] = excludes.split(" ?, ?");
setExcludes(excludesList);
setIncludes(includesList);
- workspaceRelative = fs.isInWorkspace();
- absoluteToWorkspace = new HashMap<File, IPath>();
- setBasedir2(fs.getSourcePath());
+ workspaceRelative = fs.inWorkspace;
+ matches = new ArrayList<FileWrapper>();
+ matchesMap = new HashMap<String, ArrayList<FileWrapper>>();
+ setBasedir2(fs.rawPath);
}
+ /* TODO:
+ * This *must* translate all variables out before
+ * setting in superclass. Ant will not understand
+ * variables!
+ */
public void setBasedir2(IPath path) {
- IPath p = path;
if( workspaceRelative ) {
- p = ArchivesCore.getInstance().getVFS()
+ IPath p = ArchivesCore.getInstance().getVFS()
.workspacePathToAbsolutePath(path);
- absoluteToWorkspace.put(p.toFile(), path);
+ setBasedir(new FileWrapper(p.toFile(), path));
+ } else {
+ setBasedir(new FileWrapper(path.toFile(), path));
}
- setBasedir(p.toFile());
}
- public IPath getWorkspacePath(IPath absolutePath) {
- return absoluteToWorkspace.get(absolutePath.toFile());
- }
-
- protected File[] list2(File file) {
- return workspaceRelative ? list3(file) : file.listFiles();
+ protected String getName(File file) {
+ return workspaceRelative ? ((FileWrapper)file).getOutputName() :
super.getName(file);
}
- protected String getName(File file) {
- return workspaceRelative ? absoluteToWorkspace.get(file).lastSegment() :
super.getName(file);
+ /* Only used when workspace relative! */
+ protected File[] list2(File file) {
+ if( fs.inWorkspace )
+ return list2workspace(file);
+ else
+ return list2absolute(file);
}
- /* Only used when workspace relative! */
- protected File[] list3(File file) {
- IPath workspaceRelative = absoluteToWorkspace.get(file);
-
+ protected File[] list2workspace(File file) {
+ IPath workspaceRelative = ((FileWrapper)file).getWrapperPath();
if( workspaceRelative == null )
return new File[0];
@@ -133,32 +131,87 @@
.getVFS().workspacePathToAbsolutePath(childrenWorkspace);
File[] files = new File[childrenAbsolute.length];
for( int i = 0; i < files.length; i++ ) {
- files[i] = childrenAbsolute[i].toFile();
- if( files[i] != null && childrenWorkspace[i] != null )
- absoluteToWorkspace.put(files[i], childrenWorkspace[i]);
+ files[i] = new FileWrapper(childrenAbsolute[i].toFile(), childrenWorkspace[i]);
}
return files;
}
+
+ protected File[] list2absolute(File file) {
+ File[] children = file.listFiles();
+ FileWrapper[] children2 = new FileWrapper[children.length];
+ for( int i = 0; i < children.length; i++ )
+ children2[i] = new FileWrapper(children[i], new
Path(children[i].getAbsolutePath()));
+ return children2;
+ }
- public boolean isUltimatelyIncluded(String name) {
- return super.isIncluded(name) && !super.isExcluded(name);
+ protected void postInclude(File f, String relative) {
+ if( f.isFile() ) {
+ if( f instanceof FileWrapper ) {
+ FileWrapper f2 = ((FileWrapper)f);
+ f2.setFilesetRelative(relative);
+ 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);
+ }
+ }
}
+
+ // what files are being added
+ public FileWrapper[] getMatchedArray() {
+ return (FileWrapper[]) matches.toArray(new FileWrapper[matches.size()]);
+ }
- public IPath[] getAbsoluteIncludedFiles() {
- String[] relative = super.getIncludedFiles();
- if( workspaceRelative ) {
- IPath[] absolutes = new IPath[relative.length];
- for( int i = 0; i < relative.length; i++ )
- absolutes[i] = ArchivesCore.getInstance()
- .getVFS().workspacePathToAbsolutePath(fs.getSourcePath().append(relative[i]));
- return absolutes;
- } else {
- IPath base2 = new Path(basedir.getAbsolutePath());
- IPath[] absolutes = new IPath[relative.length];
- for( int i = 0; i < relative.length; i++ )
- absolutes[i] = base2.append(relative[i]);
- return absolutes;
- }
+ public HashMap<String, ArrayList<FileWrapper>> getMatchedMap() {
+ return matchesMap;
}
+
+ public class FileWrapper extends File {
+ // The actual source file
+ File f;
+
+ // The path of this file, either workspace relative or global
+ IPath path;
+
+ // the path of this file relative to the fileset
+ String fsRelative;
+
+ public FileWrapper(File delegate, IPath path2) {
+ super(delegate.getAbsolutePath());
+ f = delegate;
+ path = path2;
+ }
+ public IPath getWrapperPath() {
+ return path;
+ }
+ // workspace name is the one we care about, or absolute if not in workspace
+ public String getOutputName() {
+ return path.lastSegment();
+ }
+ public String getFilesetRelative() {
+ return fsRelative;
+ }
+
+ void setFilesetRelative(String s) {
+ fsRelative = s;
+ }
+
+ public IPath getRootArchiveRelative() {
+ if( fs.rootArchiveRelativePath != null )
+ return fs.rootArchiveRelativePath.append(fsRelative);
+ return null;
+ }
+
+ public boolean equals(Object o) {
+ if( o instanceof FileWrapper ) {
+ FileWrapper fo = (FileWrapper)o;
+ return f.equals(fo.f) && path.equals(fo.path);
+ }
+ return false;
+ }
+ }
}
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/EventManager.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/EventManager.java 2008-06-27
05:21:09 UTC (rev 8976)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/EventManager.java 2008-06-27
05:26:45 UTC (rev 8977)
@@ -23,7 +23,9 @@
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
+import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
/**
* The event manager to fire events
@@ -105,9 +107,9 @@
}
// Bulk events
- public static void filesUpdated(IArchive topLevelArchive, IArchiveFileSet fileset,
IPath[] filePath) {
+ public static void filesUpdated(IArchive topLevelArchive, IArchiveFileSet fileset,
FileWrapper[] filePath) {
for( int i = 0; i < filePath.length; i++ ) {
- fileUpdated(topLevelArchive, fileset, filePath[i]);
+ fileUpdated(topLevelArchive, fileset, new Path(filePath[i].getAbsolutePath()));
}
}
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-06-27
05:21:09 UTC (rev 8976)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/IArchiveFileSet.java 2008-06-27
05:26:45 UTC (rev 8977)
@@ -22,6 +22,7 @@
package org.jboss.ide.eclipse.archives.core.model;
import org.eclipse.core.runtime.IPath;
+import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
/**
* <p>
@@ -81,15 +82,33 @@
/**
* @return An array of matching IPath's in the filesystem (for external filesystem
filesets)
*/
- public IPath[] findMatchingPaths();
+ 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
*/
@@ -119,18 +138,4 @@
*/
public void setFlattened(boolean flattened);
- /**
- * Get the relative path of the input file to the root archive
- * @param inputFile
- * @return
- */
- public IPath getRootArchiveRelativePath(IPath inputFile);
-
- /**
- * Get a path relative only to the folder or archive that is the direct parent of the
fileset
- * @param inputFile
- * @return
- */
- public IPath getPathRelativeToParent(IPath inputFile);
-
}
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-06-27
05:21:09 UTC (rev 8976)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/model/internal/ArchiveFileSetImpl.java 2008-06-27
05:26:45 UTC (rev 8977)
@@ -22,7 +22,7 @@
package org.jboss.ide.eclipse.archives.core.model.internal;
import java.util.ArrayList;
-import java.util.Arrays;
+import java.util.HashMap;
import org.eclipse.core.runtime.Assert;
import org.eclipse.core.runtime.IPath;
@@ -32,6 +32,7 @@
import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension;
+import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.core.model.internal.xb.XbFileSet;
/**
@@ -43,7 +44,8 @@
IArchiveFileSet {
private DirectoryScannerExtension scanner;
- private ArrayList<IPath> matchingPaths;
+ private FileWrapper[] matchingPaths;
+ private HashMap<String, ArrayList<FileWrapper>> matchingMap;
private boolean rescanRequired = true;
public ArchiveFileSetImpl() {
@@ -55,14 +57,6 @@
}
/*
- * @see IArchiveFileSet#findMatchingPaths()
- */
- public synchronized IPath[] findMatchingPaths () {
- getScanner(); // ensure up to date
- return matchingPaths == null ? new IPath[0] : matchingPaths.toArray(new
IPath[matchingPaths.size()]);
- }
-
- /*
* @see IArchiveFileSet#getExcludesPattern()
*/
public String getExcludesPattern() {
@@ -118,21 +112,43 @@
* @see IArchiveFileSet#matchesPath(IPath)
*/
public boolean matchesPath(IPath path) {
- return matchesPath(getScanner(), path);
+ return matchesPath(path, null);
}
- private boolean matchesPath(DirectoryScannerExtension scanner, IPath path) {
- IPath global = getGlobalSourcePath();
- if( global != null ) {
- if( global.isPrefixOf(path)) {
- String s =
path.toOSString().substring(getGlobalSourcePath().toOSString().length()+1);
- return scanner.isUltimatelyIncluded(s);
+ public boolean matchesPath(IPath globalPath, String fsRelative) {
+ getScanner();
+ ArrayList<FileWrapper> result =
matchingMap.get(globalPath.toFile().getAbsolutePath());
+ if( result != null ) {
+ if( result.size() > 0 && fsRelative == null )
+ 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;
}
+ public FileWrapper[] getMatches(IPath path) {
+ getScanner();
+ ArrayList<FileWrapper> l = matchingMap.get(path.toFile().getAbsolutePath());
+ if( l != null )
+ return (FileWrapper[]) l.toArray(new FileWrapper[l.size()]);
+ return new FileWrapper[0];
+ }
+
/*
+ * @see IArchiveFileSet#findMatchingPaths()
+ */
+ public synchronized FileWrapper[] findMatchingPaths () {
+ getScanner();
+ return matchingPaths;
+ }
+
+ /*
* Will re-scan if required, or use cached scanner
* @return
*/
@@ -142,8 +158,10 @@
try {
scanner = DirectoryScannerFactory.createDirectoryScanner(this, true);
- if( scanner != null )
- matchingPaths = new ArrayList(Arrays.asList(scanner.getAbsoluteIncludedFiles()));
+ if( scanner != null ) {
+ matchingPaths = scanner.getMatchedArray();
+ matchingMap = scanner.getMatchedMap();
+ }
} catch( IllegalStateException ise ) {
ArchivesCore.getInstance().getLogger().log(IStatus.WARNING, "Could not create
directory scanner", ise);
}
@@ -192,7 +210,7 @@
public void setFlattened(boolean flat) {
attributeChanged(FLATTENED_ATTRIBUTE, new Boolean(isFlattened()), new Boolean(flat));
getFileSetDelegate().setFlattened(flat);
- //TODO: rescanRequired = true;
+ rescanRequired = true;
}
/*
@@ -220,29 +238,7 @@
public IPath getRootArchiveRelativePath() {
return getParent().getRootArchiveRelativePath();
}
-
- /*
- * @see IArchiveFileSet#getRootArchiveRelativePath(IPath)
- */
- public IPath getRootArchiveRelativePath(IPath inputFile) {
- if( matchesPath(inputFile)) {
- return
getParent().getRootArchiveRelativePath().append(getPathRelativeToParent(inputFile));
- }
- return null;
- }
- /*
- * @see
org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet#getPathRelativeToParent(org.eclipse.core.runtime.IPath)
- */
- public IPath getPathRelativeToParent(IPath inputFile) {
- String s;
- if( isFlattened() )
- s = inputFile.toOSString().substring(getGlobalSourcePath().toOSString().length()+1);
- else
- s = inputFile.lastSegment();
- return new Path(s);
- }
-
/*
* @see IArchiveFileSet#resetScanner()
*/
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-06-27
05:21:09 UTC (rev 8976)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/ModelUtil.java 2008-06-27
05:26:45 UTC (rev 8977)
@@ -28,6 +28,7 @@
import java.util.List;
import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
@@ -39,6 +40,7 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor;
import org.jboss.ide.eclipse.archives.core.model.IArchivesLogger;
+import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveActionImpl;
import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveFileSetImpl;
import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveFolderImpl;
@@ -134,8 +136,8 @@
}
- public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset,
IPath path) {
- return otherFilesetMatchesPathAndOutputLocation(fileset, path, null);
+ public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset,
FileWrapper file) {
+ return otherFilesetMatchesPathAndOutputLocation(fileset, file, null);
}
@@ -146,8 +148,14 @@
* @param root a node to start with, or null if the entire model
* @return
*/
- public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset,
IPath path, IArchiveNode root) {
- IArchiveFileSet[] filesets = ModelUtil.getMatchingFilesets(root, path);
+ public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset,
FileWrapper file, IArchiveNode root) {
+ return otherFilesetMatchesPathAndOutputLocation(fileset, new
Path(file.getAbsolutePath()), file.getFilesetRelative(), root);
+ }
+ public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset,
IPath absolute, IArchiveNode root) {
+ return otherFilesetMatchesPathAndOutputLocation(fileset, absolute, null, root);
+ }
+ public static boolean otherFilesetMatchesPathAndOutputLocation(IArchiveFileSet fileset,
IPath absolute, String fsRelative, IArchiveNode root) {
+ IArchiveFileSet[] filesets = ModelUtil.getMatchingFilesets(root, absolute);
if( filesets.length == 0 || (filesets.length == 1 &&
Arrays.asList(filesets).contains(fileset))) {
return false;
} else {
@@ -156,7 +164,7 @@
boolean destinationsMatch;
for( int i = 0; i < filesets.length; i++ ) {
if( fileset.equals(filesets[i])) continue;
- relativePathsMatch =
fileset.getRootArchiveRelativePath(path).equals(filesets[i].getRootArchiveRelativePath(path));
+ relativePathsMatch = filesets[i].matchesPath(absolute, fsRelative);
destinationsMatch =
fileset.getRootArchive().getArchiveFilePath().equals(filesets[i].getRootArchive().getArchiveFilePath());
if( relativePathsMatch && destinationsMatch ) {
@@ -167,16 +175,6 @@
}
return false;
}
-
- /**
- * Get the raw file for this node, specifically,
- * the file actually saved as an OS file.
- * @param node
- * @return
- */
- public static IPath getBaseDestinationFile(IArchiveNode node) {
- return getBaseDestinationFile(node, null);
- }
/**
* Get the raw file for this node, specifically,
@@ -184,8 +182,7 @@
* @param node
* @return
*/
- public static IPath getBaseDestinationFile(IArchiveNode node, IPath absolutePath) {
- IArchiveNode parameterNode = node;
+ public static IPath getBaseDestinationFile(IArchiveNode node) {
ArrayList<IArchiveNode> list = new ArrayList<IArchiveNode>();
while( node != null && !(node instanceof ArchiveModelNode)) {
list.add(node);
@@ -208,26 +205,16 @@
lastConcrete = lastConcrete.append(((IArchiveFolder)nodes[i]).getName());
}
}
-
- if( absolutePath != null && parameterNode.getNodeType() ==
IArchiveNode.TYPE_ARCHIVE_FILESET ) {
- IArchiveFileSet fs = ((IArchiveFileSet)parameterNode);
- IPath sourcePath = fs.getGlobalSourcePath();
- if( sourcePath.isPrefixOf(absolutePath)) {
- lastConcrete =
lastConcrete.append(absolutePath.removeFirstSegments(sourcePath.segmentCount()));
- }
- }
return lastConcrete;
}
-
-// public static IPath workspacePathToAbsolutePath (IPath workspacePath) {
-// String projectName = workspacePath.segment(0);
-// if( projectName == null ) return null;
-// IPath projectPath =
ArchivesCore.getInstance().getVariables().getProjectPath(projectName);
-// if( projectPath == null ) return null;
-// return projectPath.append(workspacePath.removeFirstSegments(1));
-// }
-
+ public static IPath getBaseDestinationFile(IArchiveFileSet node, IPath fsRelative) {
+ IPath last = getBaseDestinationFile(node);
+ if( fsRelative != null )
+ last = last.append(fsRelative);
+ return last;
+ }
+
public static void fillArchiveModel( XbPackages node, IArchiveModelRootNode modelNode)
throws ArchivesModelException {
for (Iterator iter = node.getAllChildren().iterator(); iter.hasNext(); ) {
XbPackageNode child = (XbPackageNode) iter.next();
@@ -277,7 +264,7 @@
if( root == null ) return new IArchive[0];
IArchiveNode[] archives = model.getRoot(project).getAllChildren();
List<IArchiveNode> list = Arrays.asList(archives);
- return (IArchive[]) list.toArray(new IArchive[list.size()]);
+ return list.toArray(new IArchive[list.size()]);
}
return null;
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java 2008-06-27
05:21:09 UTC (rev 8976)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.core/src/main/org/jboss/ide/eclipse/archives/core/util/internal/ModelTruezipBridge.java 2008-06-27
05:26:45 UTC (rev 8977)
@@ -31,7 +31,7 @@
import org.jboss.ide.eclipse.archives.core.model.IArchiveFolder;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNodeVisitor;
-import org.jboss.ide.eclipse.archives.core.model.internal.ArchiveFileSetImpl;
+import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension.FileWrapper;
import org.jboss.ide.eclipse.archives.core.util.ModelUtil;
import de.schlichtherle.io.ArchiveDetector;
@@ -72,8 +72,8 @@
fullFilesetBuild(fileset, true);
}
public static void fullFilesetBuild(final IArchiveFileSet fileset, boolean sync) {
- IPath[] paths = fileset.findMatchingPaths();
- copyFiles(fileset, paths, false);
+ FileWrapper[] files = fileset.findMatchingPaths();
+ copyFiles(fileset, files, false);
if( sync )
TrueZipUtil.sync();
}
@@ -88,15 +88,15 @@
// Let them know which files were removed, for events
public static IPath[] fullFilesetRemove(final IArchiveFileSet fileset, boolean sync) {
- IPath[] paths = fileset.findMatchingPaths();
- final ArrayList<IPath> list = new ArrayList<IPath>();
- list.addAll(Arrays.asList(paths));
- for( int i = 0; i < paths.length; i++ ) {
- if( !ModelUtil.otherFilesetMatchesPathAndOutputLocation(fileset, paths[i])) {
+ FileWrapper[] files = fileset.findMatchingPaths();
+ final ArrayList<FileWrapper> list = new ArrayList<FileWrapper>();
+ list.addAll(Arrays.asList(files));
+ for( int i = 0; i < files.length; i++ ) {
+ if( !ModelUtil.otherFilesetMatchesPathAndOutputLocation(fileset, files[i])) {
// remove
- deleteFiles(fileset, new IPath[] {paths[i]}, false);
+ deleteFiles(fileset, new FileWrapper[] {files[i]}, false);
} else {
- list.remove(paths[i]);
+ list.remove(files[i]);
}
}
@@ -109,7 +109,7 @@
if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE) {
createFile(node);
} else if( node.getNodeType() == IArchiveNode.TYPE_ARCHIVE_FOLDER) {
- createFile(node);
+ createFile(node);
}
return true;
}
@@ -122,26 +122,27 @@
}
- public static void copyFiles(IArchiveFileSet[] filesets, IPath[] paths) {
- copyFiles(filesets, paths, true);
+ public static void copyFiles(IArchiveFileSet[] filesets, FileWrapper[] files) {
+ copyFiles(filesets, files, true);
}
- public static void copyFiles(final IArchiveFileSet[] filesets, final IPath[] paths,
boolean sync) {
+ public static void copyFiles(final IArchiveFileSet[] filesets, final FileWrapper[]
files, boolean sync) {
for( int i = 0; i < filesets.length; i++ ) {
- copyFiles(filesets[i], paths, false);
+ copyFiles(filesets[i], files, false);
}
if( sync )
TrueZipUtil.sync();
}
- public static void copyFiles(IArchiveFileSet fileset, final IPath[] paths) {
- copyFiles(fileset, paths, true);
+ public static void copyFiles(IArchiveFileSet fileset, final FileWrapper[] files) {
+ copyFiles(fileset, files, true);
}
- public static void copyFiles(IArchiveFileSet fileset, final IPath[] sourcePaths, boolean
sync) {
- final File[] destFiles = getFiles(sourcePaths, fileset);
- for( int i = 0; i < sourcePaths.length; i++ ) {
- TrueZipUtil.copyFile(sourcePaths[i].toOSString(), destFiles[i]);
+
+ public static void copyFiles(IArchiveFileSet fileset, final FileWrapper[] files, boolean
sync) {
+ final File[] destFiles = getFiles(files, fileset);
+ for( int i = 0; i < files.length; i++ ) {
+ TrueZipUtil.copyFile(files[i].getAbsolutePath(), destFiles[i]);
}
if( sync )
TrueZipUtil.sync();
@@ -151,23 +152,23 @@
/*
* Deleting files
*/
- public static void deleteFiles(IArchiveFileSet[] filesets, IPath[] paths ) {
- deleteFiles(filesets, paths, true);
+ public static void deleteFiles(IArchiveFileSet[] filesets, FileWrapper[] files ) {
+ deleteFiles(filesets, files, true);
}
- public static void deleteFiles(final IArchiveFileSet[] filesets, final IPath[] paths,
boolean sync ) {
+ public static void deleteFiles(final IArchiveFileSet[] filesets, final FileWrapper[]
files, boolean sync ) {
for( int i = 0; i < filesets.length; i++ ) {
- deleteFiles(filesets[i], paths, false);
+ deleteFiles(filesets[i], files, false);
}
if( sync )
TrueZipUtil.sync();
}
- public static void deleteFiles(IArchiveFileSet fileset, final IPath[] paths ) {
+ public static void deleteFiles(IArchiveFileSet fileset, final FileWrapper[] paths ) {
deleteFiles(fileset, paths, true);
}
- public static void deleteFiles(IArchiveFileSet fileset, final IPath[] paths, boolean
sync ) {
- final File[] destFiles = getFiles(paths, fileset);
- for( int i = 0; i < paths.length; i++ ) {
+ public static void deleteFiles(IArchiveFileSet fileset, final FileWrapper[] files,
boolean sync ) {
+ final File[] destFiles = getFiles(files, fileset);
+ for( int i = 0; i < files.length; i++ ) {
TrueZipUtil.deleteAll(destFiles[i]);
}
@@ -197,11 +198,12 @@
/**
* Gets all properly-created de.sch destination files for a fileset
+ * - // TODO MAKE SURE VARIABLES ARE TRANSLATED
* @param inputFiles
* @param fs
* @return
*/
- private static File[] getFiles(IPath[] inputFiles, IArchiveFileSet fs ) {
+ private static File[] getFiles(FileWrapper[] inputFiles, IArchiveFileSet fs ) {
String filesetRelative;
File fsFile = getFile(fs);
if( fsFile == null )
@@ -210,14 +212,9 @@
File[] returnFiles = new File[inputFiles.length];
for( int i = 0; i < inputFiles.length; i++ ) {
if( fs.isFlattened() )
- filesetRelative = inputFiles[i].lastSegment();
- else if( fs.isInWorkspace() ){
- IPath wsPath =
((ArchiveFileSetImpl)fs).getScanner().getWorkspacePath(inputFiles[i]);
- filesetRelative =
wsPath.removeFirstSegments(fs.getSourcePath().segmentCount()).toString();
- } else {
- int fsLength = fs.getGlobalSourcePath().toOSString().length()+1;
- filesetRelative = inputFiles[i].toOSString().substring(fsLength);
- }
+ filesetRelative = inputFiles[i].getOutputName();
+ else
+ filesetRelative = inputFiles[i].getFilesetRelative();
File parentFile;
if(new Path(filesetRelative).segmentCount() > 1 ) {
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java 2008-06-27
05:21:09 UTC (rev 8976)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/views/ProjectArchivesView.java 2008-06-27
05:26:45 UTC (rev 8977)
@@ -38,7 +38,6 @@
import org.eclipse.ui.part.PageBook;
import org.eclipse.ui.part.ViewPart;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModel;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelCore;
import org.jboss.ide.eclipse.archives.core.model.ArchivesModelException;
import org.jboss.ide.eclipse.archives.core.model.IArchiveModelListener;
import org.jboss.ide.eclipse.archives.core.model.IArchiveModelRootNode;
@@ -234,8 +233,8 @@
if( !project.isAccessible() ) {
book.showPage(noSelectionComposite);
- } else if( ArchivesModelCore.packageFileExists(project.getLocation()) ) {
- if( ArchivesModelCore.projectRegistered(project.getLocation()))
+ } else if( ArchivesModel.instance().canReregister(project.getLocation()) ) {
+ if( ArchivesModel.instance().isProjectRegistered(project.getLocation()))
book.showPage(viewerComposite);
else {
this.project = project;
@@ -293,7 +292,7 @@
IProject[] projects2 = ResourcesPlugin.getWorkspace().getRoot().getProjects();
ArrayList<IProject> list = new ArrayList<IProject>();
for( int i = 0; i < projects2.length; i++ ) {
- if( projects2[i].isAccessible() &&
ArchivesModelCore.packageFileExists(projects2[i].getLocation())) {
+ if( projects2[i].isAccessible() &&
ArchivesModel.instance().canReregister(projects2[i].getLocation())) {
list.add(projects2[i]);
}
}
Modified:
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/FilesetInfoWizardPage.java
===================================================================
---
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/FilesetInfoWizardPage.java 2008-06-27
05:21:09 UTC (rev 8976)
+++
trunk/core/plugins/org.jboss.ide.eclipse.archives.ui/src/main/org/jboss/ide/eclipse/archives/ui/wizards/pages/FilesetInfoWizardPage.java 2008-06-27
05:26:45 UTC (rev 8977)
@@ -30,9 +30,10 @@
import org.eclipse.ui.dialogs.ContainerSelectionDialog;
import org.eclipse.ui.ide.IDE;
import org.jboss.ide.eclipse.archives.core.ArchivesCore;
-import org.jboss.ide.eclipse.archives.core.model.ArchivesModelCore;
+import org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory;
import org.jboss.ide.eclipse.archives.core.model.IArchiveFileSet;
import org.jboss.ide.eclipse.archives.core.model.IArchiveNode;
+import
org.jboss.ide.eclipse.archives.core.model.DirectoryScannerFactory.DirectoryScannerExtension;
import org.jboss.ide.eclipse.archives.ui.ArchivesSharedImages;
import org.jboss.ide.eclipse.archives.ui.ArchivesUIMessages;
import
org.jboss.ide.eclipse.archives.ui.util.composites.ArchiveFilesetDestinationComposite;
@@ -349,14 +350,17 @@
}
private void changePreview() {
- IPath inputFiles[] = ArchivesModelCore.findMatchingPaths(rootDir, includes, excludes);
+ IPath path = rootDirIsWorkspaceRelative ? new Path(workspaceRelativeRootDir) :
rootDir;
+ DirectoryScannerExtension ds = DirectoryScannerFactory.createDirectoryScanner(
+ path, null, includes, excludes, rootDirIsWorkspaceRelative, true);
+ String[] fsRelative = ds.getIncludedFiles();
IPath filesetRelative;
ArrayList<IPath> list = new ArrayList<IPath>();
- for( int i = 0; i < inputFiles.length; i++ ) {
+ for( int i = 0; i < fsRelative.length; i++ ) {
if( flattened )
- filesetRelative = new Path(inputFiles[i].lastSegment());
+ filesetRelative = new Path(new Path(fsRelative[i]).lastSegment());
else
- filesetRelative = inputFiles[i];
+ filesetRelative = new Path(fsRelative[i]);
if( !list.contains(filesetRelative))
list.add(filesetRelative);
}