### Eclipse Workspace Patch 1.0
#P org.jboss.tools.hibernate.xml
Index: src/org/jboss/tools/hibernate/xml/model/HibernateResourceTree.java
===================================================================
--- src/org/jboss/tools/hibernate/xml/model/HibernateResourceTree.java	(revision 28917)
+++ src/org/jboss/tools/hibernate/xml/model/HibernateResourceTree.java	(working copy)
@@ -9,6 +9,7 @@
 import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
 import org.jboss.tools.common.model.filesystems.XFileObject;
 import org.jboss.tools.common.model.filesystems.impl.FileSystemsImpl;
+import org.jboss.tools.common.model.filesystems.impl.Libs;
 import org.jboss.tools.common.model.impl.trees.FileSystemResourceTree;
 import org.jboss.tools.common.model.util.EclipseResourceUtil;
 import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
@@ -45,7 +46,7 @@
 			}
 			for (int i = 0; i < os.length; i++) {
 				String name = os[i].getAttributeValue(XModelObjectConstants.ATTR_NAME);
-				if(name.startsWith("lib-")) { //$NON-NLS-1$
+				if(name.startsWith(Libs.LIB_PREFIX)) {
 					list.add(os[i]);
 				}
 			}
#P org.jboss.tools.jst.web.ui
Index: src/org/jboss/tools/jst/web/ui/navigator/WebProjectsLabelProvider.java
===================================================================
--- src/org/jboss/tools/jst/web/ui/navigator/WebProjectsLabelProvider.java	(revision 31451)
+++ src/org/jboss/tools/jst/web/ui/navigator/WebProjectsLabelProvider.java	(working copy)
@@ -10,6 +10,7 @@
  ******************************************************************************/ 
 package org.jboss.tools.jst.web.ui.navigator;
 
+import org.jboss.tools.common.model.filesystems.impl.Libs;
 import org.jboss.tools.common.model.ui.navigator.NavigatorLabelProvider;
 import org.jboss.tools.common.model.ui.navigator.decorator.DecoratorManager;
 import org.jboss.tools.common.model.ui.navigator.decorator.XModelObjectDecorator;
@@ -54,7 +55,7 @@
 		while(p != null && p.getFileType() != XModelObject.SYSTEM) p = p.getParent();
 		if(p != null && p.getModelEntity().getName().equals("FileSystemJar")) {
 			String n = p.getAttributeValue("name");
-			if(n != null && n.startsWith("lib-")) n = n.substring(4);
+			if(n != null && n.startsWith(Libs.LIB_PREFIX)) n = n.substring(4);
 			String addition = (n != null) ? " - " + n : "";
 			return super.getText(element) + addition;
 		}
Index: src/org/jboss/tools/jst/web/ui/action/adf/AddADFSupportHelper.java
===================================================================
--- src/org/jboss/tools/jst/web/ui/action/adf/AddADFSupportHelper.java	(revision 31451)
+++ src/org/jboss/tools/jst/web/ui/action/adf/AddADFSupportHelper.java	(working copy)
@@ -22,6 +22,7 @@
 import org.jboss.tools.common.meta.action.impl.handlers.DefaultCreateHandler;
 import org.jboss.tools.common.model.*;
 import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
+import org.jboss.tools.common.model.filesystems.impl.Libs;
 import org.jboss.tools.common.model.plugin.ModelPlugin;
 import org.jboss.tools.common.model.util.EclipseResourceUtil;
 import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
@@ -53,16 +54,19 @@
 	public boolean isEnabled() {
 		if(object == null) return false;
 		XModel model = object.getModel();
-		XModelObject fss = FileSystemsHelper.getFileSystems(model);
-		if(fss == null) return false;
 		File adfLibFile = new File(adfLibPath);
-		if(!adfLibFile.isDirectory()) return false;
-		File[] fs = adfLibFile.listFiles();
-		if(fs == null || fs.length == 0) return false;
-		for (int i = 0; i < fs.length; i++) {
-			String n = fs[i].getName();
-			if(!n.endsWith(".jar")) continue; //$NON-NLS-1$
-			if(fss.getChildByPath("lib-" + n) == null) return true; //$NON-NLS-1$
+		if(adfLibFile.isDirectory()) {
+			File[] fs = adfLibFile.listFiles();
+			if(fs != null && fs.length > 0) {
+				Libs libs = FileSystemsHelper.getLibs(model);
+				if(libs != null) {
+					for (int i = 0; i < fs.length; i++) {
+						if(libs.getLibrary(fs[i]) != null) {
+							return true;
+						}
+					}
+				}
+			}
 		}
 		return false;
 	}
#P org.jboss.tools.cdi.core
Index: src/org/jboss/tools/cdi/internal/core/scanner/lib/ClassPathMonitor.java
===================================================================
--- src/org/jboss/tools/cdi/internal/core/scanner/lib/ClassPathMonitor.java	(revision 31497)
+++ src/org/jboss/tools/cdi/internal/core/scanner/lib/ClassPathMonitor.java	(working copy)
@@ -31,6 +31,7 @@
 import org.jboss.tools.cdi.core.CDICoreNature;
 import org.jboss.tools.cdi.core.CDICorePlugin;
 import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
 import org.jboss.tools.common.model.filesystems.impl.FileAnyImpl;
 import org.jboss.tools.common.model.project.ext.AbstractClassPathMonitor;
 import org.jboss.tools.common.model.util.EclipseResourceUtil;
@@ -59,8 +60,8 @@
 
 			String fileName = new File(p).getName();
 			if(EclipseResourceUtil.SYSTEM_JAR_SET.contains(fileName)) continue;
-			String jsname = "lib-" + fileName; //$NON-NLS-1$
-			XModelObject o = model.getByPath("FileSystems").getChildByPath(jsname); //$NON-NLS-1$
+
+			XModelObject o = FileSystemsHelper.getLibs(model).getLibrary(p);
 			if(o == null) continue;
 
 			//Load cdi extensions. Do we need beans.xml to look for extensions?
#P org.jboss.tools.jsf
Index: src/org/jboss/tools/jsf/model/pv/JSFProjectTagLibs.java
===================================================================
--- src/org/jboss/tools/jsf/model/pv/JSFProjectTagLibs.java	(revision 31350)
+++ src/org/jboss/tools/jsf/model/pv/JSFProjectTagLibs.java	(working copy)
@@ -15,6 +15,7 @@
 import org.eclipse.core.resources.IResource;
 import org.jboss.tools.common.model.XModelObject;
 import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
+import org.jboss.tools.common.model.filesystems.impl.Libs;
 import org.jboss.tools.jst.web.model.helpers.WebAppHelper;
 import org.jboss.tools.jst.web.tld.model.TLDUtil;
 
@@ -29,7 +30,7 @@
 		if(fss == null) return list.iterator();
 		XModelObject[] fs = fss.getChildren("FileSystemJar");
 		for (int i = 0; i < fs.length; i++) {
-			if(!fs[i].getAttributeValue("name").startsWith("lib-")) continue;
+			if(!fs[i].getAttributeValue("name").startsWith(Libs.LIB_PREFIX)) continue;
 			r = fs[i].getChildByPath("META-INF");
 			if(r != null) list.add(r);
 		}
Index: src/org/jboss/tools/jsf/project/capabilities/LibrariesPerformer.java
===================================================================
--- src/org/jboss/tools/jsf/project/capabilities/LibrariesPerformer.java	(revision 31350)
+++ src/org/jboss/tools/jsf/project/capabilities/LibrariesPerformer.java	(working copy)
@@ -22,6 +22,7 @@
 import org.jboss.tools.common.meta.action.impl.handlers.DefaultCreateHandler;
 import org.jboss.tools.common.model.*;
 import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
+import org.jboss.tools.common.model.filesystems.impl.Libs;
 import org.jboss.tools.common.model.plugin.ModelPlugin;
 import org.jboss.tools.common.model.util.EclipseResourceUtil;
 import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
@@ -198,7 +199,7 @@
 				}
 				FileUtil.copyFile(source, target, true);
 				changed = true;
-				String fsName = "lib-" + n;
+				String fsName = Libs.LIB_PREFIX + n;
 				if(fss.getChildByPath(fsName) == null) {
 	                Properties fsProp = new Properties();
 	                fsProp.setProperty("name", fsName);
Index: src/org/jboss/tools/jsf/web/helpers/context/AdoptJSFProjectFinisher.java
===================================================================
--- src/org/jboss/tools/jsf/web/helpers/context/AdoptJSFProjectFinisher.java	(revision 31350)
+++ src/org/jboss/tools/jsf/web/helpers/context/AdoptJSFProjectFinisher.java	(working copy)
@@ -26,6 +26,7 @@
 import org.jboss.tools.common.model.XModelObject;
 import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
 import org.jboss.tools.common.model.filesystems.impl.FileAnyImpl;
+import org.jboss.tools.common.model.filesystems.impl.Libs;
 import org.jboss.tools.common.model.util.EclipseResourceUtil;
 import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
 import org.jboss.tools.common.util.FileUtil;
@@ -192,7 +193,7 @@
 		if (jars != null)
 			for (int i = 0; i < jars.length; i++) {
 				String n = jars[i].getName();
-				getOrCreateFileSystem("lib-" + n, loc + "/" + n, "hidden=yes",
+				getOrCreateFileSystem(Libs.LIB_PREFIX + n, loc + "/" + n, "hidden=yes",
 						true, true);
 			}
 	}
#P org.jboss.tools.jst.web
Index: src/org/jboss/tools/jst/web/tld/TaglibMapping.java
===================================================================
--- src/org/jboss/tools/jst/web/tld/TaglibMapping.java	(revision 31451)
+++ src/org/jboss/tools/jst/web/tld/TaglibMapping.java	(working copy)
@@ -25,6 +25,7 @@
 import org.jboss.tools.common.model.filesystems.impl.FileAnyImpl;
 import org.jboss.tools.common.model.filesystems.impl.FolderImpl;
 import org.jboss.tools.common.model.filesystems.impl.JarSystemImpl;
+import org.jboss.tools.common.model.filesystems.impl.Libs;
 import org.jboss.tools.common.model.impl.XModelImpl;
 import org.jboss.tools.common.model.util.XModelObjectUtil;
 import org.jboss.tools.jst.web.WebModelPlugin;
@@ -205,7 +206,7 @@
 		XModelObject[] fs = fss.getChildren("FileSystemJar"); //$NON-NLS-1$
 		for (int i = 0; i < fs.length; i++) {
 			String n = fs[i].getAttributeValue("name"); //$NON-NLS-1$
-			if(n.startsWith("lib-")) findTldsInJar(fs[i]); //$NON-NLS-1$
+			if(n.startsWith(Libs.LIB_PREFIX)) findTldsInJar(fs[i]);
 		}
 	}
 	
Index: src/org/jboss/tools/jst/web/project/helpers/NewWebProjectHelper.java
===================================================================
--- src/org/jboss/tools/jst/web/project/helpers/NewWebProjectHelper.java	(revision 31451)
+++ src/org/jboss/tools/jst/web/project/helpers/NewWebProjectHelper.java	(working copy)
@@ -35,6 +35,7 @@
 import org.jboss.tools.common.model.XModelException;
 import org.jboss.tools.common.model.XModelObject;
 import org.jboss.tools.common.model.filesystems.impl.FileSystemsImpl;
+import org.jboss.tools.common.model.filesystems.impl.Libs;
 import org.jboss.tools.common.model.impl.XModelImpl;
 import org.jboss.tools.common.model.util.XMLUtil;
 import org.jboss.tools.common.model.util.XModelObjectLoaderUtil;
@@ -97,7 +98,7 @@
                 for (int i = 0; i < jars.length; i++) {
                     String jarName = jars[i].getName();
                     Properties fsProp = new Properties();
-                    fsProp.setProperty("name", "lib-"+jarName); //$NON-NLS-1$ //$NON-NLS-2$
+                    fsProp.setProperty("name", Libs.LIB_PREFIX + jarName); //$NON-NLS-1$
                     fsProp.setProperty("location", libName+jarName); //$NON-NLS-1$
                     fsProp.setProperty("info", "hidden=yes"); //$NON-NLS-1$ //$NON-NLS-2$
                     XModelObject fsJar = XModelObjectLoaderUtil.createValidObject(model, "FileSystemJar", fsProp); //$NON-NLS-1$
#P org.jboss.tools.jst.web.kb
Index: src/org/jboss/tools/jst/web/kb/internal/scanner/ClassPathMonitor.java
===================================================================
--- src/org/jboss/tools/jst/web/kb/internal/scanner/ClassPathMonitor.java	(revision 31451)
+++ src/org/jboss/tools/jst/web/kb/internal/scanner/ClassPathMonitor.java	(working copy)
@@ -28,6 +28,7 @@
 import org.jboss.tools.common.model.XJob;
 import org.jboss.tools.common.model.XJob.XRunnable;
 import org.jboss.tools.common.model.XModelObject;
+import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
 import org.jboss.tools.common.model.plugin.ModelPlugin;
 import org.jboss.tools.common.model.project.ext.AbstractClassPathMonitor;
 import org.jboss.tools.common.model.util.EclipseResourceUtil;
@@ -84,8 +85,8 @@
 
 			String fileName = new File(p).getName();
 			if(EclipseResourceUtil.SYSTEM_JAR_SET.contains(fileName)) continue;
-			String jsname = "lib-" + fileName; //$NON-NLS-1$
-			XModelObject o = model.getByPath("FileSystems").getChildByPath(jsname); //$NON-NLS-1$
+
+			XModelObject o = FileSystemsHelper.getLibs(model).getLibrary(p);
 			if(o == null) continue;
 			
 			LoadedDeclarations c = null;
@@ -99,9 +100,7 @@
 			if(c == null) {
 				c = new LoadedDeclarations();
 			}
-			if(c != null) {
-				componentsLoaded(c, new Path(p));
-			}
+			componentsLoaded(c, new Path(p));
 		}
 		
 		validateProjectDependencies();
#P org.jboss.tools.common.model
Index: src/org/jboss/tools/common/model/filesystems/impl/Libs.java
===================================================================
--- src/org/jboss/tools/common/model/filesystems/impl/Libs.java	(revision 31454)
+++ src/org/jboss/tools/common/model/filesystems/impl/Libs.java	(working copy)
@@ -45,6 +45,8 @@
 	protected List<String> paths = null;
 	Map<IPath, String> paths2 = new HashMap<IPath, String>();
 
+	LibraryNames libraryNames = new LibraryNames();
+
 	List<LibsListener> listeners = new ArrayList<LibsListener>();
 	
 	public Libs(FileSystemsImpl object) {
@@ -64,6 +66,24 @@
 		return EclipseResourceUtil.getProject(object);
 	}
 
+	public XModelObject getLibrary(String path) {
+		String libName = libraryNames.getName(path);
+		if(libName == null) {
+			//compatibility to old code.
+			libName = LIB_PREFIX + new File(path).getName();
+		}
+		return object.getChildByPath(libName);
+	}
+
+	public XModelObject getLibrary(File f) {
+		XModelObject result = null;
+		if(f.exists()) {
+			String path = f.getAbsolutePath().replace('\\', '/');
+			result = getLibrary(path);
+		}
+		return result;
+	}
+
 	public boolean update() {
 		boolean result = updatePaths();
 		if(result) fire();
@@ -103,12 +123,25 @@
 		return true;
 	}
 	
-	static String LIB_PREFIX = "lib-"; //$NON-NLS-1$
+	public static String LIB_PREFIX = "lib-"; //$NON-NLS-1$
 
 	void updateFileSystems(List<String> paths) {
 		if(fsVersion >= pathsVersion) {
 			return;
 		}
+		
+		Set<String> oldPaths = libraryNames.getPaths();
+		for (String p: oldPaths) {
+			if(!paths.contains(p)) {
+				String n = libraryNames.getName(p);
+				XModelObject o = object.getChildByPath(n);
+				if(o != null) {
+					o.removeFromParent();
+				}
+				libraryNames.removePath(p);
+			}
+		}
+		
 		XModelObject[] fs = object.getChildren();
 		Set<XModelObject> fss = new HashSet<XModelObject>();
 		for (int i = 0; i < fs.length; i++) {
@@ -123,7 +156,14 @@
 			String libEntity = isJar ? "FileSystemJar" : "FileSystemFolder"; //$NON-NLS-1$ //$NON-NLS-2$
 			String fileName = new File(path).getName();
 			if(isJar && EclipseResourceUtil.SYSTEM_JAR_SET.contains(fileName)) continue;
-			String jsname = LIB_PREFIX + fileName;
+			String jsname = libraryNames.getName(path);
+			if(jsname == null) {
+				jsname = LIB_PREFIX + fileName;
+				int q = 0;
+				while(libraryNames.hasName(jsname)) {
+					jsname = LIB_PREFIX + fileName + "-" + (++q); //$NON-NLS-1$
+				}				
+			}
 			XModelObject o = object.getChildByPath(jsname);
 			if(o != null) {
 				fss.remove(o);
@@ -134,7 +174,8 @@
 				o.set(FileSystemsLoader.IS_ADDED_TO_CLASSPATH, XModelObjectConstants.TRUE);
 				object.addChild(o);
 //				object.setModified(true);
-			}			
+			}
+			libraryNames.put(path, jsname);
 		}
 		
 		for (XModelObject o: fss) {
@@ -220,3 +261,36 @@
 	}
 
 }
+
+class LibraryNames {
+	private Map<String, String> pathToName = new HashMap<String, String>();
+	private Map<String, String> nameToPath = new HashMap<String, String>();
+
+	public void put(String path, String name) {
+		pathToName.put(path, name);
+		nameToPath.put(name, path);
+	}
+
+	public void removePath(String path) {
+		String name = pathToName.remove(path);
+		if(name != null) {
+			nameToPath.remove(name);
+		}
+	}
+
+	public String getName(String path) {
+		return pathToName.get(path);
+	}
+
+	public String getPath(String name) {
+		return nameToPath.get(name);
+	}
+
+	public boolean hasName(String name) {
+		return nameToPath.containsKey(name);
+	}
+
+	public Set<String> getPaths() {
+		return new HashSet<String>(pathToName.keySet());
+	}
+}
Index: src/org/jboss/tools/common/model/util/EclipseResourceUtil.java
===================================================================
--- src/org/jboss/tools/common/model/util/EclipseResourceUtil.java	(revision 31454)
+++ src/org/jboss/tools/common/model/util/EclipseResourceUtil.java	(working copy)
@@ -63,6 +63,7 @@
 import org.jboss.tools.common.model.filesystems.impl.FileSystemImpl;
 import org.jboss.tools.common.model.filesystems.impl.FileSystemsImpl;
 import org.jboss.tools.common.model.filesystems.impl.JarSystemImpl;
+import org.jboss.tools.common.model.filesystems.impl.Libs;
 import org.jboss.tools.common.model.icons.impl.XModelObjectIcon;
 import org.jboss.tools.common.model.impl.XModelObjectImpl;
 import org.jboss.tools.common.model.plugin.ModelPlugin;
@@ -459,7 +460,7 @@
 	
 	private static void validateJarSystem(XModelObject fs, IResource resource) {
 		if(fs == null || !isJar(resource)) return;
-		String jsname = "lib-" + resource.getName().toLowerCase(); //$NON-NLS-1$
+		String jsname = Libs.LIB_PREFIX + resource.getName().toLowerCase(); //$NON-NLS-1$
 		String location = resource.getLocation().toString().replace('\\', '/');
 		if(fs.getChildByPath(jsname) == null) {
 			XModelObject q = fs.getModel().createModelObject("FileSystemJar", null); //$NON-NLS-1$
#P org.jboss.tools.seam.core
Index: src/org/jboss/tools/seam/internal/core/scanner/lib/ClassPath.java
===================================================================
--- src/org/jboss/tools/seam/internal/core/scanner/lib/ClassPath.java	(revision 31350)
+++ src/org/jboss/tools/seam/internal/core/scanner/lib/ClassPath.java	(working copy)
@@ -27,6 +27,8 @@
 import org.jboss.tools.common.model.XJob;
 import org.jboss.tools.common.model.XModelObject;
 import org.jboss.tools.common.model.XJob.XRunnable;
+import org.jboss.tools.common.model.filesystems.FileSystemsHelper;
+import org.jboss.tools.common.model.filesystems.impl.Libs;
 import org.jboss.tools.common.model.filesystems.impl.LibsListener;
 import org.jboss.tools.common.model.project.ext.AbstractClassPathMonitor;
 import org.jboss.tools.common.model.util.EclipseResourceUtil;
@@ -81,8 +83,8 @@
 
 			String fileName = new File(p).getName();
 			if(EclipseResourceUtil.SYSTEM_JAR_SET.contains(fileName)) continue;
-			String jsname = "lib-" + fileName; //$NON-NLS-1$
-			XModelObject o = model.getByPath("FileSystems").getChildByPath(jsname); //$NON-NLS-1$
+			
+			XModelObject o = FileSystemsHelper.getLibs(model).getLibrary(p);
 			if(o == null) continue;
 			
 			LoadedDeclarations c = null;
@@ -96,9 +98,7 @@
 			if(c == null) {
 				c = new LoadedDeclarations();
 			}
-			if(c != null) {
-				componentsLoaded(c, new Path(p));
-			}
+			componentsLoaded(c, new Path(p));
 		}
 		
 		validateProjectDependencies();
