[jboss-cvs] jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model ...

Robert Stryker rob.stryker at jboss.com
Mon Apr 16 13:34:43 EDT 2007


  User: rawb    
  Date: 07/04/16 13:34:43

  Added:       core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model          
                        PackagesCore.java IPackageFolder.java
                        IPackageNodeVisitor.java
                        IPackagesModelListener.java IPackage.java
                        IPackagesBuildListener.java IPackageFileSet.java
                        IPackagesModelDelta.java IPackageNode.java
                        DirectoryScannerFactory.java
  Log:
  Complete rewrite of the the two plugins leading to a cleaner, leaner project. 
  
  Revision  Changes    Path
  1.26      +104 -500  jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/PackagesCore.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: PackagesCore.java
  ===================================================================
  RCS file: PackagesCore.java
  diff -N PackagesCore.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ PackagesCore.java	16 Apr 2007 17:34:43 -0000	1.26
  @@ -0,0 +1,177 @@
  +package org.jboss.ide.eclipse.packages.core.model;
  +
  +import java.util.ArrayList;
  +import java.util.Arrays;
  +
  +import org.apache.tools.ant.DirectoryScanner;
  +import org.eclipse.core.resources.IProject;
  +import org.eclipse.core.resources.IncrementalProjectBuilder;
  +import org.eclipse.core.resources.ResourcesPlugin;
  +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.packages.core.ExtensionManager;
  +import org.jboss.ide.eclipse.packages.core.build.ModelChangeListener;
  +import org.jboss.ide.eclipse.packages.core.model.internal.PackagesModel;
  +import org.jboss.ide.eclipse.packages.core.model.types.IPackageType;
  +
  +public class PackagesCore {
  +	private static PackagesCore instance;
  +	public static PackagesCore getInstance() {
  +		if( instance == null ) 
  +			instance = new PackagesCore();
  +		return instance;
  +	}
  +	
  +	private ArrayList buildListeners;
  +	private ArrayList modelListeners;
  +	public PackagesCore() {
  +		buildListeners = new ArrayList();
  +		modelListeners = new ArrayList();
  +		addModelListener(new ModelChangeListener());
  +	}
  +	
  +	public void addBuildListener(IPackagesBuildListener listener) {
  +		if( !buildListeners.contains(listener)) 
  +			buildListeners.add(listener);
  +	}
  +	public void removeBuildListener(IPackagesBuildListener listener) {
  +		if( buildListeners.contains(listener)) 
  +			buildListeners.remove(listener);
  +	}
  +	public IPackagesBuildListener[] getBuildListeners() {
  +		return (IPackagesBuildListener[]) buildListeners.toArray(new IPackagesBuildListener[buildListeners.size()]);
  +	}
  +	
  +	public void addModelListener(IPackagesModelListener listener) {
  +		if( !modelListeners.contains(listener)) 
  +			modelListeners.add(listener);
  +	}
  +	public void removeModelListener(IPackagesModelListener listener) {
  +		if( modelListeners.contains(listener)) 
  +			modelListeners.remove(listener);
  +	}
  +	public IPackagesModelListener[] getModelListeners() {
  +		return (IPackagesModelListener[]) modelListeners.toArray(new IPackagesModelListener[modelListeners.size()]);
  +	}
  +	
  +	
  +	
  +	
  +	
  +	
  +	/**
  +	 * Builds all of a project's packages  (performs a FULL_BUILD)
  +	 * @param project The project to build
  +	 * @param monitor A progress monitor
  +	 */
  +	public static void buildProject (IProject project, IProgressMonitor monitor) {
  +		buildProject(project, IncrementalProjectBuilder.FULL_BUILD, monitor);
  +	}
  +	
  +	/**
  +	 * 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 (IProject project, int buildType, IProgressMonitor monitor) {
  +		if (monitor == null) monitor = new NullProgressMonitor();
  +		
  +//		PackageBuildDelegate delegate = PackageBuildDelegate.instance();
  +//		delegate.setProject(project);
  +//		try {
  +//			delegate.build(buildType, null, monitor);
  +//		} catch (CoreException e) {
  +//			Trace.trace(PackagesCore.class, e);
  +//		}
  +	}
  +	
  +	/**
  +	 * Build the passed-in package.
  +	 * @param pkg The package to build
  +	 */
  +	public static void buildPackage (IPackage pkg, IProgressMonitor monitor) {
  +//		if (monitor == null) monitor = new NullProgressMonitor();
  +//
  +//		PackageBuildDelegate delegate = PackageBuildDelegate.instance();
  +//		delegate.setProject(pkg.getProject());
  +//		
  +//		delegate.buildSinglePackage(pkg, monitor);
  +	}
  +
  +	public static IPackage[] getAllProjectPackages(IProgressMonitor monitor) {
  +		IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects();
  +		ArrayList results = new ArrayList();
  +		for( int i = 0; i < projects.length; i++ ) {
  +			if( projects[i].isAccessible()) {
  +				results.addAll(Arrays.asList(getProjectPackages(projects[i], monitor, true)));
  +			}
  +		}
  +		return (IPackage[]) results.toArray(new IPackage[results.size()]);
  +	}
  +	
  +	public static IPackage[] getProjectPackages (IProject project, IProgressMonitor monitor, boolean forceInit) {
  +		if (monitor == null) monitor = new NullProgressMonitor();
  +		
  +		monitor.beginTask("Fetching packages for \"" + project.getName() + "\"...", 2);
  +		IPackage[] packages = PackagesModel.instance().getProjectPackages(project);
  +		monitor.worked(1);
  +		
  +		if (packages == null) {
  +			if (forceInit && packageFileExists(project)) {
  +				PackagesModel.instance().registerProject(project, monitor);
  +				packages = PackagesModel.instance().getProjectPackages(project);
  +			}
  +			
  +			if (packages == null) return new IPackage[0];
  +		}
  +
  +		monitor.worked(1);
  +		monitor.done();
  +		return packages;
  +	}
  +
  +	public static boolean packageFileExists (IProject project) {
  +		return project.getFile(PackagesModel.PROJECT_PACKAGES_FILE).exists();
  +	}
  +	
  +	public static boolean projectRegistered(IProject project) {
  +		return PackagesModel.instance().getRoot(project) == null ? false : true;
  +	}
  +
  +	
  +	/**
  +	 * Visit all of the top-level packages in the passed in project with the passed in node visitor
  +	 * @param project The project whose packages to visit
  +	 * @param visitor The visitor
  +	 */
  +	public static void visitProjectPackages (IProject project, IPackageNodeVisitor visitor) {
  +		if (packageFileExists(project)) {
  +			IPackage packages[] = getProjectPackages(project, null, false);
  +			if( packages == null ) return;
  +			for (int i = 0; i < packages.length; i++) {
  +				boolean keepGoing = packages[i].accept(visitor);
  +				if (!keepGoing) break;
  +			}
  +		}
  +	}
  +
  +	
  +	public static IPackageType getPackageType (String packageType) {
  +		return ExtensionManager.getPackageType(packageType);
  +	}
  +
  +	public static IPath[] findMatchingPaths(IPath root, String includes, String excludes) {
  +		DirectoryScanner scanner  = 
  +			DirectoryScannerFactory.createDirectoryScanner(root, includes, excludes, true);
  +		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;
  +	}
  +}
  
  
  
  1.4       +6 -2      jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/IPackageFolder.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: IPackageFolder.java
  ===================================================================
  RCS file: IPackageFolder.java
  diff -N IPackageFolder.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ IPackageFolder.java	16 Apr 2007 17:34:43 -0000	1.4
  @@ -0,0 +1,71 @@
  +/*
  + * 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.packages.core.model;
  +
  +
  +/**
  + * <p>
  + * This interface represents a folder inside a package definition.
  + * A folder can contain packages, filesets, and sub-folders.
  + * </p>
  + * 
  + * @author <a href="marshall at jboss.org">Marshall Culpepper</a>
  + * @version $Revision: 1.4 $
  + */
  +public interface IPackageFolder extends IPackageNode {
  +
  +	public static final String ATTRIBUTE_PREFIX = "org.jboss.ide.eclipse.packages.core.model.IPackageFolder.";
  +	public static final String NAME_ATTRIBUTE = ATTRIBUTE_PREFIX + "name";
  +
  +	
  +	/**
  +	 * @return The name of this folder
  +	 */
  +	public String getName();
  +	
  +	/**
  +	 * Set the name of this folder
  +	 * @param name The name of this folder
  +	 */
  +	public void setName(String name);
  +	
  +	/**
  +	 * @return An array of sub-packages of this folder
  +	 */
  +	public IPackage[] getPackages();
  +	
  +	/**
  +	 * @return An array of sub-folders of this folder
  +	 */
  +	public IPackageFolder[] getFolders();
  +	
  +	/**
  +	 * @return An array of filesets whose destination is this folder
  +	 */
  +	public IPackageFileSet[] getFileSets();
  +	
  +	/**
  +	 * @return The path within the package to this folder
  +	 */
  +	//public IPath getPackageRelativePath();
  +
  +}
  
  
  
  1.3       +0 -0      jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/IPackageNodeVisitor.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: IPackageNodeVisitor.java
  ===================================================================
  RCS file: IPackageNodeVisitor.java
  diff -N IPackageNodeVisitor.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ IPackageNodeVisitor.java	16 Apr 2007 17:34:43 -0000	1.3
  @@ -0,0 +1,27 @@
  +/*
  + * 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.packages.core.model;
  +
  +public interface IPackageNodeVisitor {
  +
  +	public boolean visit (IPackageNode node);
  +}
  
  
  
  1.5       +1 -42     jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/IPackagesModelListener.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: IPackagesModelListener.java
  ===================================================================
  RCS file: IPackagesModelListener.java
  diff -N IPackagesModelListener.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ IPackagesModelListener.java	16 Apr 2007 17:34:43 -0000	1.5
  @@ -0,0 +1,5 @@
  +package org.jboss.ide.eclipse.packages.core.model;
  +
  +public interface IPackagesModelListener {
  +	public void modelChanged(IPackagesModelDelta delta);
  +}
  
  
  
  1.11      +37 -64    jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/IPackage.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: IPackage.java
  ===================================================================
  RCS file: IPackage.java
  diff -N IPackage.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ IPackage.java	16 Apr 2007 17:34:43 -0000	1.11
  @@ -0,0 +1,155 @@
  +/*
  + * 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.packages.core.model;
  +
  +import org.eclipse.core.runtime.IPath;
  +import org.jboss.ide.eclipse.packages.core.model.types.IPackageType;
  +
  +/** 
  + * <p>
  + * This interface represents a package definition.
  + * A package definition consists of a list of folders, filesets, and sub-packages
  + * </p>
  + * 
  + * @author <a href="marshall at jboss.org">Marshall Culpepper</a>
  + * @version $Revision: 1.11 $
  + */
  +public interface IPackage extends IPackageNode {
  +	public static final String ATTRIBUTE_PREFIX = "org.jboss.ide.eclipse.packages.core.model.IPackage.";
  +	public static final String PACKAGE_TYPE_ATTRIBUTE = ATTRIBUTE_PREFIX + "packageType";
  +	public static final String EXPLODED_ATTRIBUTE = ATTRIBUTE_PREFIX + "exploded";
  +	public static final String DESTINATION_ATTRIBUTE = ATTRIBUTE_PREFIX + "destination";
  +	public static final String NAME_ATTRIBUTE = ATTRIBUTE_PREFIX + "name";
  +	public static final String IN_WORKSPACE_ATTRIBUTE = ATTRIBUTE_PREFIX + "inWorkspace";
  +	
  +
  +	/**
  +	 * @return The package type of this package.
  +	 */
  +	public IPackageType getPackageType();
  +	
  +	/**
  +	 * return the raw string from the delegate even if the type is not found
  +	 * @return
  +	 */
  +	public String getPackageTypeId();
  +
  +	/**
  +	 * @return The name (with extension) of this package.
  +	 */
  +	public String getName();
  +	
  +//	/**
  +//	 * @return Whether or not this package is a reference to another package.
  +//	 */
  +//	public boolean isReference();
  +	
  +//	/**
  +//	 * @return An array of references to this package.
  +//	 */
  +//	public IPackageReference[] getReferences ();
  +	
  +	/**
  +	 * @return Whether or not this package will be build exploded, or as a directory instead of a ZIP/JAR
  +	 */
  +	public boolean isExploded();
  +	
  +	/**
  +	 * @return Whether or not this package is a "top-level" package aka, not a child of another folder or package
  +	 */
  +	public boolean isTopLevel();
  +		
  +	/**
  +	 * If this package is top-level, there are two types of destinations it can have. "Inside" the workspace, and "outside" the workspace.
  +	 * If the destination is inside the workspace, you will need to call getDestinationContainer()
  +	 * Otherwise you will need to call getDestinationFolder()
  +	 * @return Wheter or not the destination of this package is in the workspace
  +	 * @see IPackage.getDestinationFolder()
  +	 * @see IPackage.getDestinationContainer()
  +	 */
  +	public boolean isDestinationInWorkspace();
  +	
  +	/**
  +	 * @return An IPath to this package's destination. 
  +	 * Destination will always be file-system based
  +	 */
  +	public IPath getDestinationPath();
  +	
  +	/**
  +	 * @return A list of sub-packages contained in this package
  +	 */
  +	public IPackage[] getPackages();
  +	
  +	/**
  +	 * @return A list of folders contained in this package
  +	 */
  +	public IPackageFolder[] getFolders();
  +	
  +	/**
  +	 * @return A list of filesets contained in this package
  +	 */
  +	public IPackageFileSet[] getFileSets();
  +
  +	/**
  +	 * Get The path to this package's output file.
  +	 * This path should be GLOBAL
  +	 * @return  the path
  +	 */
  +	public IPath getPackageFilePath();
  +	
  +	/**
  +	 * If this package is not top-level, this will return a relative path to this package from within it's parent, i.e.
  +	 * my.ear/web/my.war/WEB-INF/lib. Otherwise, this will return null
  +	 * @return a relative IPath to this package's top level parent
  +	 */
  +	//public IPath getPackageRelativePath();
  +	
  +	/**
  +	 * Set the package type of this package
  +	 * @param type The package type
  +	 */
  +	public void setPackageType(IPackageType type);
  +
  +	/**
  +	 * Set the package type via ID. 
  +	 * @param type
  +	 */
  +	public void setPackageType(String type);
  +	/**
  +	 * Set the name of this package
  +	 * @param name This package's name
  +	 */
  +	public void setName(String name);
  +	
  +	/**
  +	 * Set whether or not this package is generated as a folder
  +	 * @param exploded
  +	 */
  +	public void setExploded(boolean exploded);
  +		
  +	/**
  +	 * Sets the destination path for this package.
  +	 * @param path The absolute path where this package will be built
  +	 */
  +	public void setDestinationPath (IPath path, boolean inWorkspace);
  +		
  +}
  
  
  
  1.6       +2 -96     jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/IPackagesBuildListener.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: IPackagesBuildListener.java
  ===================================================================
  RCS file: IPackagesBuildListener.java
  diff -N IPackagesBuildListener.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ IPackagesBuildListener.java	16 Apr 2007 17:34:43 -0000	1.6
  @@ -0,0 +1,6 @@
  +package org.jboss.ide.eclipse.packages.core.model;
  +
  +public interface IPackagesBuildListener {
  +	public void buildStarted();
  +	public void buildEnded();
  +}
  
  
  
  1.7       +13 -82    jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/IPackageFileSet.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: IPackageFileSet.java
  ===================================================================
  RCS file: IPackageFileSet.java
  diff -N IPackageFileSet.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ IPackageFileSet.java	16 Apr 2007 17:34:43 -0000	1.7
  @@ -0,0 +1,113 @@
  +/*
  + * 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.packages.core.model;
  +
  +import org.eclipse.core.resources.IFile;
  +import org.eclipse.core.runtime.IPath;
  +
  +/**
  + * <p>
  + * This interface represents a file set inside of a package definition or folder.
  + * </p>
  + * 
  + * @author <a href="marshall at jboss.org">Marshall Culpepper</a>
  + * @version $Revision: 1.7 $
  + */
  +public interface IPackageFileSet extends IPackageNode {
  +	public static final String ATTRIBUTE_PREFIX = "org.jboss.ide.eclipse.packages.core.model.IPackageFileSet.";
  +	public static final String INCLUDES_ATTRIBUTE = ATTRIBUTE_PREFIX + "includes";
  +	public static final String EXCLUDES_ATTRIBUTE = ATTRIBUTE_PREFIX + "excludes";
  +	public static final String IN_WORKSPACE_ATTRIBUTE = ATTRIBUTE_PREFIX + "inWorkspace";
  +	public static final String SOURCE_PATH_ATTRIBUTE = ATTRIBUTE_PREFIX + "sourcePath";
  +
  +
  +	
  +	/**
  +	 * @return Whether or not this fileset's basedir is inside the workspace
  +	 */
  +	public boolean isInWorkspace();
  +	
  +	/**
  +	 * @return The path to the source folder ("basedir" in ant terminology) for this fileset. Note that this path can be
  +	 * filesystem-based or workspace-based.
  +	 */
  +	public IPath getSourcePath();
  +	
  +	/**
  +	 * Force the scanner to check for matched files again
  +	 */
  +	public void resetScanner();
  +	
  +	/**
  +	 * @return The includes pattern for this fileset
  +	 */
  +	public String getIncludesPattern();
  +	
  +	/**
  +	 * @return The excludes pattern for this fileset
  +	 */
  +	public String getExcludesPattern();
  +	
  +	/**
  +	 * @return An array of matching IPath's in the filesystem (for external filesystem filesets)
  +	 */
  +	public IPath[] findMatchingPaths();
  +	
  +	/**
  +	 * @param file The file to check
  +	 * @return Whether or not this fileset matches the passed-in file
  +	 */
  +	public boolean matchesFile(IFile file);
  +	
  +	/**
  +	 * @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);
  +	
  +	/**
  +	 * Sets the "root" or "source" of this fileset to be an absolute path.
  +	 * @param path The absolute path that is the source of this fileset
  +	 */
  +	public void setSourcePath(IPath path);
  +	
  +	/**
  +	 * Set the includes pattern for this fileset. This pattern uses the same syntax as Ant's include pattern.
  +	 * @param includes The includes pattern for this fileset
  +	 */
  +	public void setIncludesPattern(String includes);
  +	
  +	/**
  +	 * Set the excludes pattern for this fileset. This pattern uses the same syntax as Ant's exclude pattern.
  +	 * @param excludes The excludes pattern for this fileset
  +	 */
  +	public void setExcludesPattern(String excludes);
  +	
  +	/**
  +	 * Set whether or not this fileset's source is in the workspace. This will automatically be handled if you
  +	 * use setSingleFile, setSourceProject, setSourceContainer, or setSourceFolder.
  +	 * @param isInWorkspace Whether or not this fileset's source is in the workspace
  +	 */
  +	public void setInWorkspace(boolean isInWorkspace);
  +	
  +	public IPath getRootPackageRelativePath(IPath inputFile);
  +}
  
  
  
  1.1      date: 2007/04/16 17:34:43;  author: rawb;  state: Exp;jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/IPackagesModelDelta.java
  
  Index: IPackagesModelDelta.java
  ===================================================================
  package org.jboss.ide.eclipse.packages.core.model;
  
  
  
  public interface IPackagesModelDelta {
  	
  	/**
  	 * There is no change to this node or any of it's children
  	 */
  	public static final int NO_CHANGE = 0;
  		
  	/**
  	 * I have been added
  	 */
  	public static final int ADDED = 0x1;
  	
  	/**
  	 * I have been removed
  	 */
  	public static final int REMOVED	= 0x2;
  	
  	
  	
  	/**
  	 * Used to designate that a sub-property within 
  	 * a <property> tag has been added.
  	 */
  	public static final int PROPERTY_ADDED = 0x10;
  	
  	/**
  	 * Used to designate that a sub-property within 
  	 * a <property> tag has been removed.
  	 */
  	public static final int PROPERTY_REMOVED = 0x20;
  	
  	/**
  	 * Used to designate that a sub-property within 
  	 * a <property> tag has been changed.
  	 */
  	public static final int PROPERTY_CHANGED = 0x40;
  	
  	/**
  	 * Used to designate that an primary property of the node, 
  	 * such as inWorkspace or exploded, has changed. 
  	 */
  	public static final int ATTRIBUTE_CHANGED = 0x80;
  	
  	/**
  	 * A child has been added directly to me
  	 */
  	public static final int CHILD_ADDED		= 0x100;
  	
  	/**
  	 * A child has been removed directly from me
  	 */
  	public static final int CHILD_REMOVED	= 0x200;
  	
  	/**
  	 * Some other change has occurred, most likely a 
  	 * grand-child added or a child's property changed.
  	 */
  	public static final int DESCENDENT_CHANGED 	= 0x400;
  	
  	/**
  	 * Return the delta kind
  	 * @return
  	 */
  	public int getKind();
  
  	/**
  	 * Return the affected node after changes
  	 * @return
  	 */
  	public IPackageNode getPostNode();
  	
  	/**
  	 * Return the affected node before changes
  	 * @return
  	 */
  	public IPackageNode getPreNode();
  	
  	/**
  	 * Get the children that have also been changed
  	 * @return
  	 */
  	public IPackagesModelDelta[] getAffectedChildren();
  	
  	public String[] getPropertiesWithDeltas();
  	public INodeDelta getPropertyDelta(String key);
  	
  	public String[] getAttributesWithDeltas();
  	public INodeDelta getAttributeDelta(String key);
  	
  	public IPackagesModelDelta[] getAddedChildrenDeltas();
  	public IPackagesModelDelta[] getRemovedChildrenDeltas();
  	
  	
  	
  	public interface INodeDelta {
  		public Object getBefore();
  		public Object getAfter();
  		public int getKind();
  	}
  	
  }
  
  
  
  1.9       +17 -1     jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/IPackageNode.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: IPackageNode.java
  ===================================================================
  RCS file: IPackageNode.java
  diff -N IPackageNode.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ IPackageNode.java	16 Apr 2007 17:34:43 -0000	1.9
  @@ -0,0 +1,155 @@
  +/*
  + * 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.packages.core.model;
  +
  +import org.eclipse.core.resources.IProject;
  +import org.eclipse.core.runtime.IAdaptable;
  +import org.eclipse.core.runtime.IPath;
  +
  +/**
  + * The super type of all package nodes (IPackage, IPackageFileSet, IPackageFolder)
  + * 
  + * Each node in a package may have arbitrary properties that can be reflected upon by other plug-ins
  + * 
  + * @author <a href="marshall at jboss.org">Marshall Culpepper</a>
  + * @version $Revision: 1.9 $
  + */
  +public interface IPackageNode extends IAdaptable {
  +	/**
  +	 * The node type that represents the model
  +	 */
  +	public static final int TYPE_MODEL = -1;
  +
  +	/**
  +	 * The node type that represents an IPackage
  +	 */
  +	public static final int TYPE_PACKAGE = 0;
  +	
  +	/**
  +	 * The node type that represents an IPackageReference
  +	 */
  +	public static final int TYPE_PACKAGE_REFERENCE = 1;
  +	
  +	/**
  +	 * The node type that represents an IPackageFileSet
  +	 */
  +	public static final int TYPE_PACKAGE_FILESET = 2;
  +	
  +	/**
  +	 * The node type that represents an IPackageFolder
  +	 */
  +	public static final int TYPE_PACKAGE_FOLDER = 3;
  +	
  +	/**
  +	 * @return The parent of this package node, or null if this node is top level
  +	 */
  +	public IPackageNode getParent();
  +	
  +	/**
  +	 * Set the parent of this package node 
  +	 * @param parent The new parent of this node
  +	 */
  +	public void setParent(IPackageNode parent);
  +	
  +	/**
  +	 * @param type TYPE_PACKAGE, TYPE_PACKAGE_FILESET, or TYPE_PACKAGE_FOLDER
  +	 * @return An array of child nodes of the passed in type
  +	 */
  +	public IPackageNode[] getChildren(int type);
  +	
  +	/**
  +	 * @return An array of all children nodes
  +	 */
  +	public IPackageNode[] getAllChildren();
  +	
  +	/**
  +	 * @return Whether or not this node has children
  +	 */
  +	public boolean hasChildren();
  +	
  +	/**
  +	 * @param child A possible child node
  +	 * @return Whether or not the passed-in node is a child of this node
  +	 */
  +	public boolean hasChild(IPackageNode child);
  +	
  +	/**
  +	 * @return The type of this package node
  +	 */
  +	public int getNodeType();
  +	
  +	/**
  +	 * @param property The name of the property to fetch
  +	 * @return The value of the specified property
  +	 */
  +	public String getProperty(String property);
  +	
  +	/**
  +	 * Set a property on this package node
  +	 * @param property The name of the property to set
  +	 * @param value The new value of the property
  +	 */
  +	public void setProperty(String property, String value);
  +	
  +	/**
  +	 * @return The project that this node is defined in (not necessarily the project where this is based if this is a fileset)
  +	 */
  +	public IProject getProject();
  +	
  +	/**
  +	 * Recursively visit the package node tree below this node with the passed-in package node visitor.
  +	 * @param visitor A package node visitor
  +	 * @return Whether or not the entire sub-tree was visited
  +	 */
  +	public boolean accept(IPackageNodeVisitor visitor);
  +	
  +	/**
  +	 * Recursively visit the package node tree below this node with the passed-in package node visitor, using depth-first ordering
  +	 * @param visitor A package node visitor
  +	 * @return Whether or not the entire sub-tree was visited
  +	 */
  +	public boolean accept(IPackageNodeVisitor visitor, boolean depthFirst);
  +	
  +	/**
  +	 * Add a child node to this node
  +	 * @param child The child to add
  +	 */
  +	public void addChild(IPackageNode child);
  +	
  +	/**
  +	 * Remove a child node from this node
  +	 * @param child The child to remove
  +	 */
  +	public void removeChild(IPackageNode child);
  +	
  +	/**
  +	 * Get the highest parent that is not null
  +	 * @return
  +	 */
  +	public IPackageNode getRoot();
  +	
  +	public boolean connectedToModel();
  +	
  +	public IPath getRootArchiveRelativePath();
  +	
  +	public IPackagesModelDelta getDelta();
  +}
  
  
  
  1.4       +6 -81     jbosside/core/plugins/org.jboss.ide.eclipse.packages.core/src/main/org/jboss/ide/eclipse/packages/core/model/DirectoryScannerFactory.java
  
  (In the diff below, changes in quantity of whitespace are not shown.)
  
  Index: DirectoryScannerFactory.java
  ===================================================================
  RCS file: DirectoryScannerFactory.java
  diff -N DirectoryScannerFactory.java
  --- /dev/null	1 Jan 1970 00:00:00 -0000
  +++ DirectoryScannerFactory.java	16 Apr 2007 17:34:43 -0000	1.4
  @@ -0,0 +1,58 @@
  +/**
  + * 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.packages.core.model;
  +
  +import java.io.File;
  +
  +import org.apache.tools.ant.DirectoryScanner;
  +import org.eclipse.core.runtime.IPath;
  +
  +/**
  + *
  + * @author rob.stryker at jboss.com
  + */
  +public class DirectoryScannerFactory {
  +
  +	public static DirectoryScannerExtension createDirectoryScanner (IPath filesystemFolder, String includes, String excludes, boolean scan) {
  +		if (includes == null) includes = "";
  +		if (excludes == null) excludes = "";
  +		
  +		DirectoryScannerExtension scanner = new DirectoryScannerExtension();
  +		String excludesList[] = excludes.split(" ?, ?");
  +		String includesList[] = includes.split(" ?, ?");
  +		
  +		File basedir = filesystemFolder.toFile();	
  +		scanner.setBasedir(basedir);
  +		scanner.setExcludes(excludesList);
  +		scanner.setIncludes(includesList);
  +		if (scan)
  +			scanner.scan();
  +		
  +		return scanner;
  +	}
  +	
  +	public static class DirectoryScannerExtension extends DirectoryScanner {
  +	    public boolean isIncluded(String name) {
  +	    	return super.isIncluded(name);
  +	    }
  +	}
  +}
  
  
  



More information about the jboss-cvs-commits mailing list